API Reference

introduction.dacTool.cli

Command-line interface for introduction.dacTool.

The CLI supports the original DAC simulation workflows and a deploy-safe sphinx-skel helper used by GitHub Pages / Sphinx documentation builds.

introduction.dacTool.cli.add_common(ap)[source]

Add arguments shared by R-2R and weighted-resistor DAC workflows.

Parameters:

ap (ArgumentParser)

Return type:

None

introduction.dacTool.cli.build_parser()[source]

Build the command-line parser.

Return type:

ArgumentParser

introduction.dacTool.cli.main(argv=None)[source]

Run the dacTool command-line interface.

Parameters:

argv (list[str] | None)

Return type:

int

introduction.dacTool.apis

class introduction.dacTool.apis.Row(meta: 'Dict[str, Any]' = <factory>)[source]

Bases: object

Parameters:

meta (Dict[str, Any])

meta: Dict[str, Any]
class introduction.dacTool.apis.RunRequest(dac_type, nbits=10, vref=3.3, R_ohm=10000.0, sigma_r_pct=0.0, sigma_2r_pct=0.0, ro_over_r=1.0, res_sigma_pct=0.0, gain_err=0.0, vo_offset=0.0, csv=None, jspec=None, tupd=1e-06, in_dir='in', out_dir='out', out_csv=None, out_vcd=None, out_vcd_all=None, include_ideal_in_vcd=False, radix='dec')[source]

Bases: object

User-facing API for a single DAC simulation run.

You pick the dac_type (‘r2r’ or ‘weighted’) and pass common knobs plus paths. All relative paths are resolved against in_dir/out_dir by the CLI/app.

Parameters:
  • dac_type (str)

  • nbits (int)

  • vref (float)

  • R_ohm (float)

  • sigma_r_pct (float)

  • sigma_2r_pct (float)

  • ro_over_r (float)

  • res_sigma_pct (float)

  • gain_err (float)

  • vo_offset (float)

  • csv (str | None)

  • jspec (str | None)

  • tupd (float)

  • in_dir (str)

  • out_dir (str)

  • out_csv (str | None)

  • out_vcd (str | None)

  • out_vcd_all (str | None)

  • include_ideal_in_vcd (bool)

  • radix (str)

R_ohm: float = 10000.0
csv: str | None = None
dac_type: str
gain_err: float = 0.0
in_dir: str = 'in'
include_ideal_in_vcd: bool = False
jspec: str | None = None
nbits: int = 10
out_csv: str | None = None
out_dir: str = 'out'
out_vcd: str | None = None
out_vcd_all: str | None = None
radix: str = 'dec'
res_sigma_pct: float = 0.0
ro_over_r: float = 1.0
sigma_2r_pct: float = 0.0
sigma_r_pct: float = 0.0
tupd: float = 1e-06
vo_offset: float = 0.0
vref: float = 3.3
class introduction.dacTool.apis.RunResult(rows, updates, messages=<factory>)[source]

Bases: object

What the App returns; design helpers can persist this to files.

Parameters:
  • rows (List[Row])

  • updates (List[Update])

  • messages (List[str])

messages: List[str]
rows: List[Row]
updates: List[Update]
class introduction.dacTool.apis.Update(code: 'int', vo_ideal: 'float', vo_nonideal: 'float')[source]

Bases: object

Parameters:
  • code (int)

  • vo_ideal (float)

  • vo_nonideal (float)

code: int
vo_ideal: float
vo_nonideal: float

introduction.dacTool.app

introduction.dacTool.app.run(req)[source]
Parameters:

req (RunRequest)

Return type:

RunResult

introduction.dacTool.core

class introduction.dacTool.core.R2RDAC(nbits, vref, R_ohm, sigma_r_pct=0.0, sigma_2r_pct=0.0, seed=None, gain_err=0.0, vo_offset=0.0)[source]

Bases: object

Voltage-mode R-2R ladder DAC with nodal analysis and mismatch per resistor group.

Parameters:
  • nbits (int)

  • vref (float)

  • R_ohm (float)

  • sigma_r_pct (float)

  • sigma_2r_pct (float)

  • seed (int | None)

  • gain_err (float)

  • vo_offset (float)

vo_ideal_bits(bits_lsb_first)[source]
Parameters:

bits_lsb_first (List[int])

Return type:

float

vo_nonideal_bits(bits_lsb_first)[source]
Parameters:

bits_lsb_first (List[int])

Return type:

float

class introduction.dacTool.core.WeightedDAC(nbits, vref, ro_over_r, gain_err=0.0, vo_offset=0.0, res_sigma_pct=0.0, seed=None)[source]

Bases: object

Binary weighted-resistor DAC (summation DAC) ideal + simple mismatch model.

Parameters:
  • nbits (int)

  • vref (float)

  • ro_over_r (float)

  • gain_err (float)

  • vo_offset (float)

  • res_sigma_pct (float)

  • seed (int | None)

vo_ideal_bits(bits_lsb_first)[source]
Parameters:

bits_lsb_first (List[int])

Return type:

float

vo_nonideal_bits(bits_lsb_first)[source]
Parameters:

bits_lsb_first (List[int])

Return type:

float

introduction.dacTool.design

introduction.dacTool.design.write_results_csv(path, rows)[source]
Parameters:
  • path (str)

  • rows (List[Dict[str, Any]])

Return type:

None

introduction.dacTool.design.write_vcd(path, nbits, updates, tupd, start_time_ns=0, all_mode=False, include_ideal=False)[source]

Generic VCD writer used by both engines; values in microvolts.

Parameters:
  • path (str)

  • nbits (int)

  • updates (List[Update])

  • tupd (float)

  • start_time_ns (int)

  • all_mode (bool)

  • include_ideal (bool)

Return type:

int

introduction.dacTool.io

introduction.dacTool.io.bits_from_int(code, nbits)[source]
Parameters:
  • code (int)

  • nbits (int)

Return type:

List[int]

introduction.dacTool.io.int_from_bits(bits_lsb_first)[source]
Parameters:

bits_lsb_first (List[int])

Return type:

int

introduction.dacTool.io.load_vectors_from_csv(path, nbits)[source]
Parameters:
  • path (str)

  • nbits (int)

Return type:

Iterable[Dict[str, Any]]

introduction.dacTool.io.load_vectors_from_json(path_or_inline, nbits)[source]
Parameters:
  • path_or_inline (str)

  • nbits (int)

Return type:

Iterable[Dict[str, Any]]

introduction.dacTool.utils

introduction.dacTool.utils.bin_zero_padded(v, w, group=4)[source]
Parameters:
  • v (int)

  • w (int)

  • group (int)

Return type:

str

introduction.dacTool.utils.ensure_dir_for(path)[source]
Parameters:

path (str)

Return type:

None

introduction.dacTool.utils.is_inline_json(s)[source]
Parameters:

s (str)

Return type:

bool

introduction.dacTool.utils.resolve_input_path(p, in_dir)[source]
Parameters:
  • p (str | None)

  • in_dir (str)

Return type:

str | None

introduction.dacTool.utils.resolve_output_path(p, out_dir)[source]
Parameters:
  • p (str | None)

  • out_dir (str)

Return type:

str | None

introduction.dacTool.utils.timecall(fn)[source]
Parameters:

fn (Callable[[...], Any])

Return type:

Callable[[…], Any]