68 char * verilog_file_name = (
char *)malloc((strlen(
blif_circuit_name) + strlen(
"_post_synthesis.v") + 1) *
sizeof(char));
69 char * sdf_file_name = (
char *)malloc((strlen(
blif_circuit_name) + strlen(
"_post_synthesis.sdf") + 1) *
sizeof(
char));
71 assert(verilog_file_name);
72 assert(sdf_file_name);
73 printf(
"\nWriting the post-synthesized circuit Verilog and SDF.....\n...");
79 verilog = fopen(verilog_file_name ,
"w");
80 SDF = fopen(sdf_file_name ,
"w");
89 fprintf(verilog ,
"\nendmodule\n");
102 char *fixed_name = NULL;
109 if(!strcmp(
block[i].pb->pb_graph_node->pb_type->
name,
"io"))
112 for(current=temp ; current!=NULL ; current=current->
next)
115 fprintf(verilog ,
"\t,");
118 fprintf(verilog ,
"\t");
124 fprintf(verilog ,
"input %s\n",fixed_name);
130 fprintf(verilog ,
"output %s\n",fixed_name);
137 fprintf(verilog ,
");\n\n");
143 fprintf(SDF ,
"(DELAYFILE\n\t(SDFVERSION \"2.1\")\n\t(DIVIDER /)\n\t(TIMESCALE 1 ps)\n\n ");
152 char *fixed_name = NULL;
158 for(current=primitive_list ; current!=NULL ; current=current->
next)
167 fprintf(verilog ,
"wire %s_output_%d_%d;\n" , fixed_name , j , k);
172 fprintf(verilog ,
"assign %s_output_%d_%d = %s;\n\n",fixed_name , j , k , fixed_name);
182 fprintf(verilog ,
"wire %s_input_%d_%d;\n" , fixed_name , j , k);
186 fprintf(verilog ,
"assign %s = %s_input_%d_%d;\n\n",fixed_name , fixed_name , j , k);
204 pb_list *primitive_list = NULL;
209 if(strcmp(
block[blocks].pb->pb_graph_node->pb_type->
name,
"io"))
214 for(current=primitive_list ; current!=NULL ; current=current->
next)
220 if(clock_name && !strcmp(current->
pb->
name,clock_name))
244 char *truth_table = NULL;
246 char *fixed_name = NULL;
251 for(current=primitives ; current!=NULL ; current=current->
next)
259 assert((inputs_to_lut >= 3) && (inputs_to_lut <= 7));
264 power = 1 << inputs_to_lut;
265 fprintf(fp ,
"\nLUT_%d #(%d'b%s) lut_%s(", inputs_to_lut , power , truth_table , fixed_name);
278 fprintf(fp ,
" , %s_input_%d_%d" , fixed_name , k , j);
282 fprintf(fp ,
"%s_input_%d_%d" , fixed_name , k , j);
289 while(j<inputs_to_lut)
295 fprintf(fp ,
" , 1'b0");
300 fprintf(fp ,
"1'b0");
306 fprintf(fp ,
" , %s_output_0_0 );\n\n",fixed_name);
315 char *fixed_clock_name;
316 fixed_clock_name =
fix_name(clock_name);
317 fprintf(fp ,
"\nD_Flip_Flop DFF_%s(%s_output_0_0 , %s_input_0_0 , 1'b1 , 1'b1 , %s_output_0_0 );\n",fixed_name,fixed_clock_name,fixed_name,fixed_name);
320 free(fixed_clock_name);
332 fprintf(fp ,
"\nmult #(%d)%s(" , num_inputs , fixed_name);
334 fprintf(fp ,
"\nripple_adder #(%d)%s(" , num_inputs , fixed_name);
355 fprintf(fp ,
" , %s_input_%d_%d" , fixed_name , i_port , i_pin);
359 fprintf(fp ,
"%s_input_%d_%d" , fixed_name , i_port , i_pin);
367 fprintf(fp ,
", 1'b0");
370 fprintf(fp ,
" 1'b0");
387 fprintf(fp ,
", %s_output_%d_%d" , fixed_name , i_port , i_pin);
390 fprintf(fp ,
" %s_output_%d_%d" , fixed_name , i_port , i_pin);
396 fprintf(fp ,
");\n\n");
405 char *fixed_clock_name;
407 int data_width,addr_width;
412 fprintf(fp ,
"\nsingle_port_ram #(%d,%d)%s(" , addr_width , data_width , fixed_name);
432 fprintf(fp ,
" , %s_input_%d_%d" , fixed_name , i_port , i_pin);
436 fprintf(fp ,
"%s_input_%d_%d" , fixed_name , i_port , i_pin);
443 fprintf(fp ,
", 1'b0");
446 fprintf(fp ,
" 1'b0");
463 fprintf(fp ,
", %s_output_%d_%d" , fixed_name , i_port , i_pin);
466 fprintf(fp ,
" %s_output_%d_%d" , fixed_name , i_port , i_pin);
472 fixed_clock_name =
fix_name(clock_name);
473 fprintf(fp ,
", %s_output_0_0" , fixed_clock_name);
474 fprintf(fp ,
");\n\n");
475 free(fixed_clock_name);
481 int data1_width,data2_width,addr1_width,addr2_width,i_port,i_pin;
482 char *fixed_clock_name;
499 fprintf(fp ,
"\ndual_port_ram #(%d,%d,%d,%d)%s(" , addr1_width , data1_width , addr2_width , data2_width , fixed_name);
519 fprintf(fp ,
" , %s_input_%d_%d" , fixed_name , i_port , i_pin);
523 fprintf(fp ,
"%s_input_%d_%d" , fixed_name , i_port , i_pin);
530 fprintf(fp ,
", 1'b0");
533 fprintf(fp ,
" 1'b0");
550 fprintf(fp ,
", %s_output_%d_%d" , fixed_name , i_port , i_pin);
553 fprintf(fp ,
" %s_output_%d_%d" , fixed_name , i_port , i_pin);
559 fixed_clock_name =
fix_name(clock_name);
560 fprintf(fp ,
", %s_output_0_0" , fixed_clock_name);
561 fprintf(fp ,
");\n\n");
562 free(fixed_clock_name);
570 printf(
"Failed to generate post-synthesized verilog and sdf files. Primitive %s is unknown.\n\nAcceptable primitives are: LUTs, Flip Flops, IOs, Adders, Rams, and Multiplier blocks.\n\nTo generate the post synthesized verilog and SDF files successfully, you must append the verilog code for the %s to the primitives.v file, and contact the VPR developers team on the website: http://code.google.com/p/vtr-verilog-to-routing/ to update the VPR source code to handle the new primitive. \n",
logical_block[current->
pb->
logical_block].
model->
name ,
logical_block[current->
pb->
logical_block].
model->
name);
597 int number_of_dont_cares=0;
598 int tries,shift,which_row,i,j;
599 int possibles = 1 << inputs;
601 char *possible_row = (
char *)malloc(inputs+1 *
sizeof(
char));
602 char *tt = (
char *)malloc((possibles+1) *
sizeof(char));
604 int number_of_used_inputs_to_lut;
606 assert(possible_row);
613 for (i = 0; i < possibles; i++)
615 tt[possibles] =
'\0';
619 set_to = tt_row_blif[strlen(tt_row_blif)-1];
624 for(i=0 ; i<possibles ; i++)
630 for(i=0 ; i<possibles ; i++)
635 tt[possibles] =
'\0';
649 number_of_used_inputs_to_lut = strlen(tt_row_blif)-2;
650 if(number_of_used_inputs_to_lut == 0)
652 for(i=0 ; i<possibles ; i++)
654 tt[i] = tt_row_blif[1];
658 for(i=0; i<inputs ; i++)
660 if(tt_row_blif[i] ==
'-')
662 number_of_dont_cares++;
665 tries = 1 << number_of_dont_cares;
667 for(i=0 ; i<(tries) ; i++)
669 shift=number_of_dont_cares-1;
670 for(j=0 ; j<number_of_used_inputs_to_lut ; j++)
672 if(tt_row_blif[j]==
'-')
675 if(((i>>shift) & 0x1) == 1)
677 possible_row[j] =
'1';
680 possible_row[j] =
'0';
686 possible_row[j]=tt_row_blif[j];
691 tt[possibles-1-which_row] = set_to;
694 number_of_dont_cares = 0;
706 for(i=strlen(row)-1 ; i>=0 ; i--)
714 length = strlen(row);
717 index = index << (inputs-(strlen(row)));
732 for(i=0 ; new_[i]!=
'\0' ; i++)
734 if(new_[i]==
'^' || (
int)new_[i]<48 || ((
int)new_[i]>57 && (
int)new_[i]<65) || ((
int)new_[i]>90 && (
int)new_[i]<97) || (
int)new_[i]>122)
762 int port_number_out=-1,port_number_in=-1,i;
764 for(connections=downhill ; connections!=NULL ; connections=connections->
next)
783 assert(port_number_out >= 0 && port_number_in >= 0);
785 fprintf(fp ,
"interconnect routing_segment_%s_output_%d_%d_to_%s_input_%d_%d( %s_output_%d_%d , %s_input_%d_%d );\n",
802 float internal_delay;
804 int port_number_out=-1,port_number_in=-1,i;
806 for(connections=downhill ; connections!=NULL ; connections=connections->
next)
826 internal_delay = internal_delay * 1000000000000.00;
827 internal_delay = internal_delay + 0.5;
828 del = (int)internal_delay;
830 fprintf(SDF ,
"\t(CELL\n\t(CELLTYPE \"interconnect\")\n\t(INSTANCE inst/routing_segment_%s_output_%d_%d_to_%s_input_%d_%d)\n" ,
833 fprintf(SDF ,
"\t\t(DELAY\n\t\t(ABSOLUTE\n\t\t\t(IOPATH datain dataout (%d:%d:%d)(%d:%d:%d))\n\t\t)\n\t\t)\n\t)\n" ,
834 del , del , del , del , del , del);
847 float internal_delay;
871 internal_delay = internal_delay * 1000000000000.00;
872 internal_delay = internal_delay + 0.5;
873 del = (int)internal_delay;
876 fprintf(SDF ,
"\t(CELL\n\t(CELLTYPE \"LUT_%d\")\n\t(INSTANCE inst/lut_%s)\n\t\t(DELAY\n\t\t(ABSOLUTE\n" ,
find_number_of_inputs(pb) , fixed_name);
880 fprintf(SDF ,
"\t\t\t(IOPATH inter%d/datain inter%d/dataout (%d:%d:%d)(%d:%d:%d))\n" , j , j , del , del , del , del , del , del);
884 fprintf(SDF ,
"\t\t)\n\t\t)\n\t)\n");
892 float internal_delay;
896 fprintf(SDF ,
"\t(CELL\n\t(CELLTYPE \"D_Flip_Flop\")\n\t(INSTANCE inst/DFF_%s)\n\t\t(DELAY\n\t\t(ABSOLUTE\n" , fixed_name);
901 del = (int)internal_delay;
903 fprintf(SDF ,
"\t\t\t(IOPATH (posedge clock) Q (%d:%d:%d)(%d:%d:%d))\n" , del , del , del , del , del , del);
904 fprintf(SDF ,
"\t\t)\n\t\t)\n\t)\n");
912 float internal_delay;
916 fprintf(SDF ,
"\t(CELL\n\t(CELLTYPE \"mult\")\n\t(INSTANCE inst/%s)\n\t\t(DELAY\n\t\t(ABSOLUTE\n" , fixed_name);
922 internal_delay = internal_delay * 1000000000000.00;
923 internal_delay = internal_delay + 0.5;
924 del = (int)internal_delay;
925 fprintf(SDF ,
"\t\t\t(IOPATH delay/A delay/B (%d:%d:%d)(%d:%d:%d))\n" , del , del , del , del , del , del);
930 internal_delay = internal_delay * 1.0E12;
931 internal_delay = internal_delay + 0.5;
932 del = (int)internal_delay;
933 fprintf(SDF ,
"\t\t\t(IOPATH delay2/A delay2/B (%d:%d:%d)(%d:%d:%d))\n" , del , del , del , del , del , del);
935 fprintf(SDF ,
"\t\t)\n\t\t)\n\t)\n");
950 for (i = 0; i < total_input_ports; i++) {
961 for (k = 0; k < tNodeInput->
num_edges; k++) {
967 fprintf(SDF ,
"\t(CELL\n\t(CELLTYPE \"ripple_adder\")\n\t(INSTANCE inst/%s)\n\t\t(DELAY\n\t\t(ABSOLUTE\n" , fixed_name);
971 fprintf(SDF ,
"\t\t\t(IOPATH %s %s (%d:%d:%d)(%d:%d:%d))\n" , tNodeInput->
pb_graph_pin->
port->
name,
973 del , del , del , del , del , del);
982 fprintf(SDF ,
"\t\t)\n\t\t)\n\t)\n");
992 float internal_delay;
997 fprintf(SDF ,
"\t(CELL\n\t(CELLTYPE \"single_port_ram\")\n\t(INSTANCE inst/%s)\n\t\t(DELAY\n\t\t(ABSOLUTE\n" , fixed_name);
1002 del = (int)internal_delay;
1004 fprintf(SDF ,
"\t\t\t(IOPATH (posedge clock) out (%d:%d:%d)(%d:%d:%d))" , del , del , del , del , del , del);
1006 fprintf(SDF ,
"\t\t)\n\t\t)\n\t)\n");
1016 float internal_delay;
1021 fprintf(SDF ,
"\t(CELL\n\t(CELLTYPE \"dual_port_ram\")\n\t(INSTANCE inst/%s)\n\t\t(DELAY\n\t\t(ABSOLUTE\n" , fixed_name);
1026 del = (int)internal_delay;
1028 fprintf(SDF ,
"\t\t\t(IOPATH (posedge clock) out1 (%d:%d:%d)(%d:%d:%d))" , del , del , del , del , del , del);
1029 fprintf(SDF ,
"\t\t\t(IOPATH (posedge clock) out2 (%d:%d:%d)(%d:%d:%d))" , del , del , del , del , del , del);
1031 fprintf(SDF ,
"\t\t)\n\t\t)\n\t)\n");
1038 char *clock_in_the_design=NULL;
1050 printf(
"The post-layout netlist generator presently handles single-clock designs only. Your design contains %d clocks. \n"
1051 "Future VTR releases may support post-layout netlist generation for multi-clock designs.\n", clocks);
1054 return(clock_in_the_design);
1067 if(pb == NULL || pb->
name == NULL) {
1099 int total_output_pins;
1100 int pin_number , port_number_out=-1 , pin_number_out , starting_block , next_block , vpck_net , pin_count;
1101 float delay , start_delay , end_delay;
1103 char *temp_port_name = (
char *)malloc(1000 *
sizeof(
char));
1105 int model_port_index;
1107 assert(temp_port_name);
1110 for(i=0 ; i < total_output_ports ; i++)
1113 for(j=0 ; j < total_output_pins ; j++)
1125 if(vpck_net !=
OPEN)
1152 port_number_out = pin_number_out = -1;
1158 port_number_out = r;
1166 assert(port_number_out != -1);
1167 assert(pin_number_out != -1);
1176 delay = end_delay - start_delay;
1187 free(temp_port_name);
1195 new_list->
pb = pb_new;
1196 new_list->
next = list;
1210 new_list->
next = list;
1220 for(current=list ; current != NULL ; current=current->
next)
1222 printf(
" driver=> type: %s , name: %s , output: [%d][%d] , load=> type: %s , name: %s input: [%d][%d]\npath delay: %e\n\n",current->
driver_pb->
pb_graph_node->
pb_type->
name ,
1237 for(current=list ; current!=NULL ; current=current->
next)
1249 while(current!=NULL)
1252 current=current->
next;
1265 while(current!=NULL)
1268 current=current->
next;
t_model_ports * model_port
struct s_pb_type * pb_type_children
void instantiate_interconnect(FILE *verilog, int block_num, t_pb *pb, FILE *SDF)
t_pb_graph_pin * driver_pin
int find_index(char *row, int inputs)
struct s_rr_node * rr_graph
pb_list * traverse_clb(t_pb *pb, pb_list *prim_list)
void sdf_LUT_delay_printing(FILE *SDF, t_pb *pb)
t_pb_graph_pin * load_pin
struct s_linked_vptr * truth_table
t_pb_graph_pin ** output_pins
void instantiate_primitive_modules(FILE *fp, char *clock_name, FILE *SDF)
void instantiate_SDF_header(FILE *SDF)
void interconnect_printing(FILE *fp, conn_list *downhill)
void SDF_ram_dual_port_delay_printing(FILE *SDF, t_pb *pb)
float driver_to_load_delay
void SDF_Adder_delay_printing(FILE *SDF, t_pb *pb)
pb_list * insert_to_linked_list(t_pb *pb_new, pb_list *list)
void verilog_writer(void)
char * load_truth_table(int inputs, t_pb *pb)
void traverse_linked_list_conn(conn_list *list)
struct s_pb_graph_node * parent_node
char * find_clock_name(void)
void SDF_ram_single_port_delay_printing(FILE *SDF, t_pb *pb)
struct s_linked_vptr * next
void instantiate_input_interconnect(FILE *verilog, FILE *SDF, char *clock_name)
t_pb_graph_pin * pb_graph_pin
void traverse_linked_list(pb_list *list)
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)
struct s_pb_type * pb_type
void instantiate_wires(FILE *verilog)
struct found_connectivity * next
void sdf_DFF_delay_printing(FILE *SDF, t_pb *pb)
conn_list * free_linked_list_conn(conn_list *list)
void SDF_interconnect_delay_printing(FILE *SDF, conn_list *downhill)
void SDF_Mult_delay_printing(FILE *SDF, t_pb *pb)
pb_list * free_linked_list(pb_list *list)
char * my_strdup(const char *str)
int find_number_of_inputs(t_pb *pb)
conn_list * find_connected_primitives_downhill(int block_num, t_pb *pb, conn_list *list)
t_pb_graph_node * pb_graph_node
char * fix_name(char *name)
t_pb_graph_pin ** input_pins
struct s_logical_block * logical_block
void instantiate_top_level_module(FILE *verilog)
t_pb_graph_pin * get_pb_graph_node_pin_from_vpack_net(int inet, int ipin)