API Reference

introduction.muxTool.cli

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

Build the command-line parser.

Return type:

ArgumentParser

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

Run the muxTool command-line interface.

Parameters:

argv (list[str] | None)

Return type:

int

introduction.muxTool.apis

class introduction.muxTool.apis.RunRequest(csv=None, json=None, out=None, bits=8, trace=None, in_dir='in', out_dir='out')[source]

Bases: object

Immutable run request for MuxApp.

Parameters:
  • csv (str | None)

  • json (str | None)

  • out (str | None)

  • bits (int)

  • trace (str | None)

  • in_dir (str)

  • out_dir (str)

bits: int = 8
csv: str | None = None
in_dir: str = 'in'
json: str | None = None
out: str | None = None
out_dir: str = 'out'
trace: str | None = None
class introduction.muxTool.apis.RunResult(rows, out_csv=None, out_vcd=None)[source]

Bases: object

Results returned by a run: rows (list of dict), and any file outputs.

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

  • out_csv (str | None)

  • out_vcd (str | None)

out_csv: str | None = None
out_vcd: str | None = None
rows: List[Dict[str, Any]]

introduction.muxTool.app

class introduction.muxTool.app.MuxApp[source]

Bases: object

High-level application orchestrator for muxTool.

run(req)[source]

Run the mux simulation and write optional CSV/VCD outputs.

Parameters:

req (RunRequest)

Return type:

RunResult

introduction.muxTool.core

class introduction.muxTool.core.MuxCore(data_bw=8, *, prefer_pyrtl=True)[source]

Bases: object

Core 4:1 mux simulator.

The runtime implementation prefers PyRTL when it is available, but the module remains importable without PyRTL so Sphinx autodoc and lightweight CI jobs do not fail just because optional simulation dependencies are missing.

The logical behavior is always:

y = d0  when sel == 0
y = d1  when sel == 1
y = d2  when sel == 2
y = d3  when sel == 3
Parameters:
  • data_bw (int) – Data-path bit width used to mask d0 through d3 and y.

  • prefer_pyrtl (bool) – If true, use PyRTL when it is installed. If false, always use the pure Python fallback simulator.

build()[source]

Build the PyRTL mux circuit and return its ports.

This method is only needed when PyRTL-backed simulation is desired. It intentionally imports PyRTL lazily so importing this module stays safe for documentation builds.

Return type:

Dict[str, Any]

simulate(vectors)[source]

Simulate the mux, using PyRTL when available and Python otherwise.

Parameters:

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

Return type:

List[Dict[str, int]]

simulate_pyrtl(vectors)[source]

Simulate the mux with PyRTL.

Parameters:

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

Return type:

List[Dict[str, int]]

simulate_python(vectors)[source]

Simulate the mux with a dependency-free Python implementation.

Parameters:

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

Return type:

List[Dict[str, int]]

introduction.muxTool.design

introduction.muxTool.design.write_vcd(filename, rows, data_bw, timescale='1ns')[source]

Minimal VCD writer for signals: sel (2 bits), d0..d3 (data_bw), y (data_bw). One timestamp per cycle (10 ns apart).

Parameters:
  • filename (str)

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

  • data_bw (int)

  • timescale (str)

Return type:

None

introduction.muxTool.io

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

path (str)

Return type:

Iterator[Dict[str, int]]

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

path_or_inline (str)

Return type:

Iterator[Dict[str, int]]

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

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

Return type:

None

introduction.muxTool.utils

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

path (str)

Return type:

None

introduction.muxTool.utils.log_call(fn)[source]

Lightweight decorator to log entry/exit for testability and debugging.

Parameters:

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

Return type:

Callable[[…], Any]

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

s (str)

Return type:

bool

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

  • bits (int)

Return type:

int

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

  • in_dir (str)

Return type:

str | None

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

  • out_dir (str)

Return type:

str | None