CGRA-ME
ModuleFPUnit.cpp
Go to the documentation of this file.
1 #include <CGRA/Module.h>
2 #include <CGRA/ModuleFPUnit.h>
3 #include <regex>
4 
5 //Module Definition for Adder
6 FPAdd::FPAdd(std::string name, Location loc, unsigned size)
7  : Module(name, loc, size)
8 {
9  adds_synchronous_circuitry = true; //Adder has sequential elements
10 
11  //Create ports
12 
13  addPort("X", PORT_INPUT, "size", size + 2);
14  addPort("Y", PORT_INPUT, "size", size + 2);
15  addPort("R", PORT_OUTPUT, "size", size + 2);
16  addPort("FP_clk_en", PORT_INPUT, 1);
17 
18 }
19 
20 //Virtual function that override Module::GenericName. Returns generic name for the adder
21 std::string FPAdd::GenericName()
22 {
23  return "FPAdder";
24 }
25 
26 //Virtual function that overrides Module::CoreIRGetFunctionality. Generates functionality for the adder
28 {
29  nlohmann::json vjson;
30 
31  //Create Header
32  vjson["prefix"] = "cgrame_";
33  vjson["parameters"] = {};
34  for (auto& parameter : parameterlist)
35  {
36  vjson["parameters"].push_back(parameter.first);
37  }
38  vjson["interface"] = {};
39  vjson["interface"].push_back("CGRA_Clock");
40  vjson["interface"].push_back("CGRA_Reset");
41  vjson["interface"].push_back("CGRA_Enable");
42 
43  for (auto& port : ports)
44  {
45  std::string portName = port.second->getName();
46  vjson["interface"].push_back(portName);
47  }
48 
49  //module definition
50  std::string moduleDefinition;
51  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Clock;\n";
52  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Reset;\n";
53  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Enable;\n";
54 
55  for (auto& port : ports)
56  {
57  port_type portType = port.second->pt;
58  std::string portTypeString = {};
59  if(portType == port_type::PORT_INPUT)
60  {
61  portTypeString = "input";
62  }
63  else if (portType == port_type::PORT_OUTPUT)
64  {
65  portTypeString = "output";
66  }
67  else if (portType == port_type::PORT_OUTPUT_REG)
68  {
69  portTypeString = "output reg";
70  }
71  else
72  {
73  portTypeString = "inout";
74  }
75  std::string portSizeString;
76  if (!(port.second->parameter).empty()) // Check if size is parameterized
77  {
78  std::string portParameterName = port.second->parameter;
79  portSizeString = "[" + portParameterName + "-1:0]";
80  }
81  else
82  {
83  portSizeString = "[" + std::to_string(port.second->size - 1) + ":0]";
84  }
85  std::string portName = port.second->getName();
86  std::string portDeclaration = portTypeString + " " + portSizeString + " " + portName + ";\n";
87  moduleDefinition += std::string(SET_INDENT) + portDeclaration;
88  }
89 
90  // Functionality
91  moduleDefinition += std::string(SET_INDENT) + "FPAdd FPAdder (\n";
92  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
93  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
94  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".ce(~FP_clk_en),\n";
95  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".X(X),\n";
96  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".Y(Y),\n";
97  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".R(R)\n";
98  moduleDefinition += std::string(SET_INDENT) + ");\n";
99 
100  vjson["definition"] = moduleDefinition;
101  return vjson;
102 
103 }
104 
105 //Class destructor
107 {
108  //Empty Destructor
109 }
110 
111 
112 
113 
114 //Module Definition for Multiplier
115 FPMult::FPMult(std::string name, Location loc, unsigned size)
116  : Module(name, loc, size)
117 {
118  adds_synchronous_circuitry = true; //Multiplier has sequential elements
119 
120  //Create ports
121 
122  addPort("X", PORT_INPUT, "size", size + 2);
123  addPort("Y", PORT_INPUT, "size", size + 2);
124  addPort("R", PORT_OUTPUT, "size", size + 2);
125  addPort("FP_clk_en", PORT_INPUT, 1);
126 }
127 
128 //Virtual function that override Module::GenericName. Returns generic name for the Multiplier
129 std::string FPMult::GenericName()
130 {
131  return "FPMultiplier";
132 }
133 
134 //Virtual function that overrides Module::CoreIRGetFunctionality. Generates functionality for the Multiplier
136 {
137  nlohmann::json vjson;
138 
139  //Create Header
140  vjson["prefix"] = "cgrame_";
141  vjson["parameters"] = {};
142  for (auto& parameter : parameterlist)
143  {
144  vjson["parameters"].push_back(parameter.first);
145  }
146  vjson["interface"] = {};
147  vjson["interface"].push_back("CGRA_Clock");
148  vjson["interface"].push_back("CGRA_Reset");
149  vjson["interface"].push_back("CGRA_Enable");
150 
151  for (auto& port : ports)
152  {
153  std::string portName = port.second->getName();
154  vjson["interface"].push_back(portName);
155  }
156 
157  //module definition
158  std::string moduleDefinition;
159  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Clock;\n";
160  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Reset;\n";
161  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Enable;\n";
162 
163  for (auto& port : ports)
164  {
165  port_type portType = port.second->pt;
166  std::string portTypeString = {};
167  if(portType == port_type::PORT_INPUT)
168  {
169  portTypeString = "input";
170  }
171  else if (portType == port_type::PORT_OUTPUT)
172  {
173  portTypeString = "output";
174  }
175  else if (portType == port_type::PORT_OUTPUT_REG)
176  {
177  portTypeString = "output reg";
178  }
179  else
180  {
181  portTypeString = "inout";
182  }
183  std::string portSizeString;
184  if (!(port.second->parameter).empty()) // Check if size is parameterized
185  {
186  std::string portParameterName = port.second->parameter;
187  portSizeString = "[" + portParameterName + "-1:0]";
188  }
189  else
190  {
191  portSizeString = "[" + std::to_string(port.second->size - 1) + ":0]";
192  }
193  std::string portName = port.second->getName();
194  std::string portDeclaration = portTypeString + " " + portSizeString + " " + portName + ";\n";
195  moduleDefinition += std::string(SET_INDENT) + portDeclaration;
196  }
197 
198  // Functionality
199  moduleDefinition += std::string(SET_INDENT) + "FPMult FPMultiplier (\n";
200  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
201  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
202  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".ce(~FP_clk_en),\n";
203  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".X(X),\n";
204  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".Y(Y),\n";
205  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".R(R)\n";
206  moduleDefinition += std::string(SET_INDENT) + ");\n";
207 
208  vjson["definition"] = moduleDefinition;
209  return vjson;
210 
211 }
212 
213 //Class destructor
215 {
216  //Empty Destructor
217 }
218 
219 
220 
221 
222 //Module Definition for Divider
223 FPDiv::FPDiv(std::string name, Location loc, unsigned size)
224  : Module(name, loc, size)
225 {
226  adds_synchronous_circuitry = true; //Divider has sequential elements
227 
228  //Create ports
229 
230  addPort("X", PORT_INPUT, "size", size + 2);
231  addPort("Y", PORT_INPUT, "size", size + 2);
232  addPort("R", PORT_OUTPUT, "size", size + 2);
233  addPort("FP_clk_en", PORT_INPUT, 1);
234 }
235 
236 //Virtual function that override Module::GenericName. Returns generic name for the Divider
237 std::string FPDiv::GenericName()
238 {
239  return "FPDivider";
240 }
241 
242 //Virtual function that overrides Module::CoreIRGetFunctionality. Generates functionality for the Divider
244 {
245  nlohmann::json vjson;
246 
247  //Create Header
248  vjson["prefix"] = "cgrame_";
249  vjson["parameters"] = {};
250  for (auto& parameter : parameterlist)
251  {
252  vjson["parameters"].push_back(parameter.first);
253  }
254  vjson["interface"] = {};
255  vjson["interface"].push_back("CGRA_Clock");
256  vjson["interface"].push_back("CGRA_Reset");
257  vjson["interface"].push_back("CGRA_Enable");
258 
259  for (auto& port : ports)
260  {
261  std::string portName = port.second->getName();
262  vjson["interface"].push_back(portName);
263  }
264 
265  //module definition
266  std::string moduleDefinition;
267  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Clock;\n";
268  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Reset;\n";
269  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Enable;\n";
270 
271  for (auto& port : ports)
272  {
273  port_type portType = port.second->pt;
274  std::string portTypeString = {};
275  if(portType == port_type::PORT_INPUT)
276  {
277  portTypeString = "input";
278  }
279  else if (portType == port_type::PORT_OUTPUT)
280  {
281  portTypeString = "output";
282  }
283  else if (portType == port_type::PORT_OUTPUT_REG)
284  {
285  portTypeString = "output reg";
286  }
287  else
288  {
289  portTypeString = "inout";
290  }
291  std::string portSizeString;
292  if (!(port.second->parameter).empty()) // Check if size is parameterized
293  {
294  std::string portParameterName = port.second->parameter;
295  portSizeString = "[" + portParameterName + "-1:0]";
296  }
297  else
298  {
299  portSizeString = "[" + std::to_string(port.second->size - 1) + ":0]";
300  }
301  std::string portName = port.second->getName();
302  std::string portDeclaration = portTypeString + " " + portSizeString + " " + portName + ";\n";
303  moduleDefinition += std::string(SET_INDENT) + portDeclaration;
304  }
305 
306  // Functionality
307  moduleDefinition += std::string(SET_INDENT) + "FPDiv FPDivider (\n";
308  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
309  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
310  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".ce(~FP_clk_en),\n";
311  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".X(X),\n";
312  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".Y(Y),\n";
313  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".R(R)\n";
314  moduleDefinition += std::string(SET_INDENT) + ");\n";
315 
316  vjson["definition"] = moduleDefinition;
317  return vjson;
318 
319 }
320 
321 //Class destructor
323 {
324  //Empty Destructor
325 }
326 
327 
328 
329 
330 //Module Definition for Sqrt
331 FPSqrt::FPSqrt(std::string name, Location loc, unsigned size)
332  : Module(name, loc, size)
333 {
334  adds_synchronous_circuitry = true; //Sqrt has sequential elements
335 
336  //Create ports
337 
338  addPort("X", PORT_INPUT, "size", size + 2);
339  addPort("R", PORT_OUTPUT, "size", size + 2);
340  addPort("FP_clk_en", PORT_INPUT, 1);
341 }
342 
343 //Virtual function that override Module::GenericName. Returns generic name for the Sqrt
344 std::string FPSqrt::GenericName()
345 {
346  return "FPSqrt";
347 }
348 
349 //Virtual function that overrides Module::CoreIRGetFunctionality. Generates functionality for the Sqrt
351 {
352  nlohmann::json vjson;
353 
354  //Create Header
355  vjson["prefix"] = "cgrame_";
356  vjson["parameters"] = {};
357  for (auto& parameter : parameterlist)
358  {
359  vjson["parameters"].push_back(parameter.first);
360  }
361  vjson["interface"] = {};
362  vjson["interface"].push_back("CGRA_Clock");
363  vjson["interface"].push_back("CGRA_Reset");
364  vjson["interface"].push_back("CGRA_Enable");
365 
366  for (auto& port : ports)
367  {
368  std::string portName = port.second->getName();
369  vjson["interface"].push_back(portName);
370  }
371 
372  //module definition
373  std::string moduleDefinition;
374  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Clock;\n";
375  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Reset;\n";
376  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Enable;\n";
377 
378  for (auto& port : ports)
379  {
380  port_type portType = port.second->pt;
381  std::string portTypeString = {};
382  if(portType == port_type::PORT_INPUT)
383  {
384  portTypeString = "input";
385  }
386  else if (portType == port_type::PORT_OUTPUT)
387  {
388  portTypeString = "output";
389  }
390  else if (portType == port_type::PORT_OUTPUT_REG)
391  {
392  portTypeString = "output reg";
393  }
394  else
395  {
396  portTypeString = "inout";
397  }
398  std::string portSizeString;
399  if (!(port.second->parameter).empty()) // Check if size is parameterized
400  {
401  std::string portParameterName = port.second->parameter;
402  portSizeString = "[" + portParameterName + "-1:0]";
403  }
404  else
405  {
406  portSizeString = "[" + std::to_string(port.second->size - 1) + ":0]";
407  }
408  std::string portName = port.second->getName();
409  std::string portDeclaration = portTypeString + " " + portSizeString + " " + portName + ";\n";
410  moduleDefinition += std::string(SET_INDENT) + portDeclaration;
411  }
412 
413  // Functionality
414  moduleDefinition += std::string(SET_INDENT) + "FPSqrt FPSqroot (\n";
415  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
416  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
417  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".ce(~FP_clk_en),\n";
418  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".X(X),\n";
419  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".R(R)\n";
420  moduleDefinition += std::string(SET_INDENT) + ");\n";
421 
422  vjson["definition"] = moduleDefinition;
423  return vjson;
424 
425 }
426 
427 //Class destructor
429 {
430  //Empty Destructor
431 }
432 
433 //Module Definition for Input
434 InputIEEE2FloPoCo::InputIEEE2FloPoCo(std::string name, Location loc, unsigned size)
435  : Module(name, loc, size)
436 {
437  adds_synchronous_circuitry = true; //Input has sequential elements
438 
439  //Create ports
440 
441  addPort("X", PORT_INPUT, "size_in", size);
442  addPort("R", PORT_OUTPUT, "size_out", size + 2);
443 }
444 
445 //Virtual function that override Module::GenericName. Returns generic name for the Input
447 {
448  return "FPInput";
449 }
450 
451 //Virtual function that overrides Module::CoreIRGetFunctionality. Generates functionality for the Input
453 {
454  nlohmann::json vjson;
455 
456  //Create Header
457  vjson["prefix"] = "cgrame_";
458  vjson["parameters"] = {};
459  for (auto& parameter : parameterlist)
460  {
461  vjson["parameters"].push_back(parameter.first);
462  }
463  vjson["interface"] = {};
464  vjson["interface"].push_back("CGRA_Clock");
465  vjson["interface"].push_back("CGRA_Reset");
466  vjson["interface"].push_back("CGRA_Enable");
467 
468  for (auto& port : ports)
469  {
470  std::string portName = port.second->getName();
471  vjson["interface"].push_back(portName);
472  }
473 
474  //module definition
475  std::string moduleDefinition;
476  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Clock;\n";
477  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Reset;\n";
478  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Enable;\n";
479  for (auto& port : ports)
480  {
481  port_type portType = port.second->pt;
482  std::string portTypeString = {};
483  if(portType == port_type::PORT_INPUT)
484  {
485  portTypeString = "input";
486  }
487  else if (portType == port_type::PORT_OUTPUT)
488  {
489  portTypeString = "output";
490  }
491  else if (portType == port_type::PORT_OUTPUT_REG)
492  {
493  portTypeString = "output reg";
494  }
495  else
496  {
497  portTypeString = "inout";
498  }
499  std::string portSizeString;
500  if (!(port.second->parameter).empty()) // Check if size is parameterized
501  {
502  std::string portParameterName = port.second->parameter;
503  portSizeString = "[" + portParameterName + "-1:0]";
504  }
505  else
506  {
507  portSizeString = "[" + std::to_string(port.second->size - 1) + ":0]";
508  }
509  std::string portName = port.second->getName();
510  std::string portDeclaration = portTypeString + " " + portSizeString + " " + portName + ";\n";
511  moduleDefinition += std::string(SET_INDENT) + portDeclaration;
512  }
513 
514  // Functionality
515  moduleDefinition += std::string(SET_INDENT) + "InputIEEE2FloPoCo FPInput (\n";
516  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
517  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
518  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".X(X),\n";
519  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".R(R)\n";
520  moduleDefinition += std::string(SET_INDENT) + ");\n";
521 
522  vjson["definition"] = moduleDefinition;
523  return vjson;
524 
525 }
526 
527 //Class destructor
529 {
530  //Empty Destructor
531 }
532 
533 //Module Definition for Output
534 OutputFloPoCo2IEEE::OutputFloPoCo2IEEE(std::string name, Location loc, unsigned size)
535  : Module(name, loc, size)
536 {
537  adds_synchronous_circuitry = true; //Output has sequential elements
538 
539  //Create ports
540  addPort("X", PORT_INPUT, "size_in", size + 2);
541  addPort("R", PORT_OUTPUT, "size_out", size);
542 }
543 
544 //Virtual function that override Module::GenericName. Returns generic name for the Output
546 {
547  return "FPOutput";
548 }
549 
550 //Virtual function that overrides Module::CoreIRGetFunctionality. Generates functionality for the Output
552 {
553  nlohmann::json vjson;
554 
555  //Create Header
556  vjson["prefix"] = "cgrame_";
557  vjson["parameters"] = {};
558  for (auto& parameter : parameterlist)
559  {
560  vjson["parameters"].push_back(parameter.first);
561  }
562  vjson["interface"] = {};
563  vjson["interface"].push_back("CGRA_Clock");
564  vjson["interface"].push_back("CGRA_Reset");
565  vjson["interface"].push_back("CGRA_Enable");
566 
567  for (auto& port : ports)
568  {
569  std::string portName = port.second->getName();
570  vjson["interface"].push_back(portName);
571  }
572 
573  //module definition
574  std::string moduleDefinition;
575  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Clock;\n";
576  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Reset;\n";
577  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Enable;\n";
578  for (auto& port : ports)
579  {
580  port_type portType = port.second->pt;
581  std::string portTypeString = {};
582  if(portType == port_type::PORT_INPUT)
583  {
584  portTypeString = "input";
585  }
586  else if (portType == port_type::PORT_OUTPUT)
587  {
588  portTypeString = "output";
589  }
590  else if (portType == port_type::PORT_OUTPUT_REG)
591  {
592  portTypeString = "output reg";
593  }
594  else
595  {
596  portTypeString = "inout";
597  }
598  std::string portSizeString;
599  if (!(port.second->parameter).empty()) // Check if size is parameterized
600  {
601  std::string portParameterName = port.second->parameter;
602  portSizeString = "[" + portParameterName + "-1:0]";
603  }
604  else
605  {
606  portSizeString = "[" + std::to_string(port.second->size - 1) + ":0]";
607  }
608  std::string portName = port.second->getName();
609  std::string portDeclaration = portTypeString + " " + portSizeString + " " + portName + ";\n";
610  moduleDefinition += std::string(SET_INDENT) + portDeclaration;
611  }
612 
613  // Functionality
614  moduleDefinition += std::string(SET_INDENT) + "OutputFloPoCo2IEEE FPOutput (\n";
615  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
616  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
617  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".X(X),\n";
618  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".R(R)\n";
619  moduleDefinition += std::string(SET_INDENT) + ");\n";
620 
621  vjson["definition"] = moduleDefinition;
622  return vjson;
623 
624 }
625 
626 //Class destructor
628 {
629  //Empty Destructor
630 }
631 
632 
633 const std::map<OpGraphOpCode, LLVMMode> OutputConvert2FP::all_modes =
634 {
635  {OpCode::INT2FP, {"op_fp2int", "int2fp", {"5"}, "int2fp_sel"}},
636 };
637 
638 
639 //Module Definition for FP2Fix
640 OutputConvert2FP::OutputConvert2FP(std::string name, Location loc, unsigned size, std::vector<OpGraphOpCode> supported_modes_)
641  : Module(name, loc, size), supported_modes(std::move(supported_modes_))
642 {
643  adds_synchronous_circuitry = true; //FP2Fix has sequential elements
644 
645  //Create ports
646  addPort("data_in", PORT_INPUT, "size", size);
647  addPort("data_out", PORT_OUTPUT, "size", size);
648  addPort("valid_upstream", PORT_INPUT, 1);
649  addPort("stop_downstream", PORT_INPUT, 1);
650  addPort("stop_upstream", PORT_OUTPUT_REG, 1);
651  addPort("valid_downstream", PORT_OUTPUT_REG, 1);
652 
653  node_relative_position.insert({"data_in", {0.5, 0}});
654  node_relative_position.insert({"int2fp", {0.5, 0.33}});
655  node_relative_position.insert({"data_out", {0.5, 0.67}});
656 }
657 
658 //Virtual function that override Module::GenericName. Returns generic name for the FP2Fix
660 {
661  return "OutputConvert2FP";
662 }
663 
664 //Virtual function that overrides Module::CoreIRGetFunctionality. Generates functionality for the FP2Fix
666 {
667  nlohmann::json vjson;
668 
669  //Create Header
670  vjson["prefix"] = "cgrame_";
671  vjson["parameters"] = {};
672  for (auto& parameter : parameterlist)
673  {
674  vjson["parameters"].push_back(parameter.first);
675  }
676  vjson["interface"] = {};
677  vjson["interface"].push_back("CGRA_Clock");
678  vjson["interface"].push_back("CGRA_Reset");
679  vjson["interface"].push_back("CGRA_Enable");
680 
681  for (auto& port : ports)
682  {
683  std::string portName = port.second->getName();
684  vjson["interface"].push_back(portName);
685  }
686 
687  //module definition
688  std::string moduleDefinition;
689  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Clock;\n";
690  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Reset;\n";
691  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Enable;\n";
692  for (auto& port : ports)
693  {
694  port_type portType = port.second->pt;
695  std::string portTypeString = {};
696  if(portType == port_type::PORT_INPUT)
697  {
698  portTypeString = "input";
699  }
700  else if (portType == port_type::PORT_OUTPUT)
701  {
702  portTypeString = "output";
703  }
704  else if (portType == port_type::PORT_OUTPUT_REG)
705  {
706  portTypeString = "output reg";
707  }
708  else
709  {
710  portTypeString = "inout";
711  }
712  std::string portSizeString;
713  if (!(port.second->parameter).empty()) // Check if size is parameterized
714  {
715  std::string portParameterName = port.second->parameter;
716  portSizeString = "[" + portParameterName + "-1:0]";
717  }
718  else
719  {
720  portSizeString = "[" + std::to_string(port.second->size - 1) + ":0]";
721  }
722  std::string portName = port.second->getName();
723  std::string portDeclaration = portTypeString + " " + portSizeString + " " + portName + ";\n";
724  moduleDefinition += std::string(SET_INDENT) + portDeclaration;
725  }
726 
727  // Functionality
728  moduleDefinition += std::string(SET_INDENT) + "wire [size+1:0] out_int2fp;\n";
729  moduleDefinition += std::string(SET_INDENT) + "reg [1:0] register;\n";
730  moduleDefinition += "\n";
731 
732  moduleDefinition += std::string(SET_INDENT) + "Fix2FP int2fp(\n";
733  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
734  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
735  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".ce(~stop_downstream),\n";
736  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".I(data_in),\n";
737  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".O(out_int2fp)\n";
738  moduleDefinition += std::string(SET_INDENT) + ");\n";
739 
740  moduleDefinition += std::string(SET_INDENT) + "OutputFloPoCo2IEEE IEEE2FP(\n";
741  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
742  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
743  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".X(out_int2fp),\n";
744  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".R(data_out)\n";
745  moduleDefinition += std::string(SET_INDENT) + ");\n";
746 
747  moduleDefinition += std::string(SET_INDENT) + "always@(posedge CGRA_Clock) begin\n";
748  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "if (CGRA_Reset) begin\n";
749  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "stop_upstream <= 0;\n";
750  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "register <= 0;\n";
751  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end\n";
752  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "else if (~stop_downstream) begin\n";
753  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "register <= {valid_upstream, register[1:1]};\n";
754  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end\n";
755  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "else if (stop_downstream) begin\n";
756  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "stop_upstream <= 1;\n";
757  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "register <= register;\n";
758  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end\n";
759  moduleDefinition += std::string(SET_INDENT) + "end\n";
760  moduleDefinition += "\n";
761  moduleDefinition += std::string(SET_INDENT) + "always@(posedge CGRA_Clock) begin\n";
762  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "if (CGRA_Reset) begin\n";
763  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "valid_downstream <= 0;\n";
764  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end else if (~register[0]) begin\n";
765  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "valid_downstream <= 0;\n";
766  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end else if (register[0]) begin\n";
767  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "valid_downstream <= 1;\n";
768  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end\n";
769  moduleDefinition += std::string(SET_INDENT) + "end\n";
770 
771  vjson["definition"] = moduleDefinition;
772  return vjson;
773 
774 }
775 
776 //Class destructor
778 {
779  //Empty Destructor
780 }
781 
783 {
784  MRRG* result_ptr = new MRRG(II);
785  auto& result = *result_ptr;
786 
787  for(unsigned i = 0; i < II; i+= II)
788  {
789  // create nodes
790  MRRG::NodeDescriptor datain_result = result.insert(MRRGNode::make_operand_pin(this, data_size, i, "data_in", {Operands::BINARY_LHS, Operands::BINARY_ANY})).first;
791 
792  MRRG::NodeDescriptor int2fp = result.insert(MRRGNode::make_function(this, data_size, i, "int2fp", 0, supported_modes)).first;
793 
794  MRRG::NodeDescriptor dataout = result.insert(MRRGNode::make_routing(this, data_size, i, "data_out")).first;
795 
796  result.link(datain_result, int2fp);
797  result.link(int2fp, dataout);
798 
799  }
800 
801  return result_ptr;
802 }
803 
804 
805 
806 
807 const std::map<OpGraphOpCode, LLVMMode> OutputConvert2Int::all_modes =
808 {
809  {OpCode::FP2INT, {"op_fp2int", "fp2int", {"1"}, "fp2int_sel"}},
810 };
811 
812 
813 //Module Definition for FP2Fix
814 OutputConvert2Int::OutputConvert2Int(std::string name, Location loc, unsigned size, std::vector<OpGraphOpCode> supported_modes_)
815  : Module(name, loc, size), supported_modes(std::move(supported_modes_))
816 {
817  adds_synchronous_circuitry = true; //FP2Fix has sequential elements
818 
819  //Create ports
820  addPort("data_in", PORT_INPUT, "size", size);
821  addPort("data_out", PORT_OUTPUT, "size", size);
822  addPort("valid_upstream", PORT_INPUT, 1);
823  addPort("stop_downstream", PORT_INPUT, 1);
824  addPort("stop_upstream", PORT_OUTPUT_REG, 1);
825  addPort("valid_downstream", PORT_OUTPUT_REG, 1);
826 
827  node_relative_position.insert({"data_in", {0.5, 0}});
828  node_relative_position.insert({"fp2int", {0.5, 0.33}});
829  node_relative_position.insert({"data_out", {0.5, 0.67}});
830 }
831 
832 //Virtual function that override Module::GenericName. Returns generic name for the FP2Fix
834 {
835  return "FPOutputConvert2Int";
836 }
837 
838 //Virtual function that overrides Module::CoreIRGetFunctionality. Generates functionality for the FP2Fix
840 {
841  nlohmann::json vjson;
842 
843  //Create Header
844  vjson["prefix"] = "cgrame_";
845  vjson["parameters"] = {};
846  for (auto& parameter : parameterlist)
847  {
848  vjson["parameters"].push_back(parameter.first);
849  }
850  vjson["interface"] = {};
851  vjson["interface"].push_back("CGRA_Clock");
852  vjson["interface"].push_back("CGRA_Reset");
853  vjson["interface"].push_back("CGRA_Enable");
854 
855  for (auto& port : ports)
856  {
857  std::string portName = port.second->getName();
858  vjson["interface"].push_back(portName);
859  }
860 
861  //module definition
862  std::string moduleDefinition;
863  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Clock;\n";
864  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Reset;\n";
865  moduleDefinition += std::string(SET_INDENT) + "input CGRA_Enable;\n";
866  for (auto& port : ports)
867  {
868  port_type portType = port.second->pt;
869  std::string portTypeString = {};
870  if(portType == port_type::PORT_INPUT)
871  {
872  portTypeString = "input";
873  }
874  else if (portType == port_type::PORT_OUTPUT)
875  {
876  portTypeString = "output";
877  }
878  else if (portType == port_type::PORT_OUTPUT_REG)
879  {
880  portTypeString = "output reg";
881  }
882  else
883  {
884  portTypeString = "inout";
885  }
886  std::string portSizeString;
887  if (!(port.second->parameter).empty()) // Check if size is parameterized
888  {
889  std::string portParameterName = port.second->parameter;
890  portSizeString = "[" + portParameterName + "-1:0]";
891  }
892  else
893  {
894  portSizeString = "[" + std::to_string(port.second->size - 1) + ":0]";
895  }
896  std::string portName = port.second->getName();
897  std::string portDeclaration = portTypeString + " " + portSizeString + " " + portName + ";\n";
898  moduleDefinition += std::string(SET_INDENT) + portDeclaration;
899  }
900 
901  // Functionality
902  moduleDefinition += std::string(SET_INDENT) + "wire [size+1:0] out_fp2int;\n";
903  moduleDefinition += std::string(SET_INDENT) + "reg [1:0] register;\n";
904  moduleDefinition += "\n";
905  moduleDefinition += std::string(SET_INDENT) + "InputIEEE2FloPoCo ieee2fp(\n";
906  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
907  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
908  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".X(data_in),\n";
909  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".R(out_fp2int)\n";
910  moduleDefinition += std::string(SET_INDENT) + ");\n";
911  moduleDefinition += "\n";
912  moduleDefinition += std::string(SET_INDENT) + "FP2Fix fp2int(\n";
913  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".clk(CGRA_Clock),\n";
914  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".rst(CGRA_Reset),\n";
915  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".ce(~stop_downstream),\n";
916  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".I(out_fp2int),\n";
917  moduleDefinition += std::string(SET_DOUBLE_INDENT) + ".O(data_out)\n";
918  moduleDefinition += std::string(SET_INDENT) + ");\n";
919 
920  moduleDefinition += std::string(SET_INDENT) + "always@(posedge CGRA_Clock) begin\n";
921  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "if (CGRA_Reset) begin\n";
922  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "stop_upstream <= 0;\n";
923  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "register <= 0;\n";
924  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end\n";
925  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "else if (~stop_downstream) begin\n";
926  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "register <= {valid_upstream, register[1:1]};\n";
927  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end\n";
928  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "else if (stop_downstream) begin\n";
929  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "register <= register;\n";
930  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "stop_upstream <= 1;\n";
931  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end\n";
932  moduleDefinition += std::string(SET_INDENT) + "end\n";
933  moduleDefinition += "\n";
934  moduleDefinition += std::string(SET_INDENT) + "always@(posedge CGRA_Clock) begin\n";
935  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "if (CGRA_Reset) begin\n";
936  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "valid_downstream <= 0;\n";
937  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end else if (~register[0]) begin\n";
938  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "valid_downstream <= 0;\n";
939  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end else if (register[0]) begin\n";
940  moduleDefinition += std::string(SET_TRIPLE_INDENT) + "valid_downstream <= 1;\n";
941  moduleDefinition += std::string(SET_DOUBLE_INDENT) + "end\n";
942  moduleDefinition += std::string(SET_INDENT) + "end\n";
943 
944  vjson["definition"] = moduleDefinition;
945  return vjson;
946 
947 }
948 
949 //Class destructor
951 {
952  //Empty Destructor
953 }
954 
956 {
957  MRRG* result_ptr = new MRRG(II);
958  auto& result = *result_ptr;
959 
960  for(unsigned i = 0; i < II; i+= II)
961  {
962  // create nodes
963  MRRG::NodeDescriptor datain_result = result.insert(MRRGNode::make_operand_pin(this, data_size, i, "data_in", {Operands::BINARY_LHS, Operands::BINARY_ANY})).first;
964 
965  MRRG::NodeDescriptor fp2int = result.insert(MRRGNode::make_function(this, data_size, i, "fp2int", 0, supported_modes)).first;
966 
967  MRRG::NodeDescriptor dataout = result.insert(MRRGNode::make_routing(this, data_size, i, "data_out")).first;
968 
969  result.link(datain_result, fp2int);
970  result.link(fp2int, dataout);
971 
972  }
973 
974  return result_ptr;
975 }
976 
977 const std::map<OpGraphOpCode, LLVMMode> FPUnit::all_modes =
978 {
979  {OpCode::FADD, {"op_add", "add", {"8"}, "add_sel"}}, // janders was 7 from Adham originally
980  {OpCode::FMUL, {"op_multiply", "multiply", {"0"}, "mul_sel"}},
981  {OpCode::FDIV, {"op_divide", "divide", {"20"}, "div_sel"}},
982  {OpCode::SQRT, {"op_sqrt", "sqrt", {"17"}, "sqrt_sel"}},
983 };
984 
985 std::string FPUnit::GenericName()
986 {
987  std::string NameToReturn = "fpunit_" + std::to_string(getSize()) + "b"; // Base name is "func"
988  for (unsigned i = 0; i < supported_modes.size(); i++)
989  {
990  // Add a "_(module_name_inside)" to the name
991  NameToReturn.append("_");
992  NameToReturn.append(all_modes.at(supported_modes.at(i)).OpName);
993  }
994  return NameToReturn;
995 }
996 
997 FPUnit::FPUnit(std::string name, Location loc, std::vector<OpGraphOpCode> supported_modes_, unsigned size, int II, int latency)
998  : Module(name, loc, size), pipeline_mode(II, latency), supported_modes(std::move(supported_modes_))
999 {
1000  if (II != 1) {
1001  std::cout << II << '\n';
1002  make_and_throw<cgrame_error>([&](auto&& s) { s << "dont support an II other than 1 (given II=" << II << ')'; });
1003  }
1004 
1005  parameterlist["latency"] = latency;
1006 
1007  // Create the ports
1008  addPort("in_a", PORT_INPUT, "size", size);
1009  addPort("in_b", PORT_INPUT, "size", size);
1010  addPort("out", PORT_OUTPUT, "size", size);
1011 
1012  if (supported_modes.size() > 1) // If there is more than one mode, we need to add a select line, we will also have a mux, so make port "out" a reg
1013  {
1014  addPort("opcode", PORT_INPUT, ceil(log2(supported_modes.size())));
1015  }
1016  addPort("FP_clk_en", PORT_INPUT, 1);
1017 
1018  addSubModule(new InputIEEE2FloPoCo("fpinput1", loc, size), 0.5, 0, 0.1, 0.5);
1019  addSubModule(new InputIEEE2FloPoCo("fpinput2", loc, size), 1.0, 0, 0.1, 0.5);
1020 
1021  for (unsigned i = 0; i < supported_modes.size(); i++)
1022  {
1023  if (all_modes.at(supported_modes.at(i)).ModuleName == "op_add"){
1024  addSubModule(new FPAdd("fpadd", loc, size), 0, 0.5, 0.1, 0.5);
1025  }
1026  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_multiply"){
1027  addSubModule(new FPMult("fpmult", loc, size), 0.5, 0.5, 0.1, 0.5);
1028  }
1029  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_divide"){
1030  addSubModule(new FPDiv("fpdiv", loc, size), 1.0, 0.5, 0.1, 0.5);
1031  }
1032  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_sqrt"){
1033  addSubModule(new FPSqrt("fpsqroot", loc, size), 1.5, 0.5, 0.1, 0.5);
1034  }
1035  }
1036 
1037  if (supported_modes.size() > 1)
1038  {
1039  addSubModule(new Multiplexer("result_mux", loc, supported_modes.size(), size + 2), 0.75, 1.0, 0.1, 0.5);
1040  }
1041  addSubModule(new OutputFloPoCo2IEEE("fpoutput", loc, size), 0.75, 1.5, 0.1, 0.5);
1042 
1043  addConnection("this.in_a", "fpinput1.X");
1044  addConnection("this.in_b", "fpinput2.X");
1045 
1046  for (unsigned i = 0; i < supported_modes.size(); i++)
1047  {
1048  if (all_modes.at(supported_modes.at(i)).ModuleName == "op_add"){
1049  addConnection("fpinput1.R", "fpadd.X");
1050  addConnection("fpinput2.R", "fpadd.Y");
1051  addConnection("this.FP_clk_en", "fpadd.FP_clk_en");
1052  }
1053  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_multiply"){
1054  addConnection("fpinput1.R", "fpmult.X");
1055  addConnection("fpinput2.R", "fpmult.Y");
1056  addConnection("this.FP_clk_en", "fpmult.FP_clk_en");
1057  }
1058  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_divide"){
1059  addConnection("fpinput1.R", "fpdiv.X");
1060  addConnection("fpinput2.R", "fpdiv.Y");
1061  addConnection("this.FP_clk_en", "fpdiv.FP_clk_en");
1062  }
1063  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_sqrt"){
1064  addConnection("fpinput1.R", "fpsqroot.X");
1065  addConnection("this.FP_clk_en", "fpsqroot.FP_clk_en");
1066  }
1067  }
1068  if (supported_modes.size() > 1) {
1069  for (unsigned i = 0; i < supported_modes.size(); i++) {
1070  if (all_modes.at(supported_modes.at(i)).ModuleName == "op_add"){
1071  addConnection("fpadd.R", "result_mux.in" + std::to_string(i));
1072  }
1073  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_multiply"){
1074  addConnection("fpmult.R", "result_mux.in" + std::to_string(i));
1075  }
1076  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_divide"){
1077  addConnection("fpdiv.R", "result_mux.in" + std::to_string(i));
1078  }
1079  else if (all_modes.at(supported_modes.at(i)).ModuleName == "op_sqrt"){
1080  addConnection("fpsqroot.R", "result_mux.in" + std::to_string(i));
1081  }
1082  }
1083  }
1084  else if (supported_modes.size() == 1)
1085  {
1086  if (all_modes.at(supported_modes.at(0)).ModuleName == "op_add"){
1087  addConnection("fpadd.R", "fpoutput.X");
1088  }
1089  else if (all_modes.at(supported_modes.at(0)).ModuleName == "op_multiply"){
1090  addConnection("fpmult.R", "fpoutput.X");
1091  }
1092  else if (all_modes.at(supported_modes.at(0)).ModuleName == "op_divide"){
1093  addConnection("fpdiv.R", "fpoutput.X");
1094  }
1095  else if (all_modes.at(supported_modes.at(0)).ModuleName == "op_sqrt"){
1096  addConnection("fpsqroot.R", "fpoutput.X");
1097  }
1098  }
1099  if (supported_modes.size() > 1)
1100  {
1101  addConnection("result_mux.select", "this.opcode");
1102  addConnection("result_mux.out", "fpoutput.X");
1103  }
1104  addConnection("fpoutput.R", "this.out");
1105 
1106  node_relative_position.insert({"in_a", {0.33, 0}});
1107  node_relative_position.insert({"in_b", {0.67, 0}});
1108  node_relative_position.insert({"fpunit", {0.5, 0.33}});
1109  node_relative_position.insert({"out", {0.5, 0.67}});
1110 }
1111 
1113  const MRRG& mrrg, const OpGraph & og,
1114  const Mapping& map,
1115  const ConfigCell& ccell,
1116  const MRRGNodesFromOpNode& mrrg_nodes_from_op_node,
1117  const MRRGNodesFromValNode& mrrg_nodes_from_val_node
1118 ) const {
1119  (void)ccell;
1120  (void)mrrg_nodes_from_val_node;
1121  const auto bits_needed = std::lround(ceil(log2(supported_modes.size())));
1122 
1123  BitConfig bitConfig(mrrg.initiationInterval());
1124 
1125  // Organize nodes mapping by cycle
1126  std::vector<MRRGNodesFromOpNode> opNodesByCycle(mrrg.initiationInterval());
1127  for (const auto& op_and_mrrg_nodes : mrrg_nodes_from_op_node) {
1128  for (const auto& mrrg_node : op_and_mrrg_nodes.second) {
1129  opNodesByCycle[mrrg_node->cycle][op_and_mrrg_nodes.first].insert(mrrg_node);
1130  }
1131  }
1132 
1133  int cycle = 0;
1134  for (auto & op_and_mrrg_nodes : opNodesByCycle) {
1135  if (op_and_mrrg_nodes.empty()) {
1136  bitConfig.add({ (size_t)bits_needed, BitSetting::DONT_CARE_PREFER_LOW }, cycle);
1137  } else if (op_and_mrrg_nodes.size() == 1) {
1138  const auto find_result = std::find(begin(supported_modes), end(supported_modes), begin(op_and_mrrg_nodes)->first->opcode);
1139  if (find_result == end(supported_modes)) {
1140  throw cgrame_error("couldn't find op in supported modes list");
1141  } else {
1142  bitConfig.add( bitsettings_from_int(std::distance(begin(supported_modes), find_result), bits_needed), cycle);
1143  }
1144 
1145  } else {
1146  throw cgrame_error("expect either 0 or 1 op nodes");
1147  }
1148  ++cycle;
1149  }
1150 
1151  return bitConfig;
1152 }
1153 
1155 {
1156 }
1157 
1158 MRRG* FPUnit::createMRRG(unsigned II = 1)
1159 {
1160  MRRG* result_ptr = new MRRG(II);
1161  auto& result = *result_ptr;
1162 
1163  for(unsigned i = 0; i < II; i+= getII())
1164  {
1165  // create nodes
1168  MRRG::NodeDescriptor fpunit = result.insert(MRRGNode::make_function(this, data_size, i, "fpunit", 0, supported_modes)).first;
1169  MRRG::NodeDescriptor out = result.insert(MRRGNode::make_routing(this, data_size, i, "out")).first;
1170 
1171  result.link(in_a, fpunit);
1172  result.link(in_b, fpunit);
1173  (void)out;
1174  }
1175 
1176  for(unsigned i = 0; i < II; i+= getII())
1177  {
1178  MRRG::NodeDescriptor fpunit = result.getNode(i, "fpunit");
1179  MRRG::NodeDescriptor out_next = result.getNode(MOD_II(i + getLatency()), "out");
1180 
1181  result.link(fpunit, out_next);
1182  }
1183 
1184  return result_ptr;
1185 }
1186 
FPDiv::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:237
BitConfig
Definition: BitSetting.h:58
OutputConvert2Int::all_modes
static const std::map< OpGraphOpCode, LLVMMode > all_modes
Definition: ModuleFPUnit.h:68
ConfigCell
Definition: Module.h:825
OutputFloPoCo2IEEE::CoreIRGenFunctionality
virtual nlohmann::json CoreIRGenFunctionality() override
Definition: ModuleFPUnit.cpp:551
Multiplexer
Zero-cycle latency multiplexer.
Definition: Module.h:592
SET_TRIPLE_INDENT
const char *const SET_TRIPLE_INDENT
Definition: Module.h:39
MRRG
Definition: MRRG.h:216
PORT_OUTPUT_REG
@ PORT_OUTPUT_REG
Definition: Module.h:65
MRRGNodesFromOpNode
std::map< OpGraphOp *, std::set< MRRG::NodeDescriptor > > MRRGNodesFromOpNode
Definition: Module.h:146
Location
Definition: Module.h:156
Module::data_size
unsigned data_size
Definition: Module.h:338
Operands::BINARY_LHS
static constexpr auto & BINARY_LHS
Definition: OpGraph.h:89
OutputConvert2FP::supported_modes
std::vector< OpGraphOpCode > supported_modes
Definition: ModuleFPUnit.h:87
Module::addConnection
void addConnection(std::string src, std::string dst, bool isInMRRG=true)
Definition: Module.cpp:1241
OutputFloPoCo2IEEE::OutputFloPoCo2IEEE
OutputFloPoCo2IEEE(std::string name, Location, unsigned size)
Definition: ModuleFPUnit.cpp:534
begin
auto begin(const SingleItemImmutableSet< VertexID > &siis)
Definition: Collections.h:137
Module.h
FPUnit::getII
int getII() const
Definition: ModuleFPUnit.h:105
Module::adds_synchronous_circuitry
bool adds_synchronous_circuitry
Definition: Module.h:370
OutputConvert2FP::all_modes
static const std::map< OpGraphOpCode, LLVMMode > all_modes
Definition: ModuleFPUnit.h:83
FPDiv::CoreIRGenFunctionality
virtual nlohmann::json CoreIRGenFunctionality() override
Definition: ModuleFPUnit.cpp:243
FPUnit::~FPUnit
virtual ~FPUnit()
Definition: ModuleFPUnit.cpp:1154
Module::parameterlist
std::map< std::string, unsigned > parameterlist
Definition: Module.h:224
FPAdd::FPAdd
FPAdd(std::string name, Location, unsigned size)
Definition: ModuleFPUnit.cpp:6
BitSetting::DONT_CARE_PREFER_LOW
@ DONT_CARE_PREFER_LOW
BitConfig::add
void add(std::vector< BitSetting > bitsetting, int cycle)
Definition: BitSetting.h:63
FPAdd::CoreIRGenFunctionality
virtual nlohmann::json CoreIRGenFunctionality() override
Definition: ModuleFPUnit.cpp:27
Module::addPort
void addPort(std::string portname, port_type pt, unsigned size)
Definition: Module.cpp:1354
FPMult
Definition: ModuleFPUnit.h:15
Module::node_relative_position
std::map< std::string, VisualPositionPoint > node_relative_position
Definition: Module.h:360
InputIEEE2FloPoCo::InputIEEE2FloPoCo
InputIEEE2FloPoCo(std::string name, Location, unsigned size)
Definition: ModuleFPUnit.cpp:434
FPSqrt::~FPSqrt
virtual ~FPSqrt()
Definition: ModuleFPUnit.cpp:428
OutputConvert2FP::~OutputConvert2FP
virtual ~OutputConvert2FP()
Definition: ModuleFPUnit.cpp:777
OpCode::INT2FP
@ INT2FP
FPMult::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:129
FPUnit::all_modes
static const std::map< OpGraphOpCode, LLVMMode > all_modes
Definition: ModuleFPUnit.h:108
InputIEEE2FloPoCo
Definition: ModuleFPUnit.h:42
OutputConvert2Int::size
unsigned size
Definition: ModuleFPUnit.h:71
ModuleFPUnit.h
to_string
const std::string & to_string(const OpGraphOpCode &opcode)
Definition: OpGraph.cpp:111
OutputConvert2FP::CoreIRGenFunctionality
virtual nlohmann::json CoreIRGenFunctionality() override
Definition: ModuleFPUnit.cpp:665
MRRGNodesFromValNode
std::map< OpGraphVal *, std::set< MRRG::NodeDescriptor > > MRRGNodesFromValNode
Definition: Module.h:147
FPDiv::FPDiv
FPDiv(std::string name, Location, unsigned size)
Definition: ModuleFPUnit.cpp:223
OutputConvert2Int::createMRRG
MRRG * createMRRG(unsigned II) override
Definition: ModuleFPUnit.cpp:955
InputIEEE2FloPoCo::~InputIEEE2FloPoCo
virtual ~InputIEEE2FloPoCo()
Definition: ModuleFPUnit.cpp:528
Mapping
Definition: Mapping.h:31
MOD_II
#define MOD_II(x)
Definition: Module.h:32
InputIEEE2FloPoCo::CoreIRGenFunctionality
virtual nlohmann::json CoreIRGenFunctionality() override
Definition: ModuleFPUnit.cpp:452
FPUnit::createMRRG
virtual MRRG * createMRRG(unsigned II) override
Definition: ModuleFPUnit.cpp:1158
FPSqrt::FPSqrt
FPSqrt(std::string name, Location, unsigned size)
Definition: ModuleFPUnit.cpp:331
FPMult::FPMult
FPMult(std::string name, Location, unsigned size)
Definition: ModuleFPUnit.cpp:115
FPAdd::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:21
Operands::BINARY_RHS
static constexpr auto & BINARY_RHS
Definition: OpGraph.h:90
OutputFloPoCo2IEEE
Definition: ModuleFPUnit.h:51
MRRGNode::make_operand_pin
static MRRGNode make_operand_pin(Module *parent, int bitwidth, int cycle, STR &&name, SupportedOpTags operand_tags, int latency=0, int max_cap=1)
Definition: MRRG.h:164
FPUnit::getLatency
int getLatency() const
Definition: ModuleFPUnit.h:106
MRRGNode::make_function
static MRRGNode make_function(Module *parent, int bitwidth, int cycle, STR &&name, int latency, SupportedOps supported_ops, int max_cap=1, bool is_const_unit=false)
Definition: MRRG.h:191
FPDiv
Definition: ModuleFPUnit.h:24
OutputConvert2Int::~OutputConvert2Int
virtual ~OutputConvert2Int()
Definition: ModuleFPUnit.cpp:950
SET_INDENT
const char *const SET_INDENT
Definition: Module.h:37
Module
Definition: Module.h:163
FPMult::CoreIRGenFunctionality
virtual nlohmann::json CoreIRGenFunctionality() override
Definition: ModuleFPUnit.cpp:135
PORT_INPUT
@ PORT_INPUT
Definition: Module.h:63
OpCode::FMUL
@ FMUL
OutputConvert2FP::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:659
OpCode::FDIV
@ FDIV
OutputFloPoCo2IEEE::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:545
OutputConvert2Int::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:833
OutputConvert2Int::OutputConvert2Int
OutputConvert2Int(std::string name, Location, unsigned size, std::vector< OpGraphOpCode > supported_modes)
Definition: ModuleFPUnit.cpp:814
OutputConvert2Int::supported_modes
std::vector< OpGraphOpCode > supported_modes
Definition: ModuleFPUnit.h:72
end
auto end(const SingleItemImmutableSet< VertexID > &siis)
Definition: Collections.h:138
OpCode::SQRT
@ SQRT
FPAdd::~FPAdd
virtual ~FPAdd()
Definition: ModuleFPUnit.cpp:106
FPUnit::FPUnit
FPUnit(std::string name, Location, std::vector< OpGraphOpCode > supported_modes, unsigned size, int II, int latency)
Definition: ModuleFPUnit.cpp:997
MRRGNode
Definition: MRRG.h:60
Module::getSize
int getSize() const
Definition: Module.h:246
FPMult::~FPMult
virtual ~FPMult()
Definition: ModuleFPUnit.cpp:214
FPSqrt
Definition: ModuleFPUnit.h:33
Module::addSubModule
void addSubModule(Module *m)
Definition: Module.cpp:1124
OutputConvert2FP::createMRRG
MRRG * createMRRG(unsigned II) override
Definition: ModuleFPUnit.cpp:782
SET_DOUBLE_INDENT
const char *const SET_DOUBLE_INDENT
Definition: Module.h:38
Module::ports
std::map< std::string, Port * > ports
Definition: Module.h:225
FPAdd
Definition: ModuleFPUnit.h:6
Module::loc
Location loc
Definition: Module.h:239
MRRG::initiationInterval
int initiationInterval() const
Definition: MRRG.h:346
OutputConvert2FP::OutputConvert2FP
OutputConvert2FP(std::string name, Location, unsigned size, std::vector< OpGraphOpCode > supported_modes)
Definition: ModuleFPUnit.cpp:640
FPDiv::~FPDiv
virtual ~FPDiv()
Definition: ModuleFPUnit.cpp:322
FPUnit::supported_modes
std::vector< OpGraphOpCode > supported_modes
Definition: ModuleFPUnit.h:111
MRRGNode::make_routing
static MRRGNode make_routing(Module *parent, int bitwidth, int cycle, STR &&name, int latency=0, int max_cap=1)
Definition: MRRG.h:151
Operands::BINARY_ANY
static constexpr auto & BINARY_ANY
Definition: OpGraph.h:91
port_type
port_type
Definition: Module.h:61
FPUnit::getBitConfig
virtual BitConfig getBitConfig(const MRRG &mrrg, const OpGraph &og, const Mapping &map, const ConfigCell &ccell, const MRRGNodesFromOpNode &mrrg_nodes_from_op_node, const MRRGNodesFromValNode &mrrg_nodes_from_val_node) const override
Definition: ModuleFPUnit.cpp:1112
OutputConvert2Int::CoreIRGenFunctionality
virtual nlohmann::json CoreIRGenFunctionality() override
Definition: ModuleFPUnit.cpp:839
FPSqrt::CoreIRGenFunctionality
virtual nlohmann::json CoreIRGenFunctionality() override
Definition: ModuleFPUnit.cpp:350
OutputConvert2FP::size
unsigned size
Definition: ModuleFPUnit.h:86
OpCode::FP2INT
@ FP2INT
OpCode::FADD
@ FADD
OpGraph
Definition: OpGraph.h:215
FPSqrt::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:344
FPUnit::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:985
cgrame_error
Definition: Exception.h:20
OutputFloPoCo2IEEE::~OutputFloPoCo2IEEE
virtual ~OutputFloPoCo2IEEE()
Definition: ModuleFPUnit.cpp:627
InputIEEE2FloPoCo::GenericName
virtual std::string GenericName() override
Definition: ModuleFPUnit.cpp:446
PORT_OUTPUT
@ PORT_OUTPUT
Definition: Module.h:64
bitsettings_from_int
std::vector< BitSetting > bitsettings_from_int(const INTEGRAL &value, int num_bits)
Definition: BitSetting.h:52