- Introduced test status signals (test_done_o, test_pass_o, test_code_o) in sysctrl interface and module. - Updated memory map to include TEST_STATUS offset. - Enhanced retrosoc_tb to monitor test completion and report results. - Modified Emulator to handle test status and return appropriate exit codes. - Updated formal verification to include assertions for test status. - Added CoreMark log parsing script and integrated it into the regression tests. - Implemented tests for test status handling in sysctrl_fault_tb. - Adjusted simulation success and failure markers in various scripts and tests. - Ensured compatibility with existing performance logging and regression testing frameworks.
10 KiB
retroSoC Agent Development Contract
This file is the repository entry point for coding agents. Read it before changing code, build rules, dependencies, or quality policy. If this document conflicts with executable configuration or policy, the executable source of truth wins.
Repository Map and Sources of Truth
- README.md defines supported profiles, prerequisites, common flows, and release outputs.
- docs/engineering.md defines reproducible inputs, artifact layout, warning baselines, metric promotion, and CI behavior.
- docs/misra-c-2012.md defines the embedded-C MISRA baseline and quality/misra/deviations.md records approved Required-rule deviations.
- crt/README.md defines the freestanding RISC-V runtime and SDK layout; app/README.md defines application composition.
Makefile,rtl/mini/mk/software.mk, committedconfigs/*.mk, and the GitHub workflows define the active build and regression behavior.quality/embedded_c_policy.json,quality/warnings/, andquality/metrics/policy.jsondefine the active quality policy.
Do not guess a profile, tool version, dependency revision, or generated-file location. Inspect the corresponding source of truth first.
Top-Level Directory Guides
Every Git-tracked first-level directory has a README that defines its ownership and validation boundary.
| Directory | Guide | Role |
|---|---|---|
.github/ |
.github/GUIDE.md | CI, release automation, reusable actions, and ownership metadata. |
app/ |
app/README.md | Firmware applications and integrations. |
config/ |
config/README.md | Locked external inputs and checksums. |
configs/ |
configs/README.md | Reproducible build profiles. |
crt/ |
crt/README.md | Freestanding runtime and SDK. |
docs/ |
docs/README.md | Engineering and MISRA policy. |
fpga/ |
fpga/README.md | FPGA wrapper and board constraints. |
licenses/ |
licenses/README.md | Third-party notices and license texts. |
pd/ |
pd/README.md | Physical-design entry points. |
pdk/ |
pdk/README.md | Managed PDK and technology inputs. |
quality/ |
quality/README.md | Executable quality policy and baselines. |
requirements/ |
requirements/README.md | Pinned Python tool requirements. |
rtl/ |
rtl/README.md | RTL, testbench, and SoC integration. |
scripts/ |
scripts/README.md | Build, setup, regression, and quality helpers. |
sta/ |
sta/README.md | Static timing analysis. |
syn/ |
syn/README.md | Synthesis and source export. |
tests/ |
tests/README.md | Host C and Python test suites. |
Do not create project documentation inside generated/local roots such as
build/, .cache/, .sw_build/, or tool caches, or inside managed vendor
subtrees. When adding a new Git-tracked first-level directory, add a concise
README that states its ownership, source of truth, and validation expectations.
Ownership and Architecture
crt/is the freestanding SDK. Its active layers arearch/riscv,include/retrosoc/{core,hal,lib,service},src/{core,hal,lib,service}, andlinker.app/is the application layer. Its active areas areapps,board,media,middleware,network,ports, andbenchmark.- Consume SDK interfaces through
<retrosoc/...>public headers. Use thers_API namespace andrs_status_tfor operations that can fail. - Applications are selected by
APP. The supported values arebenchmark,bringup,debug, andshell; each profile is declared inapp/apps/<name>/app.mk. Thedebugapplication is an RTL debug-transport acceptance image, not a user-facing firmware profile. - Do not add new dependencies on
crt/inc, retiredtinynames, or legacyrs_*.h/tiny*.hinclude paths. - Treat
app/coremark/coremark-main,app/fatfs/ff16,app/lvgl/lvgl-main, and managed ports as third-party or managed code. Update them through their setup/integration flow, not as ordinary project source.
Embedded C Rules
- Self-owned
crt/andapp/C/H code follows MISRA C:2012 with Amendment 2. The exclusions inquality/embedded_c_policy.jsonare authoritative; do not claim MISRA conformance for excluded vendor, generated, compatibility, port, assembly, or linker material. - Mandatory rules are not waived. Required-rule deviations need a reviewed
record in
quality/misra/deviations.md; Advisory-rule exceptions require a proportionate review rationale. Current automated checks enforce only a partial mechanical subset, not complete MISRA certification. - Keep SDK code freestanding: do not introduce hosted-library, dynamic-memory, or operating-system dependencies.
- Follow the project
.clang-formatstyle withclang-format-14, the version installed by CI. The formatter and policy gates cover self-owned C and header files, not all generated, assembly, or vendor files. - Outside approved compatibility files, do not introduce
strcpy,strcat,strncpy,sprintf,vsprintf,malloc,free, oratoi. - Prefer bounded interfaces (
rs_strlcpy,rs_strlcat,rs_snprintf) and timeout-based register waits. Check inputs, overflow boundaries, and error returns at SDK/API boundaries. - Place public headers in the matching
include/retrosoc/<layer>/directory and implementations in the corresponding source layer. Add deterministic host tests for logic that does not require real registers or board timing.
Build and Repository Safety
- Start from a committed configuration profile. Build products belong below
build/<profile>-<YYYY-MM-DD-HH-MM>-<config-hash>/; caches belong below.cache/. Do not commit generated outputs. - Preserve unrelated worktree changes. Do not reset, discard, or reformat files outside the requested scope.
- All external repositories, archives, checksums, and locked tool versions are
controlled by
config/dependencies.lock.json. Do not add direct downloads to workflows or setup scripts. Use the shared dependency helpers and review a full Git revision or SHA-256 checksum when updating the lock. - Do not hand-edit warning baseline signatures. Regenerate only an affected baseline from a successful flow, review every normalized signature, and keep baseline changes separate from the implementation change they approve.
- Metrics are currently in
observemode. Do not promote them to a blocking gate without the documented ten successfulmainruns and reviewed baseline.
Required Validation
Run the smallest relevant set locally, then report any gate that was not run and why. CI is authoritative for toolchain-dependent flows.
| Change area | Minimum validation |
|---|---|
| Markdown or documentation | Verify links and commands, then run git diff --check. |
Self-owned crt/ or app/ C/H |
Review applicable MISRA rules and deviations; run make sw-format-check sw-policy-check sw-host-test; build an affected committed profile with make CONFIG=<profile> firmware. |
| Deterministic SDK or media logic | Extend tests/c/test_runtime.c and run make sw-host-test. |
| Python/build tooling | ruff check . and python3 -m pytest -q. |
| Dependency-lock or setup changes | python3 scripts/dependency_lock.py --lock config/dependencies.lock.json, affected setup update/doctor flow, Pytest, and affected regression. |
| GitHub Actions or CI definitions | yamllint .github .yamllint.yml, actionlint, and python3 scripts/regress.py --root . --suite pr --dry-run plus --suite nightly --dry-run. |
| RTL, configuration, linker, or hardware-facing changes | Run the affected firmware build and simulator; use make regress-pr for the supported PR matrix and make regress-nightly for extended coverage. |
The fast CI quality gate also validates the dependency lock, Python lint, embedded-C formatting and policy, host tests, Pytest, YAML, GitHub Actions, and both regression definitions. The regression CI runs supported Verilator and Icarus simulations, Yosys synthesis, Icarus netlist simulation, OpenSTA timing, warning checks, and metric collection.
Regression Verdicts and Known Conditions
- Automated firmware completes by writing SYSCTRL
TEST_STATUS: bit 31 is valid, bit 0 is pass, and bits 15:8 contain a result code. The first valid full-word write is sticky until reset. Testbenches emitSIM_TEST_PASSorSIM_TEST_FAIL; UART startup output is diagnostic only. A simulation passes only when its command succeeds, its log contains the configured success marker, and the log contains noFAILED,FATAL,assertion failed,%Error,SIM_TEST_FAIL, orSIM_TEST_TIMEOUTmarker. - New self-owned C compiler warnings fail the regression. New or increased EDA
warning signatures make
check-warningsfail when invoked directly, but the regression runner records them as non-blocking observations so CI uploads the warning and metric reports; resolved warnings are reported. check-metricsrecords firmware size, area, cell count, timing, and flow duration. It is non-blocking in the regression runner, including if a future policy changes the standalone command into a gate.- Verilator currently runs through
scripts/run_flow.py, which captures the emulator stdout in a pipe. UART output can therefore appear only after a newline or when simulation ends. Treatsim.logandresult-sim*.jsonas the verdict; delayed terminal UART display is a known operational condition, not evidence that the simulation has failed.
Before Hand-off
- State the selected profile and commands run.
- Summarize code, configuration, and public-interface changes separately.
- Report validation results, applicable MISRA deviations, and explicitly identify unrun gates.
- Mention any remaining hardware, timing, vendor, or simulator coverage gap.