Skip to content

Feature/topology loader#10

Merged
ankenman merged 4 commits into
mainfrom
feature/topology-loader
May 23, 2026
Merged

Feature/topology loader#10
ankenman merged 4 commits into
mainfrom
feature/topology-loader

Conversation

@ankenman
Copy link
Copy Markdown
Owner

Add JSON topology loading

Introduces TopologyLoader to construct and wire SoC modules from a JSON
file, replacing the hardcoded topology in main.cpp.

Topology file format:

  • modules: array of {name, type, id, neighbors, config}
  • module types: initiator, home_agent, target, interconnect
  • neighbors: list of module names this module connects to (symmetric;
    loader dedupes when the same edge appears in both endpoints' lists)
  • config: per-module knob overrides

The loader:

  • Parses JSON, validates schema and module types
  • Constructs each module via a type-specific factory method
  • Applies per-module config blocks to the knob system
  • Wires neighbors by allocating ports keyed by neighbor id and binding
    the resulting port pairs

Module refactoring for topology-driven construction:

  • Initiator, HomeAgent, Target: constructor takes only (sim, sys, id,
    name); previously type-specific args like clock_period_ps,
    home_id, downstream_target_id, and data_latency_cycles. These are now
    knobs, captured in elaborate().
  • WorkQueues and TransactionQueue (which depend on clock_period_ps or
    tq_capacity) become unique_ptr members, constructed in elaborate()
    after knobs are finalized.
  • Port management moves to Module base: each module owns a port_map
    keyed by neighbor id, via add_port(neighbor_id) and get_port(...).
    Single-port agents use single_port() helper.
  • Callback registration (on_receive) moves to elaborate(), running
    after the loader has allocated ports.
  • Interconnect's attach() removed; the loader's wire_neighbors handles
    what attach used to do.

Port: store peer as a pointer instead of snapshotting the callback at
bind time. This allows on_receive to be registered after bind, which
the new construction order requires.

Main.cpp: phases reduced to parse_command_line (non-strict) →
loader.load(topology_file) → check_for_help → parse_command_line
(strict) → elaborate_all → tracer setup → start_all → run.

Adds --topology command-line flag handled in csim::config
alongside --config and --json.

Tests: topology_loader_test covers smoke, construction, config block
application, neighbor wiring, and error cases (duplicate names,
unknown types, unknown neighbors).

ankenman added 4 commits May 23, 2026 15:17
Introduces TopologyLoader to construct and wire SoC modules from a JSON
file, replacing the hardcoded topology in main.cpp.

Topology file format:
- modules: array of {name, type, id, neighbors, config}
- module types: initiator, home_agent, target, interconnect
- neighbors: list of module names this module connects to (symmetric;
  loader dedupes when the same edge appears in both endpoints' lists)
- config: per-module knob overrides

The loader:
- Parses JSON, validates schema and module types
- Constructs each module via a type-specific factory method
- Applies per-module config blocks to the knob system
- Wires neighbors by allocating ports keyed by neighbor id and binding
  the resulting port pairs

Module refactoring for topology-driven construction:
- Initiator, HomeAgent, Target: constructor takes only (sim, sys, id,
  name); previously type-specific args like clock_period_ps,
  home_id, downstream_target_id, and data_latency_cycles. These are now
  knobs, captured in elaborate().
- WorkQueues and TransactionQueue (which depend on clock_period_ps or
  tq_capacity) become unique_ptr members, constructed in elaborate()
  after knobs are finalized.
- Port management moves to Module base: each module owns a port_map
  keyed by neighbor id, via add_port(neighbor_id) and get_port(...).
  Single-port agents use single_port() helper.
- Callback registration (on_receive) moves to elaborate(), running
  after the loader has allocated ports.
- Interconnect's attach() removed; the loader's wire_neighbors handles
  what attach used to do.

Port: store peer as a pointer instead of snapshotting the callback at
bind time. This allows on_receive to be registered after bind, which
the new construction order requires.

Main.cpp: phases reduced to parse_command_line (non-strict) →
loader.load(topology_file) → check_for_help → parse_command_line
(strict) → elaborate_all → tracer setup → start_all → run.

Adds --topology <file> command-line flag handled in csim::config
alongside --config and --json.

Tests: topology_loader_test covers smoke, construction, config block
application, neighbor wiring, and error cases (duplicate names,
unknown types, unknown neighbors).
@ankenman ankenman merged commit 629ea16 into main May 23, 2026
2 checks passed
@ankenman ankenman deleted the feature/topology-loader branch May 23, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant