#include <genlib.h>

main()
{
int i;

i = genvst(74,8,1);
}

int genvst(n,l,c)
int n;
int l;
int c;
{
 int i;

 DEF_LOFIG(NAME("mem_%d_%d",l,c));
 LOCON(NAME("adr[%d:0]",l+c-1),'I',NAME("ad[%d:0]",l+c-1));
 LOCON(NAME("sout[%d:0]",n-1),'O',NAME("sor[%d:0]",n-1));
 LOCON("ck",'I',"clk");
 LOCON("write",'I',"ecr");
 LOCON("vdd",'X',"VDD");
 LOCON("vss",'X',"VSS");

 LOINS("deco","decoder",NAME("ad[%d:0]",l+c-1),NAME("wln[%d:0]",puiss(l)-1),NAME("selm[%d:0]",puiss(c)-1),"ecr","ecr2","lect","clk","VDD","VSS",0);

 for(i=0;i<n;i++)
 {
  LOINS("rbit",NAME("bit_%d",i),NAME("wln[%d:0]",puiss(l)-1),NAME("selm[%d:0]",puiss(c)-1),"lect","ecr2",NAME("sor[%d]",i),"VDD","VSS",0);
 }

 SAVE_LOFIG();
}

int puiss(i)
int i;
{
 if(i==0) return(1);
 else return(2*puiss(i-1));
}

