scc  2022.4.0
SystemC components library
scc::configurer Class Reference

design configuration reader More...

#include <configurer.h>

Inheritance diagram for scc::configurer:
Collaboration diagram for scc::configurer:

Classes

struct  ConfigHolder
 

Public Types

enum  { NEVER = 0 , BEFORE_END_OF_ELABORATION = 1 , END_OF_ELABORATION = 2 , START_OF_SIMULATION = 4 }
 
using base_type = sc_core::sc_module
 
using broker_t = cci::cci_broker_handle
 
using cci_param_cln = std::vector< std::pair< cci::cci_param_post_write_callback_untyped, std::unique_ptr< cci::cci_param_untyped > >>
 

Public Member Functions

 configurer (std::string const &filename, unsigned sc_attr_config_phases=BEFORE_END_OF_ELABORATION)
 
 configurer (const configurer &)=delete
 
 configurer (configurer &&)=delete
 
configureroperator= (const configurer &)=delete
 
configureroperator= (configurer &&)=delete
 
void read_input_file (std::string const &filename)
 
void configure ()
 
void dump_configuration (std::ostream &os=std::cout, bool as_yaml=true, bool with_description=false, sc_core::sc_object *obj=nullptr)
 
void dump_configuration (std::string const &file_name, bool with_description=false)
 
template<typename T >
void set_value (std::string const &hier_name, T value)
 
void set_configuration_value (sc_core::sc_attr_base *attr_base, sc_core::sc_object *owner)
 

Static Public Member Functions

static configurerget ()
 

Protected Member Functions

 configurer (std::string const &filename, unsigned sc_attr_config_phases, sc_core::sc_module_name nm)
 
void config_check ()
 
void before_end_of_elaboration () override
 
void end_of_elaboration () override
 
void start_of_simulation () override
 
void set_value (const std::string &hier_name, cci::cci_value value)
 

Protected Attributes

unsigned const config_phases
 
std::string dump_file_name {""}
 
bool with_description {false}
 
broker_t cci_broker
 
cci_param_cln cci2sc_attr
 
cci::cci_originator cci_originator
 
std::unique_ptr< ConfigHolderroot
 

Detailed Description

design configuration reader

A class to configure a design hierarchy using a JSON input file. It reads a file and and stores its values into a CCI broker. It can apply the value also to sc_attribute once the design is installed.

Definition at line 41 of file configurer.h.

Constructor & Destructor Documentation

◆ configurer()

scc::configurer::configurer ( std::string const &  filename,
unsigned  sc_attr_config_phases = BEFORE_END_OF_ELABORATION 
)

create a configurer using an input file

Parameters
filenamethe input file to read containing the values to apply
sc_attr_config_phasesdefines when to apply the values to sc_attribute instances

Definition at line 627 of file configurer.cpp.

Member Function Documentation

◆ configure()

void scc::configurer::configure ( )

configure the design hierarchy using the input file. Apply the values to sc_core::sc_attribute in th edsign hierarchy

Definition at line 683 of file configurer.cpp.

◆ dump_configuration() [1/2]

void scc::configurer::dump_configuration ( std::ostream &  os = std::cout,
bool  as_yaml = true,
bool  with_description = false,
sc_core::sc_object *  obj = nullptr 
)

dump the parameters of a design hierarchy to output stream immediately

Parameters
osthe output stream, std::cout by default
objif not null specifies the root object of the dump

Definition at line 661 of file configurer.cpp.

◆ dump_configuration() [2/2]

void scc::configurer::dump_configuration ( std::string const &  file_name,
bool  with_description = false 
)
inline

schedule the dump the parameters of a design hierarchy to a file during start_of_simulation()

Parameters
file_namethe output stream, std::cout by default

Definition at line 88 of file configurer.h.

◆ get()

static configurer& scc::configurer::get ( )
inlinestatic

find the configurer in the design hierarchy

Returns
reference to the singleton

Definition at line 115 of file configurer.h.

◆ set_configuration_value()

void scc::configurer::set_configuration_value ( sc_core::sc_attr_base *  attr_base,
sc_core::sc_object *  owner 
)

set a value of an sc_attribute from given configuration. This is being used by the scc::ext_attribute which allows to use config values during construction

Parameters
attr_base
owner

Definition at line 685 of file configurer.cpp.

◆ set_value()

template<typename T >
void scc::configurer::set_value ( std::string const &  hier_name,
value 
)
inline

set a value of some property (sc_attribute or cci_param) from programmatically

In case the configurer is being used without CCI the function can only be called after the simulation objects are instantiated since the sc_attributes have to exist.

Parameters
hier_namethe hierarchical name of the property
valuethe value to put

Definition at line 101 of file configurer.h.


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