API Reference

introduction.demuxTool.cli

Command-line interface for introduction.demuxTool.

The CLI preserves the original demultiplexer workflow while adding a small, conservative Sphinx skeleton generator for GitHub Pages deployments.

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

Build the command-line parser.

Return type:

ArgumentParser

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

Run the demuxTool command-line interface.

Parameters:

argv (list[str] | None)

Return type:

int

introduction.demuxTool.apis

class introduction.demuxTool.apis.RunRequest(n_outputs=4, data_bw=8, strict=False, csv_path=None, json_spec=None, out_csv=None, out_vcd=None, in_dir='in', out_dir='out')[source]

Bases: object

Immutable request for a demux simulation run.

Parameters:
  • n_outputs (int)

  • data_bw (int)

  • strict (bool)

  • csv_path (str | None)

  • json_spec (str | None)

  • out_csv (str | None)

  • out_vcd (str | None)

  • in_dir (str)

  • out_dir (str)

csv_path: str | None = None
data_bw: int = 8
in_dir: str = 'in'
json_spec: str | None = None
n_outputs: int = 4
out_csv: str | None = None
out_dir: str = 'out'
out_vcd: str | None = None
strict: bool = False
class introduction.demuxTool.apis.RunResult(rows: 'List[Dict[str, int]]' = <factory>, sel_bits: 'int' = 1, data_bw: 'int' = 8, n_outputs: 'int' = 4, out_csv: 'Optional[str]' = None, out_vcd: 'Optional[str]' = None)[source]

Bases: object

Parameters:
  • rows (List[Dict[str, int]])

  • sel_bits (int)

  • data_bw (int)

  • n_outputs (int)

  • out_csv (str | None)

  • out_vcd (str | None)

data_bw: int = 8
n_outputs: int = 4
out_csv: str | None = None
out_vcd: str | None = None
rows: List[Dict[str, int]]
sel_bits: int = 1

introduction.demuxTool.app

Application orchestration for introduction.demuxTool.

class introduction.demuxTool.app.DemuxApp[source]

Bases: object

High-level demultiplexer workflow.

The app resolves input/output paths, loads CSV or JSON vectors, runs the demultiplexer circuit, and writes optional CSV/VCD outputs.

run(req)[source]

Run a complete demux simulation.

Parameters:

req (RunRequest)

Return type:

RunResult

introduction.demuxTool.core

Core demultiplexer model for introduction.demuxTool.

The production simulator prefers PyRTL when it is installed, but this module is safe to import in documentation environments that do not install optional EDA packages. A small pure-Python simulator is kept as a deterministic fallback so Sphinx autodoc and lightweight CI jobs can import the package without pulling in pyrtl.

class introduction.demuxTool.core.DemuxCircuit(n_outputs=4, data_bw=8, strict=False)[source]

Bases: object

Combinational N-way demultiplexer.

The demultiplexer routes one data word x to exactly one output yN according to the select value sel. All non-selected outputs are zero.

Parameters:
  • n_outputs (int) – Number of demultiplexer outputs. Must be at least 2.

  • data_bw (int) – Data bit width for the input and each output.

  • strict (bool) – When True, selections outside 0 <= sel < n_outputs drive all outputs to zero. When False, the select word is simply masked to the internal select width, matching the original PyRTL-oriented behavior.

Notes

build() requires the optional pyrtl package. simulate() uses PyRTL when available and otherwise falls back to a pure-Python equivalent. This keeps the package importable during Sphinx builds where PyRTL may not be installed.

build()[source]

Build the PyRTL combinational demultiplexer and return its ports.

Returns:

Mapping with sel, x, and ys PyRTL wire objects.

Return type:

dict

simulate(vectors)[source]

Simulate the demultiplexer for a list of input vectors.

The method uses PyRTL when it is importable. If PyRTL is missing, the pure-Python fallback returns the same row schema.

Parameters:

vectors (List[Dict[str, int]])

Return type:

List[Dict[str, int]]

introduction.demuxTool.design

introduction.demuxTool.design.class_diagram_dot()[source]
Return type:

str

introduction.demuxTool.design.render_class_diagram(out_path)[source]

Render DOT to a PNG if graphviz is installed; else write DOT.

Parameters:

out_path (str)

Return type:

str

introduction.demuxTool.io

introduction.demuxTool.io.load_rows_from_csv(path)[source]
Parameters:

path (str)

Return type:

Iterator[Dict[str, int]]

introduction.demuxTool.io.load_rows_from_json(path_or_inline)[source]
Parameters:

path_or_inline (str)

Return type:

Iterator[Dict[str, int]]

introduction.demuxTool.io.write_results_csv(filename, rows, n_outputs)[source]
Parameters:
  • filename (str)

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

  • n_outputs (int)

Return type:

None

introduction.demuxTool.io.write_vcd(filename, rows, data_bw, n_outputs, sel_bits, timescale='1ns')[source]
Parameters:
  • filename (str)

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

  • data_bw (int)

  • n_outputs (int)

  • sel_bits (int)

  • timescale (str)

Return type:

None

introduction.demuxTool.utils

introduction.demuxTool.utils.ensure_dir(path)[source]
Parameters:

path (str)

Return type:

None

introduction.demuxTool.utils.looks_inline_json(s)[source]
Parameters:

s (str)

Return type:

bool

introduction.demuxTool.utils.mask(v, bits)[source]
Parameters:
  • v (int)

  • bits (int)

Return type:

int

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

  • in_dir (str)

Return type:

str | None

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

  • out_dir (str)

Return type:

str | None