59 const std::vector<ModuleGenerator::parameter>& _p,
60 const std::vector<ModuleGenerator::parameter>& ,
61 const std::vector<ModuleGenerator::parameter>& ,
62 const std::vector<ModuleGenerator::parameter>& )
64 const auto data_bus_bitsize =
STR(HLSMgr->Rmem->get_bus_data_bitsize());
65 const auto addr_bus_bitsize =
STR(HLSMgr->get_address_bitsize());
66 const auto size_bus_bitsize =
STR(HLSMgr->Rmem->get_bus_size_bitsize());
68 const auto selector_dimension =
STR(_p.size() < 2
U ? 2
U : _p.size());
69 const auto selector_left =
STR(((_p.size() - 1
U) < 1
U) ? 1
U : (_p.size() - 1
U));
71 std::string sensitivity;
72 for(
auto i = 0
U; i < _p.size(); i++)
74 sensitivity +=
" or " + _p[i].name;
77 std::string case_statement;
80 case_statement =
"case (_present_selector)\n";
81 for(
auto i = 0
U, selector = 1
U; i < _p.size(); i++, selector *= 2)
83 case_statement +=
" " + selector_dimension +
"'d" +
STR(selector) +
89 " data1_size=BITSIZE_in" +
94 case_statement +=
" default:\n" 97 " data1_size = 8'b0;\n" 108 "// synthesis translate_off\n" 109 "function real bits32_to_real64;\n" 110 " input [31:0] fin1;\n" 111 " reg [7:0] exponent1;\n" 112 " reg is_exp_zero;\n" 113 " reg is_all_ones;\n" 114 " reg [10:0] exp_tmp;\n" 115 " reg [63:0] fout1;\n" 117 " exponent1 = fin1[30:23];\n" 118 " is_exp_zero = exponent1 == 8'd0;\n" 119 " is_all_ones = exponent1 == {8{1'b1}};\n" 120 " exp_tmp = {3'd0, exponent1} + 11'd896;\n" 121 " fout1[63] = fin1[31];\n" 122 " fout1[62:52] = is_exp_zero ? 11'd0 : (is_all_ones ? {11{1'b1}} : exp_tmp);\n" 123 " fout1[51:29] = fin1[22:0];\n" 124 " fout1[28:0] = 29'd0;\n" 125 " bits32_to_real64 = $bitstoreal(fout1);\n" 128 "// synthesis translate_on\n" 129 "reg [BITSIZE_Mout_addr_ram-1:0] _present_pointer;\n" 130 "reg [BITSIZE_Mout_addr_ram-1:0] _next_pointer;\n" 131 "reg [BITSIZE_Mout_addr_ram-1:0] _present_pointer1;\n" 132 "reg [BITSIZE_Mout_addr_ram-1:0] _next_pointer1;\n" 133 "reg mem_sel_LOAD;\n" 134 "reg start_memory_op;\n" 135 "wire mem_done_port;\n" 146 "mem_ctrl_kernel #(.TAG_MEM_REQ(0), .BITSIZE_in1(" +
147 data_bus_bitsize +
"), .BITSIZE_in2(" + addr_bus_bitsize +
"), .BITSIZE_in3(" + size_bus_bitsize +
148 "), .BITSIZE_out1(" + data_bus_bitsize +
149 "), .BITSIZE_Mout_oe_ram(BITSIZE_Mout_oe_ram), .BITSIZE_Mout_we_ram(BITSIZE_Mout_we_ram), " 150 ".BITSIZE_Mout_addr_ram(BITSIZE_Mout_addr_ram), .BITSIZE_Mout_data_ram_size(BITSIZE_Mout_data_ram_size), " 151 ".BITSIZE_Mout_Wdata_ram(BITSIZE_Mout_Wdata_ram), .BITSIZE_Mout_tag_ram(BITSIZE_Mout_tag_ram), " 152 ".BITSIZE_M_Rdata_ram(BITSIZE_M_Rdata_ram), .BITSIZE_M_DataRdy(BITSIZE_M_DataRdy), " 153 ".BITSIZE_Min_tag(BITSIZE_Min_tag), .BITSIZE_request_accepted(BITSIZE_request_accepted)) " 154 "mem_ctrl_kernel_instance (.clock(clock), .in1(0), .in2(mem_in2), .in3(mem_in3), .in4(1'b1), " 155 ".sel_LOAD(mem_sel_LOAD), .sel_STORE(1'b0), .done_port(mem_done_port), .out1(mem_out1), " 156 ".Mout_oe_ram(Mout_oe_ram), .Mout_we_ram(Mout_we_ram), .Mout_addr_ram(Mout_addr_ram), " 157 ".Mout_data_ram_size(Mout_data_ram_size), .Mout_Wdata_ram(Mout_Wdata_ram), .Mout_tag_ram(Mout_tag_ram), " 158 ".M_Rdata_ram(M_Rdata_ram), .M_DataRdy(M_DataRdy), .Min_tag(Min_tag), .request_accepted(request_accepted), " 159 ".start_port(start_memory_op));\n" 161 "parameter [3:0] S_0 = 4'd0,\n" 172 "reg [3:0] _present_state;\n" 173 "reg [3:0] _next_state;\n" 176 ":0] _present_selector;\n" 179 ":0] _next_selector;\n" 180 "reg [63:0] data1;\n" 181 "reg [7:0] _present_data2;\n" 182 "reg [7:0] _next_data2;\n" 183 "reg [7:0] data1_size;\n" 186 " always @(posedge clock 1RESET_EDGE)\n" 187 " if (1RESET_VALUE)\n" 189 " _present_state <= S_0;\n" 190 " _present_pointer <= {BITSIZE_Mout_addr_ram{1'b0}};\n" 191 " _present_pointer1 <= {BITSIZE_Mout_addr_ram{1'b0}};\n" 192 " _present_selector <=" +
195 " _present_data2 <= 8'b0;\n" 199 " _present_state <= _next_state;\n" 200 " _present_pointer <= _next_pointer;\n" 201 " _present_pointer1 <= _next_pointer1;\n" 202 " _present_selector <= _next_selector;\n" 203 " _present_data2 <= _next_data2;\n" 206 " always @(_present_state or _present_pointer or _present_pointer1 or _present_selector or start_port or " 209 " or _present_data2 or mem_done_port or M_Rdata_ram[7:0])\n" 211 " _next_state = _present_state;\n" 212 " _next_pointer = _present_pointer;\n" 213 " _next_pointer1 = _present_pointer1;\n" 214 " _next_selector = _present_selector;\n" 215 " _next_data2 = _present_data2;\n" 216 " done_port = 1'b0;\n" 217 " mem_sel_LOAD = 1'b0;\n" 218 " start_memory_op= 1'b0;\n" 228 " case (_present_state)\n" 232 " _next_pointer=0;\n" 233 " _next_pointer1=0;\n" 234 " _next_state=S_1; \n" 242 " mem_in2 = in1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer;\n" 243 " mem_in3 = {{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8};\n" 244 " mem_sel_LOAD=1'b1;\n" 245 " start_memory_op= 1'b1;\n" 246 " if(mem_done_port)\n" 248 " _next_data2 = mem_out1[7:0];\n" 249 " _next_state=S_2;\n" 250 " // synthesis translate_off\n" 251 " write_done=1'b0;\n" 252 " // synthesis translate_on\n" 256 " _next_state=S_8;\n" 261 " mem_sel_LOAD=1'b1;\n" 262 " start_memory_op= 1'b0;\n" 263 " if(mem_done_port)\n" 265 " _next_data2 = mem_out1[7:0];\n" 266 " _next_state=S_2;\n" 267 " // synthesis translate_off\n" 268 " write_done=1'b0;\n" 269 " // synthesis translate_on\n" 273 " _next_state=S_8;\n" 278 " _next_pointer=_present_pointer+1'd1;\n" 279 " if((_present_data2!=8'd0)&&(_present_data2!=8'd37))\n" 281 "// synthesis translate_off\n" 284 " $write(\"%c\",_present_data2);\n" 285 " write_done=1'b1;\n" 287 "// synthesis translate_on\n" 288 " _next_state=S_1;\n" 290 " else if(_present_data2==8'd37)\n" 291 " _next_state=S_3;\n" 292 " else if(_present_data2==8'd0)\n" 294 " done_port = 1'b1;\n" 295 " _next_state=S_0;\n" 300 " mem_in2 = in1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer;\n" 301 " mem_in3 = {{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8};\n" 302 " mem_sel_LOAD=1'b1;\n" 303 " start_memory_op= 1'b1;\n" 304 " if(mem_done_port)\n" 306 " _next_data2 = mem_out1[7:0];\n" 307 " _next_state=S_5;\n" 308 " // synthesis translate_off\n" 309 " write_done=1'b0;\n" 310 " // synthesis translate_on\n" 314 " _next_state=S_9;\n" 319 " mem_sel_LOAD=1'b1;\n" 320 " if(mem_done_port)\n" 322 " _next_data2 = mem_out1[7:0];\n" 323 " _next_state=S_5;\n" 324 " // synthesis translate_off\n" 325 " write_done=1'b0;\n" 326 " // synthesis translate_on\n" 330 " _next_state=S_9;\n" 335 " _next_state=S_6;\n" 336 " _next_pointer=_present_pointer+1'd1;\n" 337 " case(_present_data2)\n" 340 " _next_state=S_1;\n" 341 "// synthesis translate_off\n" 344 " $write(\"%c\",8'd37);\n" 345 " write_done=1'b1;\n" 347 "// synthesis translate_on\n" 351 "// synthesis translate_off\n" 354 " $write(\"%c\",data1[7:0]);\n" 355 " write_done=1'b1;\n" 357 "// synthesis translate_on\n" 359 " 8'd100: //Decimal %d\n" 360 " if(data1_size ==8'd64)\n" 362 "// synthesis translate_off\n" 365 " $write(\"%0d\",$signed(data1));\n" 366 " write_done=1'b1;\n" 368 "// synthesis translate_on\n" 370 " else if(data1_size ==8'd32)\n" 372 "// synthesis translate_off\n" 375 " $write(\"%0d\",$signed(data1[31:0]));\n" 376 " write_done=1'b1;\n" 378 "// synthesis translate_on\n" 380 " else if(data1_size ==8'd16)\n" 382 "// synthesis translate_off\n" 385 " $write(\"%0d\",$signed(data1[15:0]));\n" 386 " write_done=1'b1;\n" 388 "// synthesis translate_on\n" 390 " else if(data1_size ==8'd8)\n" 392 "// synthesis translate_off\n" 395 " $write(\"%0d\",$signed(data1[7:0]));\n" 396 " write_done=1'b1;\n" 398 "// synthesis translate_on\n" 402 "// synthesis translate_off\n" 403 " $display(\"ERROR - Decimal precision not supported (d) %d\", data1_size);\n" 405 "// synthesis translate_on\n" 407 " 8'd105: //Decimal %i\n" 408 " if(data1_size ==8'd64)\n" 410 "// synthesis translate_off\n" 413 " $write(\"%0d\",$signed(data1));\n" 414 " write_done=1'b1;\n" 416 "// synthesis translate_on\n" 418 " else if(data1_size ==8'd32)\n" 420 "// synthesis translate_off\n" 423 " $write(\"%0d\",$signed(data1[31:0]));\n" 424 " write_done=1'b1;\n" 426 "// synthesis translate_on\n" 428 " else if(data1_size ==8'd16)\n" 430 "// synthesis translate_off\n" 433 " $write(\"%0d\",$signed(data1[15:0]));\n" 434 " write_done=1'b1;\n" 436 "// synthesis translate_on\n" 438 " else if(data1_size ==8'd8)\n" 440 "// synthesis translate_off\n" 443 " $write(\"%0d\",$signed(data1[7:0]));\n" 444 " write_done=1'b1;\n" 446 "// synthesis translate_on\n" 450 "// synthesis translate_off\n" 451 " $display(\"ERROR - Decimal precision not supported (i) %d\", data1_size);\n" 453 "// synthesis translate_on\n" 455 " 8'd101: //Exponential %e\n" 457 " if(data1_size ==8'd64)\n" 459 "// synthesis translate_off\n" 462 " $write(\"%e\",$bitstoreal(data1));\n" 463 " write_done=1'b1;\n" 465 "// synthesis translate_on\n" 467 " else if(data1_size ==8'd32)\n" 469 "// synthesis translate_off\n" 472 " $write(\"%e\",bits32_to_real64(data1[31:0]));\n" 473 " write_done=1'b1;\n" 475 "// synthesis translate_on\n" 479 "// synthesis translate_off\n" 480 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 482 "// synthesis translate_on\n" 485 " 8'd69: //Exponential %E\n" 487 " if(data1_size ==8'd64)\n" 489 "// synthesis translate_off\n" 492 " $write(\"%e\",$bitstoreal(data1));\n" 493 " write_done=1'b1;\n" 495 "// synthesis translate_on\n" 497 " else if(data1_size ==8'd32)\n" 499 "// synthesis translate_off\n" 502 " $write(\"%e\",bits32_to_real64(data1[31:0]));\n" 503 " write_done=1'b1;\n" 505 "// synthesis translate_on\n" 509 "// synthesis translate_off\n" 510 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 512 "// synthesis translate_on\n" 515 " 8'd102: //Float %f\n" 517 " if(data1_size==8'd64)\n" 519 "// synthesis translate_off\n" 522 " $write(\"%20.20f\",$bitstoreal(data1));\n" 523 " write_done=1'b1;\n" 525 "// synthesis translate_on\n" 527 " else if(data1_size ==8'd32)\n" 529 "// synthesis translate_off\n" 532 " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n" 533 " write_done=1'b1;\n" 535 "// synthesis translate_on\n" 539 "// synthesis translate_off\n" 540 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 542 "// synthesis translate_on\n" 545 " 8'd70: //Float %F\n" 547 " if(data1_size==8'd64)\n" 549 "// synthesis translate_off\n" 552 " $write(\"%20.20f\",$bitstoreal(data1));\n" 553 " write_done=1'b1;\n" 555 "// synthesis translate_on\n" 557 " else if(data1_size ==8'd32)\n" 559 "// synthesis translate_off\n" 562 " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n" 563 " write_done=1'b1;\n" 565 "// synthesis translate_on\n" 569 "// synthesis translate_off\n" 570 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 572 "// synthesis translate_on\n" 575 " 8'd103: //Float %g\n" 577 " if(data1_size==8'd64)\n" 579 "// synthesis translate_off\n" 582 " $write(\"%20.20g\",$bitstoreal(data1));\n" 583 " write_done=1'b1;\n" 585 "// synthesis translate_on\n" 587 " else if(data1_size ==8'd32)\n" 589 "// synthesis translate_off\n" 592 " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n" 593 " write_done=1'b1;\n" 595 "// synthesis translate_on\n" 599 "// synthesis translate_off\n" 600 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 602 "// synthesis translate_on\n" 605 " 8'd71: //Float %G\n" 607 " if(data1_size==8'd64)\n" 609 "// synthesis translate_off\n" 612 " $write(\"%20.20g\",$bitstoreal(data1));\n" 613 " write_done=1'b1;\n" 615 "// synthesis translate_on\n" 617 " else if(data1_size ==8'd32)\n" 619 "// synthesis translate_off\n" 622 " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n" 623 " write_done=1'b1;\n" 625 "// synthesis translate_on\n" 629 "// synthesis translate_off\n" 630 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 632 "// synthesis translate_on\n" 636 " if(data1_size ==8'd64)\n" 638 "// synthesis translate_off\n" 641 " $write(\"%0o\",data1);\n" 642 " write_done=1'b1;\n" 644 "// synthesis translate_on\n" 646 " else if(data1_size ==8'd32)\n" 648 "// synthesis translate_off\n" 651 " $write(\"%0o\",data1[31:0]);\n" 652 " write_done=1'b1;\n" 654 "// synthesis translate_on\n" 656 " else if(data1_size ==8'd16)\n" 658 "// synthesis translate_off\n" 661 " $write(\"%0o\",data1[15:0]);\n" 662 " write_done=1'b1;\n" 664 "// synthesis translate_on\n" 666 " else if(data1_size ==8'd8)\n" 668 "// synthesis translate_off\n" 671 " $write(\"%0o\",data1[7:0]);\n" 672 " write_done=1'b1;\n" 674 "// synthesis translate_on\n" 678 "// synthesis translate_off\n" 679 " $display(\"ERROR - Octal precision not supported %d\", data1_size);\n" 681 "// synthesis translate_on\n" 685 "// synthesis translate_off\n" 688 " $write(\"0x%0h\",data1);\n" 689 " write_done=1'b1;\n" 691 "// synthesis translate_on\n" 693 " 8'd115: //String\n" 695 " _next_state=S_7;\n" 696 " _next_pointer1=0;\n" 698 " 8'd117: //unsigned int %u TO BE FIXED\n" 699 " if(data1_size ==8'd64)\n" 701 "// synthesis translate_off\n" 704 " $write(\"%0d\",$unsigned(data1));\n" 705 " write_done=1'b1;\n" 707 "// synthesis translate_on\n" 709 " else if(data1_size ==8'd32)\n" 711 "// synthesis translate_off\n" 714 " $write(\"%0d\",$unsigned(data1[31:0]));\n" 715 " write_done=1'b1;\n" 717 "// synthesis translate_on\n" 719 " else if(data1_size ==8'd16)\n" 721 "// synthesis translate_off\n" 724 " $write(\"%0d\",$unsigned(data1[15:0]));\n" 725 " write_done=1'b1;\n" 727 "// synthesis translate_on\n" 729 " else if(data1_size ==8'd8)\n" 731 "// synthesis translate_off\n" 734 " $write(\"%0d\",$unsigned(data1[7:0]));\n" 735 " write_done=1'b1;\n" 737 "// synthesis translate_on\n" 741 "// synthesis translate_off\n" 742 " $display(\"ERROR - Unsigned precision not supported %d\", data1_size);\n" 744 "// synthesis translate_on\n" 746 " 8'd120: //Hex %x\n" 747 " if(data1_size ==8'd64)\n" 749 "// synthesis translate_off\n" 752 " $write(\"%0h\",data1);\n" 753 " write_done=1'b1;\n" 755 "// synthesis translate_on\n" 757 " else if(data1_size ==8'd32)\n" 759 "// synthesis translate_off\n" 762 " $write(\"%0h\",data1[31:0]);\n" 763 " write_done=1'b1;\n" 765 "// synthesis translate_on\n" 767 " else if(data1_size ==8'd16)\n" 769 "// synthesis translate_off\n" 772 " $write(\"%0h\",data1[15:0]);\n" 773 " write_done=1'b1;\n" 775 "// synthesis translate_on\n" 777 " else if(data1_size ==8'd8)\n" 779 "// synthesis translate_off\n" 782 " $write(\"%0h\",data1[7:0]);\n" 783 " write_done=1'b1;\n" 785 "// synthesis translate_on\n" 789 "// synthesis translate_off\n" 790 " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n" 792 "// synthesis translate_on\n" 795 " if(data1_size ==8'd64)\n" 797 "// synthesis translate_off\n" 800 " $write(\"%0h\",data1);\n" 801 " write_done=1'b1;\n" 803 "// synthesis translate_on\n" 805 " else if(data1_size ==8'd32)\n" 807 "// synthesis translate_off\n" 810 " $write(\"%0h\",data1[31:0]);\n" 811 " write_done=1'b1;\n" 813 "// synthesis translate_on\n" 815 " else if(data1_size ==8'd16)\n" 817 "// synthesis translate_off\n" 820 " $write(\"%0h\",data1[15:0]);\n" 821 " write_done=1'b1;\n" 823 "// synthesis translate_on\n" 825 " else if(data1_size ==8'd8)\n" 827 "// synthesis translate_off\n" 830 " $write(\"%0h\",data1[7:0]);\n" 831 " write_done=1'b1;\n" 833 "// synthesis translate_on\n" 837 "// synthesis translate_off\n" 838 " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n" 840 "// synthesis translate_on\n" 843 " _next_state=S_3;\n" 848 " _next_selector=_present_selector<<1;\n" 849 " _next_state=S_1;\n" 853 " mem_in2 = data1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer1;\n" 854 " mem_in3 = {{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8};\n" 855 " mem_sel_LOAD=1'b1;\n" 856 " start_memory_op= 1'b1;\n" 857 " if(mem_done_port)\n" 859 " _next_data2 = mem_out1[7:0];\n" 860 " _next_state=S_4;\n" 861 "// synthesis translate_off\n" 862 " write_done=1'b0;\n" 863 "// synthesis translate_on\n" 867 " _next_state=S_10;\n" 872 " mem_sel_LOAD=1'b1;\n" 873 " if(mem_done_port)\n" 875 " _next_data2 = mem_out1[7:0];\n" 876 " _next_state=S_4;\n" 877 " // synthesis translate_off\n" 878 " write_done=1'b0;\n" 879 " // synthesis translate_on\n" 883 " _next_state=S_10;\n" 888 " _next_pointer1=_present_pointer1+1'd1;\n" 889 " if(_present_data2!=8'd0)\n" 891 "// synthesis translate_off\n" 894 " $write(\"%c\",_present_data2);\n" 895 " write_done=1'b1;\n" 897 "// synthesis translate_on\n" 898 " _next_state=S_7;\n" 901 " _next_state=S_6;\n" Data structure representing the entire HLS information.
PrintfCSModuleGenerator(const HLS_managerRef &HLSMgr)
void InternalExec(std::ostream &out, structural_objectRef mod, unsigned int function_id, vertex op_v, const HDLWriter_Language language, const std::vector< ModuleGenerator::parameter > &_p, const std::vector< ModuleGenerator::parameter > &_ports_in, const std::vector< ModuleGenerator::parameter > &_ports_out, const std::vector< ModuleGenerator::parameter > &_ports_inout) final
#define STR(s)
Macro which performs a lexical_cast to a string.
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Datastructure to represent memory information in high-level synthesis.