VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
read_netlist.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void read_netlist (INP const char *net_file, INP const t_arch *arch, OUTP int *L_num_blocks, OUTP struct s_block *block_list[], OUTP int *L_num_nets, OUTP struct s_net *net_list[])
 
void free_logical_blocks (void)
 
void free_logical_nets (void)
 

Function Documentation

void free_logical_blocks ( void  )

Definition at line 1305 of file read_netlist.c.

1305  {
1306  int iblk, i;
1307  t_model_ports *port;
1308  struct s_linked_vptr *tvptr, *next;
1309 
1310  for (iblk = 0; iblk < num_logical_blocks; iblk++) {
1311  port = logical_block[iblk].model->inputs;
1312  i = 0;
1313  while (port) {
1314  if (!port->is_clock) {
1315  free(logical_block[iblk].input_nets[i]);
1316  if (logical_block[iblk].input_net_tnodes) {
1317  if (logical_block[iblk].input_net_tnodes[i])
1318  free(logical_block[iblk].input_net_tnodes[i]);
1319  }
1320  i++;
1321  }
1322  port = port->next;
1323  }
1324  if (logical_block[iblk].input_net_tnodes)
1325  free(logical_block[iblk].input_net_tnodes);
1326 
1327  tvptr = logical_block[iblk].packed_molecules;
1328  while (tvptr != NULL) {
1329  next = tvptr->next;
1330  free(tvptr);
1331  tvptr = next;
1332  }
1333 
1334  free(logical_block[iblk].input_nets);
1335  port = logical_block[iblk].model->outputs;
1336  i = 0;
1337  while (port) {
1338  free(logical_block[iblk].output_nets[i]);
1339  if (logical_block[iblk].output_net_tnodes) {
1340  if (logical_block[iblk].output_net_tnodes[i])
1341  free(logical_block[iblk].output_net_tnodes[i]);
1342  }
1343  i++;
1344  port = port->next;
1345  }
1346  if (logical_block[iblk].output_net_tnodes) {
1347  free(logical_block[iblk].output_net_tnodes);
1348  }
1349  free(logical_block[iblk].output_nets);
1350  free(logical_block[iblk].name);
1351  tvptr = logical_block[iblk].truth_table;
1352  while (tvptr != NULL) {
1353  if (tvptr->data_vptr)
1354  free(tvptr->data_vptr);
1355  next = tvptr->next;
1356  free(tvptr);
1357  tvptr = next;
1358  }
1359  }
1360  free(logical_block);
1361  logical_block = NULL;
1362 }
struct s_model_ports * next
Definition: logic_types.h:28
struct s_linked_vptr * packed_molecules
Definition: vpr_types.h:228
struct s_linked_vptr * truth_table
Definition: vpr_types.h:227
boolean is_clock
Definition: logic_types.h:26
t_model_ports * inputs
Definition: logic_types.h:35
t_model_ports * outputs
Definition: logic_types.h:36
struct s_linked_vptr * next
Definition: util.h:36
void * data_vptr
Definition: util.h:35
int num_logical_blocks
Definition: globals.c:17
t_model * model
Definition: vpr_types.h:209
struct s_logical_block * logical_block
Definition: globals.c:20

+ Here is the caller graph for this function:

void free_logical_nets ( void  )

Definition at line 1365 of file read_netlist.c.

1365  {
1366  int inet;
1367 
1368  for (inet = 0; inet < num_logical_nets; inet++) {
1369  free(vpack_net[inet].name);
1370  free(vpack_net[inet].node_block);
1371  free(vpack_net[inet].node_block_port);
1372  free(vpack_net[inet].node_block_pin);
1373  }
1374  free(vpack_net);
1375  vpack_net = NULL;
1376 }
int num_logical_nets
Definition: globals.c:17
struct s_net * vpack_net
Definition: globals.c:19

+ Here is the caller graph for this function:

void read_netlist ( INP const char *  net_file,
INP const t_arch arch,
OUTP int *  L_num_blocks,
OUTP struct s_block block_list[],
OUTP int *  L_num_nets,
OUTP struct s_net net_list[] 
)

Author: Jason Luu Date: May 2009

Read a circuit netlist in XML format and populate the netlist data structures for VPR

Initializes the block_list with info from a netlist net_file - Name of the netlist file to read num_blocks - number of CLBs in netlist block_list - array of blocks in netlist [0..num_blocks - 1] num_nets - number of nets in netlist net_list - nets in netlist [0..num_nets - 1]

Definition at line 72 of file read_netlist.c.

74  {
75  ezxml_t Cur, Prev, Top;
76  int i;
77  const char *Prop;
78  int bcount;
79  struct s_block *blist;
80  int ext_ncount;
81  struct s_net *ext_nlist;
82  struct s_hash **vpack_net_hash, **logical_block_hash, *temp_hash;
83  char **circuit_inputs, **circuit_outputs, **circuit_clocks;
84  int Count, Len;
85 
86  int num_primitives = 0;
87 
88  /* Parse the file */
89  vpr_printf(TIO_MESSAGE_INFO, "Begin parsing packed FPGA netlist file.\n");
90  Top = ezxml_parse_file(net_file);
91  if (NULL == Top) {
92  vpr_printf(TIO_MESSAGE_ERROR, "Unable to load netlist file '%s'.\n", net_file);
93  exit(1);
94  }
95  vpr_printf(TIO_MESSAGE_INFO, "Finished parsing packed FPGA netlist file.\n");
96 
97  /* Root node should be block */
98  CheckElement(Top, "block");
99 
100  /* Check top-level netlist attributes */
101  Prop = FindProperty(Top, "name", TRUE);
102  vpr_printf(TIO_MESSAGE_INFO, "Netlist generated from file '%s'.\n", Prop);
103  ezxml_set_attr(Top, "name", NULL);
104 
105  Prop = FindProperty(Top, "instance", TRUE);
106  if (strcmp(Prop, "FPGA_packed_netlist[0]") != 0) {
107  vpr_printf(TIO_MESSAGE_ERROR, "[Line %d] Expected instance to be \"FPGA_packed_netlist[0]\", found %s.",
108  Top->line, Prop);
109  exit(1);
110  }
111  ezxml_set_attr(Top, "instance", NULL);
112 
113  /* Parse top-level netlist I/Os */
114  Cur = FindElement(Top, "inputs", TRUE);
115  circuit_inputs = GetNodeTokens(Cur);
116  FreeNode(Cur);
117  Cur = FindElement(Top, "outputs", TRUE);
118  circuit_outputs = GetNodeTokens(Cur);
119  FreeNode(Cur);
120 
121  Cur = FindElement(Top, "clocks", TRUE);
122  CountTokensInString(Cur->txt, &Count, &Len);
123  if (Count > 0) {
124  circuit_clocks = GetNodeTokens(Cur);
125  } else {
126  circuit_clocks = NULL;
127  }
128  FreeNode(Cur);
129 
130  /* Parse all CLB blocks and all nets*/
131  bcount = CountChildren(Top, "block", 1);
132  blist = (struct s_block *) my_calloc(bcount, sizeof(t_block));
133 
134  /* create quick hash look up for vpack_net and logical_block
135  Also reset logical block data structure for pb
136  */
137  vpack_net_hash = alloc_hash_table();
138  logical_block_hash = alloc_hash_table();
139  for (i = 0; i < num_logical_nets; i++) {
140  temp_hash = insert_in_hash_table(vpack_net_hash, vpack_net[i].name, i);
141  assert(temp_hash->count == 1);
142  }
143  for (i = 0; i < num_logical_blocks; i++) {
144  temp_hash = insert_in_hash_table(logical_block_hash, logical_block[i].name, i);
145  logical_block[i].pb = NULL;
146  assert(temp_hash->count == 1);
147  }
148 
149  /* Prcoess netlist */
150 
151  Cur = Top->child;
152  i = 0;
153  while (Cur) {
154  if (0 == strcmp(Cur->name, "block")) {
155  CheckElement(Cur, "block");
156  processComplexBlock(Cur, blist, i, &num_primitives, arch, vpack_net_hash, logical_block_hash);
157  Prev = Cur;
158  Cur = Cur->next;
159  FreeNode(Prev);
160  i++;
161  } else {
162  Cur = Cur->next;
163  }
164  }
165  assert(i == bcount);
166  assert(num_primitives == num_logical_blocks);
167 
168  /* Error check */
169  for (i = 0; i < num_logical_blocks; i++) {
170  if (logical_block[i].pb == NULL) {
171  vpr_printf(TIO_MESSAGE_ERROR, ".blif file and .net file do not match, .net file missing atom %s.\n",
172  logical_block[i].name);
173  exit(1);
174  }
175  }
176  /* TODO: Add additional check to make sure net connections match */
177 
178 
179  mark_constant_generators(bcount, blist, num_logical_nets, vpack_net);
180  load_external_nets_and_cb(bcount, blist, num_logical_nets, vpack_net, &ext_ncount,
181  &ext_nlist, circuit_clocks);
182 
183  /* TODO: create this function later
184  check_top_IO_matches_IO_blocks(circuit_inputs, circuit_outputs, circuit_clocks, blist, bcount);
185  */
186 
187  FreeTokens(&circuit_inputs);
188  FreeTokens(&circuit_outputs);
189  if (circuit_clocks)
190  FreeTokens(&circuit_clocks);
191  FreeNode(Top);
192 
193  /* load mapping between external nets and all nets */
194  /* jluu TODO: Should use local variables here then assign to globals later, clean up later */
195  clb_to_vpack_net_mapping = (int *) my_malloc(ext_ncount * sizeof(int));
196  vpack_to_clb_net_mapping = (int *) my_malloc(num_logical_nets * sizeof(int));
197  for (i = 0; i < num_logical_nets; i++) {
199  }
200 
201  for (i = 0; i < ext_ncount; i++) {
202  temp_hash = get_hash_entry(vpack_net_hash, ext_nlist[i].name);
203  assert(temp_hash != NULL);
204  clb_to_vpack_net_mapping[i] = temp_hash->index;
205  vpack_to_clb_net_mapping[temp_hash->index] = i;
206  }
207 
208  /* Return blocks and nets */
209  *L_num_blocks = bcount;
210  *block_list = blist;
211  *L_num_nets = ext_ncount;
212  *net_list = ext_nlist;
213 
214  free_hash_table(logical_block_hash);
215  free_hash_table(vpack_net_hash);
216 }
struct s_hash ** alloc_hash_table(void)
Definition: hash.c:7
Definition: ezxml.h:44
int count
Definition: hash.h:6
void FreeTokens(INOUTP char ***TokensPtr)
Definition: ReadLine.c:9
int index
Definition: hash.h:5
int * clb_to_vpack_net_mapping
Definition: globals.c:33
char * txt
Definition: ezxml.h:47
struct s_hash * get_hash_entry(struct s_hash **hash_table, char *name)
Definition: hash.c:119
void * my_calloc(size_t nelem, size_t size)
Definition: util.c:132
int num_logical_nets
Definition: globals.c:17
static void processComplexBlock(INOUTP ezxml_t Parent, INOUTP t_block *cb, INP int index, INOUTP int *num_primitives, INP const t_arch *arch, INP struct s_hash **vpack_net_hash, INP struct s_hash **logical_block_hash)
Definition: read_netlist.c:226
char * name
Definition: vpr_types.h:560
void free_hash_table(struct s_hash **hash_table)
Definition: hash.c:18
ezxml_t next
Definition: ezxml.h:49
ezxml_t ezxml_set_attr(ezxml_t xml, char *name, char *value)
Definition: ezxml.c:1165
static void * my_malloc(int ibytes)
Definition: graphics.c:499
ezxml_t FindElement(INP ezxml_t Parent, INP const char *Name, INP boolean Required)
Definition: read_xml_util.c:11
int * vpack_to_clb_net_mapping
Definition: globals.c:34
void FreeNode(INOUTP ezxml_t Node)
Definition: read_xml_util.c:73
static void load_external_nets_and_cb(INP int L_num_blocks, INP struct s_block block_list[], INP int ncount, INP struct s_net nlist[], OUTP int *ext_ncount, OUTP struct s_net **ext_nets, INP char **circuit_clocks)
Definition: read_netlist.c:807
int line
Definition: ezxml.h:56
void CountTokensInString(INP const char *Str, OUTP int *Num, OUTP int *Len)
char ** GetNodeTokens(INP ezxml_t Node)
static void mark_constant_generators(INP int L_num_blocks, INP struct s_block block_list[], INP int ncount, INOUTP struct s_net nlist[])
char * name
Definition: ezxml.h:45
int num_logical_blocks
Definition: globals.c:17
Definition: slre.c:50
ezxml_t ezxml_parse_file(const char *file)
Definition: ezxml.c:846
t_pb * pb
Definition: vpr_types.h:567
int CountChildren(INP ezxml_t Node, INP const char *Name, INP int min_count)
struct s_net * vpack_net
Definition: globals.c:19
messagelogger vpr_printf
Definition: util.c:17
ezxml_t child
Definition: ezxml.h:52
struct s_hash * insert_in_hash_table(struct s_hash **hash_table, char *name, int next_free_index)
Definition: hash.c:76
void CheckElement(INP ezxml_t Node, INP const char *Name)
Definition: read_xml_util.c:59
const char * FindProperty(INP ezxml_t Parent, INP const char *Name, INP boolean)
Definition: hash.h:3
struct s_logical_block * logical_block
Definition: globals.c:20
Definition: util.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function: