Feature/topology loader#10
Merged
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
loader dedupes when the same edge appears in both endpoints' lists)
The loader:
the resulting port pairs
Module refactoring for topology-driven construction:
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().
tq_capacity) become unique_ptr members, constructed in elaborate()
after knobs are finalized.
keyed by neighbor id, via add_port(neighbor_id) and get_port(...).
Single-port agents use single_port() helper.
after the loader has allocated ports.
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).