PitonConfig
PitonConfig, in chia_openpiton/state_def.py, describes one OpenPiton configuration and names the model directory its build lives in. It is a frozen dataclass: assigning to a field raises dataclasses.FrozenInstanceError. configure() returns a PitonConfig with the checkout’s revisions filled in. Code can also construct one directly, as MACE’s loop does for each task.
Fields
Field |
Type |
Default |
Meaning |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
Mesh width |
|
|
|
Mesh height |
|
|
|
|
|
|
|
RTL define names |
|
|
A copy of |
Cache name to |
|
|
|
Further |
|
|
|
Checkout commit, set by |
|
|
|
Ariane submodule commit, set by |
|
|
|
|
|
|
|
Unstaged diff under |
|
|
|
Hash of the edits a caller applied with apply_edits() for this build |
|
|
|
For |
Constants
DEFAULT_CACHES = {
"l1i": (16384, 4),
"l1d": (8192, 4),
"l15": (8192, 4),
"l2": (65536, 4),
}
MAX_TILES_PER_AXIS = 256
COVERAGE_LINE_FLAG = "-vlt_build_args=--coverage-line"
ARIANE_WAY_RULE = "On Ariane, neither the L1D nor the L1I may have more ways than the L1.5."
DEFAULT_CACHES mirrors piton/tools/src/sims/manycore.config. Each cache name fills the <name> in -config_<name>_size and -config_<name>_associativity. MAX_TILES_PER_AXIS matches the limit sims enforces with DIE. x_tiles can be at most 256. Adding COVERAGE_LINE_FLAG to extra_flags turns on Verilator line coverage (see Code Coverage).
Validation
__post_init__ raises ValueError on an invalid configuration:
Condition |
Example message |
|---|---|
Unknown core |
|
Tile count not an |
|
Tile count outside 1 to 256 |
|
Unknown network |
|
Unknown cache name |
|
Size or associativity not positive |
|
__post_init__ does not check sys.
After validation it fills in each cache a caches mapping leaves out from DEFAULT_CACHES, and stores every geometry as a tuple.
Derived values
Member |
Value |
|---|---|
|
|
|
SHA-256 hex digest of the configuration’s identity |
|
|
|
|
|
The |
|
One line per L1 that has more ways than the L1.5, such as |
Ariane’s way rule
Ariane’s L1.5 adapter, core/cache_subsystem/wt_l15_adapter.sv in the Ariane submodule, asserts ARIANE_WAY_RULE, but inside `ifndef VERILATOR.
A Verilator build of a configuration that breaks the rule therefore compiles and runs.
build() refuses such a configuration instead, and a co-design search rejects one before building it.
key and build_id
key hashes a JSON object, serialized with sorted keys, that holds sys, core, x_tiles, y_tiles, network_config, config_rtl (sorted), caches (sorted by name), extra_flags (in order), source_rev, ariane_rev, verilator_version, and diff, plus source_edits and generic_core when they are set, so a key recorded before those fields existed stays the same. build() passes build_id to sims as -build_id. sims writes every model to rel-0.1 by default, so without a per-configuration ID two configurations overwrite each other’s model.
caches always holds all four caches, so a mapping that names only some of them and the same mapping with the defaults written out share a key and a model directory.
Earlier versions hashed a partial mapping as given.
A model they built from one sits under a build ID that nothing computes now, so that configuration builds once more.
Beyond the configuration fields, the key covers source_edits, which the caller sets, and what configure() records: the committed revision, the Ariane submodule commit, the Verilator version, and the unstaged diff under piton/verif/env/manycore. Edits anywhere else in the working tree leave the key unchanged. A directly constructed PitonConfig leaves those four fields empty, so its key depends on the configuration fields alone. The build cache covers the rest of the checkout: build() reuses a model only while the checkout’s source fingerprint matches the one recorded when the model was built.
sims_flags()
For sys="manycore", sims_flags() emits these flags in order:
Source |
Flags |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
No flag |
|
|
|
|
|
Each flag, verbatim |
The default configuration produces:
-sys=manycore -x_tiles=1 -y_tiles=1 -network_config=2dmesh_config -ariane
-config_rtl=MINIMAL_MONITORING
-config_l15_size=8192 -config_l15_associativity=4
-config_l1d_size=8192 -config_l1d_associativity=4
-config_l1i_size=16384 -config_l1i_associativity=4
-config_l2_size=65536 -config_l2_associativity=4
-network_config is always explicit. Left unset, sims defaults to the string 2d_mesh, which pyhplib.py does not recognise. For pico, -rv32_target_triple makes piton/tools/bin/rv32_as use the installed riscv64-unknown-elf-gcc for rv32ima/ilp32 instead of a riscv32-unknown-elf toolchain (see PicoRV32). Every cache gets both flags, including one the caches mapping left out.
For any other sys, sims_flags() returns -sys=<sys> followed by extra_flags. The mesh, core, and cache fields still count toward key.
extra_flags carries anything else sims accepts. For example, -rv64_march=rv64imafdc_zicsr_zifencei lets OpenPiton’s diags assemble under binutils 2.38 and later.