Project Defines
Compile-time defines for OCAH RTL: the names that apply across OCAH, then
the defines specific to one subsystem. Set the OCAH names in this chapter. Do
not set vendor preprocessor names; hw/common/defs/ocah_vendor_defines.svh
derives the aliases those names imply. OCAH lint and Yosys force-include that header. Native DV expands the
same aliases onto the command line. An adopter compile must do one of those
two. Block-selection defines ride the Bender filelist as define lines
(Synthesis filelist defines); do not restate
them on the command line.
A / define in a header is visible only in compilation units that include
it. Command-line `define-D is global. Force-include (or the flow’s
alias expansion) is what makes the mapping apply to vendored files that never
include an OCAH header.
1. SIMULATION
SIMULATION selects the verification view of OCAH RTL. Set it on every
simulation compile and on no other kind of build:
+define+SIMULATION # VCS, Xcelium
-DSIMULATION # Verilator, Icarus
OCAH’s own DV flows set it; a compile driven by an adopter’s testbench does not.
|
Do not let |
Without the define, these testbench hooks are not compiled in and the plusargs are silently ignored:
| Plusarg | Effect |
|---|---|
|
|
|
Loads the shadow registers from a hex image. Takes effect only alongside
|
|
Preloads |
|
Arms every |
The define also zeroes the RMA and security-disable token and digest bits in
efuse_token_processing at time 0, which have no reset and otherwise power up
X, and routes OpenTitan assertion failures in the SEP prim_assert shim to
$error on non-UVM runs.
Two model families it enables make simulation deliberately non-deterministic:
prim_flop_2sync, its Adams Bridge equivalent, and the OCAH
prim_sync3 / prim_sync4 cells insert prim_cdc_rand_delay ahead of the
synchronizer, which +cdc_instrumentation_enabled=1 arms, and
prim_lfsr and prim_double_lfsr randomize their default seed on simulators
other than Verilator (+prim_lfsr_use_default_seed=1 pins it). Two runs of one
test are therefore not identical unless the simulator seed is fixed; record the
seed with any failure you intend to reproduce.
2. SYNTHESIS
SYNTHESIS selects the implementation view: simulation-only SVA, $readmemh
preload, procedural delays, and similar non-synthesizable paths are omitted.
Slang lint, Verilator lint, and Yosys set it (OCAH_FLOW_COMMON_DEFINES, or
+define+SYNTHESIS=1 for Verilator lint). The Bender synth view emits
+define+SYNTHESIS=1 on its filelist, so a synthesis compile that consumes
the filelist’s defines (below) gets it without
tool setup; Synopsys tools also predefine the name. Native DV does not set
it, except the SMC dual target, which lists it next to SMC_DUAL. The open
formal path (sby / read_slang) keeps it defined. Licensed formal backends
leave it unset.
3. EMULATION
EMULATION selects the emulation view of OCAH RTL: synthesizable RTL for a
hardware emulator (Palladium, Zebu, and similar) that keeps the debug hooks an
emulator can map into hardware. Set it on the emulator compile, and set neither
SIMULATION nor SYNTHESIS alongside it:
+define+EMULATION
| Compiled in | Compiled out |
|---|---|
Concurrent and immediate assertions, cover and assume: first-party, OpenTitan, Adams Bridge, Caliptra, and PULP macros. |
Procedural delays. |
Elaboration-time parameter checks. |
Random CDC delay models and randomized seeds. |
|
Testbench handshake |
|
DPI exports, and the |
|
EMULATION takes precedence over SYNTHESIS in first-party RTL and in the
vendored assertion headers, so a compile where the tool predefines SYNTHESIS
still gets the view above. Generated RTL (the SMC CPU cluster and the register
blocks) and vendored logic outside the assertion headers still follow
SYNTHESIS, so a compile that sets both loses their elaboration checks and
debug messages. First-party RTL gives EMULATION precedence over SIMULATION
too, but vendored CDC delay models and seed randomization follow SIMULATION
whatever else is set.
The vendor aliases need the force-include or alias expansion described at the
top of this chapter; without it, PULP assertions follow SYNTHESIS and
ASSERTS_OFF instead.
In the emulation view the entropy source ring oscillator is a zero-delay combinational loop. The emulator compile must break or model it.
The emulation view has no testbench preloads. OCAH4CORECluster_rom_ext is a
prim_rom with an empty MemInitFile, so load the SMC CPU ROM image through
the emulator’s memory backdoor. Fuse sense reads the bank through the adopter’s
SHIM, which the emulation must model.
Do not set SYNTHESIS in order to keep emulator debug hooks; SYNTHESIS
strips assertions as well. Do not set PULP_FPGA_EMUL as a substitute:
that name is an FPGA clock-mux path.
4. Tool predefined names
Simulators and frontends define these themselves. Restate them only on that
tool’s compile line. Do not put them in a Bender filelist shared with other
tools, and do not add a Bender target named verilator (flist-plus would emit
+define+TARGET_VERILATOR into that shared .f).
| Define | Role |
|---|---|
|
Verilator’s predefine. First-party and OpenTitan SVA leave their include-assert macros undefined. |
|
VCS predefine. Some PULP AXI files branch on it. |
|
Xcelium’s predefine. Native DV uses this tool. |
|
Vivado simulator. PULP assertion macros also treat it as off. |
|
QuestaSim’s predefine. Some PULP AXI files branch on it. |
|
Auto-defined by yosys-slang. The Yosys |
5. Native DV extras
An adopter that copies the native profile sees these in addition to
SIMULATION. They are not required to elaborate OCAH RTL for silicon.
| Define | Role |
|---|---|
|
Chisel/FIRRTL random-init hooks on the generated SMC cluster. Native DV zero-fills rather than randomizing. |
|
SV-UVM framework overlay. Assertion headers report through |
|
Strips inline assertion blocks inside PULP |
|
Turns off PULP |
6. Derived assertion gates
Do not set these. Headers define them from the view and tool names above.
| Define | Defined when |
|---|---|
|
First-party debug checks and messages. |
|
First-party concurrent SVA. |
|
OpenTitan-derived SVA: off under |
|
PULP |
|
Optional escape: drops first-party SVA only. No OCAH flow sets it. |
No define gates the first-party parameter and width checks. OCAH_ASSERT_STATIC
evaluates them at elaboration in every view and tool, Verilator and synthesis
included, so a configuration that fails one does not elaborate.
7. Vendor aliases
ocah_vendor_defines.svh defines these from the OCAH names. Do not set the
vendor column.
| OCAH name | Vendor alias |
|---|---|
|
|
|
|
|
|
|
|
|
|
8. Adopter overlay hooks
No checked-in config sets these. An adopter overlay
(run_dv.py --overlay) may append them.
| Define | Role |
|---|---|
|
Nests a commercial JTAG verification interface. |
|
Nests a commercial AXI verification interface. |
9. Subsystem defines
Each subsystem graph reads the view, tool and assertion names above as this chapter describes. The sections below cover the defines the rest of the chapter does not: two shared cells, then each subsystem in turn.
9.1. Shared cells
Two cells in hw/common/ocah_prim, compiled into every subsystem graph, read
a define of their own. Leave both unset.
| Define | Reason |
|---|---|
|
In the simulation view, |
|
Adds a test-master APB port set to |
9.2. SMC
The SMC graph adds three groups: first-party simulation hooks, the generated CPU cluster macros, and the i3c-core configuration.
9.2.1. Simulation hooks
The SIMULATION plusargs for the CPU ROM and the eFuse shadow registers are
listed under SIMULATION. The SMC RTL also reads these view names:
smc_4core_cpu prints scratch RAM initialization progress when neither
SYNTHESIS nor EMULATION is set.
The prim_flop_2sync, prim_sync3 and prim_sync4 synchronizers instantiate
prim_cdc_rand_delay in the simulation view, but no smc Bender target lists
prim_cdc_rand_delay.sv. Add it to any SIMULATION compile of the smc
filelist; SMC DV lists it as an extra source in
hw/sys/smc/dv/smc_sim_cfg.toml.
The SMC DV dual target sets SYNTHESIS next to SMC_DUAL, so the CPU
clusters in that build get no time-zero initialization (CPU cluster).
SMC_DUAL is read only by hw/sys/smc/dv/tb/tb_top.sv, where it selects the
two-instance testbench.
9.2.2. CPU cluster
The Chipyard-generated cluster in
hw/sys/smc/rtl/smc_cpu/chipyard_generated_files/4core reads the FIRRTL
macros in the table below. It ignores EMULATION. The generated code defines
ENABLE_INITIAL_REG_ and ENABLE_INITIAL_MEM_ only when SYNTHESIS is
absent, and those gate every time-zero initializer, so a SYNTHESIS compile
reads none of the initialization macros.
| Define | Effect |
|---|---|
|
Assigns every cluster register from |
|
Assigns every generated memory array from |
|
The value both initializers assign. Defaults to |
|
Delay before the initializers run, in simulator time units. Defaults to
|
|
Code placed at the start of every generated initializer, for a custom seeding scheme. Defaults to empty. |
|
Code placed before and after every generated |
|
Expression that gates the |
|
Expression that gates the |
Each generated module also defines a default for PRINTF_COND, but the
cluster contains no printf, so that macro has no effect.
Do not set RANDOMIZE, INIT_RANDOM_PROLOG_, ENABLE_INITIAL_REG_,
ENABLE_INITIAL_MEM_, PRINTF_COND_, ASSERT_VERBOSE_COND_ or STOP_COND_.
The generated code derives them from the macros above.
9.2.3. i3c-core configuration
vendor/chipsalliance/i3c-core/upstream/src/i3c_defines.svh fixes the
i3c-core configuration: the AXI host interface (I3C_USE_AXI) and its widths,
controller and target support, loopback disabled, and the FIFO, DAT and DCT
depths. Change a value in that header, not on the command line. The header
leaves these upstream options unset:
| Define | Effect when set |
|---|---|
|
Selects an AHB host interface instead of AXI. |
|
Adds AXI ID filtering, which needs |
|
Adds exclusive-access tracking to the AXI subordinate. |
|
Multiplies the HCI and TTI IBI FIFO depths by 8. |
|
Removes the two-flop synchronizers on the SCL and SDA inputs. |
9.3. DTP
The dtp graph reads no define of its own. Two parts of it respond to the view
names:
-
jtag2axiasserts AXI valid stability and address and data pairing on its manager port whenOCAH_DEBUG_LIVEis defined. -
The
prim_flop_2sync,prim_sync3andprim_sync4synchronizers instantiateprim_cdc_rand_delayin the simulation view. The Bendersimulationtarget addsprim_cdc_rand_delay.svto thedtpgraph, so generate a simulation filelist with-t dtp -t simulation.
9.4. SEP
The SEP graph adds five groups: the Adams Bridge block-selection defines, the VeeR EL2 core configuration, first-party view checks, the key manager’s defines, and testbench-side DV names.
9.4.1. Adams Bridge
The Adams Bridge source group of the sep Bender target sets these three
defines, and flist-plus emits them ahead of the source list. Every flow that
uses the sep target gets them.
| Define | Effect |
|---|---|
|
Includes the Adams Bridge post-quantum engine: |
|
Adds the Caliptra Key Vault ports to |
|
Removes the behavioural latch gate from |
Adams Bridge also reads RV_FPGA_SCA, which adds FPGA side-channel trigger
outputs to abr_top, and FCOV, which adds a covergroup to its AHB
subordinate. No OCAH flow sets either.
9.4.2. VeeR EL2 core
The RV_* names that configure the VeeR EL2 core come from the snapshot
header vendor/chipsalliance/Cores-VeeR-EL2/overlay/snapshots/sep/common_defines.vh,
which the sep_el2 Bender target puts on the include path. Change the core
configuration by regenerating the snapshot with the veer command recorded in
its header, not with a command-line define.
The snapshot enables user mode (RV_USER_MODE), Smepmp (RV_SMEPMP) and the
AXI4 bus interface (RV_BUILD_AXI4). It leaves RV_BUILD_AHB_LITE,
RV_ASSERT_ON, RV_FPGA_OPTIMIZE, RV_PHYSICAL, RV_CLOCKGATE,
RV_LOCKSTEP_ENABLE and RV_LOCKSTEP_REGFILE_ENABLE unset.
RV_LOCKSTEP_ENABLE also changes SEP RTL. With it, sep_cpu connects
lockstep_ctrl_i and lockstep_status_o to the lockstep ports of
el2_veer_wrapper. Without it, sep_cpu ignores lockstep_ctrl_i and holds
lockstep_status_o at zero. The sep_cpu port list is the same either way.
The sep_el2 Bender target sets TECH_SPECIFIC_EC_RV_ICG, so beh_lib.sv
uses the snapshot’s user_clock_gate cell rather than its own behavioural
clock gate.
The core also reads GTLSIM, which zero-initializes its RAM models for
gate-level simulation, and DUMP_BTB_ON, which prints branch predictor
configuration and a trace of BTB events. No OCAH flow sets either.
9.4.3. First-party view checks
-
tlul_rsp_intg_genasserts that incoming response integrity and user bits are zero, where its parameters declare them zero, whenOCAH_DEBUG_LIVEis defined. -
In the simulation view,
entropy_ring_stage_wrappersadds a#1delay to each ring oscillator stage so the ring oscillates.SYNTHESISandEMULATIONdrop the delay, so a zero-delay simulation of either view has no entropy source oscillation.
9.4.4. Key manager
| Define | Effect |
|---|---|
|
Decodes the virtual ROM window, |
Without OCAH_KM_VROM, the window is an unmapped key manager address. A load
or store answers DECERR and sets KMCSR.IRQ_STATUS.AXI_DECERR, and an
instruction fetch sets KMCSR.IRQ_STATUS.EXEC_VIOLATION.
|
|
The key manager’s picorv32 core reads FORMAL, which compiles its embedded
assert and restrict properties, and the riscv-formal names
(RISCV_FORMAL, RISCV_FORMAL_ALTOPS, RISCV_FORMAL_BLACKBOX_REGS,
RISCV_FORMAL_BLACKBOX_ALU), the DEBUG* trace names and the
PICORV32_TESTBUG_* fault injections. Leave these unset outside a picorv32
formal flow.
9.4.5. DV testbench names
SEP DV sets these for hw/sys/sep/dv/tb/tb_top.sv and its CPU stub. No DUT
file reads them.
| Define | Effect |
|---|---|
|
Drives the OTP debug AXI-Lite port from the testbench instead of tying it off. |
|
Drives the SMN inbound AXI port from the testbench instead of tying it off. |
|
Routes the SMC address region to a testbench memory model. Set on the
|
|
Compiles |
The SEP DV Verilator flags set neither VERILATOR nor ASSERTS_OFF.
Verilator predefines the first; without the second, the PULP assertion macros
expand.
10. Synthesis filelist defines
The Bender synth view is the authoritative source for the defines a
synthesis compile needs. Generate the filelist from that view — or use the
filelist shipped in a release package, which is generated the same way:
bender script flist-plus <block targets> -t synth > <block>.f
The filelist carries the defines as define lines paired with the sources
they select:
SYNTHESIS=1, and the package switches that choose between behavioural
models and technology-cell overlays in vendored RTL. Consume the define
lines from the filelist rather than restating them on the tool command line:
the set changes as the tree does, and the filelist pairs each switch with the
overlay sources it selects.
|
A compile that drops the |
The filelist also lists ocah_vendor_defines.svh, but vendored packages
precede it in compile order, so it does not replace the force-include
described at the top of this chapter.
10.1. Synopsys Design Compiler and Fusion Compiler
analyze rejects a filelist as a native argument (VER-294), and
analyze -define covers only names given on that command. Hand the filelist
to the VCS-compatible reader, which parses its define and incdir
lines:
analyze -format sverilog -vcs "-f <block>.f"
These tools predefine SYNTHESIS; when the filelist restates it, Design
Compiler keeps its own value and warns (VER-1051). The value is 1 either way,
so the warning is harmless.
10.2. Cadence Genus
Genus parses the same lines through its optionfile reader. Select
SystemVerilog explicitly: read_hdl -f treats sources as Verilog-2001
regardless of the hdl_language attribute.
read_hdl -language sv -f <block>.f