API#
-
namespace spice_vpi#
-
class AnalogDigitalInterface#
- #include <AnalogDigitalInterface.h>
Manages the interface between analog (SPICE) and digital (HDL) signals.
This class handles:
Port discovery and management
Signal conversion between analog voltages and digital logic levels
Thread-safe access to port data
Synchronization between SPICE and HDL simulators
Public Functions
-
explicit AnalogDigitalInterface(const Config::Settings &config)#
Constructor.
- Parameters:
config – Configuration settings to use for signal conversion
-
void add_port(vpiHandle port)#
Add a port to be managed by this interface.
- Parameters:
port – VPI handle to the port
-
void set_analog_input(const char *name, double *value)#
Set analog input value (from digital side)
- Parameters:
name – Port name
value – Pointer to receive the analog value
-
void analog_outputs_update()#
Update analog output values from SPICE.
-
void set_digital_output()#
Set digital output values (to digital side)
-
void digital_input_update(vpiHandle handle)#
Update when digital input changes (called from VPI callback)
- Parameters:
handle – VPI handle to the changed signal
-
std::vector<std::string> get_analog_input_names() const#
Get all analog input names (for SPICE iteration)
- Returns:
Vector of port names
-
void print_status() const#
Print debug status information.
-
void update_all_digital_inputs()#
Update all digital inputs.
Private Functions
-
double digital_to_analog(int digital_value) const#
-
int analog_to_digital(double analog_value) const#
Private Static Functions
-
static std::string create_indexed_name(const std::string &base_name, int index)#
-
class AnalogDigitalInterface#
-
namespace spice_vpi
-
namespace spice_vpi
-
class Config#
- #include <Config.h>
Configuration manager for SPICE-VPI bridge.
Handles reading and validating environment variables and configuration
Public Static Functions
Private Static Functions
-
static std::string get_required_env_var(const char *name)#
-
static std::string get_optional_env_var(const char *name, const std::string &default_value = "")#
-
static double get_optional_env_double(const char *name, double default_value)#
-
static void parse_instance_names(const std::string &env_value, std::vector<std::string> &instance_names, bool &full_path_discovery)#
Parse comma-separated instance names from environment variable.
- Parameters:
env_value – The value from HDL_INSTANCE environment variable
instance_names – Output vector to store parsed instance names
full_path_discovery – Output flag indicating if there was any comma
-
struct Settings#
Public Members
-
std::string spice_netlist_path#
-
std::vector<std::string> hdl_instance_names#
-
bool full_path_discovery = false#
-
double vcc_voltage = 1.0#
-
double logic_threshold_low = 0.3#
-
double logic_threshold_high = 0.7#
-
double min_analog_change_threshold = 1e-9#
-
unsigned long long time_precision = 1e12#
-
std::string spice_netlist_path#
-
static std::string get_required_env_var(const char *name)#
-
class Config#
-
namespace spice_vpi
-
template<typename TimeT>
class TimeBarrier# - #include <TimeBarrier.h>
Two-party virtual-time synchronization barrier with shutdown support.
Coordinates time progression between two simulation engines (HDL and SPICE). Each engine calls update() with its current time. If one engine gets ahead, it blocks until the other catches up or shutdown is called.
- Template Parameters:
TimeT – Time type (typically unsigned long long for femtosecond precision)
Public Functions
-
inline TimeBarrier()#
-
bool update(int engine_id, TimeT current_time)#
Update time for one engine and wait for synchronization.
- Parameters:
engine_id – Engine identifier (HDL_ENGINE_ID or SPICE_ENGINE_ID)
current_time – Current virtual time for this engine
- Returns:
false if barrier was shut down before sync completed
-
void update_no_wait(int engine_id, TimeT current_time)#
Update time without waiting for synchronization.
- Parameters:
engine_id – Engine identifier
current_time – Current virtual time for this engine
-
TimeT get_time(int engine_id) const#
Get current time for specified engine.
- Parameters:
engine_id – Engine identifier
- Returns:
Current time for the engine
-
void shutdown()#
Signal shutdown to wake all waiting threads.
-
bool is_shutdown() const#
Check if barrier has been shut down.
-
void set_needs_redo(bool needs_redo)#
-
bool needs_redo() const#
Public Static Attributes
-
static constexpr int HDL_ENGINE_ID = 0#
-
static constexpr int SPICE_ENGINE_ID = 1#
Private Functions
-
void validate_engine_id(int engine_id) const#
-
template<typename TimeT>
-
namespace spice_vpi