PandA-2024.02
Public Types | Public Member Functions | Private Member Functions | Private Attributes
vcd_parser Class Reference

#include <vcd_parser.hpp>

Public Types

using vcd_filter_t = UnorderedMapStd< std::string, UnorderedSetStdStable< std::string > >
 this is the type used to select which signals have to be filtered during parsing. More...
 
using vcd_trace_t = UnorderedMapStd< std::string, CustomUnorderedMapStable< std::string, std::list< sig_variation > >>
 this type is the result of a parse. More...
 

Public Member Functions

 vcd_parser (const ParameterConstRef &params)
 constructor More...
 
vcd_trace_t parse_vcd (const std::string &vcd_file_to_parse, const vcd_parser::vcd_filter_t &selected_signals)
 parses a file selecting only a predefined set of signals. More...
 

Private Member Functions

int vcd_parse_sim ()
 Parses all lines that occur in the simulation portion of the VCD file. More...
 
int vcd_parse_def ()
 
int vcd_parse_skip_to_end ()
 Parses specified file until $end keyword is seen, ignoring all text inbetween. More...
 
int vcd_parse_def_var (const std::string &scope)
 Parses definition $var keyword line until $end keyword is seen. More...
 
void vcd_push_def_scope (std::stack< std::string > &scope)
 Parses definition $scope keyword line until $end keyword is seen. More...
 
void vcd_pop_def_scope (std::stack< std::string > &scope)
 
int vcd_parse_sim_vector (char *value, unsigned long timestamp)
 Reads the next token from the file and calls the appropriate fuction. More...
 
int vcd_parse_sim_real (char *value, unsigned long timestamp)
 Reads the next token from the file and calls the appropriate function. More...
 
bool check_filter_list (const std::string &scope_str, const std::string &name)
 Checks if a signal is to be monitored. More...
 
void vcd_add_signal (const std::string &scope, const std::string &name, const std::string &vcd_id, const std::string &type, const bool isvect, const unsigned int msb, const unsigned int lsb)
 insert a signal in the maps needed for selecting the vcd data and for relating it back to HDL and C variables More...
 
bool check_signals () const
 check if the port vectors declarations are consistent More...
 
void init_variations ()
 
void add_variation (const std::string &id, const std::string &value, unsigned long long ts)
 

Private Attributes

const int debug_level
 Debug Level. More...
 
std::string vcd_filename
 name of the vcd file to parse More...
 
FILE * vcd_fp
 file pointer to the vcd file to parse More...
 
unsigned long sig_n
 total number of signals in the vcd file More...
 
vcd_filter_t filtered_signals
 set of signals to select from the vcd file. More...
 
vcd_trace_t parse_result
 holds the parsed vcd trace during the parsing More...
 
std::map< std::pair< std::string, std::string >, vcd_sig_infoscope_and_name_to_sig_info
 maps every pair (scope, signal name) to the corresponding sig_info More...
 
std::map< std::string, CustomUnorderedSet< std::pair< std::string, std::string > > > vcd_id_to_scope_and_name
 maps every signal id in the vcd to the set of the corresponding pairs (scope, hdl signal name) More...
 

Detailed Description

Definition at line 85 of file vcd_parser.hpp.

Member Typedef Documentation

◆ vcd_filter_t

using vcd_parser::vcd_filter_t = UnorderedMapStd<std::string, UnorderedSetStdStable<std::string> >

this is the type used to select which signals have to be filtered during parsing.

the key of the map is a std::string representing a scope. the value type is a UnorderedSetStd containing all the names of the signal that have to be selected in that scope

Definition at line 101 of file vcd_parser.hpp.

◆ vcd_trace_t

using vcd_parser::vcd_trace_t = UnorderedMapStd<std::string, CustomUnorderedMapStable<std::string, std::list<sig_variation> >>

this type is the result of a parse.

the primary key is the scope. the secondary key is the name of the signal. the value type is std::list of sig_variation representing the waveform

Definition at line 109 of file vcd_parser.hpp.

Constructor & Destructor Documentation

◆ vcd_parser()

vcd_parser::vcd_parser ( const ParameterConstRef param)
explicit

constructor

Parameters
[in]paramsis the class holding bambu parameters
Author
Pietro Fezzardi pietr.nosp@m.ofez.nosp@m.zardi.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Definition at line 48 of file vcd_parser.cpp.

Member Function Documentation

◆ add_variation()

void vcd_parser::add_variation ( const std::string &  id,
const std::string &  value,
unsigned long long  ts 
)
private

◆ check_filter_list()

bool vcd_parser::check_filter_list ( const std::string &  scope_str,
const std::string &  name 
)
private

Checks if a signal is to be monitored.

Returns
: true if the signal has to be monitored, false if not.
Parameters
[in]nameis the name of the signal to be monitored.
[in,out]scope_strin input this is the signal scope in the vcd; if the signal has to be monitored the string referenced by this parameter is modified, trimming the initial part of the scope to avoid simulator-dependent path names. After this change the remaining part of the path starts from the top functional unit

Definition at line 511 of file vcd_parser.cpp.

References filtered_signals.

Referenced by vcd_parse_def_var().

Here is the caller graph for this function:

◆ check_signals()

bool vcd_parser::check_signals ( ) const
private

check if the port vectors declarations are consistent

Definition at line 557 of file vcd_parser.cpp.

References DEBUG_LEVEL_NONE, vcd_sig_info::is_vec, vcd_sig_info::lsb, vcd_sig_info::msb, PRINT_OUT_MEX, scope_and_name_to_sig_info, and vcd_sig_info::vcd_id_to_bit.

Referenced by vcd_parse_def().

Here is the caller graph for this function:

◆ init_variations()

void vcd_parser::init_variations ( )
private

Definition at line 577 of file vcd_parser.cpp.

References vcd_sig_info::lsb, vcd_sig_info::msb, parse_result, scope_and_name_to_sig_info, and vcd_id_to_scope_and_name.

Referenced by vcd_parse_sim().

Here is the caller graph for this function:

◆ parse_vcd()

vcd_parser::vcd_trace_t vcd_parser::parse_vcd ( const std::string &  vcd_file_to_parse,
const vcd_parser::vcd_filter_t selected_signals 
)

parses a file selecting only a predefined set of signals.

Parameters
[in]vcd_file_to_parsename of the file to parse
[in]selected_signalssignals to be selected. all signals are selected if this parameter is empty
Returns
: the traces of the selected vcd signals

Definition at line 53 of file vcd_parser.cpp.

References debug_level, DEBUG_LEVEL_VERBOSE, filtered_signals, INDENT_DBG_MEX, parse_result, scope_and_name_to_sig_info, sig_n, STR, THROW_ERROR, vcd_filename, vcd_fp, vcd_id_to_scope_and_name, vcd_parse_def(), and vcd_parse_sim().

Referenced by vcd_utility::Exec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcd_add_signal()

void vcd_parser::vcd_add_signal ( const std::string &  scope,
const std::string &  name,
const std::string &  vcd_id,
const std::string &  type,
const bool  isvect,
const unsigned int  msb,
const unsigned int  lsb 
)
private

insert a signal in the maps needed for selecting the vcd data and for relating it back to HDL and C variables

Parameters
[in]scopeis the string representing the scope in the parsed vcd
[in]namethe signal name in the parsed vcd
[in]vcd_ida string used as unique identifier for the signal in the vcd
[in]typestring describing the signal type
[in]isvecttrue if the signal is a bit vector
[in]msbmost significant bit of the signal
[in]lsbless significant bit of the signal

Definition at line 526 of file vcd_parser.cpp.

References vcd_sig_info::is_vec, key, vcd_sig_info::lsb, max, min, vcd_sig_info::msb, parse_result, scope_and_name_to_sig_info, THROW_ASSERT, THROW_ERROR, vcd_sig_info::type, and vcd_id_to_scope_and_name.

Referenced by vcd_parse_def_var().

Here is the caller graph for this function:

◆ vcd_parse_def()

int vcd_parser::vcd_parse_def ( )
private

Definition at line 321 of file vcd_parser.cpp.

References check_signals(), STR, THROW_ERROR, vcd_filename, vcd_fp, vcd_parse_def_var(), vcd_parse_skip_to_end(), vcd_pop_def_scope(), and vcd_push_def_scope().

Referenced by parse_vcd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcd_parse_def_var()

int vcd_parser::vcd_parse_def_var ( const std::string &  scope)
private

Parses definition $var keyword line until $end keyword is seen.

Definition at line 143 of file vcd_parser.cpp.

References check_filter_list(), debug_level, DEBUG_LEVEL_VERBOSE, PRINT_DBG_MEX, sig_n, THROW_ERROR, test_panda::type, vcd_add_signal(), and vcd_fp.

Referenced by vcd_parse_def().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcd_parse_sim()

int vcd_parser::vcd_parse_sim ( )
private

Parses all lines that occur in the simulation portion of the VCD file.

Definition at line 443 of file vcd_parser.cpp.

References add_variation(), init_variations(), STR, THROW_ERROR, vcd_filename, vcd_fp, vcd_parse_sim_real(), vcd_parse_sim_vector(), and vcd_parse_skip_to_end().

Referenced by parse_vcd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcd_parse_sim_real()

int vcd_parser::vcd_parse_sim_real ( char *  value,
unsigned long  timestamp 
)
private

Reads the next token from the file and calls the appropriate function.

Definition at line 418 of file vcd_parser.cpp.

References add_variation(), THROW_ERROR, and vcd_fp.

Referenced by vcd_parse_sim().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcd_parse_sim_vector()

int vcd_parser::vcd_parse_sim_vector ( char *  value,
unsigned long  timestamp 
)
private

Reads the next token from the file and calls the appropriate fuction.

Definition at line 392 of file vcd_parser.cpp.

References add_variation(), THROW_ERROR, and vcd_fp.

Referenced by vcd_parse_sim().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcd_parse_skip_to_end()

int vcd_parser::vcd_parse_skip_to_end ( )
private

Parses specified file until $end keyword is seen, ignoring all text inbetween.

Definition at line 113 of file vcd_parser.cpp.

References THROW_ERROR, and vcd_fp.

Referenced by vcd_parse_def(), and vcd_parse_sim().

Here is the caller graph for this function:

◆ vcd_pop_def_scope()

void vcd_parser::vcd_pop_def_scope ( std::stack< std::string > &  scope)
private

Definition at line 292 of file vcd_parser.cpp.

References debug_level, DEBUG_LEVEL_VERY_PEDANTIC, PRINT_DBG_MEX, THROW_ERROR, and vcd_fp.

Referenced by vcd_parse_def().

Here is the caller graph for this function:

◆ vcd_push_def_scope()

void vcd_parser::vcd_push_def_scope ( std::stack< std::string > &  scope)
private

Parses definition $scope keyword line until $end keyword is seen.

Definition at line 271 of file vcd_parser.cpp.

References debug_level, DEBUG_LEVEL_VERY_PEDANTIC, HIERARCHY_SEPARATOR, PRINT_DBG_MEX, STR, THROW_ERROR, and vcd_fp.

Referenced by vcd_parse_def().

Here is the caller graph for this function:

Field Documentation

◆ debug_level

const int vcd_parser::debug_level
private

Debug Level.

Definition at line 124 of file vcd_parser.hpp.

Referenced by parse_vcd(), vcd_parse_def_var(), vcd_pop_def_scope(), and vcd_push_def_scope().

◆ filtered_signals

vcd_filter_t vcd_parser::filtered_signals
private

set of signals to select from the vcd file.

if it's empty all the signals will be selected, otherwise the data about uninteresting signals are discarded to save memory

Definition at line 148 of file vcd_parser.hpp.

Referenced by check_filter_list(), and parse_vcd().

◆ parse_result

vcd_trace_t vcd_parser::parse_result
private

holds the parsed vcd trace during the parsing

Definition at line 155 of file vcd_parser.hpp.

Referenced by add_variation(), init_variations(), parse_vcd(), and vcd_add_signal().

◆ scope_and_name_to_sig_info

std::map<std::pair<std::string, std::string>, vcd_sig_info> vcd_parser::scope_and_name_to_sig_info
private

maps every pair (scope, signal name) to the corresponding sig_info

Definition at line 160 of file vcd_parser.hpp.

Referenced by add_variation(), check_signals(), init_variations(), parse_vcd(), and vcd_add_signal().

◆ sig_n

unsigned long vcd_parser::sig_n
private

total number of signals in the vcd file

Definition at line 141 of file vcd_parser.hpp.

Referenced by parse_vcd(), and vcd_parse_def_var().

◆ vcd_filename

std::string vcd_parser::vcd_filename
private

name of the vcd file to parse

Definition at line 131 of file vcd_parser.hpp.

Referenced by parse_vcd(), vcd_parse_def(), and vcd_parse_sim().

◆ vcd_fp

FILE* vcd_parser::vcd_fp
private

◆ vcd_id_to_scope_and_name

std::map<std::string, CustomUnorderedSet<std::pair<std::string, std::string> > > vcd_parser::vcd_id_to_scope_and_name
private

maps every signal id in the vcd to the set of the corresponding pairs (scope, hdl signal name)

Definition at line 165 of file vcd_parser.hpp.

Referenced by add_variation(), init_variations(), parse_vcd(), and vcd_add_signal().


The documentation for this class was generated from the following files:

Generated on Mon Feb 12 2024 13:04:09 for PandA-2024.02 by doxygen 1.8.13