API Reference

class introduction.adcTool.app.ADCApp[source]
run(req: RunRequest) RunResult[source]
class introduction.adcTool.apis.RunRequest(adc_type: 'ADCType', csv: 'str | None' = None, json: 'str | None' = None, nbits: 'int' = 10, vref: 'float' = 3.3, comp_offset: 'float' = 0.0, dac_gain: 'float' = 1.0, dac_offset: 'float' = 0.0, jitter_rms: 'float' = 0.0, radix: 'str' = 'dec', tclk: 'float' = 1e-06, tbit: 'float' = 1e-06, in_dir: 'str' = 'in', out_dir: 'str' = 'out', out_csv: 'str | None' = None, trace_vcd: 'str | None' = None, trace_all_vcd: 'str | None' = None)[source]
adc_type: Literal['counter', 'sar']
comp_offset: float = 0.0
csv: str | None = None
dac_gain: float = 1.0
dac_offset: float = 0.0
in_dir: str = 'in'
jitter_rms: float = 0.0
json: str | None = None
nbits: int = 10
out_csv: str | None = None
out_dir: str = 'out'
radix: str = 'dec'
tbit: float = 1e-06
tclk: float = 1e-06
trace_all_vcd: str | None = None
trace_vcd: str | None = None
vref: float = 3.3
class introduction.adcTool.apis.RunResult(results: 'List[SampleSummary]' = <factory>, wrote_csv: 'str | None' = None, wrote_vcd: 'str | None' = None, wrote_vcd_all: 'str | None' = None)[source]
results: List[SampleSummary]
wrote_csv: str | None = None
wrote_vcd: str | None = None
wrote_vcd_all: str | None = None
class introduction.adcTool.apis.SampleSummary(data: 'Dict[str, Any]')[source]
data: Dict[str, Any]
class introduction.adcTool.core.ADCBase(nbits: int, vref: float, comp_offset: float = 0.0, dac_gain: float = 1.0, dac_offset: float = 0.0, jitter_rms: float = 0.0)[source]
simulate_sample(vin: float) Tuple[Dict[str, Any], List[Dict[str, Any]]][source]
class introduction.adcTool.core.CounterADC(tclk: float, **kwargs)[source]
simulate_sample(vin: float) Tuple[Dict[str, Any], List[Dict[str, Any]]][source]
class introduction.adcTool.core.SARADC(tbit: float, **kwargs)[source]
simulate_sample(vin: float) Tuple[Dict[str, Any], List[Dict[str, Any]]][source]
introduction.adcTool.core.make_engine(adc_type: str, **kwargs) ADCBase[source]
introduction.adcTool.io.load_vins_from_csv(path: str) Iterable[float][source]
introduction.adcTool.io.load_vins_from_json(path_or_inline: str) Iterable[float][source]
introduction.adcTool.io.write_results_csv(path: str, rows: List[Dict[str, Any]]) None[source]
introduction.adcTool.utils.bin_zero_padded(v: int, w: int, group: int | None = None) str[source]

Return a zero-padded binary string of width w for integer v.

By default, no grouping is applied. If group is a positive integer, insert ‘_’ separators every group bits from the MSB side. .. rubric:: Example

bin_zero_padded(0xAB, 8) -> ‘10101011’ bin_zero_padded(0xAB, 8, group=4) -> ‘1010_1011’

introduction.adcTool.utils.ensure_dir(path: str) None[source]

Ensure the parent directory of path exists (safe for file paths). If path itself is a directory path, it will also be created.

introduction.adcTool.utils.fmt_code(code: int, nbits: int, radix: str) str[source]
Format the digital code using the given radix:
  • ‘dec’ -> decimal (e.g., ‘13’)

  • ‘hex’ -> hexadecimal with zero-padding to nbits/4 (e.g., ‘0x0D’)

  • ‘bin’ -> binary with zero-padding to nbits (e.g., ‘0b00001101’)

  • ‘all’ -> combined ‘dec (0b…, 0x…)’

Grouping underscores are NOT added by default in ‘bin’/’all’.

introduction.adcTool.utils.resolve_input_path(p: str | None, in_dir: str) str | None[source]
Resolve an input specification:
  • Inline JSON (string starting with ‘[’ or ‘{’) is returned as-is.

  • Absolute paths or existing paths are returned unchanged.

  • Otherwise, we look for the file under in_dir and return that if it exists.

  • If it still does not exist, return the original p (caller may handle).

introduction.adcTool.utils.resolve_output_path(p: str | None, out_dir: str) str | None[source]
Resolve an output path according to project policy:
  • Absolute path: keep absolute and ensure parent directory exists.

  • Relative path (even if it contains its own subdirectories like ‘foo/bar.txt’): place it under out_dir and ensure the resulting parent directory exists.