Skip to content

Commit a91dd88

Browse files
[doc] Expand README, incl. porting notes
Some further improvements to the README, including some notes on porting top-level DV from OpenTitan to Sunburst Chip.
1 parent 711f133 commit a91dd88

File tree

1 file changed

+81
-8
lines changed

1 file changed

+81
-8
lines changed

README.md

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,26 @@
22

33
**Sunburst Chip** is an open-source microcontroller chip design based around the CHERI-enabled [CHERIoT Ibex](https://github.com/microsoft/CherIoT-ibex) RISC-V core.
44

5-
This repository hosts the logical design, verification environment, and associated bare-metal test software for Sunburst Chip.
5+
This repository hosts the logical design, design verification (DV) environment, and associated bare-metal test software for Sunburst Chip.
66
It has been put together by [lowRISC C.I.C.](https://lowrisc.org/)
77

88
Sunburst Chip is part of the [Sunburst Project](https://www.sunburst-project.org) funded by [UKRI](https://www.ukri.org/) / [DSbD](https://www.dsbd.tech/) under grant number 107540.
99

10+
## Contents
11+
12+
Major sections below include:
13+
14+
- [Overview](#overview)
15+
- [Dependencies](#dependencies)
16+
- [Test software](#test-software)
17+
- [Top-level Xcelium simulation](#top-level-xcelium-simulation)
18+
- [Top-level Verilator simulation](#top-level-verilator-simulation)
19+
- [Block-level Xcelium simulation](#block-level-xcelium-simulation)
20+
- [Sonata XL development board](#sonata-xl-development-board)
21+
- [Vendoring](#vendoring)
22+
- [Porting](#porting)
23+
- [Licence](#licence)
24+
1025
## Overview
1126

1227
Sunburst Chip combines the CHERIoT Ibex core with a useful selection of peripherals (amongst other bits) from the open-source [OpenTitan](https://github.com/lowRISC/opentitan) project, along with some bits from the open-source [Sonata](https://github.com/lowRISC/sonata-system) project.
@@ -63,8 +78,13 @@ Some parts of Sunburst Chip are currently using temporary workarounds that must
6378
Key pre-tapeout actions include (but are not be limited to):
6479

6580
- Implement a true random number generator
66-
- Currently generate pseudo-random numbers in `dif_rv_core_ibex_read_rnd_data`.
67-
- Possibly want to replicate the interface in [OpenTitan `rv_core_ibex`](https://opentitan.org/book/hw/ip/rv_core_ibex/doc/registers.html#rnd_data) for software compatibility.
81+
- Currently, pseudo-random numbers are generated in `dif_rv_core_ibex_read_rnd_data` due to the lack of true random numbers.
82+
- May want to replicate the interface in [OpenTitan `rv_core_ibex`](https://opentitan.org/book/hw/ip/rv_core_ibex/doc/registers.html#rnd_data) for software compatibility.
83+
- Implement a real reset and clock manager.
84+
- Currently, there are only simulation and FPGA-specific implementations.
85+
- Implement top-level tests for all blocks for which performing integration testing makes sense.
86+
- Currently, only some key blocks have top-level tests defined in [*top_chip_sim_cfg.hjson*](hw/top_chip/dv/top_chip_sim_cfg.hjson).
87+
- Triage the many TODOs throughout the codebase.
6888

6989
## Dependencies
7090

@@ -157,9 +177,12 @@ The primary simulator for running top-level tests is Xcelium, via DVsim.
157177
Note that DVsim does not build the test software for you.
158178
It must have already been compiled using the instructions in the [Test software section](#Test-software) before you call DVsim.
159179

180+
All DVsim tests and test sets are defined in [*top_chip_sim_cfg.hjson*](hw/top_chip/dv/top_chip_sim_cfg.hjson).
181+
Each test
182+
160183
### Build & run
161184

162-
The **`smoke` regression test set** (defined in top_chip_sim_cfg.hjson) can be built and run under Xcellium using the following commands:
185+
The **`smoke` regression test set** can be built and run under Xcellium using the following commands:
163186

164187
```sh
165188
# -- Build and run top-level `smoke` regression set using Xcelium --
@@ -169,7 +192,7 @@ The **`smoke` regression test set** (defined in top_chip_sim_cfg.hjson) can be b
169192
./hw/vendor/lowrisc_ip/util/dvsim/dvsim.py ./hw/top_chip/dv/top_chip_sim_cfg.hjson -i smoke
170193
```
171194

172-
**Single tests** (also defined in top_chip_sim_cfg.hjson) can be specified in the same way, such as `usbdev_vbus_test`:
195+
**Single tests** can be specified in the same way, such as `usbdev_vbus_test`:
173196

174197
```sh
175198
# -- Build and run the `usbdev_vbus_test` top-level test using Xcelium --
@@ -314,7 +337,7 @@ hw/vendor/lowrisc_ip/util/dvsim/dvsim.py hw/vendor/lowrisc_ip/ip/usbdev/dv/usbde
314337

315338
Like the top-level DVsim tests, artefacts end up under *scratch/* and additional output can be generated using the `-w shm` and `-v h` options.
316339

317-
## Sonata XL board
340+
## Sonata XL development board
318341

319342
Sonata XL is an FPGA-based development board developed by [NewAE Technology Inc.](https://www.newae.com/).
320343
It is a larger sibling of the more common Sonata development board and is intended for emulating sunburst-chip.
@@ -429,7 +452,12 @@ picocom /dev/ttyUSB2 -b 1500000 --imap lfcrlf
429452

430453
## Vendoring
431454

432-
Newer versions of vendored code, or new patches, can be vendored in using the following command:
455+
Many blocks in the design and associated code have been imported from the Ibex, OpenTitan, and Sonata repositories using the 'vendor' flow.
456+
The goal is to import select parts of the target repositories, optionally from a particular revision, and automatically apply local patches that make Sunburst Chip-specific changes.
457+
The [*vendor.py*](util/vendor.py) script automates this process based on the *\*.vendor.hjson* configuration files in *hw/vendor*.
458+
All the vendored code ends up in subdirectories under *hw/vendor*.
459+
460+
The vendoring flow can be run using the following command:
433461

434462
```sh
435463
# -- Apply patches to vendored OpenTitan IP --
@@ -438,6 +466,51 @@ Newer versions of vendored code, or new patches, can be vendored in using the fo
438466
util/vendor.py --update -Dupstream.rev=5ad6963fa71a63b4cc7817fb3bae5052c796bfc1 --verbose hw/vendor/lowrisc_ip_earlgrey_v1.vendor.hjson
439467
```
440468

469+
If the target *.vendor.hjson* file does not specify specific revision, then the `-Dupstream.rev` option is redundant.
470+
Otherwise (when *.vendor.hjson* specifies a branch), dropping the `-Dupstream.rev` option will cause code from a newer revision of the relevant repository to be imported.
471+
472+
## Porting
473+
474+
Modifying and integrating the imported blocks and associated code is often more involved than simply vendoring it in, particularly for top-level verification.
475+
Porting top-level DV elements such as UVM agents, virtual sequences (vseq), and test software for an OpenTitan block can be take days to weeks depending on the complexity.
476+
Factors include the complexity of the top-level DV for that block, applicable differences between OpenTitan and Sunburst Chip (e.g. PLIC interrupt granularity), and familiarity with the two projects.
477+
478+
Here are some notes on common steps required when porting top-level DV for a block from OpenTitan to Sunburst Chip:
479+
480+
- UVM agent integration (for I/O blocks)
481+
- Add and connect to the DUT the appropriate virtual interface (such as `spi_if`) in the testbench *hw/top_chip/dv/tb/tb.sv* for export using `uvm_config_db`.
482+
- This may require adding an enable signal if the DUT connections need to be shared with a DPI model.
483+
- OpenTitan has an additional level of interface in the form of [chip_if.sv](https://github.com/lowRISC/opentitan/blob/earlgrey_1.0.0/hw/top_earlgrey/dv/env/chip_if.sv), but this has been omitted to keep Sunburst Chip simpler.
484+
- Add a sequencer variable or array thereof to *hw/top_chip/dv/env/top_chip_dv_virtual_sequencer.sv*
485+
- Add an agent or array of agents to *hw/top_chip/dv/env/top_chip_dv_env.sv*.
486+
- Instantiate and set in `uvm_config_db` in the `build_phase()`.
487+
- Store handles to their sequencers into the virtual sequencer in the `connect_phase()`.
488+
- Add a randomised agent config in *hw/top_chip/dv/env/top_chip_dv_env_cfg.sv*.
489+
Initialise it in `initialize()`.
490+
- Add the agent to *hw/top_chip/dv/env/top_chip_dv_env.core*
491+
- Import the agent’s package in *hw/top_chip/dv/env/top_chip_dv_env_pkg.sv*
492+
- Virtual sequence porting
493+
- Copy vseq into *hw/top_chip/dv/env/seq_lib/*
494+
- Check for any block-specific base vseq and copy that too.
495+
- Rename vseq to use Sunburst Chip top-level prefix `top_chip_dv_`.
496+
- Remember to update it in the `uvm_object_utils` call too.
497+
- Change `chip_sw_base_vseq` to `top_chip_dv_base_vseq` in `class ... extends` section.
498+
- Replace OpenTitan chip constants (such as `NUM_SPI_HOSTS`) with an equivalent in *hw/top_chip/dv/env/top_chip_dv_env_pkg.sv* or other appropriate package.
499+
- Prepend `p_sequencer.` to `cfg.*` usages.
500+
- Merge contents of task `cpu_init()` with the top of task `body()`.
501+
- Add `p_sequencer.ifs.peri_clk_if.wait_for_reset();` near the start of `body()`, if required.
502+
- Change clock interface from `peri_clk_if` if the block is driven by a different clock.
503+
- Replace `` `DV_WAIT `` with `wait`, removing any failure message (unfortunately).
504+
- Waits that check against `sw_logger_vif` should be removed/reworked, as the logger interface is not working at present.
505+
- Add the vseq to the lists in following files:
506+
- *hw/top_chip/dv/env/seq_lib/top_chip_dv_vseq_list.sv*
507+
- *hw/top_chip/dv/env/top_chip_dv_env.core*
508+
- *hw/top_chip/dv/top_chip_sim_cfg.hjson*
509+
- Test program porting
510+
- Rework interrupt code (if any) to account for the PLIC only having one interrupt per block rather than per cause in each block.
511+
- Move inlined `irq_global_ctrl()` call (if any) to be inside `test_main()` rather than any sub-function to avoid trouble with interrupt-clearing backward sentries.
512+
441513
## Licence
442514

443-
Unless otherwise noted, everything in the repository is covered by the [Apache License](https://www.apache.org/licenses/LICENSE-2.0.html), Version 2.0. See the [LICENSE](https://github.com/lowRISC/sonata-system/blob/main/LICENSE) file for more information on licensing.
515+
Unless otherwise noted, everything in the repository is covered by the [Apache License](https://www.apache.org/licenses/LICENSE-2.0.html), Version 2.0.
516+
See the [LICENSE](https://github.com/lowRISC/sonata-system/blob/main/LICENSE) file for more information on licensing.

0 commit comments

Comments
 (0)