VPR-7.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
verilog_writer.h
Go to the documentation of this file.
1 #include <assert.h>
2 #include <stdio.h>
3 #include <sys/types.h>
4 #include <time.h>
5 #include "util.h"
6 #include "vpr_types.h"
7 #include "vpr_utils.h"
8 #include "globals.h"
9 #include "read_place.h"
10 #include "draw.h"
11 #include "stats.h"
12 #include "check_route.h"
13 #include "rr_graph.h"
14 #include "path_delay.h"
15 #include "net_delay.h"
16 #include "timing_place.h"
17 #include "read_xml_arch_file.h"
18 #include "ReadOptions.h"
19 #include "physical_types.h"
20 #include "globals.h"
21 #include "string.h"
22 #include "stdlib.h"
23 #include "math.h"
24 
25 /*
26 verilog_writer.c defines the main functions used to:
27 
28  1) identify the primitives in a design
29  2) find the connectivity between primitives
30  3) Write the verilog code representing the post-synthesized (packed,placed,routed) design consisting of LUTs, IOs, Flip Flops, Multiplier blocks, and RAM blocks
31  4) Write the Standard Delay Format(SDF) file corresponding to the verilog code mentioned in (3). The SDF file contains all the timing information of the design which
32  allows the user to perform timing simulation
33 */
34 
35 
36 
37 
38 /* ***************************************************************************************************************
39  The pb_list data structure is used in a linked list by the function traverse_clb that will find primitives.
40  This data structure represents a single primitive.
41 
42  pb: A pointer to the t_pb data structure representing the primitive.
43  pb_graph: A pointer to the t_pb_graph_node representing the primitive.
44  driver_pin: (Only applicable to "find_connected_primitives_downhill" & "find_connected_primitives_uphill")
45  A pointer to the t_pb_graph_pin data structure corresponding to the pin that drives the signal on the load_pin of this pb primitive.
46  The port index and pin number for the pin is accessible through this data structure.
47  load_pin: (Only applicable to "find_connected_primitives_downhill" & "find_connected_primitives_uphill")
48  A pointer to the t_pb_graph_pin data structure corresponding to the input pin that receives the signal from the driver_pin.
49  The port index and pin number for the pin is accessible through this data structure.
50  next: pointer to the next pb primitive found in the linked list*/
51 typedef struct found_pins{
52 
53  t_pb *pb;
54 
55  struct found_pins *next;
56 
57 }pb_list;
58 
59 
60 /* ***************************************************************************************************************
61  The conn_list data structure is used in a linked list by functions that will be used by functions that will find the connectivity between primitives.
62  This data structure represents a single driver to load pair of primitives.
63 
64  driver_pb: A pointer to the t_pb data structure representing the driver primitive.
65  load_pb: A pointer to the t_pb data structure representing the load primitive.
66  driver_pin: A pointer to the t_pb_graph_pin data structure corresponding to the pin that drives the signal on the load_pin of this pb primitive.
67  The port index and pin number for the pin is accessible through this data structure.
68  load_pin: A pointer to the t_pb_graph_pin data structure corresponding to the input pin that receives the signal from the driver_pin.
69  The port index and pin number for the pin is accessible through this data structure.
70  driver_to_load_delay: The delay, in seconds, for a signal to propagate from the driver pin to the load pin.
71  next: pointer to the next driver-load pair found.
72 */
73 typedef struct found_connectivity{
74 
77 
80 
82 
84 
85 }conn_list;
86 
87 
88 /*The verilog_writer function is the main function that will generate and write to the verilog and SDF files
89  Al the functions declared bellow are called directly or indirectly by verilog_writer.c
90  net_delay is a float 2D array containing the inter clb delay information.*/
91 void verilog_writer(void);
92 
93 /*The traverse_clb function returns a linked list of all the primitives inside a complex block.
94  These primitives may be LUTs , FlipFlops , etc.
95  block_num: the block number for the complex block.
96  pb: The t_pb data structure corresponding to the complex block. (i.e block[block_num].pb)
97  prim_list: A pin_list pointer corresponding to the head of the linked list. The function will populate this head pointer.*/
98 pb_list *traverse_clb(t_pb *pb, pb_list *prim_list);
99 
100 
101 /*The find_connected_primitives_downhill function will return a linked list of all the primitives that a particular primitive connects to.
102  block_num: the block number of the complex block that the primitive resides in.
103  pb: A pointer to the t_pb data structure that represents the primitive (not the complex block).
104  list: A head pointer to the start of a linked list. This function will populate the linked list. The linked list can be empty (i.e list=NULL)
105  or contain other primitives.*/
106 conn_list *find_connected_primitives_downhill(int block_num , t_pb *pb , conn_list *list);
107 
108 /*The function insert_to_linked_list inserts a new primitive to the pb_list type linked list pointed by "list".*/
109 pb_list *insert_to_linked_list(t_pb *pb_new , pb_list *list);
110 
111 /*The function insert_to_linked_list_conn inserts a new primitive to the conn_list type linked list pointed by "list".*/
112 conn_list *insert_to_linked_list_conn(t_pb *driver_new , t_pb *load_new , t_pb_graph_pin *driver_pin_ , t_pb_graph_pin *load_pin_ , float path_delay , conn_list *list);
113 
114 /*The traverse_linked_list function prints the entire pb_list type linked list pointed to by "list"*/
115 void traverse_linked_list(pb_list *list);
116 
117 /*The traverse_linked_list_conn function prints the entire conn_list type linked list pointed to by "list"*/
119 
120 /*The free_linked_list function frees the memory used by the pb_list type linked list pointed to by "list"*/
122 
123 /*The free_linked_list_conn function frees the memory used by the conn_list type linked list pointed to by "list"*/
125 
126 /*The function instantiate_top_level_module instantiates the top level verilog module of the post-synthesized circuit and the list of inputs and outputs to that module*/
127 void instantiate_top_level_module(FILE *Verilog);
128 
129 /*The instantiate_wires function instantiates all the wire in the post-synthesized design*/
130 void instantiate_wires(FILE *Verilog);
131 
132 /*The function instantiate_input_interconnect will instantiate the interconnect segments from input pins to the rest of the design*/
133 void instantiate_input_interconnect(FILE *Verilog , FILE *SDF , char *clock_name);
134 
135 /*This function instantiates the interconnect modules that connect from the output pins of the primitive "pb" to whatever it connects to*/
136 void instantiate_interconnect(FILE *Verilog , int block_num , t_pb *pb , FILE *SDF);
137 
138 /*This function instantiates the primitive verilog modules e.g. LUTs ,Flip Flops, etc.*/
139 void instantiate_primitive_modules(FILE *Verilog , char *clock_name , FILE *SDF);
140 
141 /*This function returns the truth table corresponding to the LUT primitive represented by "pb"*/
142 char *load_truth_table(int inputs , t_pb *pb);
143 
144 /*The names of some primitives contain certain characters that would cause syntax errors in Verilog (e.g. '^' , '~' , '[' , etc. ). This function returns a new string
145  with those illegal characters removed and replaced with '_'*/
146 char *fix_name(char *name);
147 
148 /*This function finds the number of inputs to a primitive.*/
149 int find_number_of_inputs(t_pb *pb);
150 
151 /*This function is a utility function used by load_truth_table and load_truth_table_new functions. It will return the index of a particular row in the truth table*/
152 int find_index(char *row,int inputs);
153 
154 /*This function is a utility function called by intantiate_interconnect*/
155 void interconnect_printing(FILE *fp , conn_list *downhill);
156 
157 /*This function will instantiate the header of te Standar Delay Format (SDF) file.*/
158 void instantiate_SDF_header(FILE *SDF);
159 
160 /*This funciton will instantiate the SDF cell that contains the delay information of the Verilog interconnect modules*/
161 void SDF_interconnect_delay_printing(FILE *SDF , conn_list *downhill);
162 
163 /*This function instantiates the SDF cell that contains the delay information of a LUT*/
164 void sdf_LUT_delay_printing(FILE *SDF , t_pb *pb);
165 
166 /*This function instantiates the SdF cell that contains the delay information of a Flip Flop*/
167 void sdf_DFF_delay_printing(FILE *SDF , t_pb *pb);
168 
169 /*This function instantiates the SdF cell that contains the delay information of a Multiplier*/
170 void SDF_Mult_delay_printing(FILE *SDF , t_pb *pb);
171 
172 /*This function instantiates the SdF cell that contains the delay information of a Adder*/
173 void SDF_Adder_delay_printing(FILE *SDF , t_pb *pb);
174 
175 /*Finds and returns the name of the clock signal int he circuit*/
176 char *find_clock_name(void);
177 
178 /*This function instantiates the SdF cell that contains the delay information of a Single_port_RAM*/
179 void SDF_ram_single_port_delay_printing(FILE *SDF , t_pb *pb);
180 
181 /*This function instantiates the SdF cell that contains the delay information of a Dual_port_RAM*/
182 void SDF_ram_dual_port_delay_printing(FILE *SDF , t_pb *pb);
void SDF_ram_single_port_delay_printing(FILE *SDF, t_pb *pb)
void SDF_Mult_delay_printing(FILE *SDF, t_pb *pb)
t_pb_graph_pin * driver_pin
pb_list * traverse_clb(t_pb *pb, pb_list *prim_list)
void instantiate_SDF_header(FILE *SDF)
void verilog_writer(void)
void SDF_interconnect_delay_printing(FILE *SDF, conn_list *downhill)
void traverse_linked_list(pb_list *list)
t_pb_graph_pin * load_pin
void traverse_linked_list_conn(conn_list *list)
struct found_pins pb_list
void sdf_DFF_delay_printing(FILE *SDF, t_pb *pb)
void instantiate_interconnect(FILE *Verilog, int block_num, t_pb *pb, FILE *SDF)
void SDF_ram_dual_port_delay_printing(FILE *SDF, t_pb *pb)
conn_list * find_connected_primitives_downhill(int block_num, t_pb *pb, conn_list *list)
conn_list * free_linked_list_conn(conn_list *list)
struct found_connectivity conn_list
void instantiate_top_level_module(FILE *Verilog)
int find_index(char *row, int inputs)
void instantiate_input_interconnect(FILE *Verilog, FILE *SDF, char *clock_name)
void sdf_LUT_delay_printing(FILE *SDF, t_pb *pb)
pb_list * insert_to_linked_list(t_pb *pb_new, pb_list *list)
void interconnect_printing(FILE *fp, conn_list *downhill)
void SDF_Adder_delay_printing(FILE *SDF, t_pb *pb)
void instantiate_wires(FILE *Verilog)
pb_list * free_linked_list(pb_list *list)
void instantiate_primitive_modules(FILE *Verilog, char *clock_name, FILE *SDF)
struct found_pins * next
struct found_connectivity * next
conn_list * insert_to_linked_list_conn(t_pb *driver_new, t_pb *load_new, t_pb_graph_pin *driver_pin_, t_pb_graph_pin *load_pin_, float path_delay, conn_list *list)
int find_number_of_inputs(t_pb *pb)
char * fix_name(char *name)
char * load_truth_table(int inputs, t_pb *pb)
char * find_clock_name(void)