61 const std::vector<ModuleGenerator::parameter>& _p,
62 const std::vector<ModuleGenerator::parameter>& ,
63 const std::vector<ModuleGenerator::parameter>& ,
64 const std::vector<ModuleGenerator::parameter>& )
66 const auto data_bus_bitsize =
STR(HLSMgr->Rmem->get_bus_data_bitsize());
67 const auto addr_bus_bitsize =
STR(HLSMgr->get_address_bitsize());
68 const auto size_bus_bitsize =
STR(HLSMgr->Rmem->get_bus_size_bitsize());
70 const auto selector_dimension =
STR(_p.size() < 2
U ? 2
U : _p.size());
71 const auto selector_left =
STR(((_p.size() - 1
U) < 1
U) ? 1
U : (_p.size() - 1
U));
73 std::string sensitivity;
74 for(
auto i = 0
U; i < _p.size(); i++)
76 sensitivity +=
" or " + _p[i].name;
79 std::string case_statement;
82 case_statement =
"case (_present_selector)\n";
83 for(
auto i = 0
U, selector = 1
U; i < _p.size(); i++, selector *= 2)
85 case_statement +=
" " + selector_dimension +
"'d" +
STR(selector) +
91 " data1_size=BITSIZE_in" +
96 case_statement +=
" default:\n" 99 " data1_size = 8'b0;\n" 109 "// synthesis translate_off\n" 110 "function real bits32_to_real64;\n" 111 " input [31:0] fin1;\n" 112 " reg [7:0] exponent1;\n" 113 " reg is_exp_zero;\n" 114 " reg is_all_ones;\n" 115 " reg [10:0] exp_tmp;\n" 116 " reg [63:0] fout1;\n" 118 " exponent1 = fin1[30:23];\n" 119 " is_exp_zero = exponent1 == 8'd0;\n" 120 " is_all_ones = exponent1 == {8{1'b1}};\n" 121 " exp_tmp = {3'd0, exponent1} + 11'd896;\n" 122 " fout1[63] = fin1[31];\n" 123 " fout1[62:52] = is_exp_zero ? 11'd0 : (is_all_ones ? {11{1'b1}} : exp_tmp);\n" 124 " fout1[51:29] = fin1[22:0];\n" 125 " fout1[28:0] = 29'd0;\n" 126 " bits32_to_real64 = $bitstoreal(fout1);\n" 129 "// synthesis translate_on\n" 130 "reg [BITSIZE_Mout_addr_ram-1:0] _present_pointer;\n" 131 "reg [BITSIZE_Mout_addr_ram-1:0] _next_pointer;\n" 132 "reg [BITSIZE_Mout_addr_ram-1:0] _present_pointer1;\n" 133 "reg [BITSIZE_Mout_addr_ram-1:0] _next_pointer1;\n" 134 "reg mem_sel_LOAD;\n" 135 "wire mem_done_port;\n" 137 "reg mem_start_port;\n" 147 " MEMORY_CTRL_P1N #(.BITSIZE_in1(" +
148 data_bus_bitsize +
"), .BITSIZE_in2(" + addr_bus_bitsize +
"), .BITSIZE_in3(" + size_bus_bitsize +
149 "), .BITSIZE_in4(1), .BITSIZE_out1(" + data_bus_bitsize +
150 "), .BITSIZE_Min_oe_ram(BITSIZE_Min_oe_ram), .PORTSIZE_Min_oe_ram(PORTSIZE_Min_oe_ram), " 151 ".BITSIZE_Min_we_ram(BITSIZE_Min_we_ram), .PORTSIZE_Min_we_ram(PORTSIZE_Min_we_ram), " 152 ".BITSIZE_Mout_oe_ram(BITSIZE_Mout_oe_ram), .PORTSIZE_Mout_oe_ram(PORTSIZE_Mout_oe_ram), " 153 ".BITSIZE_Mout_we_ram(BITSIZE_Mout_we_ram), .PORTSIZE_Mout_we_ram(PORTSIZE_Mout_we_ram), " 154 ".BITSIZE_M_DataRdy(BITSIZE_M_DataRdy), .PORTSIZE_M_DataRdy(PORTSIZE_M_DataRdy), " 155 ".BITSIZE_Min_addr_ram(BITSIZE_Min_addr_ram), .PORTSIZE_Min_addr_ram(PORTSIZE_Min_addr_ram), " 156 ".BITSIZE_Mout_addr_ram(BITSIZE_Mout_addr_ram), .PORTSIZE_Mout_addr_ram(PORTSIZE_Mout_addr_ram), " 157 ".BITSIZE_M_Rdata_ram(BITSIZE_M_Rdata_ram), .PORTSIZE_M_Rdata_ram(PORTSIZE_M_Rdata_ram), " 158 ".BITSIZE_Min_Wdata_ram(BITSIZE_Min_Wdata_ram), .PORTSIZE_Min_Wdata_ram(PORTSIZE_Min_Wdata_ram), " 159 ".BITSIZE_Mout_Wdata_ram(BITSIZE_Mout_Wdata_ram), .PORTSIZE_Mout_Wdata_ram(PORTSIZE_Mout_Wdata_ram), " 160 ".BITSIZE_Min_data_ram_size(BITSIZE_Min_data_ram_size), " 161 ".PORTSIZE_Min_data_ram_size(PORTSIZE_Min_data_ram_size), " 162 ".BITSIZE_Mout_data_ram_size(BITSIZE_Mout_data_ram_size), " 163 ".PORTSIZE_Mout_data_ram_size(PORTSIZE_Mout_data_ram_size), .BITSIZE_access_allowed(BITSIZE_access_allowed), " 164 ".PORTSIZE_access_allowed(PORTSIZE_access_allowed), .BITSIZE_access_request(BITSIZE_access_request), " 165 ".PORTSIZE_access_request(PORTSIZE_access_request)) MEMORY_CTRL_P1N_instance (.done_port(mem_done_port), " 166 ".out1(mem_out1), .Mout_oe_ram(Mout_oe_ram), .Mout_we_ram(Mout_we_ram), .Mout_addr_ram(Mout_addr_ram), " 167 ".Mout_Wdata_ram(Mout_Wdata_ram), .Mout_data_ram_size(Mout_data_ram_size), .access_request(access_request), " 168 ".clock(clock), .start_port(mem_start_port), .in1(0), .in2(mem_in2), .in3(mem_in3), .in4(1), " 169 ".sel_LOAD(mem_sel_LOAD), .sel_STORE(1'b0), .Min_oe_ram(Min_oe_ram), .Min_we_ram(Min_we_ram), " 170 ".Min_addr_ram(Min_addr_ram), .M_Rdata_ram(M_Rdata_ram), .Min_Wdata_ram(Min_Wdata_ram), " 171 ".Min_data_ram_size(Min_data_ram_size), .M_DataRdy(M_DataRdy), .access_allowed(access_allowed));\n" 173 "parameter [2:0] S_0 = 3'd0,\n" 181 "reg [2:0] _present_state;\n" 182 "reg [2:0] _next_state;\n" 185 ":0] _present_selector;\n" 188 ":0] _next_selector;\n" 189 "reg [63:0] data1;\n" 190 "reg [7:0] _present_data2;\n" 191 "reg [7:0] _next_data2;\n" 192 "reg [7:0] data1_size;\n" 195 " always @(posedge clock 1RESET_EDGE)\n" 196 " if (1RESET_VALUE)\n" 198 " _present_state <= S_0;\n" 199 " _present_pointer <= {BITSIZE_Mout_addr_ram{1'b0}};\n" 200 " _present_pointer1 <= {BITSIZE_Mout_addr_ram{1'b0}};\n" 201 " _present_selector <=" +
204 " _present_data2 <= 8'b0;\n" 208 " _present_state <= _next_state;\n" 209 " _present_pointer <= _next_pointer;\n" 210 " _present_pointer1 <= _next_pointer1;\n" 211 " _present_selector <= _next_selector;\n" 212 " _present_data2 <= _next_data2;\n" 215 " always @(_present_state or _present_pointer or _present_pointer1 or _present_selector or start_port or " 216 "M_DataRdy[0] or Min_we_ram or Min_oe_ram or Min_Wdata_ram or Min_addr_ram or Min_data_ram_size" +
218 " or _present_data2 or mem_done_port or M_Rdata_ram[7:0])\n" 220 " _next_state = _present_state;\n" 221 " _next_pointer = _present_pointer;\n" 222 " _next_pointer1 = _present_pointer1;\n" 223 " _next_selector = _present_selector;\n" 224 " _next_data2 = _present_data2;\n" 225 " done_port = 1'b0;\n" 226 " mem_sel_LOAD = 1'b0;\n" 227 " mem_start_port = 1'b0;\n" 237 " case (_present_state)\n" 241 " _next_pointer=0;\n" 242 " _next_pointer1=0;\n" 243 " _next_state=S_1; \n" 251 " mem_in2 = in1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer;\n" 252 " mem_in3 = {{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8};\n" 253 " mem_sel_LOAD=1'b1;\n" 254 " mem_start_port=1'b1;\n" 255 " if(mem_done_port)\n" 257 " _next_data2 = mem_out1[7:0];\n" 258 " _next_state=S_2;\n" 259 "// synthesis translate_off\n" 260 " write_done=1'b0;\n" 261 "// synthesis translate_on\n" 266 " _next_pointer=_present_pointer+1'd1;\n" 267 " if((_present_data2!=8'd0)&&(_present_data2!=8'd37))\n" 269 "// synthesis translate_off\n" 272 " $write(\"%c\",_present_data2);\n" 273 " write_done=1'b1;\n" 275 "// synthesis translate_on\n" 276 " _next_state=S_1;\n" 278 " else if(_present_data2==8'd37)\n" 279 " _next_state=S_3;\n" 280 " else if(_present_data2==8'd0)\n" 282 " done_port = 1'b1;\n" 283 " _next_state=S_0;\n" 288 " mem_in2 = in1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer;\n" 289 " mem_in3 = {{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8};\n" 290 " mem_sel_LOAD=1'b1;\n" 291 " if(mem_done_port)\n" 293 " _next_data2 = mem_out1[7:0];\n" 294 " _next_state=S_5;\n" 295 "// synthesis translate_off\n" 296 " write_done=1'b0;\n" 297 "// synthesis translate_on\n" 302 " _next_state=S_6;\n" 303 " _next_pointer=_present_pointer+1'd1;\n" 304 " case(_present_data2)\n" 307 " _next_state=S_1;\n" 308 "// synthesis translate_off\n" 311 " $write(\"%c\",8'd37);\n" 312 " write_done=1'b1;\n" 314 "// synthesis translate_on\n" 318 "// synthesis translate_off\n" 321 " $write(\"%c\",data1[7:0]);\n" 322 " write_done=1'b1;\n" 324 "// synthesis translate_on\n" 326 " 8'd100: //Decimal %d\n" 327 " if(data1_size ==8'd64)\n" 329 "// synthesis translate_off\n" 332 " $write(\"%0d\",$signed(data1));\n" 333 " write_done=1'b1;\n" 335 "// synthesis translate_on\n" 337 " else if(data1_size ==8'd32)\n" 339 "// synthesis translate_off\n" 342 " $write(\"%0d\",$signed(data1[31:0]));\n" 343 " write_done=1'b1;\n" 345 "// synthesis translate_on\n" 347 " else if(data1_size ==8'd16)\n" 349 "// synthesis translate_off\n" 352 " $write(\"%0d\",$signed(data1[15:0]));\n" 353 " write_done=1'b1;\n" 355 "// synthesis translate_on\n" 357 " else if(data1_size ==8'd8)\n" 359 "// synthesis translate_off\n" 362 " $write(\"%0d\",$signed(data1[7:0]));\n" 363 " write_done=1'b1;\n" 365 "// synthesis translate_on\n" 369 "// synthesis translate_off\n" 370 " $display(\"ERROR - Decimal precision not supported (d) %d\", data1_size);\n" 372 "// synthesis translate_on\n" 374 " 8'd105: //Decimal %i\n" 375 " if(data1_size ==8'd64)\n" 377 "// synthesis translate_off\n" 380 " $write(\"%0d\",$signed(data1));\n" 381 " write_done=1'b1;\n" 383 "// synthesis translate_on\n" 385 " else if(data1_size ==8'd32)\n" 387 "// synthesis translate_off\n" 390 " $write(\"%0d\",$signed(data1[31:0]));\n" 391 " write_done=1'b1;\n" 393 "// synthesis translate_on\n" 395 " else if(data1_size ==8'd16)\n" 397 "// synthesis translate_off\n" 400 " $write(\"%0d\",$signed(data1[15:0]));\n" 401 " write_done=1'b1;\n" 403 "// synthesis translate_on\n" 405 " else if(data1_size ==8'd8)\n" 407 "// synthesis translate_off\n" 410 " $write(\"%0d\",$signed(data1[7:0]));\n" 411 " write_done=1'b1;\n" 413 "// synthesis translate_on\n" 417 "// synthesis translate_off\n" 418 " $display(\"ERROR - Decimal precision not supported (i) %d\", data1_size);\n" 420 "// synthesis translate_on\n" 422 " 8'd101: //Exponential %e\n" 424 " if(data1_size ==8'd64)\n" 426 "// synthesis translate_off\n" 429 " $write(\"%e\",$bitstoreal(data1));\n" 430 " write_done=1'b1;\n" 432 "// synthesis translate_on\n" 434 " else if(data1_size ==8'd32)\n" 436 "// synthesis translate_off\n" 439 " $write(\"%e\",bits32_to_real64(data1[31:0]));\n" 440 " write_done=1'b1;\n" 442 "// synthesis translate_on\n" 446 "// synthesis translate_off\n" 447 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 449 "// synthesis translate_on\n" 452 " 8'd69: //Exponential %E\n" 454 " if(data1_size ==8'd64)\n" 456 "// synthesis translate_off\n" 459 " $write(\"%e\",$bitstoreal(data1));\n" 460 " write_done=1'b1;\n" 462 "// synthesis translate_on\n" 464 " else if(data1_size ==8'd32)\n" 466 "// synthesis translate_off\n" 469 " $write(\"%e\",bits32_to_real64(data1[31:0]));\n" 470 " write_done=1'b1;\n" 472 "// synthesis translate_on\n" 476 "// synthesis translate_off\n" 477 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 479 "// synthesis translate_on\n" 482 " 8'd102: //Float %f\n" 484 " if(data1_size==8'd64)\n" 486 "// synthesis translate_off\n" 489 " $write(\"%20.20f\",$bitstoreal(data1));\n" 490 " write_done=1'b1;\n" 492 "// synthesis translate_on\n" 494 " else if(data1_size ==8'd32)\n" 496 "// synthesis translate_off\n" 499 " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n" 500 " write_done=1'b1;\n" 502 "// synthesis translate_on\n" 506 "// synthesis translate_off\n" 507 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 509 "// synthesis translate_on\n" 512 " 8'd70: //Float %F\n" 514 " if(data1_size==8'd64)\n" 516 "// synthesis translate_off\n" 519 " $write(\"%20.20f\",$bitstoreal(data1));\n" 520 " write_done=1'b1;\n" 522 "// synthesis translate_on\n" 524 " else if(data1_size ==8'd32)\n" 526 "// synthesis translate_off\n" 529 " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n" 530 " write_done=1'b1;\n" 532 "// synthesis translate_on\n" 536 "// synthesis translate_off\n" 537 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 539 "// synthesis translate_on\n" 542 " 8'd103: //Float %g\n" 544 " if(data1_size==8'd64)\n" 546 "// synthesis translate_off\n" 549 " $write(\"%20.20g\",$bitstoreal(data1));\n" 550 " write_done=1'b1;\n" 552 "// synthesis translate_on\n" 554 " else if(data1_size ==8'd32)\n" 556 "// synthesis translate_off\n" 559 " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n" 560 " write_done=1'b1;\n" 562 "// synthesis translate_on\n" 566 "// synthesis translate_off\n" 567 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 569 "// synthesis translate_on\n" 572 " 8'd71: //Float %G\n" 574 " if(data1_size==8'd64)\n" 576 "// synthesis translate_off\n" 579 " $write(\"%20.20g\",$bitstoreal(data1));\n" 580 " write_done=1'b1;\n" 582 "// synthesis translate_on\n" 584 " else if(data1_size ==8'd32)\n" 586 "// synthesis translate_off\n" 589 " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n" 590 " write_done=1'b1;\n" 592 "// synthesis translate_on\n" 596 "// synthesis translate_off\n" 597 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 599 "// synthesis translate_on\n" 603 " if(data1_size ==8'd64)\n" 605 "// synthesis translate_off\n" 608 " $write(\"%0o\",data1);\n" 609 " write_done=1'b1;\n" 611 "// synthesis translate_on\n" 613 " else if(data1_size ==8'd32)\n" 615 "// synthesis translate_off\n" 618 " $write(\"%0o\",data1[31:0]);\n" 619 " write_done=1'b1;\n" 621 "// synthesis translate_on\n" 623 " else if(data1_size ==8'd16)\n" 625 "// synthesis translate_off\n" 628 " $write(\"%0o\",data1[15:0]);\n" 629 " write_done=1'b1;\n" 631 "// synthesis translate_on\n" 633 " else if(data1_size ==8'd8)\n" 635 "// synthesis translate_off\n" 638 " $write(\"%0o\",data1[7:0]);\n" 639 " write_done=1'b1;\n" 641 "// synthesis translate_on\n" 645 "// synthesis translate_off\n" 646 " $display(\"ERROR - Octal precision not supported %d\", data1_size);\n" 648 "// synthesis translate_on\n" 652 "// synthesis translate_off\n" 655 " $write(\"0x%0h\",data1);\n" 656 " write_done=1'b1;\n" 658 "// synthesis translate_on\n" 660 " 8'd115: //String\n" 662 " _next_state=S_7;\n" 663 " _next_pointer1=0;\n" 665 " 8'd117: //unsigned int %u TO BE FIXED\n" 666 " if(data1_size ==8'd64)\n" 668 "// synthesis translate_off\n" 671 " $write(\"%0d\",$unsigned(data1));\n" 672 " write_done=1'b1;\n" 674 "// synthesis translate_on\n" 676 " else if(data1_size ==8'd32)\n" 678 "// synthesis translate_off\n" 681 " $write(\"%0d\",$unsigned(data1[31:0]));\n" 682 " write_done=1'b1;\n" 684 "// synthesis translate_on\n" 686 " else if(data1_size ==8'd16)\n" 688 "// synthesis translate_off\n" 691 " $write(\"%0d\",$unsigned(data1[15:0]));\n" 692 " write_done=1'b1;\n" 694 "// synthesis translate_on\n" 696 " else if(data1_size ==8'd8)\n" 698 "// synthesis translate_off\n" 701 " $write(\"%0d\",$unsigned(data1[7:0]));\n" 702 " write_done=1'b1;\n" 704 "// synthesis translate_on\n" 708 "// synthesis translate_off\n" 709 " $display(\"ERROR - Unsigned precision not supported %d\", data1_size);\n" 711 "// synthesis translate_on\n" 713 " 8'd120: //Hex %x\n" 714 " if(data1_size ==8'd64)\n" 716 "// synthesis translate_off\n" 719 " $write(\"%0h\",data1);\n" 720 " write_done=1'b1;\n" 722 "// synthesis translate_on\n" 724 " else if(data1_size ==8'd32)\n" 726 "// synthesis translate_off\n" 729 " $write(\"%0h\",data1[31:0]);\n" 730 " write_done=1'b1;\n" 732 "// synthesis translate_on\n" 734 " else if(data1_size ==8'd16)\n" 736 "// synthesis translate_off\n" 739 " $write(\"%0h\",data1[15:0]);\n" 740 " write_done=1'b1;\n" 742 "// synthesis translate_on\n" 744 " else if(data1_size ==8'd8)\n" 746 "// synthesis translate_off\n" 749 " $write(\"%0h\",data1[7:0]);\n" 750 " write_done=1'b1;\n" 752 "// synthesis translate_on\n" 756 "// synthesis translate_off\n" 757 " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n" 759 "// synthesis translate_on\n" 762 " if(data1_size ==8'd64)\n" 764 "// synthesis translate_off\n" 767 " $write(\"%0h\",data1);\n" 768 " write_done=1'b1;\n" 770 "// synthesis translate_on\n" 772 " else if(data1_size ==8'd32)\n" 774 "// synthesis translate_off\n" 777 " $write(\"%0h\",data1[31:0]);\n" 778 " write_done=1'b1;\n" 780 "// synthesis translate_on\n" 782 " else if(data1_size ==8'd16)\n" 784 "// synthesis translate_off\n" 787 " $write(\"%0h\",data1[15:0]);\n" 788 " write_done=1'b1;\n" 790 "// synthesis translate_on\n" 792 " else if(data1_size ==8'd8)\n" 794 "// synthesis translate_off\n" 797 " $write(\"%0h\",data1[7:0]);\n" 798 " write_done=1'b1;\n" 800 "// synthesis translate_on\n" 804 "// synthesis translate_off\n" 805 " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n" 807 "// synthesis translate_on\n" 810 " _next_state=S_3;\n" 815 " _next_selector=_present_selector<<1;\n" 816 " _next_state=S_1;\n" 820 " mem_in2 = data1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer1;\n" 821 " mem_in3 = {{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8};\n" 822 " mem_sel_LOAD=1'b1;\n" 823 " if(mem_done_port)\n" 825 " _next_data2 = mem_out1[7:0];\n" 826 " _next_state=S_4;\n" 827 "// synthesis translate_off\n" 828 " write_done=1'b0;\n" 829 "// synthesis translate_on\n" 834 " _next_pointer1=_present_pointer1+1'd1;\n" 835 " if(_present_data2!=8'd0)\n" 837 "// synthesis translate_off\n" 840 " $write(\"%c\",_present_data2);\n" 841 " write_done=1'b1;\n" 843 "// synthesis translate_on\n" 844 " _next_state=S_7;\n" 847 " _next_state=S_6;\n" Data structure representing the entire HLS information.
PrintfP1NModuleGenerator(const HLS_managerRef &HLSMgr)
#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...
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
Datastructure to represent memory information in high-level synthesis.