PandA-2024.02
Read_validModuleGenerator.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  */
48 
49 #include "behavioral_helper.hpp"
50 #include "call_graph_manager.hpp"
51 #include "constant_strings.hpp"
52 #include "function_behavior.hpp"
53 #include "hls_manager.hpp"
54 #include "language_writer.hpp"
55 #include "structural_objects.hpp"
56 
57 enum in_port
58 {
59  i_clock = 0,
66 };
67 
69 {
70  o_done = 0,
73 };
74 
76 {
77 }
78 
79 void Read_validModuleGenerator::InternalExec(std::ostream& out, structural_objectRef mod, unsigned int function_id,
80  vertex /* op_v */, const HDLWriter_Language /* language */,
81  const std::vector<ModuleGenerator::parameter>& /* _p */,
82  const std::vector<ModuleGenerator::parameter>& _ports_in,
83  const std::vector<ModuleGenerator::parameter>& _ports_out,
84  const std::vector<ModuleGenerator::parameter>& /* _ports_inout */)
85 {
86  THROW_ASSERT(_ports_in.size() >= i_last, "");
87  THROW_ASSERT(_ports_out.size() >= o_last, "");
88 
89  const auto bundle_name = mod->get_id().substr(0, mod->get_id().find(STR_CST_interface_parameter_keyword));
90  const auto top_fid = HLSMgr->CGetCallGraphManager()->GetRootFunction(function_id);
91  const auto top_fname = HLSMgr->CGetFunctionBehavior(top_fid)->CGetBehavioralHelper()->GetMangledFunctionName();
92  const auto& iface_attrs = HLSMgr->module_arch->GetArchitecture(top_fname)->ifaces.at(bundle_name);
93 
94  if(iface_attrs.find(FunctionArchitecture::iface_register) != iface_attrs.end())
95  {
96  THROW_ERROR("Registered valid interface not yet implemented.");
97  }
98  out << "parameter ASYNC=0;\n\n"; // TODO: this should be controlled by InterfaceInfer step
99  out << "reg started, started0;\n\n";
100 
101  out << R"(generate
102 if(ASYNC)
103 begin
104  reg validated, validated0;
105  reg [)"
106  << (_ports_in[i_in3].type_size - 1) << R"(:0] stored;
107 
108  always @(posedge clock 1RESET_EDGE)
109  begin
110  if (1RESET_VALUE)
111  begin
112  started <= 0;
113  validated <= 0;
114  stored <= 0;
115  end
116  else
117  begin
118  started <= started0;
119  validated <= validated0;
120  stored <= )"
121  << _ports_in[i_in3].name << R"(;
122  end
123  end
124 
125  always @(*)
126  begin
127  started0 = (started | )"
128  << _ports_in[i_start].name << R"() & ~(validated | )" << _ports_in[i_vld].name << R"();
129  validated0 = (validated | )"
130  << _ports_in[i_vld].name << R"() & ~(started | )" << _ports_in[i_start].name << R"();
131  end
132 
133  assign )"
134  << _ports_out[o_out1].name << " = " << _ports_in[i_vld].name << " ? " << _ports_in[i_in3].name << R"( : stored;
135  assign )"
136  << _ports_out[o_done].name << " = ((started | " << _ports_in[i_start].name << ") & " << _ports_in[i_vld].name
137  << ") | (validated & " << _ports_in[i_start].name << R"();
138 end
139 else
140 begin
141  always @(posedge clock 1RESET_EDGE)
142  begin
143  if (1RESET_VALUE)
144  begin
145  started <= 0;
146  end
147  else
148  begin
149  started <= started0;
150  end
151  end
152 
153  always @(*)
154  begin
155  started0 = (started | )"
156  << _ports_in[i_start].name << R"() & ~)" << _ports_in[i_vld].name << R"(;
157  end
158 
159  assign )"
160  << _ports_out[o_out1].name << " = " << _ports_in[i_in3].name << R"(;
161  assign )"
162  << _ports_out[o_done].name << " = (started | " << _ports_in[i_start].name << ") & " << _ports_in[i_vld].name
163  << R"(;
164 end
165 endgenerate)";
166 }
Data structure representing the entire HLS information.
#define STR_CST_interface_parameter_keyword
interface_parameter_keyword
const std::string & get_id() const
Return the identifier associated with the structural_object.
HDLWriter_Language
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
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
Read_validModuleGenerator(const HLS_managerRef &HLSMgr)
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
This class describes all classes used to represent a structural object.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
constant strings
Wrapper to call graph.
A brief description of the C++ Header File.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

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