PandA-2024.02
vcd_utility.hpp
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) 2015-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  */
37 #ifndef VCD_UTILITY_HPP
38 #define VCD_UTILITY_HPP
39 
40 // Superclass include
41 #include "hls_function_step.hpp"
42 
43 // include from parser/vcd/
44 #include "DiscrepancyOpInfo.hpp"
45 #include "vcd_parser.hpp"
46 
47 // STL include
48 #include "custom_map.hpp"
49 #include "custom_set.hpp"
50 #include <list>
51 #include <string>
52 
53 #include "refcount.hpp"
54 
59 
60 struct vcd_trace_head;
61 
63 {
64  unsigned long long op_start_time;
65  unsigned long long op_end_time;
67  unsigned int op_id;
68  unsigned int ssa_id;
69  unsigned int fun_id;
70  std::string op_start_state;
71  std::string fu_name;
72  std::string stmt_string;
73  std::string c_val;
74  std::string vcd_val;
75  std::string fullsigname;
76  uint64_t context;
77  unsigned int bitsize;
78  unsigned int el_idx;
79  // these are valid only if the variable is a vector or a complex
80  std::string::size_type first_c_bit;
81  std::string::size_type c_size;
87  unsigned int base_index;
88 
89  DiscrepancyLog(const HLS_managerConstRef HLSMgr, const vcd_trace_head& t, const uint64_t c_context,
90  std::string _c_val, const unsigned int el_idx, const std::string::size_type _first_c_bit,
91  const std::string::size_type _c_size, const unsigned int _b);
92 
94 };
95 
96 class vcd_utility : public HLS_step
97 {
98  public:
103  const DesignFlowManagerConstRef design_flow_manager);
104 
105  /* Destructor */
106  ~vcd_utility() override = default;
107 
112  DesignFlowStep_Status Exec() override;
113 
114  bool HasToBeExecuted() const override;
115 
116  protected:
118 
120 
121  unsigned long long possibly_lost_address{0};
122 
123  unsigned long long mismatched_integers{0};
124 
126 
127  std::list<DiscrepancyLog> discr_list;
128 
129  std::list<DiscrepancyLog> soft_discr_list;
130 
132  std::string present_state_name;
133 
134  unsigned long long GetClockPeriod(const vcd_parser::vcd_trace_t& vcd_trace) const;
135 
141  ComputeHLSRelationships(const DesignFlowStep::RelationshipType relationship_type) const override;
142 
143  bool detect_mismatch(const vcd_trace_head& t, const uint64_t c_context, const std::string& c_val);
144 
145  bool detect_regular_mismatch(const vcd_trace_head& t, const std::string& c_val, const std::string& vcd_val) const;
146 
147  bool detect_binary_float_mismatch(const std::string& c_val, const std::string& resized_vcd_val) const;
148 
149  bool detect_binary_double_mismatch(const std::string& c_val, const std::string& resized_vcd_val) const;
150 
151  bool detect_address_mismatch(const DiscrepancyOpInfo& op_info, const uint64_t c_context, const std::string& c_val,
152  const std::string& vcd_val, unsigned int& base_index);
153 
154  bool detect_fixed_address_mismatch(const DiscrepancyOpInfo& op_info, const uint64_t c_context,
155  const std::string& c_val, const std::string& vcd_val,
156  const unsigned int base_index) const;
157 
158  bool detect_mismatch_element(const vcd_trace_head& t, const uint64_t c_context, const std::string& c_val,
159  const unsigned int el_idx);
160 
161  bool detect_mismatch_simple(const vcd_trace_head& t, const uint64_t c_context, const std::string& c_val,
162  const unsigned int el_idx, const std::string::size_type first_c_bit,
163  const std::string::size_type c_size);
164 
165  void update_discr_list(const vcd_trace_head& t, const uint64_t c_context, const std::string& c_val,
166  const unsigned int el_idx, const std::string::size_type first_c_bit,
167  const std::string::size_type c_size, const unsigned int base_index);
168 
169  void print_failed_vcd_head(const vcd_trace_head& t, bool one_hot_encoding, const int verbosity) const;
170 
171  void print_discrepancy(const DiscrepancyLog& l, bool one_hot_encoding, const int verbosity) const;
172 
173  std::string compute_fsm_state_from_vcd_string(const std::string& vcd_state_string, bool one_hot_encoding) const;
174 };
175 #endif
std::string fullsigname
Definition: vcd_utility.hpp:75
DiscrepancyLog(const HLS_managerConstRef HLSMgr, const vcd_trace_head &t, const uint64_t c_context, std::string _c_val, const unsigned int el_idx, const std::string::size_type _first_c_bit, const std::string::size_type _c_size, const unsigned int _b)
Definition: vcd_utility.cpp:77
std::list< DiscrepancyLog > discr_list
unsigned int fun_id
Definition: vcd_utility.hpp:69
std::list< DiscrepancyLog > soft_discr_list
REF_FORWARD_DECL(Discrepancy)
const DiscrepancyRef Discr
unsigned int bitsize
Definition: vcd_utility.hpp:77
std::string stmt_string
Definition: vcd_utility.hpp:72
std::string fu_name
Definition: vcd_utility.hpp:71
RelationshipType
The relationship type.
This class manages the tree structures extracted from the raw file.
unsigned int el_idx
Definition: vcd_utility.hpp:78
discrepancy_type_mask
std::string c_val
Definition: vcd_utility.hpp:73
redefinition of map to manage ordered/unordered structures
unsigned long long op_end_time
Definition: vcd_utility.hpp:65
bool allow_uninitialized
unsigned int op_id
Definition: vcd_utility.hpp:67
uint64_t context
Definition: vcd_utility.hpp:76
unsigned int ssa_id
Definition: vcd_utility.hpp:68
redefinition of set to manage ordered/unordered structures
UnorderedMapStd< std::string, CustomUnorderedMapStable< std::string, std::list< sig_variation > >> vcd_trace_t
this type is the result of a parse.
Definition: vcd_parser.hpp:109
DesignFlowStep_Status
The status of a step.
Template definition of refcount.
enum discrepancy_type_mask type
Definition: vcd_utility.hpp:66
std::string present_state_name
The name of the present state signal.
CONSTREF_FORWARD_DECL(FunctionBehavior)
const tree_managerRef TM
std::string op_start_state
Definition: vcd_utility.hpp:70
unsigned long long op_start_time
Definition: vcd_utility.hpp:64
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
std::string::size_type first_c_bit
Definition: vcd_utility.hpp:80
std::string vcd_val
Definition: vcd_utility.hpp:74
std::string::size_type c_size
Definition: vcd_utility.hpp:81
unsigned int base_index
valid only if type is DISCR_ADDR.
Definition: vcd_utility.hpp:87

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