HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::NetlistSimulator Class Reference

#include </home/runner/work/hal/hal/plugins/simulator/hal_simulator/include/netlist_simulator/netlist_simulator.h>

Inheritance diagram for hal::NetlistSimulator:
Inheritance graph
Collaboration diagram for hal::NetlistSimulator:
Collaboration graph

Public Member Functions

const std::unordered_set< Gate * > & get_gates () const
 
void set_input (const Net *net, BooleanFunction::Value value)
 
void initialize_sequential_gates (const std::function< bool(const Gate *)> &filter=nullptr)
 
void initialize_sequential_gates (BooleanFunction::Value value, const std::function< bool(const Gate *)> &filter=nullptr)
 
void load_initial_values (BooleanFunction::Value value)
 
void load_initial_values_from_netlist ()
 
void initialize ()
 
void simulate (u64 picoseconds)
 
SimulationInputget_simulation_input () const override
 
void reset ()
 
void set_simulation_state (const Simulation &state)
 
const Simulationget_simulation_state () const
 
void set_iteration_timeout (u64 iterations)
 
u64 get_simulation_timeout () const
 
bool generate_vcd (const std::filesystem::path &path, u32 start_time, u32 end_time, std::set< const Net * > nets={}) const
 
std::vector< WaveEventget_simulation_events (u32 netId) const override
 
bool inputEvent (const SimulationInputNetEvent &netEv) override
 
- Public Member Functions inherited from hal::SimulationEngineEventDriven
 SimulationEngineEventDriven (const std::string &nam)
 
- Public Member Functions inherited from hal::SimulationEngine
 SimulationEngine (const std::string &nam)
 
virtual ~SimulationEngine ()
 
std::string name () const
 
State state () const
 
int get_state () const
 
std::string get_working_directory () const
 
void set_working_directory (const std::string &workDir)
 
bool clock_events_required () const
 
bool can_share_memory () const
 
bool install_saleae_parser (std::string dirname) const
 
virtual void setResultFilename (const std::string filename)
 
std::string get_result_filename () const
 
virtual bool finalize ()
 
virtual void failed ()
 
virtual void set_engine_property (const std::string &key, const std::string &value)
 
virtual std::string get_engine_property (const std::string &key)
 
virtual const std::unordered_map< std::string, std::string > & get_engine_properties () const
 

Friends

class NetlistSimulatorFactory
 
class NetlistSimulatorPlugin
 

Additional Inherited Members

- Public Types inherited from hal::SimulationEngine
enum  State { Failed = -1 , Done = 0 , Running = 1 , Preparing = 2 }
 
- Protected Attributes inherited from hal::SimulationEngine
bool mRequireClockEvents
 
bool mCanShareMemory
 
std::string mResultFilename
 
State mState
 
std::unordered_map< std::string, std::string > mProperties
 
SimulationInputmSimulationInput
 
std::string mWorkDir
 

Detailed Description

HAL's built-in event-driven simulation engine.

Definition at line 45 of file netlist_simulator.h.

Member Function Documentation

◆ generate_vcd()

bool hal::NetlistSimulator::generate_vcd ( const std::filesystem::path &  path,
u32  start_time,
u32  end_time,
std::set< const Net * >  nets = {} 
) const

Generates the a VCD file for parts the simulated netlist.

Parameters
[in]path- The path to the VCD file.
[in]start_time- Start of the timeframe to write to the file (in picoseconds).
[in]end_time- End of the timeframe to write to the file (in picoseconds).
[in]nets- Nets to include in the VCD file.
Returns
true if the file gerneration was successful, false otherwise.

Definition at line 568 of file netlist_simulator.cpp.

References log_error, and net.

Referenced by hal::PYBIND11_PLUGIN().

◆ get_gates()

const std::unordered_set<Gate*>& hal::NetlistSimulator::get_gates ( ) const

Get all gates that are in the simulation set.

Returns
The simulation set.

◆ get_simulation_events()

std::vector< WaveEvent > hal::NetlistSimulator::get_simulation_events ( u32  netId) const
overridevirtual

Get vector of simulated events for net

Parameters
[in]netId- The net for which events where simulated
Returns
Vector of events

Reimplemented from hal::SimulationEngineEventDriven.

Definition at line 230 of file netlist_simulator.cpp.

References hal::Simulation::get_events_by_net_id().

◆ get_simulation_input()

SimulationInput* hal::NetlistSimulator::get_simulation_input ( ) const
inlineoverridevirtual

Get simulation input

Returns
Pointer to input instance

Reimplemented from hal::SimulationEngine.

Definition at line 116 of file netlist_simulator.h.

References hal::SimulationEngine::mSimulationInput.

◆ get_simulation_state()

const Simulation & hal::NetlistSimulator::get_simulation_state ( ) const

Get the current simulation state.

Returns
The current simulation state.

Definition at line 215 of file netlist_simulator.cpp.

Referenced by hal::PYBIND11_PLUGIN().

◆ get_simulation_timeout()

u64 hal::NetlistSimulator::get_simulation_timeout ( ) const

Get the current iteration timeout value.

Returns
The iteration timeout.

Definition at line 225 of file netlist_simulator.cpp.

Referenced by hal::PYBIND11_PLUGIN().

◆ initialize()

void hal::NetlistSimulator::initialize ( )

Initialize the simulation. No additional gates or clocks can be added after this point.

Definition at line 248 of file netlist_simulator.cpp.

References hal::WaveEvent::affected_net, log_error, measure_block_time, net, hal::WaveEvent::new_value, pins, and hal::WaveEvent::time.

Referenced by hal::PYBIND11_PLUGIN().

◆ initialize_sequential_gates() [1/2]

void hal::NetlistSimulator::initialize_sequential_gates ( BooleanFunction::Value  value,
const std::function< bool(const Gate *)> &  filter = nullptr 
)

Configure the sequential gates matching the (optional) user-defined filter condition with the specified value. Schedules the respective gates for initialization, the actual configuration is applied during initialization of the simulator. This function can only be called before the simulation has started.

Parameters
[in]value- The value to initialize the selected gates with.
[in]filter- The optional filter to be applied before initialization.

Definition at line 63 of file netlist_simulator.cpp.

References log_error.

◆ initialize_sequential_gates() [2/2]

void hal::NetlistSimulator::initialize_sequential_gates ( const std::function< bool(const Gate *)> &  filter = nullptr)

Configure the sequential gates matching the (optional) user-defined filter condition with initialization data specified within the netlist. Schedules the respective gates for initialization, the actual configuration is applied during initialization of the simulator. This function can only be called before the simulation has started.

Parameters
[in]filter- The optional filter to be applied before initialization.

Definition at line 50 of file netlist_simulator.cpp.

References log_error.

Referenced by hal::PYBIND11_PLUGIN().

◆ inputEvent()

bool hal::NetlistSimulator::inputEvent ( const SimulationInputNetEvent netEv)
overridevirtual

Must be implemented by derived class

Passes an event to engine to trigger simulation

Parameters
[in]netEvinput event asigning input values (0,1,X,Z) for nets and providing number of cycles to simulate
Returns
true if event was handled successfully, false otherwise

Implements hal::SimulationEngineEventDriven.

Definition at line 235 of file netlist_simulator.cpp.

References hal::SimulationInputNetEvent::get_simulation_duration().

◆ load_initial_values()

void hal::NetlistSimulator::load_initial_values ( BooleanFunction::Value  value)
Deprecated:
DEPRECATED
Load the specified initial value into the current state of all sequential elements.
Parameters
[in]value- The initial value to load.

Definition at line 76 of file netlist_simulator.cpp.

References hal::WaveEvent::affected_net, hal::WaveEvent::new_value, hal::WaveEvent::time, and hal::simulation_utils::toggle().

Referenced by hal::PYBIND11_PLUGIN().

◆ load_initial_values_from_netlist()

void hal::NetlistSimulator::load_initial_values_from_netlist ( )
Deprecated:
DEPRECATED
Load the initial value specified within the netlist file into the current state of all sequential elements. This is especially relevant for FPGA netlists, since these may provide initial values to load on startup.

Definition at line 118 of file netlist_simulator.cpp.

References hal::WaveEvent::affected_net, hal::InitComponent::get_init_category(), hal::InitComponent::get_init_identifiers(), hal::GateType::get_name(), hal::InitComponent::get_type(), log_error, hal::WaveEvent::new_value, hal::WaveEvent::time, and hal::simulation_utils::toggle().

Referenced by hal::PYBIND11_PLUGIN().

◆ reset()

void hal::NetlistSimulator::reset ( )

Reset the simulator state, i.e., treat all signals as unknown. Does not remove gates/nets from the simulation set.

Definition at line 200 of file netlist_simulator.cpp.

Referenced by hal::PYBIND11_PLUGIN().

◆ set_input()

void hal::NetlistSimulator::set_input ( const Net net,
BooleanFunction::Value  value 
)

Set the signal for a specific wire to control input signals between simulation cycles.

Parameters
[in]net- The net to set a signal value for.
[in]value- The value to set.

Definition at line 27 of file netlist_simulator.cpp.

References hal::WaveEvent::affected_net, log_error, net, hal::WaveEvent::new_value, and hal::WaveEvent::time.

Referenced by hal::PYBIND11_PLUGIN().

◆ set_iteration_timeout()

void hal::NetlistSimulator::set_iteration_timeout ( u64  iterations)

Set the iteration timeout, i.e., the maximum number of events processed for a single point in time. Useful to abort in case of infinite loops. A value of 0 disables the timeout.

Parameters
[in]iterations- The iteration timeout.

Definition at line 220 of file netlist_simulator.cpp.

Referenced by hal::PYBIND11_PLUGIN().

◆ set_simulation_state()

void hal::NetlistSimulator::set_simulation_state ( const Simulation state)

Set the simulator state, i.e., net signals, to a given state. Does not influence gates/nets added to the simulation set.

Parameters
[in]state- The state to apply.

Definition at line 210 of file netlist_simulator.cpp.

References hal::state.

Referenced by hal::PYBIND11_PLUGIN().

◆ simulate()

void hal::NetlistSimulator::simulate ( u64  picoseconds)

Simulate for a specific period, advancing the internal state. Automatically initializes the simulation if 'initialize' has not yet been called. Use 'set_input' to control specific signals.

Parameters
[in]picoseconds- The duration to simulate.

Definition at line 188 of file netlist_simulator.cpp.

References hal::initialize().

Referenced by hal::PYBIND11_PLUGIN().

Friends And Related Function Documentation

◆ NetlistSimulatorFactory

friend class NetlistSimulatorFactory
friend

Definition at line 47 of file netlist_simulator.h.

◆ NetlistSimulatorPlugin

friend class NetlistSimulatorPlugin
friend

Definition at line 180 of file netlist_simulator.h.


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