60 const std::vector<ModuleGenerator::parameter>& _p,
61 const std::vector<ModuleGenerator::parameter>& ,
62 const std::vector<ModuleGenerator::parameter>& ,
63 const std::vector<ModuleGenerator::parameter>& )
65 const auto selector_dimension =
STR(_p.size() < 2
U ? 2
U : _p.size());
66 const auto selector_left =
STR(((_p.size() - 1
U) < 1
U) ? 1
U : (_p.size() - 1
U));
68 std::string sensitivity;
69 for(
auto i = 0
U; i < _p.size(); i++)
71 sensitivity +=
" or " + _p[i].name;
74 std::string case_statement;
77 case_statement =
"case (_present_selector)\n";
78 for(
auto i = 0
U, selector = 1
U; i < _p.size(); i++, selector *= 2)
80 case_statement +=
" " + selector_dimension +
"'d" +
STR(selector) +
86 " data1_size=BITSIZE_in" +
91 case_statement +=
" default:\n" 94 " data1_size = 8'b0;\n" 105 "// synthesis translate_off\n" 106 "function real bits32_to_real64;\n" 107 " input [31:0] fin1;\n" 108 " reg [7:0] exponent1;\n" 109 " reg is_exp_zero;\n" 110 " reg is_all_ones;\n" 111 " reg [10:0] exp_tmp;\n" 112 " reg [63:0] fout1;\n" 114 " exponent1 = fin1[30:23];\n" 115 " is_exp_zero = exponent1 == 8'd0;\n" 116 " is_all_ones = exponent1 == {8{1'b1}};\n" 117 " exp_tmp = {3'd0, exponent1} + 11'd896;\n" 118 " fout1[63] = fin1[31];\n" 119 " fout1[62:52] = is_exp_zero ? 11'd0 : (is_all_ones ? {11{1'b1}} : exp_tmp);\n" 120 " fout1[51:29] = fin1[22:0];\n" 121 " fout1[28:0] = 29'd0;\n" 122 " bits32_to_real64 = $bitstoreal(fout1);\n" 125 "// synthesis translate_on\n" 126 "reg [BITSIZE_Mout_addr_ram-1:0] _present_pointer;\n" 127 "reg [BITSIZE_Mout_addr_ram-1:0] _next_pointer;\n" 128 "reg [BITSIZE_Mout_addr_ram-1:0] _present_pointer1;\n" 129 "reg [BITSIZE_Mout_addr_ram-1:0] _next_pointer1;\n" 131 "reg [PORTSIZE_Mout_oe_ram-1:0] Mout_oe_ram;\n" 132 "reg [PORTSIZE_Mout_we_ram-1:0] Mout_we_ram;\n" 133 "reg [(PORTSIZE_Mout_addr_ram*BITSIZE_Mout_addr_ram)+(-1):0] Mout_addr_ram;\n" 134 "reg [(PORTSIZE_Mout_Wdata_ram*BITSIZE_Mout_Wdata_ram)+(-1):0] Mout_Wdata_ram;\n" 135 "reg [(PORTSIZE_Mout_data_ram_size*BITSIZE_Mout_data_ram_size)+(-1):0] Mout_data_ram_size;\n" 136 "reg active_request;\n" 137 "reg active_request_next;\n" 139 "parameter [2:0] S_0 = 3'd0,\n" 147 "reg [2:0] _present_state;\n" 148 "reg [2:0] _next_state;\n" 151 ":0] _present_selector;\n" 154 ":0] _next_selector;\n" 155 "reg [63:0] data1;\n" 156 "reg [7:0] _present_data2;\n" 157 "reg [7:0] _next_data2;\n" 158 "reg [7:0] data1_size;\n" 161 " always @(posedge clock 1RESET_EDGE)\n" 162 " if (1RESET_VALUE)\n" 164 " _present_state <= S_0;\n" 165 " _present_pointer <= {BITSIZE_Mout_addr_ram{1'b0}};\n" 166 " _present_pointer1 <= {BITSIZE_Mout_addr_ram{1'b0}};\n" 167 " _present_selector <=" +
170 " _present_data2 <= 8'b0;\n" 174 " _present_state <= _next_state;\n" 175 " _present_pointer <= _next_pointer;\n" 176 " _present_pointer1 <= _next_pointer1;\n" 177 " _present_selector <= _next_selector;\n" 178 " _present_data2 <= _next_data2;\n" 181 " always @(posedge clock 1RESET_EDGE)\n" 183 " if (1RESET_VALUE)\n" 185 " active_request <= 0;\n" 189 " active_request <= active_request_next;\n" 192 " always @(_present_state or _present_pointer or _present_pointer1 or _present_selector or start_port or " 193 "M_DataRdy[0] or Min_we_ram or Min_oe_ram or Min_Wdata_ram or Min_addr_ram or Min_data_ram_size" +
195 " or _present_data2 or M_Rdata_ram[7:0])\n" 197 " Mout_we_ram = Min_we_ram;\n" 198 " Mout_Wdata_ram = Min_Wdata_ram;\n" 199 " Mout_oe_ram=Min_oe_ram;\n" 200 " Mout_addr_ram=Min_addr_ram;\n" 201 " Mout_data_ram_size=Min_data_ram_size;\n" 202 " done_port = 1'b0;\n" 203 " active_request_next =1'b0;\n" 204 " _next_state = _present_state;\n" 205 " _next_pointer = _present_pointer;\n" 206 " _next_pointer1 = _present_pointer1;\n" 207 " _next_selector = _present_selector;\n" 208 " _next_data2 = _present_data2;\n" 212 " case (_present_state)\n" 216 " _next_pointer=0;\n" 217 " _next_pointer1=0;\n" 218 " _next_state=S_1; \n" 219 " active_request_next =1'b1;\n" 227 " Mout_addr_ram[BITSIZE_Mout_addr_ram-1:0]=(in1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer) & " 228 "{BITSIZE_Mout_addr_ram{active_request}};\n" 229 " Mout_data_ram_size[BITSIZE_Mout_data_ram_size-1:0]={{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8} & " 230 "{BITSIZE_Mout_data_ram_size{active_request}};\n" 231 " Mout_oe_ram[0]=active_request;\n" 232 " if(M_DataRdy[0])\n" 234 " _next_data2 = M_Rdata_ram[7:0];\n" 235 " _next_state=S_2;\n" 236 "// synthesis translate_off\n" 237 " write_done=1'b0;\n" 238 "// synthesis translate_on\n" 243 " _next_pointer=_present_pointer+1'd1;\n" 244 " if((_present_data2!=8'd0)&&(_present_data2!=8'd37))\n" 246 "// synthesis translate_off\n" 249 " $write(\"%c\",_present_data2);\n" 250 " write_done=1'b1;\n" 252 "// synthesis translate_on\n" 253 " _next_state=S_1;\n" 254 " active_request_next =1'b1;\n" 256 " else if(_present_data2==8'd37)\n" 258 " _next_state=S_3;\n" 259 " active_request_next =1'b1;\n" 261 " else if(_present_data2==8'd0)\n" 263 " done_port = 1'b1;\n" 264 " _next_state=S_0;\n" 269 " Mout_addr_ram[BITSIZE_Mout_addr_ram-1:0]=(in1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer) & " 270 "{BITSIZE_Mout_addr_ram{active_request}};\n" 271 " Mout_data_ram_size[BITSIZE_Mout_data_ram_size-1:0]={{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8} & " 272 "{BITSIZE_Mout_data_ram_size{active_request}};\n" 273 " Mout_oe_ram[0]=active_request;\n" 274 " if(M_DataRdy[0])\n" 276 " _next_data2 = M_Rdata_ram[7:0];\n" 277 " _next_state=S_5;\n" 278 "// synthesis translate_off\n" 279 " write_done=1'b0;\n" 280 "// synthesis translate_on\n" 285 " _next_state=S_6;\n" 286 " _next_pointer=_present_pointer+1'd1;\n" 287 " case(_present_data2)\n" 290 " _next_state=S_1;\n" 291 " active_request_next =1'b1;\n" 292 "// synthesis translate_off\n" 295 " $write(\"%c\",8'd37);\n" 296 " write_done=1'b1;\n" 298 "// synthesis translate_on\n" 302 "// synthesis translate_off\n" 305 " $write(\"%c\",data1[7:0]);\n" 306 " write_done=1'b1;\n" 308 "// synthesis translate_on\n" 310 " 8'd100: //Decimal %d\n" 311 " if(data1_size ==8'd64)\n" 313 "// synthesis translate_off\n" 316 " $write(\"%0d\",$signed(data1));\n" 317 " write_done=1'b1;\n" 319 "// synthesis translate_on\n" 321 " else if(data1_size ==8'd32)\n" 323 "// synthesis translate_off\n" 326 " $write(\"%0d\",$signed(data1[31:0]));\n" 327 " write_done=1'b1;\n" 329 "// synthesis translate_on\n" 331 " else if(data1_size ==8'd16)\n" 333 "// synthesis translate_off\n" 336 " $write(\"%0d\",$signed(data1[15:0]));\n" 337 " write_done=1'b1;\n" 339 "// synthesis translate_on\n" 341 " else if(data1_size ==8'd8)\n" 343 "// synthesis translate_off\n" 346 " $write(\"%0d\",$signed(data1[7:0]));\n" 347 " write_done=1'b1;\n" 349 "// synthesis translate_on\n" 353 "// synthesis translate_off\n" 354 " $display(\"ERROR - Decimal precision not supported (d) %d\", data1_size);\n" 356 "// synthesis translate_on\n" 358 " 8'd105: //Decimal %i\n" 359 " if(data1_size ==8'd64)\n" 361 "// synthesis translate_off\n" 364 " $write(\"%0d\",$signed(data1));\n" 365 " write_done=1'b1;\n" 367 "// synthesis translate_on\n" 369 " else if(data1_size ==8'd32)\n" 371 "// synthesis translate_off\n" 374 " $write(\"%0d\",$signed(data1[31:0]));\n" 375 " write_done=1'b1;\n" 377 "// synthesis translate_on\n" 379 " else if(data1_size ==8'd16)\n" 381 "// synthesis translate_off\n" 384 " $write(\"%0d\",$signed(data1[15:0]));\n" 385 " write_done=1'b1;\n" 387 "// synthesis translate_on\n" 389 " else if(data1_size ==8'd8)\n" 391 "// synthesis translate_off\n" 394 " $write(\"%0d\",$signed(data1[7:0]));\n" 395 " write_done=1'b1;\n" 397 "// synthesis translate_on\n" 401 "// synthesis translate_off\n" 402 " $display(\"ERROR - Decimal precision not supported (i) %d\", data1_size);\n" 404 "// synthesis translate_on\n" 406 " 8'd101: //Exponential %e\n" 408 " if(data1_size ==8'd64)\n" 410 "// synthesis translate_off\n" 413 " $write(\"%e\",$bitstoreal(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(\"%e\",bits32_to_real64(data1[31:0]));\n" 424 " write_done=1'b1;\n" 426 "// synthesis translate_on\n" 430 "// synthesis translate_off\n" 431 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 433 "// synthesis translate_on\n" 436 " 8'd69: //Exponential %E\n" 438 " if(data1_size ==8'd64)\n" 440 "// synthesis translate_off\n" 443 " $write(\"%e\",$bitstoreal(data1));\n" 444 " write_done=1'b1;\n" 446 "// synthesis translate_on\n" 448 " else if(data1_size ==8'd32)\n" 450 "// synthesis translate_off\n" 453 " $write(\"%e\",bits32_to_real64(data1[31:0]));\n" 454 " write_done=1'b1;\n" 456 "// synthesis translate_on\n" 460 "// synthesis translate_off\n" 461 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 463 "// synthesis translate_on\n" 466 " 8'd102: //Float %f\n" 468 " if(data1_size==8'd64)\n" 470 "// synthesis translate_off\n" 473 " $write(\"%20.20f\",$bitstoreal(data1));\n" 474 " write_done=1'b1;\n" 476 "// synthesis translate_on\n" 478 " else if(data1_size ==8'd32)\n" 480 "// synthesis translate_off\n" 483 " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n" 484 " write_done=1'b1;\n" 486 "// synthesis translate_on\n" 490 "// synthesis translate_off\n" 491 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 493 "// synthesis translate_on\n" 496 " 8'd70: //Float %F\n" 498 " if(data1_size==8'd64)\n" 500 "// synthesis translate_off\n" 503 " $write(\"%20.20f\",$bitstoreal(data1));\n" 504 " write_done=1'b1;\n" 506 "// synthesis translate_on\n" 508 " else if(data1_size ==8'd32)\n" 510 "// synthesis translate_off\n" 513 " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n" 514 " write_done=1'b1;\n" 516 "// synthesis translate_on\n" 520 "// synthesis translate_off\n" 521 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 523 "// synthesis translate_on\n" 526 " 8'd103: //Float %g\n" 528 " if(data1_size==8'd64)\n" 530 "// synthesis translate_off\n" 533 " $write(\"%20.20g\",$bitstoreal(data1));\n" 534 " write_done=1'b1;\n" 536 "// synthesis translate_on\n" 538 " else if(data1_size ==8'd32)\n" 540 "// synthesis translate_off\n" 543 " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n" 544 " write_done=1'b1;\n" 546 "// synthesis translate_on\n" 550 "// synthesis translate_off\n" 551 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 553 "// synthesis translate_on\n" 556 " 8'd71: //Float %G\n" 558 " if(data1_size==8'd64)\n" 560 "// synthesis translate_off\n" 563 " $write(\"%20.20g\",$bitstoreal(data1));\n" 564 " write_done=1'b1;\n" 566 "// synthesis translate_on\n" 568 " else if(data1_size ==8'd32)\n" 570 "// synthesis translate_off\n" 573 " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n" 574 " write_done=1'b1;\n" 576 "// synthesis translate_on\n" 580 "// synthesis translate_off\n" 581 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 583 "// synthesis translate_on\n" 587 " if(data1_size ==8'd64)\n" 589 "// synthesis translate_off\n" 592 " $write(\"%0o\",data1);\n" 593 " write_done=1'b1;\n" 595 "// synthesis translate_on\n" 597 " else if(data1_size ==8'd32)\n" 599 "// synthesis translate_off\n" 602 " $write(\"%0o\",data1[31:0]);\n" 603 " write_done=1'b1;\n" 605 "// synthesis translate_on\n" 607 " else if(data1_size ==8'd16)\n" 609 "// synthesis translate_off\n" 612 " $write(\"%0o\",data1[15:0]);\n" 613 " write_done=1'b1;\n" 615 "// synthesis translate_on\n" 617 " else if(data1_size ==8'd8)\n" 619 "// synthesis translate_off\n" 622 " $write(\"%0o\",data1[7:0]);\n" 623 " write_done=1'b1;\n" 625 "// synthesis translate_on\n" 629 "// synthesis translate_off\n" 630 " $display(\"ERROR - Octal precision not supported %d\", data1_size);\n" 632 "// synthesis translate_on\n" 636 "// synthesis translate_off\n" 639 " $write(\"0x%0h\",data1);\n" 640 " write_done=1'b1;\n" 642 "// synthesis translate_on\n" 644 " 8'd115: //String\n" 646 " _next_state=S_7;\n" 647 " active_request_next =1'b1;\n" 648 " _next_pointer1=0;\n" 650 " 8'd117: //unsigned int %u TO BE FIXED\n" 651 " if(data1_size ==8'd64)\n" 653 "// synthesis translate_off\n" 656 " $write(\"%0d\",$unsigned(data1));\n" 657 " write_done=1'b1;\n" 659 "// synthesis translate_on\n" 661 " else if(data1_size ==8'd32)\n" 663 "// synthesis translate_off\n" 666 " $write(\"%0d\",$unsigned(data1[31:0]));\n" 667 " write_done=1'b1;\n" 669 "// synthesis translate_on\n" 671 " else if(data1_size ==8'd16)\n" 673 "// synthesis translate_off\n" 676 " $write(\"%0d\",$unsigned(data1[15:0]));\n" 677 " write_done=1'b1;\n" 679 "// synthesis translate_on\n" 681 " else if(data1_size ==8'd8)\n" 683 "// synthesis translate_off\n" 686 " $write(\"%0d\",$unsigned(data1[7:0]));\n" 687 " write_done=1'b1;\n" 689 "// synthesis translate_on\n" 693 "// synthesis translate_off\n" 694 " $display(\"ERROR - Unsigned precision not supported %d\", data1_size);\n" 696 "// synthesis translate_on\n" 698 " 8'd120: //Hex %x\n" 699 " if(data1_size ==8'd64)\n" 701 "// synthesis translate_off\n" 704 " $write(\"%0h\",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(\"%0h\",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(\"%0h\",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(\"%0h\",data1[7:0]);\n" 735 " write_done=1'b1;\n" 737 "// synthesis translate_on\n" 741 "// synthesis translate_off\n" 742 " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n" 744 "// synthesis translate_on\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" 796 " _next_state=S_3;\n" 797 " active_request_next =1'b1;\n" 803 " _next_selector=_present_selector<<1;\n" 804 " _next_state=S_1;\n" 805 " active_request_next =1'b1;\n" 809 " Mout_addr_ram[BITSIZE_Mout_addr_ram-1:0]=(data1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer1) & " 810 "{BITSIZE_Mout_addr_ram{active_request}};\n" 811 " Mout_data_ram_size[BITSIZE_Mout_data_ram_size-1:0]={{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8} & " 812 "{BITSIZE_Mout_data_ram_size{active_request}};\n" 813 " Mout_oe_ram[0]=active_request;\n" 814 " if(M_DataRdy[0])\n" 816 " _next_data2 = M_Rdata_ram[7:0];\n" 817 " _next_state=S_4;\n" 818 "// synthesis translate_off\n" 819 " write_done=1'b0;\n" 820 "// synthesis translate_on\n" 825 " _next_pointer1=_present_pointer1+1'd1;\n" 826 " if(_present_data2!=8'd0)\n" 828 "// synthesis translate_off\n" 831 " $write(\"%c\",_present_data2);\n" 832 " write_done=1'b1;\n" 834 "// synthesis translate_on\n" 835 " _next_state=S_7;\n" 836 " active_request_next =1'b1;\n" 839 " _next_state=S_6;\n" Data structure representing the entire HLS information.
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.
PrintfNModuleGenerator(const HLS_managerRef &HLSMgr)
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.