Design RISC-V CPU core from description to GDSII
- Tools
- Verilator, Spike, riscv32-unknown-elf-gcc, OpenROAD-flow-scripts
- Time limit
- 4 hours
Agent is asked to design a RISC-V CPU core and take it all the way to GDSII.
Agent Input
What the agent is given: the instruction and its input files.
Design a RISC-V CPU core and take it all the way to GDSII.
The workspace is /app; start with /app/README.md, then
/app/docs/INTERFACE_CONTRACT.md and /app/docs/SCORING.md.
- What to build: implement
module core(ISArv32i_zmmul_zicsr) behind the frozen interface in/app/rtl, and list your sources and lane widths in/app/rtl/design.mk. - Functional verification: the core must pass Spike lock-step cosim on all
directed tests, in both instruction-memory models with the
RAM_DIFF=1bus cross-check, and on every Embench-IoT program (make eval). - Performance: each Embench-IoT program is run whole under the
request-gated instruction-memory model, and the geometric mean of their IPC
(instructions retired / cycles) must be at least 2.07 (
make embench). - Physical design: take
core_pnrfrom RTL to GDSII with OpenROAD-flow-scripts on ASAP7 at the TT corner usingmake pd, with your settings in/app/pd/config.mk. Sign-off must be clean: no detailed-route DRC or antenna violations, no hold or max slew/cap/fanout violations, and a fully constrained design. - Fmax: must be at least 1520 MHz, where Fmax = 1 / (clock period − worst
setup slack) from
make pdsign-off. - Die area: the routed
core_pnrmust be at most 20300 µm² (make pdreports it). - Netlist binding: the netlist that ORFS builds must behave identically to
the RTL you verified (
make check-netlist). - RTL content: no file in
/app/rtlmay use DPI imports or exports,$system,$fopen,$writememh/$writememb,$dump*, Verilator$c, or`systemc_*blocks.
Only /app/rtl and /app/pd are collected. The grader re-runs make eval,
make pd and make check-netlist from a clean copy of the workspace with your
rtl/ and pd/; make pd gets 8 CPUs and fails if it has not finished within
3.5 hours. The design must meet every requirement above.
You have 14400 seconds to complete this task. ps -o etimes= -p 1 prints the
seconds elapsed since your environment started; check it regularly rather than
estimating. If any requirement is still unmet, do not stop: keep working until
the time is nearly used up. Keep /app/rtl and /app/pd ready to submit, since
they are collected as they stand when time runs out. Do not cheat by using
online solutions or hints specific to this task.
rv32cpu task
Task
Implement a rv32i_zmmul_zicsr RISC-V CPU, verify it against the provided
tests and the Embench-IoT benchmarks using the cosim environment, and take it
from RTL to a DRC-clean GDSII with OpenROAD-flow-scripts (ORFS) on ASAP7 at
the TT corner.
The same design must also meet these requirements:
- Embench IPC ≥ 2.07: the geometric mean, over the Embench-IoT programs,
of each program's IPC (instructions retired / cycles) when run whole under
IMEM_REQ_GATE=1(make embench,docs/SCORING.md). - Fmax ≥ 1520 MHz, where Fmax = 1 / (clock period − worst setup slack) from
sign-off STA of the routed design (
make pd). - Die area ≤ 20300 µm² for the routed
core_pnr(make pd).
Quickstart
source env/setup_env.sh # pin the toolchain on PATH (RISC-V gcc + Spike in $RISCV/bin)
make check-env # hard-gate tool versions vs VERSIONS.lock (fails loudly on drift)
make smoke # RTL-free sign of life with the shipped stub (~1 min)
# after implementing `module core` and listing its sources in rtl/design.mk:
make eval # cosim (both IMEM models, RAM_DIFF=1) + Embench
make pd # RTL -> GDSII + sign-off (route DRC, antenna, STA) -> build/pd/pd_report.json
make check-netlist # the ORFS-elaborated netlist matches the RTL cycle-for-cycle
Every command assumes source env/setup_env.sh was run first. make help lists
all targets.
What you implement
The body of module core (replace rtl/core_stub.sv, or add your own files),
honoring docs/INTERFACE_CONTRACT.md: independently
configurable fetch and in-order commit widths, external synchronous 1-cycle SRAM
timing, synchronous active-high reset, and the commit_* retire-trace semantics.
ISA is RV32I + Zmmul + minimal Zicsr (-march=rv32i_zmmul_zicsr, Spike
--isa=rv32i_zmmul_zicsr_zicntr). core_pkg.sv and core_pnr.sv are provided
complete — do not change their public API (core_pnr.sv is replaced by the
original at grading).
rtl/design.mk is the single description of your design used by every flow and
by the grader: RTL_SRCS (your sources under rtl/, in compile order, including
rtl/core_pkg.sv), FETCH_LANES and COMMIT_LANES. pd/config.mk holds your
ORFS settings. Only rtl/ and pd/ are collected for grading; everything else
in the workspace is restored to its original state.
Physical design
make pd (scripts/pd/run_pd.py) runs ORFS on core_pnr exactly as the grader
does:
- platform
asap7,CORNER=TC(typical libraries), NLDM, the slang SystemVerilog front end (-D SYNTHESIS), ORFS logic-equivalence checking (LEC_CHECK=1) between the synthesized and final netlists; - sources, include dir and
VERILOG_TOP_PARAMScome fromrtl/design.mk; - the SDC is generated: clock
clkwith periodCLOCK_PERIOD_PS;core_pnrforwards it to the memories on itsmem_clkoutput (a generated clock), and all other inputs and the memory outputs have a 100 ps external delay againstmem_clkas it leaves the core: read data is valid 100 ps after its edge, and address and write data must arrive 100 ps before the next one;rstis a false path; pd/config.mkmay set only the knobs inKNOBSinscripts/pd/run_pd.py(clock period, synthesis options, utilization/density, VT selection viaASAP7_USE_VT, repair and CTS options, ...). No Tcl hooks, extra files, or extra libraries/macros are accepted. Unless set,SLEW_MARGINandCAP_MARGINdefault to 50 and 25: the percent by which ORFSrepair_designover-fixes slew and capacitance, since it works from pre-route parasitic estimates that run below the extracted values sign-off uses;- outputs go to
build/pd/(ORFSresults/,reports/,logs/under it).--keep(make pd PD_ARGS=--keep) reuses an existing run directory so ORFS only redoes out-of-date steps; the grader always starts clean. For experiments you can also drive ORFS directly with the generatedbuild/pd/config.mk.
Sign-off (scripts/pd/signoff.tcl, on the routed design with OpenRCX parasitics)
requires all of: the flow completes and writes a GDS; zero detailed-route DRC
violations (OpenROAD's router checks against the ASAP7 tech LEF rules, which is
ORFS's DRC sign-off for this platform); zero antenna violations; hold slack ≥ 0;
zero max slew/capacitance/fanout violations; and a fully constrained design
(check_setup reports nothing: every register clocked by clk, no
combinational loops). Fmax is then 1e6 / (CLOCK_PERIOD_PS − setup WNS) MHz.
Sign-off STA uses the propagated clock tree: register-to-register paths include
clock skew, and I/O paths are timed against the actual mem_clk edge at its
port, which leaves through the clock tree like any register clock.
The die area (die_area_um2 in pd_report.json) is the area of the routed
design's die box, which CORE_UTILIZATION, CORE_ASPECT_RATIO and
CORE_MARGIN size from the synthesized cell area.
make check-netlist (scripts/pd/check_netlist.py) proves that what ORFS builds
is what you verified: it takes ORFS's own elaboration of core_pnr (same front
end, defines and parameters), flattens it to a generic gate netlist and runs every
directed test and Embench-IoT program on it in tb_top. Bus-store streams, console output
and the HTIF exit cycle must match the RTL core simulation exactly. Latches are
rejected, and synthesis ignores initial values (reset state explicitly). Logic
that differs between simulation and synthesis (e.g. ifdef SYNTHESIS, or
behavior that depends on COMMIT_LOG) fails this check.
Grading
The grader starts from a clean copy of this workspace plus your rtl/ and pd/,
then runs make eval (all directed tests in both IMEM models with RAM_DIFF=1,
and Embench), make pd, and make check-netlist. make pd gets 8 CPUs
and fails if it has not finished within 3.5 hours. The task passes only if every
requirement is met.
Toolchain (pinned; gated by make check-env, authoritative strings in VERSIONS.lock)
| Tool | Version |
|---|---|
| Verilator | 5.032 |
| Spike | 1.1.1-dev |
| riscv32-unknown-elf-gcc | 16.1.0 |
| python3 | 3.14.4 |
| pip | 25.2 |
| ORFS (OpenROAD, Yosys, KLayout) | openroad/orfs:26Q4-421-g73c804d45 at /OpenROAD-flow-scripts |
The self-eval flows use only the Python standard library + a hand-rolled C++ ELF
loader — no vcdvcd, numpy, pandas, pyelftools, or cocotb.
Layout
env/ version/PATH gate (check_env.sh, setup_env.sh); VERSIONS.lock (repo root) pins versions
rtl/ core_pkg.sv, core_stub.sv (replace), core_pnr.sv, design.mk (your source list + widths)
pd/ config.mk (your ORFS knobs)
sim/ Spike lock-step cosim harness (tb_top.cpp + cosim_diff.py + run_cosim.sh)
sw/ bare-metal runtime, directed test ladder, Embench-IoT (embench/: src/, build/ ELFs, build.sh)
docs/ interface contract and scoring
scripts/ pd/ (ORFS flow, sign-off, netlist check)
| Doc | Covers |
|---|---|
docs/INTERFACE_CONTRACT.md | the binding core interface (ports, memory, reset, commit trace, ISA) |
docs/SCORING.md | how Embench IPC is measured (task grading is under "Grading" above) |
Grading & Reference Solution
How the submission is scored, and a human expert-authored reference solution.
Gates
rtl/ and pd/ well formed; RTL uses no forbidden construct.
- design.mk valid · Lists existing .sv/.v sources under rtl/ (RTL_SRCS) and positive lane widths, FETCH_LANES ≤ 8.
- config.mk valid · Sets CLOCK_PERIOD_PS and only allowed ORFS knobs, each in range; no Tcl hooks, extra files or libraries.
- RTL content rules · No DPI, $system, $fopen, $writemem*, $dump*, Verilator $c or `systemc_* in rtl/ (comments ignored).
Matches Spike; physical design signs off clean; ORFS netlist is the verified RTL.
- Directed cosim · 15 directed tests match Spike instruction by instruction to exit, with RAM_DIFF=1 bus cross-check.
- Directed cosim, request-gated · Same 15 tests with strict request-gated instruction memory.
- Embench-IoT lock-step · 19 Embench-IoT programs match Spike to exit, request-gated memory.
- Flow completes · make pd: OpenROAD-flow-scripts on core_pnr (ASAP7, typical corner) through GDSII and sign-off.
- Route DRC clean · Detailed-route DRC violations against the ASAP7 tech LEF rules.
- Antenna clean · Nets with antenna violations.
- Hold met · Sign-off hold slack on the routed design with OpenRCX parasitics.
- No design-rule violations · Max slew, max capacitance and max fanout violations at sign-off.
- Fully constrained · check_setup: no unconstrained paths, every register clocked by clk, no combinational loops.
- Fmax measured · Fmax = 1e6 / (CLOCK_PERIOD_PS − setup WNS) MHz, from sign-off slack.
- Netlist matches RTL · ORFS gate netlist runs all tests and programs; bus stores, console, exit cycle equal RTL's; no latches.
Instructions per cycle on Embench-IoT.
- Embench IPC · Geometric mean over 19 programs of instruction count / cycles from reset to exit store.
Scored Categories
Clock rate and area, in one check.
- Fmax and die area · Fmax from sign-off setup slack (only if sign-off clean); die area of routed core_pnr.
