[hw] rom_ctrl added to mocha#389
Conversation
KolosKoblasz-Semify
commented
Mar 27, 2026
- existing source files vendored in
- rom_ctrl integrated at topl level, AXI and TL busnetwork extended
- new smoketest written for reading rom init values
- xbar_peri regenerated include new rom_ctrl_regs TL interface
2affd6c to
499b597
Compare
marnovandermaas
left a comment
There was a problem hiding this comment.
Some initial comments from my end. Please also have a look at the CI failures.
| }, | ||
| { name: "rom_ctrl_regs", // Rom_ctrl_regs | ||
| type: "device", | ||
| clock: "clk_io_i", |
There was a problem hiding this comment.
This should be clk_main_i
| { name: "rom_ctrl_regs", // Rom_ctrl_regs | ||
| type: "device", | ||
| clock: "clk_io_i", | ||
| reset: "rst_io_ni", |
There was a problem hiding this comment.
This should be rst_main_ni
There was a problem hiding this comment.
Why did you move this file?
There was a problem hiding this comment.
The .hjson file is relocated now because I found counter intuitive to store the "source" file for IP generation in the generated folder.
| {from: "hw/ip/rom_ctrl", to: "ip/rom_ctrl", patch_dir: "rom_ctrl"}, // ROM Control. | ||
| {from: "hw/ip/kmac", to: "ip/kmac", patch_dir: "kmac"}, // kmac. |
There was a problem hiding this comment.
Adding the patch directories should be in the same commit as where you add them to the vendor.hjson file.
There was a problem hiding this comment.
Fixed. IPs and vendoring script committed at the same time
hw/top_chip/dv/tb/tb.sv
Outdated
| top_chip_system #() dut ( | ||
| top_chip_system # ( | ||
| .SramInitFile(""), | ||
| .BootRomInitFile("sw/device/tests/rom_ctrl/mem_init_file.vmem") |
hw/top_chip/rtl/top_chip_system.sv
Outdated
| // Inter-module signals | ||
| .rom_cfg_i ('0), // TO DO: What goes here? | ||
| .pwrmgr_data_o (), // TO DO: What goes here? | ||
| .keymgr_data_o (), // TO DO: What goes here? | ||
| .kmac_data_o (), // TO DO: What goes here? | ||
| .kmac_data_i ('0), // TO DO: What goes here? |
There was a problem hiding this comment.
Can you make any progress by looking at this file: https://github.com/lowRISC/opentitan/blob/697c06af0222c97734577eae52217d957874277c/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv#L2786
There was a problem hiding this comment.
Wired up unconnected ports with signals.
sw/device/lib/hal/mocha.c
Outdated
| rom_t mocha_system_rom(void) | ||
| { | ||
| #if defined(__riscv_zcherihybrid) | ||
| return (uart_t)create_mmio_capability(rom_base, 0x48u); |
There was a problem hiding this comment.
The second argument should be the size of the ROM which is 32 KiB.
sw/device/lib/hal/rom_ctrl.c
Outdated
| uint32_t res; | ||
|
|
||
| res = DEV_READ(rom + 4*word_idx); | ||
|
|
||
| return res; |
There was a problem hiding this comment.
Nit: just return the DEV_READ.
There was a problem hiding this comment.
It might be good to put some data in the middle and at the end of ROM as well to test the edges out.
There was a problem hiding this comment.
Date put at the beginning, middle and end sections of the ROM. rom_ctrl_smoketest revised to test all relevant address ranges.
* rom_ctrl_regs if added to xbapr_peri cfg
* kmac vendored in * lowrisc_ip.vendor.hjson modified
499b597 to
212d815
Compare
* axi bus network expanded to handle rom_ctrl data interface * xbar_peri module connected to rom_ctrl register interface * verilator rule exclusions added * Path to ROM init file added to tb.sv * clk and reset of the new axi bus and rom_ctrl fixed on top level
212d815 to
71fd63b
Compare
* new testcase implemented among top level sw tests * the new test reads the compile time initialized ROM values * if any comparision fails (expected values differs from read value) test is terminated with an error * sw test files reformated to compplie with clang format
* util/artifacts.py regenrates the xbar_peri files and it needs correct paths pointing at the .hjson cfg file and the output directory
71fd63b to
e3eebff
Compare
ziuziakowska
left a comment
There was a problem hiding this comment.
Just some nits on the software.
Something to consider might also be modelling the ROM as a const char * instead of a void * typedef, as that could prevent writing through the pointer (although I believe that should cause a fault anyway).
| bool read_test_res; | ||
|
|
||
| uart_init(console); | ||
|
|
||
| read_test_res = rom_read_test(rom, console); | ||
|
|
||
| return read_test_res; | ||
| } |
There was a problem hiding this comment.
Nit: Just return rom_read_test(...)
| #define ROM_CTRL_FROM_BASE_ADDR(addr) ((rom_ctrl_t)(addr)) | ||
| #define ROM_FROM_BASE_ADDR(addr) ((rom_t)(addr)) |
There was a problem hiding this comment.
Nit: These macros are unused, create_mmio_capability and casting is preferred.
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| set(SRCS clkmgr.c gpio.c i2c.c mailbox.c mocha.c plic.c rstmgr.c spi_device.c timer.c uart.c) | ||
| set(SRCS clkmgr.c gpio.c i2c.c mailbox.c mocha.c plic.c rstmgr.c spi_device.c timer.c uart.c rom_ctrl.c) |
There was a problem hiding this comment.
Nit: Should be between plic and rstmgr.
| uint8_t data_length = 4; | ||
|
|
||
| // ROM Address values | ||
| const uint32_t expected_addresses[3] = { 0x00000000, 0x00004000, 0x00007FF0 }; |
There was a problem hiding this comment.
Nit: I would call this just addresses.
| for (uint8_t address_idx = 0; address_idx < address_length; address_idx++) { | ||
| for (uint8_t word_idx = 0; word_idx < data_length; word_idx++) { |
There was a problem hiding this comment.
In builtin.h we have an ARRAY_LEN macro to get the lengths of static arrays.