PandA-2024.02
PrintfModuleGenerator.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2022-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
50 
51 #include "exceptions.hpp"
52 #include "language_writer.hpp"
53 
55 {
56 }
57 
59  unsigned int /* function_id */, vertex /* op_v */,
60  const HDLWriter_Language language,
61  const std::vector<ModuleGenerator::parameter>& _p,
62  const std::vector<ModuleGenerator::parameter>& /* _ports_in */,
63  const std::vector<ModuleGenerator::parameter>& /* _ports_out */,
64  const std::vector<ModuleGenerator::parameter>& /* _ports_inout */)
65 {
66  if(language != HDLWriter_Language::VERILOG)
67  {
68  THROW_UNREACHABLE("Unsupported output language.");
69  }
70 
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));
73 
74  std::string sensitivity;
75  for(auto i = 0U; i < _p.size(); i++)
76  {
77  sensitivity += " or " + _p[i].name;
78  }
79 
80  std::string case_statement;
81  if(_p.size() > 1)
82  {
83  case_statement = "case (_present_selector)\n";
84  for(auto i = 0U, selector = 1U; i < _p.size(); i++, selector *= 2)
85  {
86  case_statement += " " + selector_dimension + "'d" + STR(selector) +
87  ":\n"
88  " begin\n"
89  " data1=" +
90  _p[i].name +
91  ";\n"
92  " data1_size=BITSIZE_in" +
93  STR(i + 1) +
94  ";\n"
95  " end\n";
96  }
97  case_statement += " default:\n"
98  " begin\n"
99  " data1 = 64'b0;\n"
100  " data1_size = 8'b0;\n"
101  " end\n"
102  " endcase";
103  }
104  else
105  {
106  case_statement = "";
107  }
108 
109  const auto fsm =
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"
118  "begin\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"
128  "end\n"
129  "endfunction\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"
135  "reg done_port;\n"
136  "reg Mout_oe_ram;\n"
137  "reg Mout_we_ram;\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"
143  "\n"
144  "parameter [2:0] S_0 = 3'd0,\n"
145  " S_1 = 3'd1,\n"
146  " S_2 = 3'd2,\n"
147  " S_3 = 3'd3,\n"
148  " S_4 = 3'd4,\n"
149  " S_5 = 3'd5,\n"
150  " S_6 = 3'd6,\n"
151  " S_7 = 3'd7;\n"
152  "reg [2:0] _present_state;\n"
153  "reg [2:0] _next_state;\n"
154  "reg [" +
155  selector_left +
156  ":0] _present_selector;\n"
157  "reg [" +
158  selector_left +
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"
164  "reg write_done;\n"
165  "\n"
166  " always @(posedge clock 1RESET_EDGE)\n"
167  " if (1RESET_VALUE)\n"
168  " begin\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 <=" +
173  selector_dimension +
174  "'d0;\n"
175  " _present_data2 <= 8'b0;\n"
176  " end\n"
177  " else\n"
178  " begin\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"
184  " end\n"
185  "\n"
186  " always @(posedge clock 1RESET_EDGE)\n"
187  " begin\n"
188  " if (1RESET_VALUE)\n"
189  " begin\n"
190  " active_request <= 0;\n"
191  " end\n"
192  " else\n"
193  " begin\n"
194  " active_request <= active_request_next;\n"
195  " end\n"
196  " end\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" +
199  sensitivity +
200  " or _present_data2 or M_Rdata_ram)\n"
201  " begin\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"
214  " " +
215  case_statement +
216  "\n"
217  " case (_present_state)\n"
218  " S_0:\n"
219  " if(start_port)\n"
220  " begin\n"
221  " _next_pointer=0;\n"
222  " _next_pointer1=0;\n"
223  " _next_state=S_1; \n"
224  " active_request_next =1'b1;\n"
225  " _next_selector=" +
226  selector_dimension +
227  "'d2;\n"
228  " end\n"
229  " \n"
230  " S_1:\n"
231  " begin\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"
237  " if(M_DataRdy)\n"
238  " begin\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"
244  " end\n"
245  " end\n"
246  " S_2:\n"
247  " begin\n"
248  " _next_pointer=_present_pointer+1'd1;\n"
249  " if((_present_data2!=8'd0)&&(_present_data2!=8'd37))\n"
250  " begin\n"
251  "// synthesis translate_off\n"
252  " if(!write_done)\n"
253  " begin\n"
254  " $write(\"%c\",_present_data2);\n"
255  " write_done=1'b1;\n"
256  " end\n"
257  "// synthesis translate_on\n"
258  " _next_state=S_1;\n"
259  " active_request_next =1'b1;\n"
260  " end\n"
261  " else if(_present_data2==8'd37)\n"
262  " begin\n"
263  " _next_state=S_3;\n"
264  " active_request_next =1'b1;\n"
265  " end\n"
266  " else if(_present_data2==8'd0)\n"
267  " begin\n"
268  " done_port = 1'b1;\n"
269  " _next_state=S_0;\n"
270  " end\n"
271  " end\n"
272  " S_3:\n"
273  " begin\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"
279  " if(M_DataRdy)\n"
280  " begin\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"
286  " end\n"
287  " end\n"
288  " S_5 :\n"
289  " begin\n"
290  " _next_state=S_6;\n"
291  " _next_pointer=_present_pointer+1'd1;\n"
292  " case(_present_data2)\n"
293  " 8'd37: //%%\n"
294  " begin\n"
295  " _next_state=S_1;\n"
296  " active_request_next =1'b1;\n"
297  "// synthesis translate_off\n"
298  " if(!write_done)\n"
299  " begin\n"
300  " $write(\"%c\",8'd37);\n"
301  " write_done=1'b1;\n"
302  " end\n"
303  "// synthesis translate_on\n"
304  " end\n"
305  " 8'd99: //Char\n"
306  " begin\n"
307  "// synthesis translate_off\n"
308  " if(!write_done)\n"
309  " begin\n"
310  " $write(\"%c\",data1[7:0]);\n"
311  " write_done=1'b1;\n"
312  " end\n"
313  "// synthesis translate_on\n"
314  " end\n"
315  " 8'd100: //Decimal %d\n"
316  " if(data1_size ==8'd64)\n"
317  " begin\n"
318  "// synthesis translate_off\n"
319  " if(!write_done)\n"
320  " begin\n"
321  " $write(\"%0d\",$signed(data1));\n"
322  " write_done=1'b1;\n"
323  " end\n"
324  "// synthesis translate_on\n"
325  " end\n"
326  " else if(data1_size ==8'd32)\n"
327  " begin\n"
328  "// synthesis translate_off\n"
329  " if(!write_done)\n"
330  " begin\n"
331  " $write(\"%0d\",$signed(data1[31:0]));\n"
332  " write_done=1'b1;\n"
333  " end\n"
334  "// synthesis translate_on\n"
335  " end\n"
336  " else if(data1_size ==8'd16)\n"
337  " begin\n"
338  "// synthesis translate_off\n"
339  " if(!write_done)\n"
340  " begin\n"
341  " $write(\"%0d\",$signed(data1[15:0]));\n"
342  " write_done=1'b1;\n"
343  " end\n"
344  "// synthesis translate_on\n"
345  " end\n"
346  " else if(data1_size ==8'd8)\n"
347  " begin\n"
348  "// synthesis translate_off\n"
349  " if(!write_done)\n"
350  " begin\n"
351  " $write(\"%0d\",$signed(data1[7:0]));\n"
352  " write_done=1'b1;\n"
353  " end\n"
354  "// synthesis translate_on\n"
355  " end\n"
356  " else\n"
357  " begin\n"
358  "// synthesis translate_off\n"
359  " $display(\"ERROR - Decimal precision not supported (d) %d\", data1_size);\n"
360  " $finish;\n"
361  "// synthesis translate_on\n"
362  " end\n"
363  " 8'd105: //Decimal %i\n"
364  " if(data1_size ==8'd64)\n"
365  " begin\n"
366  "// synthesis translate_off\n"
367  " if(!write_done)\n"
368  " begin\n"
369  " $write(\"%0d\",$signed(data1));\n"
370  " write_done=1'b1;\n"
371  " end\n"
372  "// synthesis translate_on\n"
373  " end\n"
374  " else if(data1_size ==8'd32)\n"
375  " begin\n"
376  "// synthesis translate_off\n"
377  " if(!write_done)\n"
378  " begin\n"
379  " $write(\"%0d\",$signed(data1[31:0]));\n"
380  " write_done=1'b1;\n"
381  " end\n"
382  "// synthesis translate_on\n"
383  " end\n"
384  " else if(data1_size ==8'd16)\n"
385  " begin\n"
386  "// synthesis translate_off\n"
387  " if(!write_done)\n"
388  " begin\n"
389  " $write(\"%0d\",$signed(data1[15:0]));\n"
390  " write_done=1'b1;\n"
391  " end\n"
392  "// synthesis translate_on\n"
393  " end\n"
394  " else if(data1_size ==8'd8)\n"
395  " begin\n"
396  "// synthesis translate_off\n"
397  " if(!write_done)\n"
398  " begin\n"
399  " $write(\"%0d\",$signed(data1[7:0]));\n"
400  " write_done=1'b1;\n"
401  " end\n"
402  "// synthesis translate_on\n"
403  " end\n"
404  " else\n"
405  " begin\n"
406  "// synthesis translate_off\n"
407  " $display(\"ERROR - Decimal precision not supported (i) %d\", data1_size);\n"
408  " $finish;\n"
409  "// synthesis translate_on\n"
410  " end\n"
411  " 8'd101: //Exponential %e\n"
412  " begin\n"
413  " if(data1_size ==8'd64)\n"
414  " begin\n"
415  "// synthesis translate_off\n"
416  " if(!write_done)\n"
417  " begin\n"
418  " $write(\"%e\",$bitstoreal(data1));\n"
419  " write_done=1'b1;\n"
420  " end\n"
421  "// synthesis translate_on\n"
422  " end\n"
423  " else if(data1_size ==8'd32)\n"
424  " begin\n"
425  "// synthesis translate_off\n"
426  " if(!write_done)\n"
427  " begin\n"
428  " $write(\"%e\",bits32_to_real64(data1[31:0]));\n"
429  " write_done=1'b1;\n"
430  " end\n"
431  "// synthesis translate_on\n"
432  " end\n"
433  " else\n"
434  " begin\n"
435  "// synthesis translate_off\n"
436  " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n"
437  " $finish;\n"
438  "// synthesis translate_on\n"
439  " end\n"
440  " end\n"
441  " 8'd69: //Exponential %E\n"
442  " begin\n"
443  " if(data1_size ==8'd64)\n"
444  " begin\n"
445  "// synthesis translate_off\n"
446  " if(!write_done)\n"
447  " begin\n"
448  " $write(\"%e\",$bitstoreal(data1));\n"
449  " write_done=1'b1;\n"
450  " end\n"
451  "// synthesis translate_on\n"
452  " end\n"
453  " else if(data1_size ==8'd32)\n"
454  " begin\n"
455  "// synthesis translate_off\n"
456  " if(!write_done)\n"
457  " begin\n"
458  " $write(\"%e\",bits32_to_real64(data1[31:0]));\n"
459  " write_done=1'b1;\n"
460  " end\n"
461  "// synthesis translate_on\n"
462  " end\n"
463  " else\n"
464  " begin\n"
465  "// synthesis translate_off\n"
466  " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n"
467  " $finish;\n"
468  "// synthesis translate_on\n"
469  " end\n"
470  " end\n"
471  " 8'd102: //Float %f\n"
472  " begin\n"
473  " if(data1_size==8'd64)\n"
474  " begin\n"
475  "// synthesis translate_off\n"
476  " if(!write_done)\n"
477  " begin\n"
478  " $write(\"%20.20f\",$bitstoreal(data1));\n"
479  " write_done=1'b1;\n"
480  " end\n"
481  "// synthesis translate_on\n"
482  " end\n"
483  " else if(data1_size ==8'd32)\n"
484  " begin\n"
485  "// synthesis translate_off\n"
486  " if(!write_done)\n"
487  " begin\n"
488  " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n"
489  " write_done=1'b1;\n"
490  " end\n"
491  "// synthesis translate_on\n"
492  " end\n"
493  " else\n"
494  " begin\n"
495  "// synthesis translate_off\n"
496  " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n"
497  " $finish;\n"
498  "// synthesis translate_on\n"
499  " end\n"
500  " end\n"
501  " 8'd70: //Float %F\n"
502  " begin\n"
503  " if(data1_size==8'd64)\n"
504  " begin\n"
505  "// synthesis translate_off\n"
506  " if(!write_done)\n"
507  " begin\n"
508  " $write(\"%20.20f\",$bitstoreal(data1));\n"
509  " write_done=1'b1;\n"
510  " end\n"
511  "// synthesis translate_on\n"
512  " end\n"
513  " else if(data1_size ==8'd32)\n"
514  " begin\n"
515  "// synthesis translate_off\n"
516  " if(!write_done)\n"
517  " begin\n"
518  " $write(\"%20.20f\",bits32_to_real64(data1[31:0]));\n"
519  " write_done=1'b1;\n"
520  " end\n"
521  "// synthesis translate_on\n"
522  " end\n"
523  " else\n"
524  " begin\n"
525  "// synthesis translate_off\n"
526  " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n"
527  " $finish;\n"
528  "// synthesis translate_on\n"
529  " end\n"
530  " end\n"
531  " 8'd103: //Float %g\n"
532  " begin\n"
533  " if(data1_size==8'd64)\n"
534  " begin\n"
535  "// synthesis translate_off\n"
536  " if(!write_done)\n"
537  " begin\n"
538  " $write(\"%20.20g\",$bitstoreal(data1));\n"
539  " write_done=1'b1;\n"
540  " end\n"
541  "// synthesis translate_on\n"
542  " end\n"
543  " else if(data1_size ==8'd32)\n"
544  " begin\n"
545  "// synthesis translate_off\n"
546  " if(!write_done)\n"
547  " begin\n"
548  " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n"
549  " write_done=1'b1;\n"
550  " end\n"
551  "// synthesis translate_on\n"
552  " end\n"
553  " else\n"
554  " begin\n"
555  "// synthesis translate_off\n"
556  " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n"
557  " $finish;\n"
558  "// synthesis translate_on\n"
559  " end\n"
560  " end\n"
561  " 8'd71: //Float %G\n"
562  " begin\n"
563  " if(data1_size==8'd64)\n"
564  " begin\n"
565  "// synthesis translate_off\n"
566  " if(!write_done)\n"
567  " begin\n"
568  " $write(\"%20.20g\",$bitstoreal(data1));\n"
569  " write_done=1'b1;\n"
570  " end\n"
571  "// synthesis translate_on\n"
572  " end\n"
573  " else if(data1_size ==8'd32)\n"
574  " begin\n"
575  "// synthesis translate_off\n"
576  " if(!write_done)\n"
577  " begin\n"
578  " $write(\"%20.20g\",bits32_to_real64(data1[31:0]));\n"
579  " write_done=1'b1;\n"
580  " end\n"
581  "// synthesis translate_on\n"
582  " end\n"
583  " else\n"
584  " begin\n"
585  "// synthesis translate_off\n"
586  " $display(\"ERROR - Floating point precision not supported %d\", data1_size);\n"
587  " $finish;\n"
588  "// synthesis translate_on\n"
589  " end\n"
590  " end\n"
591  " 8'd111: //Octal\n"
592  " if(data1_size ==8'd64)\n"
593  " begin\n"
594  "// synthesis translate_off\n"
595  " if(!write_done)\n"
596  " begin\n"
597  " $write(\"%0o\",data1);\n"
598  " write_done=1'b1;\n"
599  " end\n"
600  "// synthesis translate_on\n"
601  " end\n"
602  " else if(data1_size ==8'd32)\n"
603  " begin\n"
604  "// synthesis translate_off\n"
605  " if(!write_done)\n"
606  " begin\n"
607  " $write(\"%0o\",data1[31:0]);\n"
608  " write_done=1'b1;\n"
609  " end\n"
610  "// synthesis translate_on\n"
611  " end\n"
612  " else if(data1_size ==8'd16)\n"
613  " begin\n"
614  "// synthesis translate_off\n"
615  " if(!write_done)\n"
616  " begin\n"
617  " $write(\"%0o\",data1[15:0]);\n"
618  " write_done=1'b1;\n"
619  " end\n"
620  "// synthesis translate_on\n"
621  " end\n"
622  " else if(data1_size ==8'd8)\n"
623  " begin\n"
624  "// synthesis translate_off\n"
625  " if(!write_done)\n"
626  " begin\n"
627  " $write(\"%0o\",data1[7:0]);\n"
628  " write_done=1'b1;\n"
629  " end\n"
630  "// synthesis translate_on\n"
631  " end\n"
632  " else\n"
633  " begin\n"
634  "// synthesis translate_off\n"
635  " $display(\"ERROR - Octal precision not supported %d\", data1_size);\n"
636  " $finish;\n"
637  "// synthesis translate_on\n"
638  " end\n"
639  " 8'd112: //%p\n"
640  " begin\n"
641  "// synthesis translate_off\n"
642  " if(!write_done)\n"
643  " begin\n"
644  " $write(\"0x%0h\",data1);\n"
645  " write_done=1'b1;\n"
646  " end\n"
647  "// synthesis translate_on\n"
648  " end\n"
649  " 8'd115: //String\n"
650  " begin\n"
651  " _next_state=S_7;\n"
652  " active_request_next =1'b1;\n"
653  " _next_pointer1=0;\n"
654  " end\n"
655  " 8'd117: //unsigned int %u TO BE FIXED\n"
656  " if(data1_size ==8'd64)\n"
657  " begin\n"
658  "// synthesis translate_off\n"
659  " if(!write_done)\n"
660  " begin\n"
661  " $write(\"%0d\",$unsigned(data1));\n"
662  " write_done=1'b1;\n"
663  " end\n"
664  "// synthesis translate_on\n"
665  " end\n"
666  " else if(data1_size ==8'd32)\n"
667  " begin\n"
668  "// synthesis translate_off\n"
669  " if(!write_done)\n"
670  " begin\n"
671  " $write(\"%0d\",$unsigned(data1[31:0]));\n"
672  " write_done=1'b1;\n"
673  " end\n"
674  "// synthesis translate_on\n"
675  " end\n"
676  " else if(data1_size ==8'd16)\n"
677  " begin\n"
678  "// synthesis translate_off\n"
679  " if(!write_done)\n"
680  " begin\n"
681  " $write(\"%0d\",$unsigned(data1[15:0]));\n"
682  " write_done=1'b1;\n"
683  " end\n"
684  "// synthesis translate_on\n"
685  " end\n"
686  " else if(data1_size ==8'd8)\n"
687  " begin\n"
688  "// synthesis translate_off\n"
689  " if(!write_done)\n"
690  " begin\n"
691  " $write(\"%0d\",$unsigned(data1[7:0]));\n"
692  " write_done=1'b1;\n"
693  " end\n"
694  "// synthesis translate_on\n"
695  " end\n"
696  " else\n"
697  " begin\n"
698  "// synthesis translate_off\n"
699  " $display(\"ERROR - Unsigned precision not supported %d\", data1_size);\n"
700  " $finish;\n"
701  "// synthesis translate_on\n"
702  " end\n"
703  " 8'd120: //Hex %x\n"
704  " if(data1_size ==8'd64)\n"
705  " begin\n"
706  "// synthesis translate_off\n"
707  " if(!write_done)\n"
708  " begin\n"
709  " $write(\"%0h\",data1);\n"
710  " write_done=1'b1;\n"
711  " end\n"
712  "// synthesis translate_on\n"
713  " end\n"
714  " else if(data1_size ==8'd32)\n"
715  " begin\n"
716  "// synthesis translate_off\n"
717  " if(!write_done)\n"
718  " begin\n"
719  " $write(\"%0h\",data1[31:0]);\n"
720  " write_done=1'b1;\n"
721  " end\n"
722  "// synthesis translate_on\n"
723  " end\n"
724  " else if(data1_size ==8'd16)\n"
725  " begin\n"
726  "// synthesis translate_off\n"
727  " if(!write_done)\n"
728  " begin\n"
729  " $write(\"%0h\",data1[15:0]);\n"
730  " write_done=1'b1;\n"
731  " end\n"
732  "// synthesis translate_on\n"
733  " end\n"
734  " else if(data1_size ==8'd8)\n"
735  " begin\n"
736  "// synthesis translate_off\n"
737  " if(!write_done)\n"
738  " begin\n"
739  " $write(\"%0h\",data1[7:0]);\n"
740  " write_done=1'b1;\n"
741  " end\n"
742  "// synthesis translate_on\n"
743  " end\n"
744  " else\n"
745  " begin\n"
746  "// synthesis translate_off\n"
747  " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n"
748  " $finish;\n"
749  "// synthesis translate_on\n"
750  " end\n"
751  " 8'd88: //Hex %X\n"
752  " if(data1_size ==8'd64)\n"
753  " begin\n"
754  "// synthesis translate_off\n"
755  " if(!write_done)\n"
756  " begin\n"
757  " $write(\"%0h\",data1);\n"
758  " write_done=1'b1;\n"
759  " end\n"
760  "// synthesis translate_on\n"
761  " end\n"
762  " else if(data1_size ==8'd32)\n"
763  " begin\n"
764  "// synthesis translate_off\n"
765  " if(!write_done)\n"
766  " begin\n"
767  " $write(\"%0h\",data1[31:0]);\n"
768  " write_done=1'b1;\n"
769  " end\n"
770  "// synthesis translate_on\n"
771  " end\n"
772  " else if(data1_size ==8'd16)\n"
773  " begin\n"
774  "// synthesis translate_off\n"
775  " if(!write_done)\n"
776  " begin\n"
777  " $write(\"%0h\",data1[15:0]);\n"
778  " write_done=1'b1;\n"
779  " end\n"
780  "// synthesis translate_on\n"
781  " end\n"
782  " else if(data1_size ==8'd8)\n"
783  " begin\n"
784  "// synthesis translate_off\n"
785  " if(!write_done)\n"
786  " begin\n"
787  " $write(\"%0h\",data1[7:0]);\n"
788  " write_done=1'b1;\n"
789  " end\n"
790  "// synthesis translate_on\n"
791  " end\n"
792  " else\n"
793  " begin\n"
794  "// synthesis translate_off\n"
795  " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n"
796  " $finish;\n"
797  "// synthesis translate_on\n"
798  " end\n"
799  " 8'd97: //Hex float %a\n"
800  " if(data1_size ==8'd64)\n"
801  " begin\n"
802  "// synthesis translate_off\n"
803  " if(!write_done)\n"
804  " begin\n"
805  " $write(\"%0h\",data1);\n"
806  " write_done=1'b1;\n"
807  " end\n"
808  "// synthesis translate_on\n"
809  " end\n"
810  " else if(data1_size ==8'd32)\n"
811  " begin\n"
812  "// synthesis translate_off\n"
813  " if(!write_done)\n"
814  " begin\n"
815  " $write(\"%0h\",data1[31:0]);\n"
816  " write_done=1'b1;\n"
817  " end\n"
818  "// synthesis translate_on\n"
819  " end\n"
820  " else if(data1_size ==8'd16)\n"
821  " begin\n"
822  "// synthesis translate_off\n"
823  " if(!write_done)\n"
824  " begin\n"
825  " $write(\"%0h\",data1[15:0]);\n"
826  " write_done=1'b1;\n"
827  " end\n"
828  "// synthesis translate_on\n"
829  " end\n"
830  " else if(data1_size ==8'd8)\n"
831  " begin\n"
832  "// synthesis translate_off\n"
833  " if(!write_done)\n"
834  " begin\n"
835  " $write(\"%0h\",data1[7:0]);\n"
836  " write_done=1'b1;\n"
837  " end\n"
838  "// synthesis translate_on\n"
839  " end\n"
840  " else\n"
841  " begin\n"
842  "// synthesis translate_off\n"
843  " $display(\"ERROR - Hex precision not supported %d\", data1_size);\n"
844  " $finish;\n"
845  "// synthesis translate_on\n"
846  " end\n"
847  " default:\n"
848  " begin\n"
849  " _next_state=S_3;\n"
850  " active_request_next =1'b1;\n"
851  " end\n"
852  " endcase\n"
853  " end\n"
854  " S_6:\n"
855  " begin\n"
856  " _next_selector=_present_selector<<1;\n"
857  " _next_state=S_1;\n"
858  " active_request_next =1'b1;\n"
859  " end\n"
860  " S_7:\n"
861  " begin\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"
867  " if(M_DataRdy)\n"
868  " begin\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"
874  " end\n"
875  " end\n"
876  " S_4:\n"
877  " begin\n"
878  " _next_pointer1=_present_pointer1+1'd1;\n"
879  " if(_present_data2!=8'd0)\n"
880  " begin\n"
881  "// synthesis translate_off\n"
882  " if(!write_done)\n"
883  " begin\n"
884  " $write(\"%c\",_present_data2);\n"
885  " write_done=1'b1;\n"
886  " end\n"
887  "// synthesis translate_on\n"
888  " _next_state=S_7;\n"
889  " active_request_next =1'b1;\n"
890  " end\n"
891  " else\n"
892  " _next_state=S_6;\n"
893  " end\n"
894  " endcase\n"
895  " end\n";
896 
897  out << fsm;
898 }
PrintfModuleGenerator(const HLS_managerRef &HLSMgr)
exceptions managed by PandA
#define STR(s)
Macro which performs a lexical_cast to a string.
HDLWriter_Language
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Definition: exceptions.hpp:292
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
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

Generated on Mon Feb 12 2024 13:02:54 for PandA-2024.02 by doxygen 1.8.13