celltable.c

来自「主要用于大规模的测试生成方法」· C语言 代码 · 共 708 行 · 第 1/2 页

C
708
字号
	if (bb) write_bb( bb);	intface = net_intface ? net_intface : geo_intface;	/* riempie la struttura dati con le informazioni sulle porte */	for (t=intface->data.tree; t; t=t->next)	{	if (t->type == Kport) write_port( t);		else if (t->type == Kcomment) write_comment( t);	}}/*----------------------------------------------------------------------------	Scrive nel descrittore le porte di ingress e quelle di	uscita*/static void write_port( port)PARSETREE *port;{	PARSETREE *t, *dir;	int	i;	extern void add_assoc();	dir = NULL;	for (t=port->data.tree; t; t=t->next)		if (t->type == Kdirection) dir = t;		if( dir )	{		if( dir->data.tree->data.token == keywords[KINPUT] )		{			descr[n_descr].attr = PI;			descr[n_descr].fanin = 0;			descr[n_descr].type = BUF;		}		else 			if( dir->data.tree->data.token == keywords[KOUTPUT] )			{				descr[n_descr].type = BUF;				descr[n_descr].attr = PO;				descr[n_descr].fanin = 0;			}		descr[n_descr].name = strdup( realnameof( port ) ); 		/* MVMV 		printf( "(write_port) Aggiungo %d, %s, ", n_descr, descr[n_descr].name );		if( descr[n_descr].attr == PI )			printf( "PI\n" );		else			printf( "PO\n" );		*/		/* aggiunge l'associazione nome->numero descrittore */		add_assoc( n_descr, descr[n_descr].name ); 		n_descr++;	}		if( n_descr >= Descr_Def_Size )	{		if(!create_silent) printf( "(write_port)Resize descr to %d\n", 2*Descr_Def_Size );		Descr_Def_Size *= 2;		descr = realloc( descr, sizeof( DESCRIPTOR )*Descr_Def_Size );		/* quando realloca deve creare lo spazio per i nuovi dati */		for( i = +Descr_Def_Size/2; i < Descr_Def_Size; i++ )		{			descr[i].fanin = 0;			descr[i].fanout = 0;			descr[i].to = NULL;			descr[i].from = malloc( sizeof( int )*MAX_FANIN);		}	}	}static void write_contents( cont)PARSETREE *cont;{	PARSETREE *t;	for (t=cont->data.tree; t; t=t->next)	{	if (t->type == Kinstance) write_instance( t);		else if (t->type == Kpage) write_page_inst( t);		else if (t->type == Kcomment) write_comment( t);	}	/* PASSO1: calcola il numero di net nel circuito */		n_net = 0;	/* numero di net identificate */	l_net = 0;	/* indice dell'ultima net */	for (t=cont->data.tree; t; t=t->next)	{	if (t->type == Knet) 			n_net++;	/* aggiunge la net nuova net */		else 				if (t->type == Kpage) 				write_page_net( t, 1);	}	if( PEDANTIC )	{		printf( "(write_contents) Identificate %d NET\n", n_net );		printf( "(write_contents) Alloco la memoria\n" );		printf( "(write_contents) Alloco memoria per %d PIN\n", (NET_MEAN_FANOUT*n_net) );	}	/* alloco la memoria per i descrittori di net */	netlist = malloc( sizeof( NET )*n_net );	if( netlist == NULL )	{		printf( "(write_contents) Errore di memoria NET\n" );		return;	}		/* alloco la memoria per i descrittori di pin */	pinlist = malloc( sizeof( PIN )*(NET_MEAN_FANOUT*n_net) );	n_pin = 0;	/* nessun pin identificato */	pinlist_size = n_net*NET_MEAN_FANOUT;	if( pinlist == NULL )	{		printf( "(write_contents) Errore di memoria PIN\n" );		return;	}	/* PASSO2: scrive la lista di PIN */	for (t=cont->data.tree; t; t=t->next)	{	if (t->type == Knet) write_net( t);		else if (t->type == Kpage) write_page_net( t, 0);	}}static void write_page_inst( page)PARSETREE *page;{	PARSETREE *t;	for (t=page->data.tree; t; t=t->next)	{	if (t->type == Kinstance) write_instance( t);		else if (t->type == Kcomment) write_comment( t);	}}static void write_page_net( page, p)PARSETREE *page;int	p;		/* p = 1 conta le net, 0 altrimenti */{	PARSETREE *t;	if( p ) 		for (t=page->data.tree; t; t=t->next)		{	if (t->type == Knet) 				n_net++;	/* aggiunge la net */			else 				if (t->type == Kcomment) 					write_comment( t);		}	else		for (t=page->data.tree; t; t=t->next)		{	if (t->type == Knet) write_net( t);			else if (t->type == Kcomment) write_comment( t);		}}/*----------------------------------------------------------------------------	Crea un nuovo elemento in descr, per ogni porta istanziata	nella net-list.*/static void write_instance( inst)PARSETREE *inst;{	PARSETREE *t;	char *name, *defname;	int	i;	extern char get_descr_type();	extern void add_assoc();	name = realnameof( inst);	defname = "";	for (t=inst->data.tree; t; t=t->next)	{	if (t->type == Kcomment) write_comment( t);		else if (t->type == KviewRef) defname = get_defname( name, t);		else if (t->type == KviewList) write_unsup( t);	}		/* MVMV inserisce la porta nella lista dei descrittori */	descr[n_descr].attr = INTERNAL;	descr[n_descr].type = get_descr_type( defname );	descr[n_descr].name = strdup( name );		/* aggiunge l'associazione nome->numero descrittore */	add_assoc( n_descr, name );		/* se i componenti sono piu` del minimo prestabilito, fa una	   realloc */	n_descr++;	if( n_descr >= Descr_Def_Size )	{		if(!create_silent) printf( "(write_instance)Resize descr to %d\n", 2*Descr_Def_Size );		Descr_Def_Size *= 2;		descr = realloc( descr, sizeof( DESCRIPTOR )*Descr_Def_Size );		/* quando realloca deve creare lo spazio per i nuovi dati */		for( i = Descr_Def_Size/2; i < Descr_Def_Size; i++ )		{			descr[i].fanin = 0;			descr[i].fanout = 0;			descr[i].to = NULL;			descr[i].from = malloc( sizeof( int )*MAX_FANIN);		}	}}char *get_defname( instname, viewref)char *instname;PARSETREE *viewref;{	PARSETREE *cellref;	cellref = viewref->data.tree->next;	if (!cellref)	{	DEBUG(0) "Missing '(cellRef ...' at instance '%s'!\n",			 instname);	        return("");        } else                return( realnameof( cellref));}static void write_net( net)PARSETREE *net;{	PARSETREE *t, *arraydim;	char *netname;	netname = realnameof( net);	arraydim = get_array_size( net);	/* MVMV */	add_net( netname, n_pin );	/*aggiunge la net alla lista */	if( PEDANTIC )		printf( "(write_net) Aggiunta NET %s\n", netname );	for (t=net->data.tree; t; t=t->next)	{	if (t->type == Kjoined) write_joined( netname, arraydim, t);		else if (t->type == Kcomment) write_comment( t);	}}static void write_joined( netname, arraydim, join)char *netname;PARSETREE *arraydim, *join;{	PARSETREE *t;	for (t=join->data.tree; t; t=t->next)	{	if (t->type == KportRef)			write_portref( netname, arraydim, t);		else if (t->type == KportList)		{	char buf[YYLMAX];			strcpy( buf, netname);			write_portlist( buf, arraydim, t);		}		else	write_unsup( t);	}}static void write_unsup( t)PARSETREE *t;{	DEBUG(0) "line %d: %d  '(%s ...' still unsupported :-(\n",	         t->line, t->type, keywords[t->type]);}static void write_portlist( netname, arraydim, portlist)char *netname;PARSETREE *arraydim, *portlist;{	PARSETREE *p;	int i, l, n;	l = strlen( netname);	n = arraydim->data.ival;	for (i=0, p=portlist->data.tree; p; p=p->next, i++)	{	sprintf( netname+l, "[%d]", i);		if (p->type == KportList)			write_portlist( netname, arraydim->next, p);		else if (p->type == KportRef)			write_portref( netname, arraydim->next, p);		else 	write_unsup( p);	}	if (i != n)	{	fprintf( stderr,			"Warning: Edif error: mismatch in array dimension\n");		fprintf( stderr,			"      Line %d: declared %d, used %d\n",			arraydim->line, n, i);	}}static void write_portref( netname, arraydim, portref)char *netname;PARSETREE *arraydim, *portref;{	PARSETREE *instref, *member;	char *portname, *instname, *dimbuf[256];	char *c;	extern	add_net_info();	if (arraydim)	{	for (c = dimbuf; arraydim; arraydim=arraydim->next)		{	sprintf( c, "[0:%d]", arraydim->data.ival - 1);			while (*c) c++;		}	} else	dimbuf[0] = '\0';	portname = strdup( realnameof( portref) );	instref = portref->data.tree->next;	member = NULL;	if (instref && (instref->type != KinstanceRef))	{	write_unsup( instref);		instname = "???";	} else	instname = instref?realnameof(instref):"-";	/* MVMV 		netname = nome del filo o della porta		dimbuf = dimensione del bus		instname = nome del componente instanziato	*/	/* MVMV		portname = nome della porta del componente			   instaziato a cui si collega la net	*/	add_net_info( netname, instname, portname );	/* aggiunge la connessione */ 	if( PEDANTIC )		printf( "(write_portref) Aggiunto PIN %s, %s\n", instname, portname );	free(portname) ;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?