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>& )
71 const auto selector_dimension =
STR(_p.size() < 2 ? 2 : _p.size());
72 const auto selector_left =
STR(((_p.size() - 1) < 1) ? 1 : (_p.size() - 1));
74 std::string sensitivity;
75 for(
auto i = 0
U; i < _p.size(); i++)
77 sensitivity +=
" or " + _p[i].name;
80 std::string case_statement;
83 case_statement =
"case (_present_selector)\n";
84 for(
auto i = 0
U, selector = 1
U; i < _p.size(); i++, selector *= 2)
86 case_statement +=
" " + selector_dimension +
"'d" +
STR(selector) +
92 " data1_size=BITSIZE_in" +
97 case_statement +=
" default:\n" 100 " data1_size = 8'b0;\n" 110 "// synthesis translate_off\n" 111 "function real bits32_to_real64;\n" 112 " input [31:0] fin1;\n" 113 " reg [7:0] exponent1;\n" 114 " reg is_exp_zero;\n" 115 " reg is_all_ones;\n" 116 " reg [10:0] exp_tmp;\n" 117 " reg [63:0] fout1;\n" 119 " exponent1 = fin1[30:23];\n" 120 " is_exp_zero = exponent1 == 8'd0;\n" 121 " is_all_ones = exponent1 == {8{1'b1}};\n" 122 " exp_tmp = {3'd0, exponent1} + 11'd896;\n" 123 " fout1[63] = fin1[31];\n" 124 " fout1[62:52] = is_exp_zero ? 11'd0 : (is_all_ones ? {11{1'b1}} : exp_tmp);\n" 125 " fout1[51:29] = fin1[22:0];\n" 126 " fout1[28:0] = 29'd0;\n" 127 " bits32_to_real64 = $bitstoreal(fout1);\n" 130 "// synthesis translate_on\n" 131 "reg [BITSIZE_Mout_addr_ram-1:0] _present_pointer;\n" 132 "reg [BITSIZE_Mout_addr_ram-1:0] _next_pointer;\n" 133 "reg [BITSIZE_Mout_addr_ram-1:0] _present_pointer1;\n" 134 "reg [BITSIZE_Mout_addr_ram-1:0] _next_pointer1;\n" 138 "reg [BITSIZE_Mout_addr_ram-1:0] Mout_addr_ram;\n" 139 "reg [BITSIZE_Mout_Wdata_ram-1:0] Mout_Wdata_ram;\n" 140 "reg [BITSIZE_Mout_data_ram_size-1:0] Mout_data_ram_size;\n" 141 "reg active_request;\n" 142 "reg active_request_next;\n" 144 "parameter [2:0] S_0 = 3'd0,\n" 152 "reg [2:0] _present_state;\n" 153 "reg [2:0] _next_state;\n" 156 ":0] _present_selector;\n" 159 ":0] _next_selector;\n" 160 "reg [63:0] data1;\n" 161 "reg [7:0] _present_data2;\n" 162 "reg [7:0] _next_data2;\n" 163 "reg [7:0] data1_size;\n" 166 " always @(posedge clock 1RESET_EDGE)\n" 167 " if (1RESET_VALUE)\n" 169 " _present_state <= S_0;\n" 170 " _present_pointer <= {BITSIZE_Mout_addr_ram{1'b0}};\n" 171 " _present_pointer1 <= {BITSIZE_Mout_addr_ram{1'b0}};\n" 172 " _present_selector <=" +
175 " _present_data2 <= 8'b0;\n" 179 " _present_state <= _next_state;\n" 180 " _present_pointer <= _next_pointer;\n" 181 " _present_pointer1 <= _next_pointer1;\n" 182 " _present_selector <= _next_selector;\n" 183 " _present_data2 <= _next_data2;\n" 186 " always @(posedge clock 1RESET_EDGE)\n" 188 " if (1RESET_VALUE)\n" 190 " active_request <= 0;\n" 194 " active_request <= active_request_next;\n" 197 " always @(_present_state or _present_pointer or _present_pointer1 or _present_selector or start_port or " 198 "M_DataRdy or Min_we_ram or Min_oe_ram or Min_Wdata_ram or Min_addr_ram or Min_data_ram_size" +
200 " or _present_data2 or M_Rdata_ram)\n" 202 " Mout_we_ram = Min_we_ram;\n" 203 " Mout_Wdata_ram = Min_Wdata_ram;\n" 204 " Mout_oe_ram=Min_oe_ram;\n" 205 " Mout_addr_ram=Min_addr_ram;\n" 206 " Mout_data_ram_size=Min_data_ram_size;\n" 207 " done_port = 1'b0;\n" 208 " active_request_next =1'b0;\n" 209 " _next_state = _present_state;\n" 210 " _next_pointer = _present_pointer;\n" 211 " _next_pointer1 = _present_pointer1;\n" 212 " _next_selector = _present_selector;\n" 213 " _next_data2 = _present_data2;\n" 217 " case (_present_state)\n" 221 " _next_pointer=0;\n" 222 " _next_pointer1=0;\n" 223 " _next_state=S_1; \n" 224 " active_request_next =1'b1;\n" 232 " Mout_addr_ram[BITSIZE_Mout_addr_ram-1:0]=(in1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer) & " 233 "{BITSIZE_Mout_addr_ram{active_request}};\n" 234 " Mout_data_ram_size={{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8} & " 235 "{BITSIZE_Mout_data_ram_size{active_request}};\n" 236 " Mout_oe_ram=active_request;\n" 239 " _next_data2 = M_Rdata_ram[7:0];\n" 240 " _next_state=S_2;\n" 241 "// synthesis translate_off\n" 242 " write_done=1'b0;\n" 243 "// synthesis translate_on\n" 248 " _next_pointer=_present_pointer+1'd1;\n" 249 " if((_present_data2!=8'd0)&&(_present_data2!=8'd37))\n" 251 "// synthesis translate_off\n" 254 " $write(\"%c\",_present_data2);\n" 255 " write_done=1'b1;\n" 257 "// synthesis translate_on\n" 258 " _next_state=S_1;\n" 259 " active_request_next =1'b1;\n" 261 " else if(_present_data2==8'd37)\n" 263 " _next_state=S_3;\n" 264 " active_request_next =1'b1;\n" 266 " else if(_present_data2==8'd0)\n" 268 " done_port = 1'b1;\n" 269 " _next_state=S_0;\n" 274 " Mout_addr_ram=(in1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer) & " 275 "{BITSIZE_Mout_addr_ram{active_request}};\n" 276 " Mout_data_ram_size={{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8} & " 277 "{BITSIZE_Mout_data_ram_size{active_request}};\n" 278 " Mout_oe_ram=active_request;\n" 281 " _next_data2 = M_Rdata_ram[7:0];\n" 282 " _next_state=S_5;\n" 283 "// synthesis translate_off\n" 284 " write_done=1'b0;\n" 285 "// synthesis translate_on\n" 290 " _next_state=S_6;\n" 291 " _next_pointer=_present_pointer+1'd1;\n" 292 " case(_present_data2)\n" 295 " _next_state=S_1;\n" 296 " active_request_next =1'b1;\n" 297 "// synthesis translate_off\n" 300 " $write(\"%c\",8'd37);\n" 301 " write_done=1'b1;\n" 303 "// synthesis translate_on\n" 307 "// synthesis translate_off\n" 310 " $write(\"%c\",data1[7:0]);\n" 311 " write_done=1'b1;\n" 313 "// synthesis translate_on\n" 315 " 8'd100: //Decimal %d\n" 316 " if(data1_size ==8'd64)\n" 318 "// synthesis translate_off\n" 321 " $write(\"%0d\",$signed(data1));\n" 322 " write_done=1'b1;\n" 324 "// synthesis translate_on\n" 326 " else if(data1_size ==8'd32)\n" 328 "// synthesis translate_off\n" 331 " $write(\"%0d\",$signed(data1[31:0]));\n" 332 " write_done=1'b1;\n" 334 "// synthesis translate_on\n" 336 " else if(data1_size ==8'd16)\n" 338 "// synthesis translate_off\n" 341 " $write(\"%0d\",$signed(data1[15:0]));\n" 342 " write_done=1'b1;\n" 344 "// synthesis translate_on\n" 346 " else if(data1_size ==8'd8)\n" 348 "// synthesis translate_off\n" 351 " $write(\"%0d\",$signed(data1[7:0]));\n" 352 " write_done=1'b1;\n" 354 "// synthesis translate_on\n" 358 "// synthesis translate_off\n" 359 " $display(\"ERROR - Decimal precision not supported (d) %d\", data1_size);\n" 361 "// synthesis translate_on\n" 363 " 8'd105: //Decimal %i\n" 364 " if(data1_size ==8'd64)\n" 366 "// synthesis translate_off\n" 369 " $write(\"%0d\",$signed(data1));\n" 370 " write_done=1'b1;\n" 372 "// synthesis translate_on\n" 374 " else if(data1_size ==8'd32)\n" 376 "// synthesis translate_off\n" 379 " $write(\"%0d\",$signed(data1[31:0]));\n" 380 " write_done=1'b1;\n" 382 "// synthesis translate_on\n" 384 " else if(data1_size ==8'd16)\n" 386 "// synthesis translate_off\n" 389 " $write(\"%0d\",$signed(data1[15:0]));\n" 390 " write_done=1'b1;\n" 392 "// synthesis translate_on\n" 394 " else if(data1_size ==8'd8)\n" 396 "// synthesis translate_off\n" 399 " $write(\"%0d\",$signed(data1[7:0]));\n" 400 " write_done=1'b1;\n" 402 "// synthesis translate_on\n" 406 "// synthesis translate_off\n" 407 " $display(\"ERROR - Decimal precision not supported (i) %d\", data1_size);\n" 409 "// synthesis translate_on\n" 411 " 8'd101: //Exponential %e\n" 413 " if(data1_size ==8'd64)\n" 415 "// synthesis translate_off\n" 418 " $write(\"%e\",$bitstoreal(data1));\n" 419 " write_done=1'b1;\n" 421 "// synthesis translate_on\n" 423 " else if(data1_size ==8'd32)\n" 425 "// synthesis translate_off\n" 428 " $write(\"%e\",bits32_to_real64(data1[31:0]));\n" 429 " write_done=1'b1;\n" 431 "// synthesis translate_on\n" 435 "// synthesis translate_off\n" 436 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 438 "// synthesis translate_on\n" 441 " 8'd69: //Exponential %E\n" 443 " if(data1_size ==8'd64)\n" 445 "// synthesis translate_off\n" 448 " $write(\"%e\",$bitstoreal(data1));\n" 449 " write_done=1'b1;\n" 451 "// synthesis translate_on\n" 453 " else if(data1_size ==8'd32)\n" 455 "// synthesis translate_off\n" 458 " $write(\"%e\",bits32_to_real64(data1[31:0]));\n" 459 " write_done=1'b1;\n" 461 "// synthesis translate_on\n" 465 "// synthesis translate_off\n" 466 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 468 "// synthesis translate_on\n" 471 " 8'd102: //Float %f\n" 473 " if(data1_size==8'd64)\n" 475 "// synthesis translate_off\n" 478 " $write(\"%20.20f\",$bitstoreal(data1));\n" 479 " write_done=1'b1;\n" 481 "// synthesis translate_on\n" 483 " else if(data1_size ==8'd32)\n" 485 "// synthesis translate_off\n" 488 " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n" 489 " write_done=1'b1;\n" 491 "// synthesis translate_on\n" 495 "// synthesis translate_off\n" 496 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 498 "// synthesis translate_on\n" 501 " 8'd70: //Float %F\n" 503 " if(data1_size==8'd64)\n" 505 "// synthesis translate_off\n" 508 " $write(\"%20.20f\",$bitstoreal(data1));\n" 509 " write_done=1'b1;\n" 511 "// synthesis translate_on\n" 513 " else if(data1_size ==8'd32)\n" 515 "// synthesis translate_off\n" 518 " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n" 519 " write_done=1'b1;\n" 521 "// synthesis translate_on\n" 525 "// synthesis translate_off\n" 526 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 528 "// synthesis translate_on\n" 531 " 8'd103: //Float %g\n" 533 " if(data1_size==8'd64)\n" 535 "// synthesis translate_off\n" 538 " $write(\"%20.20g\",$bitstoreal(data1));\n" 539 " write_done=1'b1;\n" 541 "// synthesis translate_on\n" 543 " else if(data1_size ==8'd32)\n" 545 "// synthesis translate_off\n" 548 " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n" 549 " write_done=1'b1;\n" 551 "// synthesis translate_on\n" 555 "// synthesis translate_off\n" 556 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 558 "// synthesis translate_on\n" 561 " 8'd71: //Float %G\n" 563 " if(data1_size==8'd64)\n" 565 "// synthesis translate_off\n" 568 " $write(\"%20.20g\",$bitstoreal(data1));\n" 569 " write_done=1'b1;\n" 571 "// synthesis translate_on\n" 573 " else if(data1_size ==8'd32)\n" 575 "// synthesis translate_off\n" 578 " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n" 579 " write_done=1'b1;\n" 581 "// synthesis translate_on\n" 585 "// synthesis translate_off\n" 586 " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n" 588 "// synthesis translate_on\n" 592 " if(data1_size ==8'd64)\n" 594 "// synthesis translate_off\n" 597 " $write(\"%0o\",data1);\n" 598 " write_done=1'b1;\n" 600 "// synthesis translate_on\n" 602 " else if(data1_size ==8'd32)\n" 604 "// synthesis translate_off\n" 607 " $write(\"%0o\",data1[31:0]);\n" 608 " write_done=1'b1;\n" 610 "// synthesis translate_on\n" 612 " else if(data1_size ==8'd16)\n" 614 "// synthesis translate_off\n" 617 " $write(\"%0o\",data1[15:0]);\n" 618 " write_done=1'b1;\n" 620 "// synthesis translate_on\n" 622 " else if(data1_size ==8'd8)\n" 624 "// synthesis translate_off\n" 627 " $write(\"%0o\",data1[7:0]);\n" 628 " write_done=1'b1;\n" 630 "// synthesis translate_on\n" 634 "// synthesis translate_off\n" 635 " $display(\"ERROR - Octal precision not supported %d\", data1_size);\n" 637 "// synthesis translate_on\n" 641 "// synthesis translate_off\n" 644 " $write(\"0x%0h\",data1);\n" 645 " write_done=1'b1;\n" 647 "// synthesis translate_on\n" 649 " 8'd115: //String\n" 651 " _next_state=S_7;\n" 652 " active_request_next =1'b1;\n" 653 " _next_pointer1=0;\n" 655 " 8'd117: //unsigned int %u TO BE FIXED\n" 656 " if(data1_size ==8'd64)\n" 658 "// synthesis translate_off\n" 661 " $write(\"%0d\",$unsigned(data1));\n" 662 " write_done=1'b1;\n" 664 "// synthesis translate_on\n" 666 " else if(data1_size ==8'd32)\n" 668 "// synthesis translate_off\n" 671 " $write(\"%0d\",$unsigned(data1[31:0]));\n" 672 " write_done=1'b1;\n" 674 "// synthesis translate_on\n" 676 " else if(data1_size ==8'd16)\n" 678 "// synthesis translate_off\n" 681 " $write(\"%0d\",$unsigned(data1[15:0]));\n" 682 " write_done=1'b1;\n" 684 "// synthesis translate_on\n" 686 " else if(data1_size ==8'd8)\n" 688 "// synthesis translate_off\n" 691 " $write(\"%0d\",$unsigned(data1[7:0]));\n" 692 " write_done=1'b1;\n" 694 "// synthesis translate_on\n" 698 "// synthesis translate_off\n" 699 " $display(\"ERROR - Unsigned precision not supported %d\", data1_size);\n" 701 "// synthesis translate_on\n" 703 " 8'd120: //Hex %x\n" 704 " if(data1_size ==8'd64)\n" 706 "// synthesis translate_off\n" 709 " $write(\"%0h\",data1);\n" 710 " write_done=1'b1;\n" 712 "// synthesis translate_on\n" 714 " else if(data1_size ==8'd32)\n" 716 "// synthesis translate_off\n" 719 " $write(\"%0h\",data1[31:0]);\n" 720 " write_done=1'b1;\n" 722 "// synthesis translate_on\n" 724 " else if(data1_size ==8'd16)\n" 726 "// synthesis translate_off\n" 729 " $write(\"%0h\",data1[15:0]);\n" 730 " write_done=1'b1;\n" 732 "// synthesis translate_on\n" 734 " else if(data1_size ==8'd8)\n" 736 "// synthesis translate_off\n" 739 " $write(\"%0h\",data1[7:0]);\n" 740 " write_done=1'b1;\n" 742 "// synthesis translate_on\n" 746 "// synthesis translate_off\n" 747 " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n" 749 "// synthesis translate_on\n" 752 " if(data1_size ==8'd64)\n" 754 "// synthesis translate_off\n" 757 " $write(\"%0h\",data1);\n" 758 " write_done=1'b1;\n" 760 "// synthesis translate_on\n" 762 " else if(data1_size ==8'd32)\n" 764 "// synthesis translate_off\n" 767 " $write(\"%0h\",data1[31:0]);\n" 768 " write_done=1'b1;\n" 770 "// synthesis translate_on\n" 772 " else if(data1_size ==8'd16)\n" 774 "// synthesis translate_off\n" 777 " $write(\"%0h\",data1[15:0]);\n" 778 " write_done=1'b1;\n" 780 "// synthesis translate_on\n" 782 " else if(data1_size ==8'd8)\n" 784 "// synthesis translate_off\n" 787 " $write(\"%0h\",data1[7:0]);\n" 788 " write_done=1'b1;\n" 790 "// synthesis translate_on\n" 794 "// synthesis translate_off\n" 795 " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n" 797 "// synthesis translate_on\n" 799 " 8'd97: //Hex float %a\n" 800 " if(data1_size ==8'd64)\n" 802 "// synthesis translate_off\n" 805 " $write(\"%0h\",data1);\n" 806 " write_done=1'b1;\n" 808 "// synthesis translate_on\n" 810 " else if(data1_size ==8'd32)\n" 812 "// synthesis translate_off\n" 815 " $write(\"%0h\",data1[31:0]);\n" 816 " write_done=1'b1;\n" 818 "// synthesis translate_on\n" 820 " else if(data1_size ==8'd16)\n" 822 "// synthesis translate_off\n" 825 " $write(\"%0h\",data1[15:0]);\n" 826 " write_done=1'b1;\n" 828 "// synthesis translate_on\n" 830 " else if(data1_size ==8'd8)\n" 832 "// synthesis translate_off\n" 835 " $write(\"%0h\",data1[7:0]);\n" 836 " write_done=1'b1;\n" 838 "// synthesis translate_on\n" 842 "// synthesis translate_off\n" 843 " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n" 845 "// synthesis translate_on\n" 849 " _next_state=S_3;\n" 850 " active_request_next =1'b1;\n" 856 " _next_selector=_present_selector<<1;\n" 857 " _next_state=S_1;\n" 858 " active_request_next =1'b1;\n" 862 " Mout_addr_ram=(data1[BITSIZE_Mout_addr_ram-1:0]+_present_pointer1) & " 863 "{BITSIZE_Mout_addr_ram{active_request}};\n" 864 " Mout_data_ram_size={{BITSIZE_Mout_data_ram_size-4{1'b0}}, 4'd8} & " 865 "{BITSIZE_Mout_data_ram_size{active_request}};\n" 866 " Mout_oe_ram=active_request;\n" 869 " _next_data2 = M_Rdata_ram[7:0];\n" 870 " _next_state=S_4;\n" 871 "// synthesis translate_off\n" 872 " write_done=1'b0;\n" 873 "// synthesis translate_on\n" 878 " _next_pointer1=_present_pointer1+1'd1;\n" 879 " if(_present_data2!=8'd0)\n" 881 "// synthesis translate_off\n" 884 " $write(\"%c\",_present_data2);\n" 885 " write_done=1'b1;\n" 887 "// synthesis translate_on\n" 888 " _next_state=S_7;\n" 889 " active_request_next =1'b1;\n" 892 " _next_state=S_6;\n"
PrintfModuleGenerator(const HLS_managerRef &HLSMgr)
exceptions managed by PandA
#define STR(s)
Macro which performs a lexical_cast to a string.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
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