Skip to content

Commit 946b577

Browse files
committed
[fpga] Expose HW_ID register
- 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>
1 parent af8e982 commit 946b577

2 files changed

Lines changed: 60 additions & 7 deletions

File tree

hw/top_chip/rtl/chip_mocha_genesys2.sv

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module chip_mocha_genesys2 #(
7676
);
7777
// Local parameters
7878
localparam int unsigned InitialResetCycles = 4;
79+
localparam bit [31:0] FpgaHwId = 32'h0000_000A; // FpgaGenesys2
7980

8081
// Rest of chip AXI crossbar configuration
8182
localparam axi_pkg::xbar_cfg_t xbar_cfg = '{
@@ -97,7 +98,8 @@ module chip_mocha_genesys2 #(
9798
// Rest of chip AXI crossbar address mapping
9899
axi_pkg::xbar_rule_64_t [xbar_cfg.NoAddrRules-1:0] addr_map;
99100
assign addr_map = '{
100-
'{ idx: top_pkg::Ethernet, start_addr: top_pkg::EthernetBase, end_addr: top_pkg::EthernetBase + top_pkg::EthernetLength }
101+
'{ idx: top_pkg::SwDvWindowDevIdx, start_addr: top_pkg::SwDvWindowBase, end_addr: top_pkg::SwDvWindowBase + top_pkg::SwDvWindowLength },
102+
'{ idx: top_pkg::Ethernet, start_addr: top_pkg::EthernetBase, end_addr: top_pkg::EthernetBase + top_pkg::EthernetLength }
101103
};
102104

103105
// Internal clock signals
@@ -155,6 +157,14 @@ module chip_mocha_genesys2 #(
155157
// Ethernet interrupt line
156158
logic ethernet_irq;
157159

160+
// SW-DV window AXI subordinate memory interface acting as a sink
161+
logic hw_id_mem_req;
162+
logic hw_id_mem_req_d;
163+
logic hw_id_mem_we;
164+
logic [top_pkg::AxiAddrWidth-1:0] hw_id_mem_addr;
165+
logic [top_pkg::AxiDataWidth-1:0] hw_id_mem_rdata;
166+
logic hw_id_sel_d;
167+
158168
// Clock generation
159169
clkgen_xil7series u_clk_gen (
160170
.clk_200m_i (clk_200m),
@@ -562,4 +572,44 @@ module chip_mocha_genesys2 #(
562572
.eth_rgmii_mdc_o (eth_mdc)
563573
);
564574

575+
// SW-DV window: read-only HW_ID register.
576+
// Uses the same axi_to_mem + 1-cycle loopback pattern as sim_sram_axi_sink.
577+
// Writes are accepted and discarded. Reads return FpgaHwId at offset +0x08, 0 elsewhere.
578+
axi_to_mem #(
579+
.axi_req_t (top_pkg::axi_req_t ),
580+
.axi_resp_t (top_pkg::axi_resp_t ),
581+
.DataWidth (top_pkg::AxiDataWidth),
582+
.AddrWidth (top_pkg::AxiAddrWidth),
583+
.IdWidth (top_pkg::AxiIdWidth ),
584+
.NumBanks (1 )
585+
) u_hw_id_axi_to_mem (
586+
.clk_i (u_top_chip_system.clkmgr_clocks.clk_main_infra ),
587+
.rst_ni (u_top_chip_system.rstmgr_resets.rst_main_n[rstmgr_pkg::DomainMainSel]),
588+
.busy_o ( ),
589+
.axi_req_i (xbar_device_req [top_pkg::SwDvWindowDevIdx] ),
590+
.axi_resp_o (xbar_device_resp[top_pkg::SwDvWindowDevIdx] ),
591+
.mem_req_o (hw_id_mem_req ),
592+
.mem_gnt_i (1'b1 ),
593+
.mem_addr_o (hw_id_mem_addr ),
594+
.mem_wdata_o ( ), // Ignored: RO register
595+
.mem_strb_o ( ), // Ignored: RO register
596+
.mem_atop_o ( ), // Not used
597+
.mem_we_o (hw_id_mem_we ),
598+
.mem_rvalid_i (hw_id_mem_req_d ),
599+
.mem_rdata_i (hw_id_mem_rdata )
600+
);
601+
602+
always_ff @(posedge u_top_chip_system.clkmgr_clocks.clk_main_infra
603+
or negedge u_top_chip_system.rstmgr_resets.rst_main_n[rstmgr_pkg::DomainMainSel]) begin
604+
if (!u_top_chip_system.rstmgr_resets.rst_main_n[rstmgr_pkg::DomainMainSel]) begin
605+
hw_id_mem_req_d <= 1'b0;
606+
hw_id_sel_d <= 1'b0;
607+
end else begin
608+
hw_id_mem_req_d <= hw_id_mem_req;
609+
hw_id_sel_d <= hw_id_mem_req && !hw_id_mem_we && (hw_id_mem_addr[7:0] == 8'h08);
610+
end
611+
end
612+
613+
assign hw_id_mem_rdata = hw_id_sel_d ? {{(top_pkg::AxiDataWidth-32){1'b0}}, FpgaHwId} : '0;
614+
565615
endmodule

hw/top_chip/rtl/top_pkg.sv

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ package top_pkg;
4040
SRAMBase = 64'h1000_0000,
4141
DebugMemBase = 64'h2000_0000,
4242
MailboxBase = 64'h2001_0000,
43-
RestOfChipBase = 64'h3000_0000,
43+
RestOfChipBase = 64'h2002_0000,
4444
TlCrossbarBase = 64'h4000_0000,
4545
DRAMBase = 64'h8000_0000
4646
} axi_addr_start_t;
@@ -50,7 +50,7 @@ package top_pkg;
5050
localparam longint unsigned SRAMLength = 64'h0002_0000;
5151
localparam longint unsigned DebugMemLength = 64'h0000_1000;
5252
localparam longint unsigned MailboxLength = 64'h0001_0000;
53-
localparam longint unsigned RestOfChipLength = 64'h0000_8000;
53+
localparam longint unsigned RestOfChipLength = 64'h0FFE_8000; // 0x2002_0000 to 0x3000_7FFF
5454
localparam longint unsigned TlCrossbarLength = 64'h1000_0000;
5555
localparam longint unsigned DRAMPhysicalLength = 64'h4000_0000;
5656

@@ -64,23 +64,26 @@ package top_pkg;
6464

6565
// Rest of chip AXI crossbar parameters
6666
localparam int RestOfChipAxiXbarHosts = 1;
67-
localparam int RestOfChipAxiXbarDevices = 1;
67+
localparam int RestOfChipAxiXbarDevices = 2;
6868

6969
// Rest of chip AXI crossbar hosts and devices
7070
typedef enum int unsigned {
7171
MochaAXICrossbar = 0
7272
} rest_of_chip_axi_hosts_t;
7373

7474
typedef enum int unsigned {
75-
Ethernet = 0
75+
Ethernet = 0,
76+
SwDvWindowDevIdx = 1
7677
} rest_of_chip_axi_devices_t;
7778

7879
typedef enum longint unsigned {
79-
EthernetBase = 64'h3000_0000
80+
EthernetBase = 64'h3000_0000,
81+
SwDvWindowBase = 64'h2002_0000
8082
} rest_of_chip_axi_addr_start_t;
8183

8284
// Memory lengths
83-
localparam longint unsigned EthernetLength = 64'h0000_8000;
85+
localparam longint unsigned EthernetLength = 64'h0000_8000;
86+
localparam longint unsigned SwDvWindowLength = 64'h0000_0100;
8487

8588
// Memory address masks
8689
localparam longint unsigned EthernetMask = EthernetLength - 1;

0 commit comments

Comments
 (0)