61 _testbench_generation_memory_type, _parameters),
62 indented_output_stream(_indented_output_stream)
69 size_t size = str.size();
70 if(size % 8 != 0 || size == 8)
74 for(
size_t i = 0; i < size; ++i)
87 "-->Writing C code to write " + content +
" in binary form to initialize memory");
99 base_type =
status.back().first;
103 case enumeral_type_K:
107 case function_type_K:
112 case qual_union_type_K:
113 case reference_type_K:
115 case template_type_parm_K:
116 case typename_type_K:
117 case type_argument_pack_K:
118 case type_pack_expansion_K:
120 THROW_ERROR(
"Unexpected type in initializing parameter/variable: " +
123 case aggr_init_expr_K:
127 case case_label_expr_K:
130 case identifier_node_K:
132 case statement_list_K:
134 case target_mem_ref_K:
135 case target_mem_ref461_K:
154 std::string binary_value =
"";
155 unsigned long long size = 0;
177 case enumeral_type_K:
181 case function_type_K:
186 case qual_union_type_K:
187 case reference_type_K:
189 case template_type_parm_K:
190 case typename_type_K:
191 case type_argument_pack_K:
192 case type_pack_expansion_K:
194 THROW_ERROR(
"Unexpected type in initializing parameter/variable: " +
197 case aggr_init_expr_K:
201 case case_label_expr_K:
204 case identifier_node_K:
206 case statement_list_K:
208 case target_mem_ref_K:
209 case target_mem_ref461_K:
225 "Not supported node: " +
GET_CONST_NODE(base_type)->get_kind_text());
236 " value: " + content +
"\\n\");\n");
244 for(
size_t bit = 0; bit < binary_value.size(); bit += 8)
246 memory_init_file <<
"m" + binary_value.substr(binary_value.size() - 8 - bit, 8) +
"\n";
253 " value: " + content +
"\\n\");\n");
257 "__testbench_index < " +
258 STR(binary_value.size() / 8) +
"; " +
259 "++__testbench_index)\n" 260 " fprintf(__bambu_testbench_fp, \"m00000000\\n\");\n");
264 for(
size_t bit = 0; bit < binary_value.size(); bit += 8)
267 binary_value.substr(binary_value.size() - 8 - bit, 8) +
"\\n\");\n");
278 " value: " + content +
"\\n\");\n");
279 for(
size_t bit = 0; bit < binary_value.size(); bit += 8)
282 binary_value.substr(binary_value.size() - 8 - bit, 8) +
"\\n\");\n");
292 "<--Added code to write " + content +
" (" +
STR(binary_value.size() / 8) +
293 " bytes) in binary form to initialize memory");
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
int debug_level
The debug level.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
File containing functions and utilities to support the printing of debug messagges.
const tree_nodeConstRef function_parameter
The variable/parameter being printed.
#define CASE_BINARY_EXPRESSION
This macro collects all case labels for binary_expr objects.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
std::vector< std::pair< const tree_nodeConstRef, size_t > > status
The stack representing the current status of the parser; the content is the last dumped element...
#define CASE_DECL_NODES
NOTE that cast_expr is a unary expression but it could not be included in the CASE_UNARY_EXPRESSION b...
Functor used to write initialization of the memory writer.
Generate HDL testbench for the top-level kernel testing.
Class to print indented code.
std::string ConvertInBinary(const std::string &C_value, unsigned long long precision, const bool real_type, bool unsigned_type)
Convert a string storing a number in decimal format into a string in binary format.
std::string file_variable
variable used to write in a variable
unsigned long int written_bytes
The number of bytes currently written.
void FinalizeFileInit() override
Copy and close the file.
#define STR(s)
Macro which performs a lexical_cast to a string.
std::ofstream memory_init_file
temporary file used to store the formatted memory values
static bool IsUnsignedIntegerType(const tree_nodeConstRef &type)
Return true if the treenode is of unsigned integer type.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
bool write_in_a_file
the data will be written in a data copied by the caller
#define CASE_QUATERNARY_EXPRESSION
This macro collects all case labels for quaternary_expr objects.
#define CASE_UNARY_EXPRESSION
This macro collects all case labels for unary_expr objects.
void Append(const std::string &str)
Append a string to the output.
const BehavioralHelperConstRef behavioral_helper
The behavioral helper.
#define GET_CONST_NODE(t)
static bool is_all_8zeros(const std::string &str)
Classes specification of the tree_node data structures.
This file collects some utility functions and macros.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
std::string PrintVariable(unsigned int var) const
Print the name of the variable associated to the index.
MemoryInitializationCWriter(const IndentedOutputStreamRef indented_output_stream, const tree_managerConstRef TM, const BehavioralHelperConstRef behavioral_helper, const unsigned long int reserved_mem_bytes, const tree_nodeConstRef function_parameter, const TestbenchGeneration_MemoryType testbench_generation_memory_type, const ParameterConstRef parameters)
Constructor.
void ActivateFileInit(const std::string &filename) override
In case the test_v has a size over a threshold write the tests on a file.
This file collects some utility functions.
#define CASE_CST_NODES
This macro collects all case labels for cast nodes.
Class specification of the tree_reindex support class.
#define CASE_FAKE_NODES
This macro collects all case labels for fake or empty nodes.
const TestbenchGeneration_MemoryType testbench_generation_memory_type
The type of initialization being written.
#define THROW_ERROR_CODE(code, str_expr)
helper function used to throw an error with a code error
this class is used to manage the command-line or XML options.
#define CASE_CPP_NODES
This macro collects all case labels for cpp nodes.
#define CASE_GIMPLE_NODES
This macro collects all cases labels for gimple nodes.
Functor used to write c code which writes initialization of the memory.
const IndentedOutputStreamRef indented_output_stream
The stream where C code has to be written.
TestbenchGeneration_MemoryType
Enum class used to specify which type of content has to be printed for memory initialization.
#define CASE_TERNARY_EXPRESSION
This macro collects all case labels for ternary_expr objects.
Class specification of the manager of the tree structures extracted from the raw file.
void Process(const std::string &content) override
Process an element.
#define CASE_PRAGMA_NODES
This macro collects all case labels for pragma objects.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...