https://open-source-silicon.dev logo
Title
a

Ahmed Reda

03/09/2023, 3:39 PM
@Stefan Schippers @Tim Edwards Is there a way to create a voltage source such as PWL which can read from · CSV files. Then, using this voltage source to drive analog or digital circuit. Any suggestion, please.
t

Tim Edwards

03/09/2023, 6:45 PM
I also use the xspice
d_source
component, which reads values from a file to apply for digital input. This is probably the most efficient way to apply digital vectors. The third choice is to use the iverilog cosimulation, but that requires a special compilation of ngspice that is currently buried in an obscure development branch.
1
@Ahmed Reda: This is a snippet of the code I used for a transient simulation of the DAC.
* Method to simulate transient output on a DAC:  Use d_source, pull data from
* a pre-made file representing digital data for 4 cycles of a rail-to-rail
* sine wave.
ASINE [Db7 Db6 Db5 Db4 Db3 Db2 Db1 Db0] sinegen
.model sinegen d_source(input_file=./testbench/sine1x4.dat)

ACONV7 [Db7 Db6 Db5 Db4 Db3 Db2 Db1 Db0] [b7 b6 b5 b4 b3 b2 b1 b0] dtoa
.model dtoa dac_bridge(out_high=1.8 out_low=0 t_rise=5.0e-10 t_fall=5.0e-10)
Contents of the first few lines of `sine1x4.dat`:
* Octave data file for xspice model d_source created by CACE
* Format is time value followed by digital state.
0 1s 0s 0s 0s 0s 0s 0s 0s
9.76562e-10 1s 0s 0s 0s 0s 0s 0s 0s
1.95312e-09 1s 0s 0s 0s 0s 0s 0s 1s
2.92969e-09 1s 0s 0s 0s 0s 0s 1s 0s
...
It says "octave" at the top because I used an octave script to generate the data (could have been done with numpy as well).
1
a

Ahmed Reda

03/10/2023, 12:52 PM
@Tim Edwards Thanks.