read_blif.c File Reference

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "globals.h"
#include "read_blif.h"
#include "util.h"
#include "string_cache.h"
#include "netlist_utils.h"
#include "errors.h"
#include "types.h"
Include dependency graph for read_blif.c:

Go to the source code of this file.

Defines

#define TOKENS   " \t\n"

Functions

void create_top_driver_nets (char *instance_name_prefix)
void look_for_clocks ()
void add_top_input_nodes ()
void create_top_output_nodes ()
static void read_tokens (char *buffer, int *done, char *blif_file)
static void dum_parse (char *buffer)
void create_internal_node_and_driver ()
short assign_node_type_from_node_name (char *output_name)
short read_bit_map_find_unknown_gate (int input_count, nnode_t *node)
void create_latch_node_and_driver (char *blif_file)
void create_hard_block_nodes ()
void hook_up_nets ()
char * search_clock_name (char *blif_file)
void read_blif (char *blif_file)

Variables

static FILE * blif
int linenum
STRING_CACHEoutput_nets_sc
STRING_CACHEinput_nets_sc
const char * GND = "gnd"
const char * VCC = "vcc"
const char * HBPAD = "unconn"
char * blif_one_string = "ONE_VCC_CNS"
char * blif_zero_string = "ZERO_GND_ZERO"
char * blif_pad_string = "ZERO_PAD_ZERO"
char * default_clock_name = "top^clock"
netlist_tblif_netlist
static short skip_reading_bit_map = FALSE

Define Documentation

#define TOKENS   " \t\n"

Definition at line 38 of file read_blif.c.


Function Documentation

void add_top_input_nodes (  ) 

Definition at line 1252 of file read_blif.c.

01253 {
01254 
01255 #ifdef debug_mode
01256   printf("\n Reading the add_top_input_nodes");
01257 #endif
01258 
01259   long sc_spot;// store the location of the string stored in string_cache
01260   char *ptr; 
01261   char buffer[BUFSIZE];
01262   npin_t *new_pin;
01263   nnet_t *new_net = NULL;
01264   nnode_t *new_node;
01265   char *temp_string;
01266 
01267   while (1)
01268         {
01269         /* keep reading the inputs till there is no more to read*/
01270                 ptr = my_strtok (NULL, TOKENS, blif, buffer);
01271         
01272                 if (ptr == NULL)
01273                         return;
01274 
01275         /* create a new top input node and net*/
01276         new_net= allocate_nnet();
01277         new_node = allocate_nnode();
01278 
01279         temp_string= make_full_ref_name(ptr, NULL, NULL,NULL, -1);
01280         sc_spot = sc_add_string(output_nets_sc, temp_string);
01281         if (output_nets_sc->data[sc_spot] != NULL)
01282              {
01283               error_message(NETLIST_ERROR,linenum,-1, "Net (%s) with the same name already created\n",ptr);     
01284              }
01285         
01286         /* store the data which is an idx here */
01287         output_nets_sc->data[sc_spot] = (void*)new_net;
01288 
01289         new_node->related_ast_node = NULL;
01290         new_node->type = INPUT_NODE;
01291 
01292         /* add the name of the input variable */ 
01293         new_node->name = temp_string;
01294 
01295         /* allocate the pins needed */
01296         allocate_more_node_output_pins(new_node, 1);
01297         add_output_port_information(new_node, 1);
01298 
01299         /* Create the pin connection for the net */
01300         new_pin = allocate_npin();
01301 
01302         /* hookup the pin, net, and node */
01303         add_a_output_pin_to_node_spot_idx(new_node, new_pin, 0);
01304         add_a_driver_pin_to_net(new_net, new_pin);
01305 
01306         /*adding the node to the blif_netlist input nodes
01307           add_node_to_netlist() function can also be used */
01308         
01309         blif_netlist->top_input_nodes = (nnode_t**)realloc(blif_netlist->top_input_nodes, sizeof(nnode_t*)*(blif_netlist->num_top_input_nodes+1));
01310         blif_netlist->top_input_nodes[blif_netlist->num_top_input_nodes] = new_node;
01311         blif_netlist->num_top_input_nodes++;
01312         
01313         }
01314 
01315 #ifdef debug_mode
01316         printf("\n Exiting the add_top_input_nodes");
01317 #endif
01318 
01319 }

Here is the call graph for this function:

Here is the caller graph for this function:

short assign_node_type_from_node_name ( char *  output_name  ) 

Definition at line 208 of file read_blif.c.

00209 {
00210         
00211 #ifdef debug_mode
00212         printf("\n reading assign_node_type_from_node_name");
00213         printf("\n output_name : %s",output_name);
00214 #endif
00215 
00216   int length_string;
00217   int start,end,i; //variable to extract the type
00218   int j=0;
00219   char *extracted_string;//stores the extracted string
00220   length_string=strlen(output_name);
00221 
00222   for(start=length_string-1;(start >=0) && (output_name[start]!='^');start--);
00223   for(end=length_string-1;(end>=0) && (output_name[end]!='~');end--);
00224 
00225   /* name convention does not match */
00226 
00227 #ifdef debug_mode
00228         printf("\n Start= %d  end=%d  \n",start,end);
00229 #endif
00230   
00231   if((start>=end) || (end==0))
00232           return GENERIC;
00233                 
00234   extracted_string=(char*)malloc(sizeof(char)*((end-start+2)));
00235   for(i=start+1;i<end;i++)
00236   {
00237     extracted_string[j]=output_name[i];
00238     j++;
00239   }
00240   extracted_string[j]='\0';
00241 
00242 #ifdef debug_mode
00243         printf("Extracted string: %s \n",extracted_string);
00244 #endif
00245 
00246   /* Check if the type existe, return the type else return -1 */
00247   /* if construst use , as we have strings here */
00248   if(strcmp(extracted_string,"GT")==0)
00249         return GT;
00250   else if(strcmp(extracted_string,"LT")==0)
00251         return LT;
00252   else if(strcmp(extracted_string,"ADDER_FUNC")==0)
00253         return ADDER_FUNC;
00254   else if(strcmp(extracted_string,"CARRY_FUNC")==0)
00255         return CARRY_FUNC;
00256   else if(strcmp(extracted_string,"BITWISE_NOT")==0)
00257         return BITWISE_NOT;
00258   else if(strcmp(extracted_string,"LOGICAL_AND")==0)
00259         return LOGICAL_AND;
00260   else if(strcmp(extracted_string,"LOGICAL_OR")==0)
00261         return LOGICAL_OR;
00262   else if(strcmp(extracted_string,"LOGICAL_XOR")==0)
00263         return LOGICAL_XOR;
00264   else if(strcmp(extracted_string,"LOGICAL_XNOR")==0)
00265         return LOGICAL_XNOR; 
00266   else if(strcmp(extracted_string,"LOGICAL_NAND")==0)
00267         return LOGICAL_NAND;
00268   else if(strcmp(extracted_string,"LOGICAL_NOR")==0)
00269         return LOGICAL_NOR;
00270   else if(strcmp(extracted_string,"LOGICAL_EQUAL")==0)
00271         return LOGICAL_EQUAL;
00272   else if(strcmp(extracted_string,"NOT_EQUAL")==0)
00273         return NOT_EQUAL;
00274   else if(strcmp(extracted_string,"LOGICAL_NOT")==0)
00275         return LOGICAL_NOT; 
00276   else if(strcmp(extracted_string,"MUX_2")==0)
00277         return MUX_2;
00278   else if(strcmp(extracted_string,"FF_NODE")==0)
00279         return FF_NODE;
00280   else if(strcmp(extracted_string,"MULTIPLY")==0)
00281         return MULTIPLY;
00282   else if(strcmp(extracted_string,"HARD_IP")==0)
00283         return HARD_IP;
00284   else if(strcmp(extracted_string,"INPUT_NODE")==0)
00285         return INPUT_NODE;
00286   else if(strcmp(extracted_string,"OUTPUT_NODE")==0)
00287         return OUTPUT_NODE;
00288   else if(strcmp(extracted_string,"PAD_NODE")==0)
00289         return PAD_NODE;
00290   else if(strcmp(extracted_string,"CLOCK_NODE")==0)
00291         return CLOCK_NODE;
00292   else if(strcmp(extracted_string,"GND_NODE")==0)
00293         return GND_NODE;
00294   else if(strcmp(extracted_string,"VCC_NODE")==0)
00295         return VCC_NODE;
00296   else if(strcmp(extracted_string,"BITWISE_AND")==0)
00297         return BITWISE_AND;
00298   else if(strcmp(extracted_string,"BITWISE_NAND")==0)
00299         return BITWISE_NAND;
00300   else if(strcmp(extracted_string,"BITWISE_NOR")==0)
00301         return BITWISE_NOR;
00302   else if(strcmp(extracted_string,"BITWISE_XNOR")==0)
00303         return BITWISE_XNOR;
00304   else if(strcmp(extracted_string,"BITWISE_XOR")==0)
00305         return BITWISE_XOR;
00306   else if(strcmp(extracted_string,"BITWISE_OR")==0)
00307         return BITWISE_OR;
00308   else if(strcmp(extracted_string,"BUF_NODE")==0)
00309         return BUF_NODE; 
00310    else if(strcmp(extracted_string,"MULTI_PORT_MUX")==0)
00311         return MULTI_PORT_MUX;
00312   else if(strcmp(extracted_string,"SL")==0)
00313         return SL;
00314   else if(strcmp(extracted_string,"SR")==0)
00315         return SR;
00316   else if(strcmp(extracted_string,"CASE_EQUAL")==0)
00317         return CASE_EQUAL;
00318   else if(strcmp(extracted_string,"CASE_NOT_EQUAL")==0)
00319         return CASE_NOT_EQUAL;
00320   else if(strcmp(extracted_string,"DIVIDE")==0)
00321         return DIVIDE;
00322   else if(strcmp(extracted_string,"MODULO")==0)
00323         return MODULO;
00324   else if(strcmp(extracted_string,"GTE")==0)
00325         return GTE;
00326   else if(strcmp(extracted_string,"LTE")==0)
00327         return LTE; 
00328   else if(strcmp(extracted_string,"ADD")==0)
00329         return ADD; 
00330   else if(strcmp(extracted_string,"MINUS")==0)
00331         return MINUS;  
00332   else return GENERIC; /* If name type does not exits */
00333 
00334 
00335 }

Here is the caller graph for this function:

void create_hard_block_nodes (  ) 

Definition at line 603 of file read_blif.c.

00604 {
00605   FILE *temp_search; // for searching the subckt model
00606   char buffer[BUFSIZE];
00607   char *name_subckt;
00608   char *temp1,*temp2;
00609   char **names_formal=NULL; // store the formal-actual parameter name
00610   char **names_actual=NULL;
00611   char **names_parameters=NULL;
00612   int count=0;
00613   char *ptr;
00614   int done=0;
00615   int input_count=0;
00616   long sc_spot;
00617   nnode_t *new_node = allocate_nnode();
00618   npin_t *new_pin;
00619   nnet_t *new_net;
00620   int input_port_count=0;
00621   int output_port_count=0;
00622   int i=0;
00623   fpos_t pos;// store the current position of the file pointer
00624 
00625         
00626   ptr= my_strtok (NULL, TOKENS, blif, buffer);
00627   name_subckt=(char*)malloc(sizeof(char)*(strlen(ptr)+1));
00628   sprintf(name_subckt,"%s",ptr);
00629 
00630 #ifdef debug_mode
00631   printf("\nname_subckt: %s",name_subckt);
00632 #endif
00633  
00634   /* storing the names on the fornal-actual parameter */
00635         while ((ptr= my_strtok (NULL, TOKENS, blif, buffer)) != NULL)
00636         {
00637 
00638 #ifdef debug_mode
00639           printf("\n ptr: %s",ptr);
00640 #endif
00641 
00642           count++;
00643           names_parameters= (char**)realloc(names_parameters, sizeof(char*)*count);  
00644           names_parameters[count-1]=(char*)malloc(sizeof(char)*(strlen(ptr)+1));
00645           sprintf(names_parameters[count-1],"%s",ptr);
00646         }       
00647    
00648    names_actual=(char**)malloc(sizeof(char*)*count);
00649    names_formal=(char**)malloc(sizeof(char*)*count);
00650 
00651    while(i<count)
00652         {
00653           ptr=strtok(names_parameters[i],"=");
00654 #ifdef debug_mode         
00655         printf("\n ptr: %s",ptr);
00656 #endif
00657 
00658           names_actual[i]=(char*)malloc(sizeof(char)*(strlen(ptr)+1));
00659           sprintf(names_actual[i],"%s",ptr);
00660           ptr=strtok(NULL,"=");
00661           names_formal[i]=(char*)malloc(sizeof(char)*(strlen(ptr)+1));
00662           sprintf(names_formal[i],"%s",ptr);
00663           i++;
00664         }
00665 
00666         for(i=0;i<count;i++)
00667         {
00668         free(names_parameters[i]);
00669 
00670 #ifdef debug_mode       
00671         printf("\n %s \t%s",names_actual[i],names_formal[i]);
00672 #endif
00673 
00674         }
00675         free(names_parameters);   
00676 
00677   fgetpos(blif,&pos);
00678   temp_search=blif;
00679 
00680         while (1)
00681         {
00682           my_fgets(buffer, BUFSIZE,temp_search);
00683           if(feof(temp_search)!=0)
00684           {
00685                 printf("Error : The '%s' subckt no found ",name_subckt);
00686                 exit(-1);
00687           }
00688         ptr=my_strtok(buffer,TOKENS, temp_search, buffer);
00689 #ifdef debug_mode       
00690         printf("\n ptr : %s",ptr);
00691 #endif
00692         if (ptr==NULL)
00693           continue;
00694         if(strcmp(ptr,".model")!=0)
00695         continue;
00696 
00697         ptr=my_strtok(NULL,TOKENS, temp_search, buffer);
00698         if(strcmp(ptr,name_subckt)==0)
00699                 break;
00700         
00701         }
00702 
00703   /* read the subckt model to find out the number of input pin*/
00704   /* count-input_count=number of output pin */
00705   /* Thus we can decide number of passed parameter are output parameter */
00706 
00707         while (!done && (my_fgets (buffer, BUFSIZE,temp_search) != NULL) )
00708         {
00709           ptr = my_strtok (buffer, TOKENS, temp_search, buffer);  
00710 
00711 #ifdef debug_mode       
00712           printf("\n ptr: %s",ptr);  
00713 #endif
00714 
00715           if(strcmp(ptr,".inputs")==0)
00716           {
00717                 while ((ptr= my_strtok (NULL, TOKENS,temp_search, buffer)) != NULL)
00718                  input_count++;
00719                 done=1;
00720           }
00721         }
00722 
00723 #ifdef debug_mode
00724         printf("\n input_count %d",input_count);
00725         printf("\n count %d",count); 
00726 #endif
00727 
00728   /* calculate the number of input and output port size */
00729   if(input_count>0)
00730   {
00731   input_port_count=1;
00732 
00733           for(i=0;i<input_count-1;i++)
00734           {  
00735              ptr=strtok(names_actual[i+1],"~");
00736              temp2=ptr;
00737              ptr=strtok(names_actual[i],"~");           
00738              temp1=ptr;
00739 
00740 #ifdef debug_mode
00741                 printf("\n %s \t %s",temp1,temp2);
00742 #endif
00743         
00744                 if(strcmp(temp1,temp2)!=0)
00745                 {
00746                 add_input_port_information(new_node,input_port_count);
00747                 input_port_count=1;
00748                 }
00749                 else
00750                 input_port_count++;
00751           }
00752         add_input_port_information(new_node,input_port_count);  
00753   }
00754 
00755   if(count-input_count>0)
00756   {
00757   output_port_count=1;
00758 
00759           for(i=input_count;i<count-input_count-1;i++)
00760           {  
00761              ptr=strtok(names_actual[i+1],"~");
00762              temp2=ptr;
00763              ptr=strtok(names_actual[i],"~");           
00764              temp1=ptr;
00765 
00766 #ifdef debug_mode
00767                 printf("\n %s \t %s",temp1,temp2);
00768 #endif
00769 
00770                 if(strcmp(temp1,temp2)!=0)
00771                 {
00772                 add_output_port_information(new_node,output_port_count);
00773                 output_port_count=1;
00774                 }
00775                 else
00776                 output_port_count++;
00777           }     
00778         add_output_port_information(new_node,output_port_count);
00779   }
00780 
00781   /* creating the node */
00782   // new_node->related_ast_node = NULL;
00783   if(strcmp(name_subckt,"multiply")==0)
00784    new_node->type=MULTIPLY;
00785   else
00786    new_node->type=MEMORY;
00787    
00788   /* allocate the output pin (there is always one output pin) */
00789     allocate_more_node_output_pins(new_node,count-input_count);
00790 
00791   /* allocate the input pin (= input_count-1)*/
00792          if (input_count > 0) // check if there is any input pins       
00793         {  
00794           allocate_more_node_input_pins(new_node, input_count);  
00795         }
00796   
00797   /* add names and type information to the created input pins */
00798         for(i=0;i<input_count;i++)
00799         {
00800           new_node->input_pins[i]=allocate_npin();
00801           new_node->input_pins[i]->name=names_formal[i];
00802           new_node->input_pins[i]->type=INPUT;
00803           ptr=strtok(names_actual[i],"~");
00804           new_node->input_pins[i]->mapping=(char*)malloc(sizeof(char)*(strlen(ptr)+1));         
00805           sprintf(new_node->input_pins[i]->mapping,"%s",ptr);
00806         }
00807          
00808   /* Check this , I am not sure (simulator needs this information) */
00809   new_node->related_ast_node=(ast_node_t *)calloc(1, sizeof(ast_node_t));
00810   new_node->related_ast_node->children=(ast_node_t **)calloc(1,sizeof(ast_node_t *)); 
00811   new_node->related_ast_node->children[0]=(ast_node_t *)calloc(1, sizeof(ast_node_t));
00812   new_node->related_ast_node->children[0]->types.identifier=(char*)calloc(1,sizeof(char)*(strlen(name_subckt)+1));
00813   sprintf(new_node->related_ast_node->children[0]->types.identifier,"%s",name_subckt);
00814 
00815   /* add a name for the node,same as the subckt name */
00816   new_node->name = make_full_ref_name(name_subckt,NULL, NULL, NULL,-1);  
00817 
00818   /*add this node to blif_netlist as an internal node */
00819   blif_netlist->internal_nodes = (nnode_t**)realloc(blif_netlist->internal_nodes, sizeof(nnode_t*)*(blif_netlist->num_internal_nodes+1));
00820   blif_netlist->internal_nodes[blif_netlist->num_internal_nodes] =new_node;
00821   blif_netlist->num_internal_nodes++;
00822  
00823   /*add name information and a net(driver) for the output */
00824         for(i=0;i<count-input_count;i++)
00825         {
00826         
00827         new_pin=allocate_npin();
00828         new_net=allocate_nnet();
00829         new_net->name=names_formal[i+input_count];
00830         new_pin->name=names_formal[i+input_count];
00831         new_pin->type=OUTPUT;
00832         ptr=strtok(names_actual[i+input_count],"~");
00833 
00834 #ifdef debug_mode
00835         printf("\n ptr  %s\n",ptr);
00836 #endif
00837 
00838         add_a_output_pin_to_node_spot_idx(new_node, new_pin,i);
00839         new_node->output_pins[i]->mapping=(char*)malloc(sizeof(char)*(strlen(ptr)+1));          
00840         sprintf(new_node->output_pins[i]->mapping,"%s",ptr);
00841         add_a_output_pin_to_node_spot_idx(new_node, new_pin,i);
00842         add_a_driver_pin_to_net(new_net,new_pin);
00843                 
00844   /*list this output in output_nets_sc */
00845         sc_spot = sc_add_string(output_nets_sc,names_formal[i+input_count]);
00846                 if (output_nets_sc->data[sc_spot] != NULL)
00847                 {
00848                 error_message(NETLIST_ERROR,linenum, -1,"Net (%s) with the same name already created\n",ptr);   
00849                 }
00850           /* store the data which is an idx here */
00851         output_nets_sc->data[sc_spot] = (void*)new_net;
00852         }
00853 
00854   /* Free the char**   */
00855   free(names_formal); 
00856   free(names_actual);
00857   free(names_parameters);
00858   fsetpos(blif,&pos);
00859 
00860 #ifdef debug_mode
00861   printf("\n exiting the create_hard_block module");
00862 #endif
00863          
00864 }

Here is the call graph for this function:

Here is the caller graph for this function:

void create_internal_node_and_driver (  ) 

Definition at line 871 of file read_blif.c.

00872 {
00873 
00874 #ifdef debug_mode
00875         printf("\n reading create_internal_node_driver");
00876 #endif
00877 
00878   long sc_spot;
00879   nnode_t *new_node = allocate_nnode();
00880   npin_t *new_pin;
00881   nnet_t *new_net;
00882   short node_type;
00883   char buffer[BUFSIZE];
00884   char *ptr;
00885   char ** names=NULL;// stores the names of the input and the output, last name stored would be of the output
00886   int input_count=0;
00887   int i;
00888 
00889   /* Storing the names of the input and the final output in array names */
00890         while ((ptr= my_strtok (NULL, TOKENS, blif, buffer)) != NULL)
00891         {
00892           input_count++;
00893           names= (char**)realloc(names, sizeof(char*)* input_count);  
00894           names[input_count-1]=(char*)malloc(sizeof(char)*(strlen(ptr)+1));
00895           sprintf(names[input_count-1],"%s",ptr);
00896         }
00897   
00898   /* assigning the new_node */
00899   new_node->related_ast_node = NULL;
00900   /* gnd vcc unconn already created as top module so ignore them */
00901   if( (strcmp(names[input_count-1],"gnd")==0) ||  (strcmp(names[input_count-1],"vcc")==0) ||  (strcmp(names[input_count-1],"unconn")==0))
00902         {
00903         skip_reading_bit_map=TRUE;
00904         return;
00905         }
00906 
00907 #ifdef debug_mode
00908   printf("\nnames %s",names[input_count-1]); 
00909 #endif
00910 
00911 
00912   /* assign the node type by seeing the name */
00913   node_type=assign_node_type_from_node_name(names[input_count-1]);
00914   
00915 #ifdef debug_mode
00916         printf("\n exiting assign_node_type_from_node_name\n");
00917         printf("\n node_type= %d\n",node_type);  
00918 #endif          
00919         
00920         if(node_type!=GENERIC)
00921         {
00922           new_node->type=node_type;
00923           skip_reading_bit_map=TRUE;
00924         }
00925  /* Check for GENERIC type , change the node by reading the bit map */
00926         else if(node_type == GENERIC)
00927         {
00928           new_node->type=read_bit_map_find_unknown_gate(input_count-1,new_node);
00929           skip_reading_bit_map=TRUE;
00930 
00931 #ifdef debug_mode
00932         printf("\n exiting read_bit_map_find_unknown_gate \n");
00933         printf("\n node_type= %d\n",new_node->type);  
00934 #endif
00935 
00936         }
00937  
00938   /* allocate the input pin (= input_count-1)*/
00939          if (input_count-1 > 0) // check if there is any input pins     
00940         {  
00941           allocate_more_node_input_pins(new_node, input_count-1);
00942 
00943  /* add the port information */
00944                 if(new_node->type==MUX_2)
00945                 {
00946                         add_input_port_information(new_node, (input_count-1)/2);
00947                         add_input_port_information(new_node, (input_count-1)/2);
00948                 }
00949                 else
00950                 {
00951                   for(i=0;i<input_count-1;i++)
00952                   { 
00953                         add_input_port_information(new_node, 1);
00954                   }  
00955                 }
00956         }
00957   /* add names and type information to the created input pins */
00958         for(i=0;i<=input_count-2;i++)
00959         {
00960           new_pin=allocate_npin();
00961           new_pin->name=names[i];
00962           new_pin->type=INPUT;
00963           add_a_input_pin_to_node_spot_idx(new_node, new_pin, i);
00964         }
00965 
00966   /* add information for the intermediate VCC and GND node (appears in ABC )*/
00967   if(new_node->type==GND_NODE)
00968   {
00969          allocate_more_node_input_pins(new_node,1);
00970          add_input_port_information(new_node, 1);
00971          new_pin=allocate_npin();
00972          new_pin->name=(char *)GND;
00973          new_pin->type=INPUT;
00974          add_a_input_pin_to_node_spot_idx(new_node, new_pin,0);  
00975   }
00976   
00977   if(new_node->type==VCC_NODE)
00978   {
00979          allocate_more_node_input_pins(new_node,1);
00980          add_input_port_information(new_node, 1);
00981          new_pin=allocate_npin();
00982          new_pin->name=(char *)VCC;
00983          new_pin->type=INPUT;
00984          add_a_input_pin_to_node_spot_idx(new_node, new_pin,0);  
00985   }
00986 
00987 
00988   /* allocate the output pin (there is always one output pin) */
00989   allocate_more_node_output_pins(new_node, 1);
00990   add_output_port_information(new_node, 1);
00991 
00992  /* add a name for the node, keeping the name of the node same as the output */
00993   new_node->name = make_full_ref_name(names[input_count-1],NULL, NULL, NULL,-1);   
00994   
00995   /*add this node to blif_netlist as an internal node */
00996   blif_netlist->internal_nodes = (nnode_t**)realloc(blif_netlist->internal_nodes, sizeof(nnode_t*)*(blif_netlist->num_internal_nodes+1));
00997   blif_netlist->internal_nodes[blif_netlist->num_internal_nodes] =new_node;
00998   blif_netlist->num_internal_nodes++;
00999  
01000 
01001   /*add name information and a net(driver) for the output */
01002   new_pin=allocate_npin();
01003   new_net=allocate_nnet();
01004   new_net->name=new_node->name;
01005   new_pin->name=new_node->name;
01006   new_pin->type=OUTPUT;
01007   add_a_output_pin_to_node_spot_idx(new_node, new_pin, 0);
01008   add_a_driver_pin_to_net(new_net,new_pin);
01009   
01010   /*list this output in output_nets_sc */
01011    sc_spot = sc_add_string(output_nets_sc,new_node->name );
01012         if (output_nets_sc->data[sc_spot] != NULL)
01013         {
01014           error_message(NETLIST_ERROR,linenum,-1, "Net (%s) with the same name already created\n",ptr); 
01015         }
01016         
01017   /* store the data which is an idx here */
01018   output_nets_sc->data[sc_spot] = (void*)new_net;
01019 
01020   /* Free the char** names */
01021   free(names);
01022 
01023 #ifdef debug_mode
01024         printf("\n exiting create_internal_node_driver");
01025 #endif
01026 
01027 }

Here is the call graph for this function:

Here is the caller graph for this function:

void create_latch_node_and_driver ( char *  blif_file  ) 

Definition at line 342 of file read_blif.c.

00343 {
00344 
00345 #ifdef debug_mode
00346         printf("\n Reading the create_latch_node and driver ");
00347 #endif
00348   
00349   long sc_spot;
00350   nnode_t *new_node = allocate_nnode();
00351   npin_t *new_pin;
00352   nnet_t *new_net;
00353   char buffer[BUFSIZE];
00354   char *ptr;
00355   int input_token_count=0;/*to keep track whether controlling clock is specified or not */
00356                           /*input_token_count=3 it is not and =5 it is */
00357   int i;
00358   char ** names=NULL;// Store the names of the tokens
00359   char *clock_name; // Needed if the control (clock) not specified      
00360 
00361   /* Storing the names of the input and the final output in array names */
00362         while ((ptr= my_strtok (NULL, TOKENS, blif, buffer)) != NULL)
00363         {
00364 #ifdef debug_mode
00365           printf("\n\t ptr=%s",ptr);
00366 #endif
00367           input_token_count++;
00368           names= (char**)realloc(names, sizeof(char*)* input_token_count);  
00369           names[input_token_count-1]=(char*)malloc(sizeof(char)*(strlen(ptr)+1));
00370           sprintf(names[input_token_count-1],"%s",ptr);
00371         }
00372 
00373 
00374   /* assigning the new_node */
00375 
00376 #ifdef debug_mode
00377 printf("\n\tinput_token_count=%d\n",input_token_count);
00378 #endif
00379 
00380         if(input_token_count!=5)
00381         {
00382                 /* supported added for the ABC .latch output without control */
00383                 if(input_token_count==3)
00384                 {
00385                         clock_name=search_clock_name(blif_file);
00386                         input_token_count=5;
00387                         names= (char**)realloc(names, sizeof(char*)* input_token_count);  
00388                         if(clock_name!=NULL)
00389                         {
00390                           names[3]=(char*)malloc(sizeof(char)*(strlen(clock_name)+1));
00391                           sprintf(names[3],"%s",clock_name);
00392                         }
00393                         else
00394                         names[3]=NULL;                  
00395 
00396                         names[4]=(char*)malloc(sizeof(char)*(1+1));
00397                         sprintf(names[4],"%s",names[2]);
00398                         sprintf(names[2],"re");
00399 
00400                 }
00401 
00402                 else
00403                 {       
00404                   printf("This .latch Format not supported \n\t required format :.latch <input> <output> [<type> <control/clock>] <initial val>");
00405                   exit(-1);
00406                 }
00407         }
00408 
00409   new_node->related_ast_node = NULL;
00410   new_node->type=FF_NODE;
00411   
00412   /* allocate the output pin (there is always one output pin) */
00413   allocate_more_node_output_pins(new_node, 1);
00414   add_output_port_information(new_node, 1);
00415 
00416   /* allocate the input pin */
00417   allocate_more_node_input_pins(new_node,2);/* input[1] is clock */ 
00418   
00419   /* add the port information */
00420   for(i=0;i<2;i++)
00421   {
00422     add_input_port_information(new_node,1); 
00423   }
00424 
00425   /* add names and type information to the created input pins */
00426   new_pin=allocate_npin();
00427   new_pin->name=names[0];
00428   new_pin->type=INPUT;
00429   add_a_input_pin_to_node_spot_idx(new_node, new_pin,0);
00430 
00431   new_pin=allocate_npin();
00432   new_pin->name=names[3];
00433   new_pin->type=INPUT;
00434   add_a_input_pin_to_node_spot_idx(new_node, new_pin,1);
00435 
00436 
00437   /* add a name for the node, keeping the name of the node same as the output */
00438   new_node->name = make_full_ref_name(names[1],NULL, NULL, NULL,-1);  
00439         
00440 
00441   /*add this node to blif_netlist as an ff (flip-flop) node */
00442   blif_netlist->ff_nodes = (nnode_t**)realloc(blif_netlist->ff_nodes, sizeof(nnode_t*)*(blif_netlist->num_ff_nodes+1));
00443   blif_netlist->ff_nodes[blif_netlist->num_ff_nodes] =new_node;
00444   blif_netlist->num_ff_nodes++;
00445 
00446   /*add name information and a net(driver) for the output */
00447   new_pin=allocate_npin();
00448   new_net=allocate_nnet();
00449   new_net->name=new_node->name;
00450   new_pin->name=new_node->name;
00451   new_pin->type=OUTPUT;
00452   add_a_output_pin_to_node_spot_idx(new_node, new_pin, 0);
00453   add_a_driver_pin_to_net(new_net,new_pin);
00454   
00455   /*list this output in output_nets_sc */
00456    sc_spot = sc_add_string(output_nets_sc,new_node->name);
00457 
00458 
00459         if (output_nets_sc->data[sc_spot] != NULL)
00460         {
00461           error_message(NETLIST_ERROR,linenum,-1, "Net (%s) with the same name already created\n",ptr); 
00462         }
00463 
00464   /* store the data which is an idx here */
00465   output_nets_sc->data[sc_spot] = (void*)new_net;
00466 
00467   /* Free the char** names */
00468   free(names);
00469 
00470 #ifdef debug_mode
00471         printf("\n exiting the create_latch_node and driver ");
00472 #endif
00473 
00474 }

Here is the call graph for this function:

Here is the caller graph for this function:

void create_top_driver_nets ( char *  instance_name_prefix  ) 

Definition at line 1417 of file read_blif.c.

01418 {
01419 
01420 #ifdef debug_mode
01421         printf("\nin top level driver net function");
01422 #endif
01423 
01424         npin_t *new_pin;
01425         long sc_spot;// store the location of the string stored in string_cache
01426 /* create the constant nets */
01427 
01428         /* ZERO net */ 
01429         /* description given for the zero net is same for other two */
01430         blif_netlist->zero_net = allocate_nnet(); // allocate memory to net pointer
01431         blif_netlist->gnd_node = allocate_nnode(); // allocate memory to node pointer
01432         blif_netlist->gnd_node->type = GND_NODE;  // mark the type
01433         allocate_more_node_output_pins(blif_netlist->gnd_node, 1);// alloacate 1 output pin pointer to this node 
01434         add_output_port_information(blif_netlist->gnd_node, 1);// add port info. this port has 1 pin ,till now number of port for this is one
01435         new_pin = allocate_npin();
01436         add_a_output_pin_to_node_spot_idx(blif_netlist->gnd_node, new_pin, 0);// add this pin to output pin pointer array of this node
01437         add_a_driver_pin_to_net(blif_netlist->zero_net,new_pin);// add this pin to net as driver pin 
01438 
01439         /*ONE net*/
01440 
01441         blif_netlist->one_net = allocate_nnet();
01442         blif_netlist->vcc_node = allocate_nnode();
01443         blif_netlist->vcc_node->type = VCC_NODE;
01444         allocate_more_node_output_pins(blif_netlist->vcc_node, 1);
01445         add_output_port_information(blif_netlist->vcc_node, 1);
01446         new_pin = allocate_npin();
01447         add_a_output_pin_to_node_spot_idx(blif_netlist->vcc_node, new_pin, 0);
01448         add_a_driver_pin_to_net(blif_netlist->one_net, new_pin);
01449 
01450         /* Pad net */
01451 
01452         blif_netlist->pad_net = allocate_nnet();
01453         blif_netlist->pad_node = allocate_nnode();
01454         blif_netlist->pad_node->type = PAD_NODE;
01455         allocate_more_node_output_pins(blif_netlist->pad_node, 1);
01456         add_output_port_information(blif_netlist->pad_node, 1);
01457         new_pin = allocate_npin();
01458         add_a_output_pin_to_node_spot_idx(blif_netlist->pad_node, new_pin, 0);
01459         add_a_driver_pin_to_net(blif_netlist->pad_net, new_pin);
01460 
01461         
01462         /* CREATE the driver for the ZERO */
01463         blif_zero_string = make_full_ref_name(instance_name_prefix, NULL, NULL, zero_string, -1);
01464         blif_netlist->gnd_node->name = (char *)GND;
01465 
01466         sc_spot = sc_add_string(output_nets_sc, (char *)GND);
01467         if (output_nets_sc->data[sc_spot] != NULL)
01468         {
01469                 error_message(NETLIST_ERROR,-1,-1, "Error in Odin\n");
01470         }
01471 
01472         /* store the data which is an idx here */
01473         output_nets_sc->data[sc_spot] = (void*)blif_netlist->zero_net;
01474         blif_netlist->zero_net->name =blif_zero_string;
01475 
01476         /* CREATE the driver for the ONE and store twice */
01477         blif_one_string = make_full_ref_name(instance_name_prefix, NULL, NULL, one_string, -1);
01478         blif_netlist->vcc_node->name = (char *)VCC;
01479 
01480         sc_spot = sc_add_string(output_nets_sc, (char *)VCC);
01481         if (output_nets_sc->data[sc_spot] != NULL)
01482         {
01483                 error_message(NETLIST_ERROR,-1,-1, "Error in Odin\n");
01484         }
01485         /* store the data which is an idx here */
01486         output_nets_sc->data[sc_spot] = (void*)blif_netlist->one_net;
01487         blif_netlist->one_net->name =blif_one_string;
01488 
01489         /* CREATE the driver for the PAD */
01490         blif_pad_string = make_full_ref_name(instance_name_prefix, NULL, NULL, pad_string, -1);
01491         blif_netlist->pad_node->name = (char *)HBPAD;
01492 
01493         sc_spot = sc_add_string(output_nets_sc, (char *)HBPAD);
01494         if (output_nets_sc->data[sc_spot] != NULL)
01495         {
01496                 error_message(NETLIST_ERROR, -1,-1, "Error in Odin\n");
01497         }
01498         /* store the data which is an idx here */
01499         output_nets_sc->data[sc_spot] = (void*)blif_netlist->pad_net;
01500         blif_netlist->pad_net->name = blif_pad_string;
01501 
01502 #ifdef debug_mode
01503         printf("\nexiting the top level driver net module");
01504 #endif
01505 
01506 }

Here is the call graph for this function:

void create_top_output_nodes (  ) 

Definition at line 1325 of file read_blif.c.

01326 {
01327 
01328 #ifdef debug_mode
01329   printf("\n reading the create_top_output_nodes\n");
01330 #endif
01331 
01332   char *ptr; 
01333   char buffer[BUFSIZE];
01334   npin_t *new_pin;
01335   nnode_t *new_node;
01336   char *temp_string;
01337 
01338   while (1)
01339         {
01340         /* keep reading the outputs till there is no more to read*/
01341                 ptr = my_strtok (NULL, TOKENS, blif, buffer);
01342 
01343                 if (ptr == NULL)
01344                         return;
01345 
01346         /* create a new top output node and */
01347         new_node = allocate_nnode();
01348 
01349         temp_string= make_full_ref_name(ptr, NULL, NULL,NULL, -1);;
01350         
01351         /* Create the pin connection for the net */
01352         new_pin = allocate_npin();
01353         new_pin->name=temp_string;      
01354         
01355         /*add_a_fanout_pin_to_net((nnet_t*)output_nets_sc->data[sc_spot], new_pin);*/
01356 
01357         new_node->related_ast_node = NULL;
01358         new_node->type = OUTPUT_NODE;
01359 
01360         /* add the name of the output variable */ 
01361         new_node->name = temp_string;
01362 
01363         /* allocate the input pin needed */
01364         allocate_more_node_input_pins(new_node, 1);
01365         add_input_port_information(new_node, 1);
01366 
01367         
01368 
01369         /* hookup the pin, net, and node */
01370         add_a_input_pin_to_node_spot_idx(new_node, new_pin, 0);
01371                 
01372 
01373         /*adding the node to the blif_netlist output nodes
01374           add_node_to_netlist() function can also be used */
01375         
01376         blif_netlist->top_output_nodes = (nnode_t**)realloc(blif_netlist->top_output_nodes, sizeof(nnode_t*)*(blif_netlist->num_top_output_nodes+1));
01377         blif_netlist->top_output_nodes[blif_netlist->num_top_output_nodes] = new_node;
01378         blif_netlist->num_top_output_nodes++;
01379         
01380         }
01381 
01382 #ifdef debug_mode
01383          printf("\n exiting the create_top_output_nodes");
01384 #endif
01385 
01386 } 

Here is the call graph for this function:

static void dum_parse ( char *  buffer  )  [static]

Definition at line 1511 of file read_blif.c.

01512 {
01513         /* Continue parsing to the end of this (possibly continued) line. */
01514         while (my_strtok (NULL, TOKENS, blif, buffer) != NULL);
01515 }

Here is the caller graph for this function:

void hook_up_nets (  ) 

Definition at line 1523 of file read_blif.c.

01524 {
01525   int i,j;
01526   char * name_pin;
01527   int input_pin_count=0;
01528   npin_t * input_pin;
01529   nnet_t * output_net;
01530   nnode_t * node;
01531   long sc_spot;
01532 
01533   /* hook all the input pins in all the internal nodes to the net */
01534   for(i=0;i<blif_netlist->num_internal_nodes;i++)
01535   {     
01536         node=blif_netlist->internal_nodes[i];
01537         input_pin_count=node->num_input_pins;
01538         for(j=0;j<input_pin_count;j++)
01539         {
01540                 input_pin=node->input_pins[j];
01541                 name_pin=input_pin->name;
01542                 sc_spot=sc_lookup_string(output_nets_sc,name_pin);
01543                 if(sc_spot==(-1))
01544                 {
01545                         printf("Error :Could not hook the pin %s not available ",name_pin);
01546                         exit(-1);
01547                 }
01548                 output_net=(nnet_t*)output_nets_sc->data[sc_spot];
01549                 /* add the pin to this net as fanout pin */
01550 
01551                 add_a_fanout_pin_to_net(output_net,input_pin);
01552         }
01553   }     
01554 
01555   /* hook all the ff nodes' input pin to the nets */
01556     for(i=0;i<blif_netlist->num_ff_nodes;i++)
01557   {     
01558         node=blif_netlist->ff_nodes[i];
01559         input_pin_count=node->num_input_pins;
01560         for(j=0;j<input_pin_count;j++)
01561         {
01562                 input_pin=node->input_pins[j];
01563                 name_pin=input_pin->name;
01564                 sc_spot=sc_lookup_string(output_nets_sc,name_pin);
01565                 if(sc_spot==(-1))
01566                 {                       
01567                         printf("Error :Could not hook the pin %s not available ",name_pin);
01568                         exit(-1);
01569                 }
01570                 output_net=(nnet_t*)output_nets_sc->data[sc_spot];
01571                 /* add the pin to this net as fanout pin */
01572                 add_a_fanout_pin_to_net(output_net,input_pin);  
01573                 
01574         }
01575   }
01576 
01577   /* hook the top output nodes input pins */
01578   for(i=0;i<blif_netlist->num_top_output_nodes;i++)
01579   {
01580         node=blif_netlist->top_output_nodes[i];
01581         input_pin_count=node->num_input_pins;
01582         for(j=0;j<input_pin_count;j++)
01583         {
01584                 input_pin=node->input_pins[j];
01585                 name_pin=input_pin->name;
01586                 sc_spot=sc_lookup_string(output_nets_sc,name_pin);
01587                 if(sc_spot==(-1))
01588                 {
01589                         printf("Error:Could not hook the pin %s not available ",name_pin);
01590                         exit(-1);
01591                 }
01592                 output_net=(nnet_t*)output_nets_sc->data[sc_spot];
01593                 /* add the pin to this net as fanout pin */
01594                 add_a_fanout_pin_to_net(output_net,input_pin);
01595 
01596         }
01597 
01598   }
01599 }

Here is the call graph for this function:

Here is the caller graph for this function:

void look_for_clocks (  ) 

Definition at line 1393 of file read_blif.c.

01394 {
01395         int i; 
01396         for (i = 0; i < blif_netlist->num_ff_nodes; i++)
01397         {
01398                 if (blif_netlist->ff_nodes[i]->input_pins[1]->net->driver_pin->node->type != CLOCK_NODE)
01399                 {
01400                         blif_netlist->ff_nodes[i]->input_pins[1]->net->driver_pin->node->type = CLOCK_NODE;
01401                 }
01402         }
01403 
01404 }

short read_bit_map_find_unknown_gate ( int  input_count,
nnode_t node 
)

Definition at line 1035 of file read_blif.c.

01036 {
01037 
01038 #ifdef debug_mode
01039         printf(" Reading the read_bit_map_find_unknown_gate \n");
01040 #endif
01041         
01042   FILE * temp_fpointer;
01043   char buffer[BUFSIZE];
01044   fpos_t pos;// store the current position of the file pointer
01045   char *ptr;
01046   int i,j;
01047   int line_count_bitmap=0; //stores the number of lines in a particular bit map
01048   char ** bit_map=NULL;
01049   char output_bit_map[10];// to distinguish whether for the bit_map output is 1 or 0  
01050                 
01051   fgetpos(blif,&pos);
01052   temp_fpointer=blif;
01053 
01054   if(input_count==0)
01055   {
01056         my_fgets (buffer, BUFSIZE, temp_fpointer);
01057         ptr = my_strtok(buffer,"\t\n",temp_fpointer, buffer);
01058         fsetpos(blif,&pos);
01059         if(strcmp(ptr," 0")==0)
01060         return GND_NODE;
01061         else if(strcmp(ptr," 1")==1)
01062         return VCC_NODE;
01063         else if(ptr==NULL)
01064         return GND_NODE;
01065         else
01066         return VCC_NODE;
01067   }
01068         
01069   while(1)
01070   {
01071         my_fgets (buffer, BUFSIZE, temp_fpointer);
01072         if(!(buffer[0]=='0' || buffer[0]=='1' || buffer[0]=='-'))
01073                 break;
01074 
01075         line_count_bitmap++;
01076    
01077    ptr = my_strtok(buffer,TOKENS,temp_fpointer, buffer); /* extract the input only*/
01078    bit_map=(char**)realloc(bit_map,sizeof(char*)*line_count_bitmap);
01079    bit_map[line_count_bitmap-1]=(char*)malloc(sizeof(char)*(strlen(ptr)+1));
01080    sprintf(bit_map[line_count_bitmap-1],"%s",ptr);
01081    ptr = my_strtok(NULL,TOKENS,temp_fpointer, buffer);
01082    sprintf(output_bit_map,"%s",ptr);     
01083   }
01084   
01085 #ifdef debug_mode
01086         printf(" Line_count_bitmap = %d \n",line_count_bitmap);
01087         printf(" input_count= %d \n",input_count);
01088         printf("Printing the extracted bit map \n");
01089         for(i=0;i<line_count_bitmap;i++)
01090         printf("\t: %s \n",bit_map[i]);
01091 #endif
01092 
01093   fsetpos(blif,&pos);
01094 
01095   /* check if the node type is known */ 
01096   
01097   /* Single line bit map : */
01098 
01099   if(line_count_bitmap==1)
01100   {
01101           /* GT */
01102           if(strcmp(bit_map[0],"100")==0)
01103                 return GT;
01104 
01105           /* LT */
01106           if(strcmp(bit_map[0],"010")==0)
01107                 return LT;
01108 
01109           /* LOGICAL_AND and LOGICAL_NAND for ABC*/
01110           for(i=0;i<input_count && bit_map[0][i]=='1';i++);
01111           if(i==input_count)
01112           {
01113                 if(strcmp(output_bit_map,"1")==0)
01114                 return LOGICAL_AND;
01115                 else if (strcmp(output_bit_map,"0")==0)
01116                 return LOGICAL_NAND;
01117            }
01118         
01119           /* BITWISE_NOT */
01120           if(strcmp(bit_map[0],"0")==0)
01121                 return BITWISE_NOT;
01122 
01123           /* LOGICAL_NOR and LOGICAL_OR for ABC */
01124           for(i=0;i<input_count && bit_map[0][i]=='0';i++);
01125           if(i==input_count)
01126           {
01127                 if(strcmp(output_bit_map,"1")==0)
01128                 return LOGICAL_NOR;
01129                 else if (strcmp(output_bit_map,"0")==0)
01130                 return LOGICAL_OR;
01131           }
01132 
01133           
01134           
01135 
01136   }     
01137 
01138   /* Assumption that bit map is in order when read from blif */
01139   
01140   else if(line_count_bitmap==2)
01141   {
01142 
01143 #ifdef debug_mode
01144         printf(" check : %d \n",strcmp(bit_map[0],"01"));
01145         printf(" check : %d \n",strcmp(bit_map[1],"10"));
01146 #endif
01147 
01148         /* LOGICAL_XOR */
01149         if((strcmp(bit_map[0],"01")==0) && (strcmp(bit_map[1],"10")==0))
01150                 return  LOGICAL_XOR;
01151 
01152         /* LOGICAL_XNOR */
01153         if((strcmp(bit_map[0],"00")==0) && (strcmp(bit_map[1],"11")==0))                        return  LOGICAL_XNOR;
01154  }        
01155 
01156 
01157   else if (line_count_bitmap==4)
01158   {
01159         /* ADDER_FUNC */
01160         if((strcmp(bit_map[0],"001")==0) && (strcmp(bit_map[1],"010")==0) && (strcmp(bit_map[2],"100")==0) && (strcmp(bit_map[3],"111")==0))
01161                 return ADDER_FUNC;
01162         
01163         /* CARRY_FUNC */
01164         if((strcmp(bit_map[0],"011")==0) && (strcmp(bit_map[1],"100")==0) && (strcmp(bit_map[2],"110")==0) && (strcmp(bit_map[3],"111")==0))
01165                 return  CARRY_FUNC;
01166   
01167         /* LOGICAL_XOR */
01168         if((strcmp(bit_map[0],"001")==0) && (strcmp(bit_map[1],"010")==0) && (strcmp(bit_map[2],"100")==0) && (strcmp(bit_map[3],"111")==0))
01169                 return  LOGICAL_XOR;
01170 
01171         /* LOGICAL_XNOR */
01172         if((strcmp(bit_map[0],"000")==0) && (strcmp(bit_map[1],"011")==0) && (strcmp(bit_map[2],"101")==0) && (strcmp(bit_map[3],"110")==0))
01173                 return  LOGICAL_XNOR;
01174 
01175 
01176   }
01177   
01178   if(line_count_bitmap==input_count)
01179   {
01180         /* LOGICAL_OR */
01181         for(i=0;i<line_count_bitmap;i++)
01182         {
01183                 if(bit_map[i][i]=='1')
01184                 {
01185                         for(j=1;j<input_count;j++)
01186                         {
01187                                 if(bit_map[i][(i+j)% input_count]!='-')
01188                                         break;
01189                         }
01190                         if(j!=input_count)
01191                         break;
01192                 }
01193                 else break;
01194         }       
01195         if(i==line_count_bitmap)
01196                 return LOGICAL_OR;
01197 
01198         /* LOGICAL_NAND */
01199 
01200         for(i=0;i<line_count_bitmap;i++)
01201         {
01202                 if(bit_map[i][i]=='0')
01203                 {
01204                         for(j=1;j<input_count;j++)
01205                         {
01206                                 if(bit_map[i][(i+j)% input_count]!='-')
01207                                         break;
01208                         }
01209                         if(j!=input_count)
01210                         break;
01211                 }
01212                 else break;
01213         }       
01214         if(i==line_count_bitmap)
01215                 return LOGICAL_NAND;
01216   }
01217 
01218   /* MUX_2 */   
01219   if(line_count_bitmap*2==input_count);
01220   {
01221         for(i=0;i<line_count_bitmap;i++)
01222         {
01223           if((bit_map[i][i]=='1') && (bit_map[i][i+line_count_bitmap] =='1'))
01224           {
01225                 for(j=1;j<line_count_bitmap;j++)
01226                 {
01227                         if((bit_map[i][(i+j)%line_count_bitmap]!='-') || (bit_map[i][((i+j)%line_count_bitmap)+line_count_bitmap]!='-'))
01228                                 break;  
01229                 }
01230                 if(j!=input_count)
01231                 break;
01232           }
01233           else break;
01234         }
01235         if(i==line_count_bitmap)
01236                 return MUX_2;
01237   }
01238 
01239          /* assigning the bit_map to the node if it is GENERIC */
01240         
01241         node->bit_map=bit_map;
01242         node->bit_map_line_count=line_count_bitmap;
01243         return GENERIC;
01244 
01245 }

Here is the caller graph for this function:

void read_blif ( char *  blif_file  ) 

Definition at line 74 of file read_blif.c.

00075 {
00076 
00077       int done;
00078       char buffer[BUFSIZE]; /* for storing the tokens */
00079 
00080       /* initialize the string caches that hold the aliasing of module nets and input pins */
00081       output_nets_sc = sc_new_string_cache();
00082       input_nets_sc = sc_new_string_cache();
00083 
00084       blif_netlist = allocate_netlist();
00085       /*Opening the blif file */
00086       blif = my_fopen (blif_file, "r", 0);
00087      
00088 
00089 #ifdef debug_mode
00090         printf("reading top level module");
00091 #endif
00092 
00093       /* create the top level module */     
00094       create_top_driver_nets("top");
00095 
00096       /* Extracting the netlist by reading the blif file */
00097 
00098         linenum = 0;
00099         done = 0;
00100         while (!done && (my_fgets(buffer, BUFSIZE, blif) != NULL) )
00101         {       
00102                 read_tokens(buffer,&done,blif_file);/* read one token at a time */
00103         }
00104 
00105         fclose (blif);
00106         
00107 #ifdef debug_mode  
00108         printf("\nreading look_for_clock\n");
00109 #endif
00110       /* now look for high-level signals */
00111         
00112         look_for_clocks(); 
00113         /* not need as simulator does't propogates clock signal */ 
00114 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void read_tokens ( char *  buffer,
int *  done,
char *  blif_file 
) [static]

Definition at line 122 of file read_blif.c.

00123 {
00124         
00125         /* Figures out which, if any token is at the start of this line and *
00126          * takes the appropriate action.                                    */
00127         char *ptr; // pointer to the tokens
00128 
00129         ptr = my_strtok (buffer, TOKENS, blif, buffer); // ptr has the token now compare it with the standards tokens
00130 
00131 #ifdef debug_mode
00132         printf("\nreading the read_tokens : %s",ptr);
00133 #endif
00134         
00135         if (ptr == NULL)
00136                 return;
00137                 
00138 
00139         if((skip_reading_bit_map==TRUE) &&((ptr == NULL) && ((ptr[0] == '0') || (ptr[0] == '1') || (ptr[0] == '-'))))
00140         {
00141           dum_parse(buffer);
00142           return ;
00143         }
00144         
00145         skip_reading_bit_map= FALSE;    
00146         if (strcmp (ptr, ".inputs") == 0) 
00147         {
00148         /* Create an input node */
00149            add_top_input_nodes();// create the top input nodes
00150            return;
00151         }       
00152 
00153         if (strcmp (ptr, ".outputs") == 0)
00154         {
00155         /* Create output nodes */
00156            create_top_output_nodes();// create the top output nodes
00157            return;
00158         }
00159 
00160         if (strcmp (ptr, ".names") == 0)
00161         {
00162           /* create the internal node for a .name (gate)*/      
00163           create_internal_node_and_driver();
00164           return;
00165         }
00166 
00167         if(strcmp(ptr,".latch") == 0)
00168         {
00169         /* create the ff node */        
00170         create_latch_node_and_driver(blif_file);
00171         return;
00172         }
00173 
00174         if(strcmp(ptr,".subckt") == 0)
00175         {
00176 #ifdef debug_mode
00177         printf("\n reading the subckt module \n");
00178 #endif  
00179         /* create the ff node */        
00180         create_hard_block_nodes();
00181         return;
00182         }
00183 
00184         if(strcmp(ptr,".end")==0)
00185         {
00186         /* marks the end of the main module of the blif */
00187         /* call functions to hook up the nets */
00188         hook_up_nets();
00189         *done=1;
00190         return;
00191         }
00192 
00193         if(strcmp(ptr,".model")==0)
00194         {
00195         /* not need for now */
00196         dum_parse(buffer);
00197         return;
00198         }
00199         
00200 }

Here is the call graph for this function:

Here is the caller graph for this function:

char * search_clock_name ( char *  blif_file  ) 

Definition at line 481 of file read_blif.c.

00482 {
00483   FILE * temp_read_blif;
00484   int found=0;
00485   char *ptr;
00486   char buffer[BUFSIZE];
00487   char ** input_names=NULL;
00488   int input_names_count=0;
00489   int i=0;
00490   temp_read_blif=fopen(blif_file,"r"); 
00491 
00492 #ifdef debug_mode
00493         printf("Control for the .latch not mentioned, searching for the clock\n");
00494 #endif
00495 
00496   while(1)
00497   {
00498         if(found==1)
00499         break;
00500 
00501         my_fgets(buffer,BUFSIZE,temp_read_blif);
00502 #ifdef debug_mode
00503         printf(" buffer : %s \n",buffer);
00504 #endif
00505 
00506         if(feof(temp_read_blif)!=0)// not sure if this is needed 
00507         break;
00508         
00509         ptr= my_strtok(buffer,TOKENS,temp_read_blif,buffer);
00510 #ifdef debug_mode
00511         printf(" ptr : %s \n",ptr);
00512 #endif  
00513 
00514         if(ptr==NULL)
00515         continue;
00516 
00517         if(strcmp(ptr,".end")==0)
00518         break;
00519 
00520         
00521 
00522         if(strcmp(ptr,".inputs")==0)
00523         {
00524           /* store the inputs in array of string */
00525           while(1)
00526           {
00527                 ptr=my_strtok (NULL, TOKENS,temp_read_blif, buffer);
00528 
00529 #ifdef debug_mode
00530         printf(" ptr : %s \n",ptr);
00531 #endif          
00532                 if(ptr==NULL)
00533                 break;
00534                 if(strcmp(ptr,"top^reset_n")!=0)
00535                 {
00536                 input_names_count++;
00537                 input_names=(char**)realloc(input_names,sizeof(char*) * input_names_count);
00538                 input_names[input_names_count-1]=(char*)malloc(sizeof(char)*(strlen(ptr)+1));
00539                 sprintf(input_names[input_names_count-1],"%s",ptr);
00540                 }
00541 
00542           }
00543 
00544         continue;
00545         }
00546 
00547         if(strcmp(ptr,".names")==0 || strcmp(ptr,".latch")==0)
00548         {
00549           while(1)
00550           {
00551 
00552 #ifdef debug_mode
00553         printf(" ptr : %s \n",ptr);
00554 #endif                  
00555                 ptr=my_strtok (NULL, TOKENS,temp_read_blif, buffer);
00556                 
00557                 if(ptr==NULL)
00558                   break;
00559 
00560                 for(i=0;i<input_names_count;i++)
00561                 {
00562                         if(strcmp(ptr,input_names[i])==0)
00563                         {                               
00564                           free(input_names[i]); 
00565                           input_names[i]=input_names[input_names_count-1];
00566                           input_names_count--;  
00567                         }
00568                 }
00569           }
00570         continue;
00571         }
00572         
00573         if(input_names_count==1)
00574         {
00575                 found=1;
00576                 break;
00577         }
00578                 
00579   } 
00580   fclose(temp_read_blif);
00581 
00582 
00583   if(found==1)
00584   {
00585 #ifdef debug_mode
00586         printf("Clock name found: %s\n",input_names[0]);
00587 #endif
00588         return input_names[0];
00589   }
00590   else
00591   {
00592         return default_clock_name;      
00593   }     
00594 
00595 }

Here is the caller graph for this function:


Variable Documentation

FILE* blif [static]

Definition at line 41 of file read_blif.c.

Definition at line 56 of file read_blif.c.

char* blif_one_string = "ONE_VCC_CNS"

Definition at line 51 of file read_blif.c.

char* blif_pad_string = "ZERO_PAD_ZERO"

Definition at line 53 of file read_blif.c.

char* blif_zero_string = "ZERO_GND_ZERO"

Definition at line 52 of file read_blif.c.

char* default_clock_name = "top^clock"

Definition at line 54 of file read_blif.c.

const char* GND = "gnd"

Definition at line 47 of file read_blif.c.

const char* HBPAD = "unconn"

Definition at line 49 of file read_blif.c.

Definition at line 45 of file read_blif.c.

int linenum

Definition at line 42 of file read_blif.c.

Definition at line 44 of file read_blif.c.

short skip_reading_bit_map = FALSE [static]

Definition at line 58 of file read_blif.c.

const char* VCC = "vcc"

Definition at line 48 of file read_blif.c.

Generated on Tue Aug 2 10:43:49 2011 for ODIN_II by  doxygen 1.6.3