[hw,dv,sw] Add support for HW_ID for SW#584
Conversation
martin-velay
commented
May 26, 2026
- Related to issue [DV infra] Extend the dv_window register to support querying the platform #423
- This commit adds support for a HW_ID register that can be used by SW DV tests to identify the hardware they are running on. This is useful for SW DV tests that need to run on multiple hardware platforms and need a way to differentiate between them.
engdoreis
left a comment
There was a problem hiding this comment.
Thanks for working on this, can you read the HW_ID in the test_framework and print it as test?
marnovandermaas
left a comment
There was a problem hiding this comment.
We should also have an ID for the FPGA platform.
| localparam bit [31:0] VERILATOR_SW_DV_TEST_STATUS_ADDR = VERILATOR_SW_DV_START_ADDR + 'h00; | ||
| localparam bit [31:0] VERILATOR_SW_DV_HW_ID_ADDR = VERILATOR_SW_DV_START_ADDR + 'h08; | ||
|
|
||
| localparam bit [31:0] VERILATOR_HW_ID = 32'h0000_001A; // Verilator specific ID |
There was a problem hiding this comment.
How did you choose this value?
There was a problem hiding this comment.
I followed @engdoreis instructions from this issue: #423
There was a problem hiding this comment.
@marnovandermaas, shall I keep it as it is or do you have another preference?
|
@marnovandermaas, about:
I am unsure how this can be implemented for the FPGA platform. Maybe I can add something similar as done for Verilator? |
|
I have tested, and indeed there was an issue. Now I can see this in the With this patch: diff_sw_dv_hw_id.patch |
cd48d60 to
af8e982
Compare
|
I have added similar thing for the FPGA via an "AXI sink". I have never done any FPGA, can I have guidance on how I can verify it works? |
|
I'm sorry for accidentally closing the PR, |
elliotb-lowrisc
left a comment
There was a problem hiding this comment.
I'm a bit concerned that the current changes are affecting the Mocha RTL despite this being for DV purposes. In particular, I think the strange range of the 'rest of chip' entry could make the AXI crossbar harder for the tool to implement (possibly affecting timing/area/performance). I'd like to see a before/after pair of FPGA bitstream builds to check if the impact is negligible or not.
|
@elliotb-lowrisc, your comment is fair (except that it's not DV purposes only 😄). Do you see another cleaner way of doing it? |
|
@martin-velay Nevermind, it seems I was mistaken in thinking that the Might be worth updating the tag in the PR title if this is not a DV-only change though. |
|
I have added a C check which should verify the FPGA logic will work too. I haven't verified on the board, but I rather rely on CI with this test. |
elliotb-lowrisc
left a comment
There was a problem hiding this comment.
Alright, I think this is ready to be merged
|
@ziuziakowska or maybe @marnovandermaas, as Douglas is on holidays, could you confirm that you are OK with these SW changes? |
- Related to issue lowRISC#423 - This commit adds support for a HW_ID register that can be used by SW DV tests to identify the hardware they are running on. This is useful for SW DV tests that need to run on multiple hardware platforms and need a way to differentiate between them. - Add framework C test Signed-off-by: martin-velay <mvelay@lowrisc.org>
- Extend RestOfChipBase/Length in top_pkg to encompass the SW-DV window (0x2002_0000), routing it through the rest_of_chip port without touching top_chip_system. - Add a second device to the rest-of-chip crossbar in chip_mocha_genesys2 backed by axi_to_mem; reads to offset +0x08 return the Genesys2 platform identifier (0x0000_000A), enabling SW tests to detect the platform at runtime consistently with the sim infrastructure. Signed-off-by: martin-velay <mvelay@lowrisc.org>
Update the test framework smoketest to read the HW_ID register, validate it against known values, and fail on an unrecognised ID. Signed-off-by: martin-velay <mvelay@lowrisc.org>
|
I've just added the |
| parameter bit [31:0] SW_DV_LOG_ADDR = SW_DV_START_ADDR + 'h04; | ||
| parameter bit [31:0] SW_DV_HW_ID_ADDR = SW_DV_START_ADDR + 'h08; |
There was a problem hiding this comment.
On a slightly unrelated note, I wonder if at some point we might want to have the DV Log window be 8 bytes instead of 4 bytes long, so that we can pass through 64-bit pointers/integers to it. Just in case, I would prefer if the HW ID window was at offset 4 instead and the log window at offset 8, to give it room to potentially grow, but that might not be possible.
There was a problem hiding this comment.
I also noticed that you do this in #600 but for different reasons, would be best to do it here first.
| typedef enum : uint32_t { | ||
| HW_ID_FPGA_GENESYS2 = 0x0000000Au, | ||
| HW_ID_SIM_VERILATOR = 0x0000001Au, | ||
| HW_ID_SIM_UVM = 0x0000002Au, | ||
| } dv_hw_platform_t; |
There was a problem hiding this comment.
Mocha code style is more like this:
| typedef enum : uint32_t { | |
| HW_ID_FPGA_GENESYS2 = 0x0000000Au, | |
| HW_ID_SIM_VERILATOR = 0x0000001Au, | |
| HW_ID_SIM_UVM = 0x0000002Au, | |
| } dv_hw_platform_t; | |
| enum : uint32_t { | |
| hwid_fpga_genesys2 = 0xau, | |
| hwid_sim_verilator = 0x1au, | |
| hwid_sim_uvm = 0x2au, | |
| }; |
|
|
||
| void *mocha_system_dv_hw_id(void) | ||
| { | ||
| #if defined(__riscv_zcherihybrid) | ||
| return create_mmio_capability(dv_hw_id_base, 0x4u); | ||
| #else /* !defined(__riscv_zcherihybrid) */ | ||
| return (void *)dv_hw_id_base; | ||
| #endif /* defined(__riscv_zcherihybrid) */ | ||
| } |
There was a problem hiding this comment.
The above mocha_system_dv_test_status spans the entire DV window though its a bit of a misnomer at the moment, could you rename that and the associated base to mocha_system_dv_window and create a struct in a separate hal/dv.h like so (you can look in hal/autogen to see how others are done):
typedef volatile struct [[gnu::aligned(4)]] dv_window_memory_layout {
uint32_t test_status;
uint32_t hw_id;
} *dv_window_t;|
|
||
| switch (hw_id) { | ||
| case HW_ID_FPGA_GENESYS2: | ||
| uart_puts(console, "Platform: FpgaGenesys2\n"); |
There was a problem hiding this comment.
I would put "Genesys2 FPGA", "Verilator Simulation", and "UVM Simulation", "Unknown Hardware ID" to make them nicer to read as this will be visible to users.
marnovandermaas
left a comment
There was a problem hiding this comment.
I think we shouldn't use the rest of chip crossbar for the DV window. Can we change this before merging this?
| parameter int unsigned PeriClkFreq = 50_000_000; | ||
|
|
||
| // SW DV special write locations for test status and logging will always fit in 32-bits | ||
| // SW-DV special fake registers |
There was a problem hiding this comment.
I wouldn't call these fake registers. I would prefer to expand the previous comment instead.
| `define DUT u_top_chip_system | ||
| `define SIM_SRAM_IF u_sim_sram.u_sim_sram_if | ||
|
|
||
| // Special adddresses for SW-DV communication |
There was a problem hiding this comment.
Nit: spelling mistake.
| "rv_timer_irq", | ||
| "rv_timer_irq_cheri", | ||
| "test_framework_test", | ||
| "test_framework_test_cheri", |
There was a problem hiding this comment.
You're adding these before the tests are added.
| hw_id_mem_req_d <= 1'b0; | ||
| hw_id_sel_d <= 1'b0; | ||
| end else begin | ||
| hw_id_mem_req_d <= hw_id_mem_req; |
There was a problem hiding this comment.
Latching should be called _q not _d.
| localparam longint unsigned DebugMemLength = 64'h0000_1000; | ||
| localparam longint unsigned MailboxLength = 64'h0001_0000; | ||
| localparam longint unsigned RestOfChipLength = 64'h0000_8000; | ||
| localparam longint unsigned RestOfChipLength = 64'h0FFE_8000; // 0x2002_0000 to 0x3000_7FFF |
There was a problem hiding this comment.
You shouldn't add the DV window to the rest of chip bus. It should be a separate AXI port.