Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw: Add native bootrom #168

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
9a9f210
Chagned makro names
Apr 4, 2024
86dae13
Setup Bootrom Generation.
May 14, 2024
26774f8
Bootable Bootrom instantiated.
May 14, 2024
8598be9
Setup Bootrom Generation.
MilosHirsl Apr 3, 2024
bada8fa
Bootable Bootrom instantiated.
MilosHirsl Apr 18, 2024
de56699
Linked Bootrom Scratch Register to correct address.
MilosHirsl May 3, 2024
37f73fc
Fixed Scratch Register linking address. Modified regfile for synthesis.
MilosHirsl May 3, 2024
e4e1a82
Modified bootrom to avoid synthesis issues.
MilosHirsl May 8, 2024
aae8b77
Moved Bootrom Space into Cluster Peripheral.
MilosHirsl May 15, 2024
84b2b9a
Changed Scratch Registers Software Permissions to allow Read/Write an…
MilosHirsl May 16, 2024
a59c0d5
Adjusted assignment size from generated boot data to actual boot size.
MilosHirsl May 20, 2024
3f0b447
Fixed assign statement.
MilosHirsl May 20, 2024
6080ca4
Modified bootrom after debugging to fetch address at scratch register 1.
MilosHirsl May 24, 2024
01bb61b
git: Remove unused config file
fischeti Jul 18, 2024
dea6c44
hw: Don't change reset value of performance counters
fischeti Jul 18, 2024
522e744
hw: Fix peripheral reg Makefile
fischeti Jul 18, 2024
cfc0bec
git: Remove original files
fischeti Jul 18, 2024
156aaf1
bootrom: Remove old script
fischeti Jul 18, 2024
ff98472
hw: Clean up bootrom generation
fischeti Jul 18, 2024
19208ea
util: Move bootrom generation script to util folder
fischeti Jul 18, 2024
94e6c7d
Clean up some more
fischeti Jul 18, 2024
630b8fc
lint: Python files
fischeti Jul 18, 2024
7d2e55c
lint: Fix missing license headers
fischeti Jul 18, 2024
1148172
lint: Other formatting
fischeti Jul 18, 2024
069fbef
hw: Rename `bootrom` to `snitch_bootrom`
fischeti Jul 18, 2024
96ffb68
hw: Format auto-generated SV sources
fischeti Jul 18, 2024
492491f
Revert "hw: Format auto-generated SV sources"
fischeti Jul 18, 2024
2e860eb
hw: Rename scratch registers and disable `hwext` setting
fischeti Jul 18, 2024
11b93a6
bootrom: Enable external interrupts
fischeti Jul 18, 2024
afb447f
test: Write binary entry point from testbench to scratch1 register
fischeti Jul 18, 2024
1982782
lint: C++ sources
fischeti Jul 19, 2024
8c8114e
hw: Fix unused parameters in `axi_to_mem`
fischeti Jul 19, 2024
5656e4a
test: Use simpler AXI driver for compatibility with verilator
fischeti Jul 19, 2024
15a1a87
test: Use simple bootrom that directly jumps to L3
fischeti Jul 22, 2024
20eed23
cfg: Don't specify `boot_addr`
fischeti Jul 22, 2024
9afc478
cfg: Specify `boot_rom_size` for all configurations
fischeti Jul 22, 2024
0179bf7
doc: Update `boot_addr` description
fischeti Jul 22, 2024
6b3fb12
hw: Rename `BootOrigin` to `BootAddrInternal`
fischeti Jul 22, 2024
f19d7b0
misc: Revert unused stuff
fischeti Jul 22, 2024
be60cd7
vlt: Remove `bootrom.cc`
fischeti Jul 22, 2024
80c5a11
banshee: Update addresses
fischeti Jul 22, 2024
f23d563
tb: Revert small changes
fischeti Jul 22, 2024
775afb8
bootrom: Don't write author list in auto-generated SV file
fischeti Jul 22, 2024
36f02c3
misc: Fix comments and formatting
fischeti Jul 23, 2024
d2291f5
Revert "Chagned makro names"
fischeti Jul 23, 2024
e081027
cfg: Update `dma_mchan` config
fischeti Aug 1, 2024
0dc5db1
cfg: Remove unused `boot_addr` in configs
fischeti Aug 5, 2024
38cb133
cfg: Remove obsolete quadrant config
fischeti Aug 5, 2024
077ac88
cfg: Add `boot_rom_size` config
fischeti Aug 5, 2024
d3513f9
cfg: Rename `boot_rom_size` to `bootrom_size`
fischeti Aug 5, 2024
e14744e
hw: Add bootrom generation to `rtl` target
fischeti Aug 29, 2024
dae7047
hw: Update sources
fischeti Aug 29, 2024
81309c1
bootrom: Use clang to compile bootrom
fischeti Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ sources:
- hw/snitch_cluster/src/snitch_fpu.sv
- hw/snitch_cluster/src/snitch_sequencer.sv
- hw/snitch_cluster/src/snitch_tcdm_interconnect.sv
- target/snitch_cluster/test/snitch_bootrom.sv
# Level 1
- hw/snitch_cluster/src/snitch_barrier.sv
- hw/snitch_cluster/src/snitch_fp_ss.sv
Expand Down
10 changes: 9 additions & 1 deletion docs/schema/snitch_cluster.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"boot_addr": {
"type": "number",
"description": "Address from which all harts of the cluster start to boot. The default setting is `0x8000_0000`.",
"description": "Address from which all harts of the cluster start to boot. The default setting is `0x8000_0000`. Unused if `alias_region_enable` is set.",
"default": 2147483648
},
"cluster_base_addr": {
Expand Down Expand Up @@ -89,6 +89,14 @@
64
]
},
"bootrom_size": {
"type": "number",
"description": "Address region size reserved for the Bootrom-Memory in KiByte.",
"examples": [
128,
64
]
},
"alias_region_enable": {
"type": "boolean",
"description": "Whether to provide a hardwired alias region for the TCDM (and cluster) address space.",
Expand Down
3 changes: 2 additions & 1 deletion hw/snitch/src/snitch_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ package snitch_pkg;
typedef enum int unsigned {
TCDMDMA = 0,
SoCDMAOut = 1,
ZeroMemory = 2
ZeroMemory = 2,
BootRom = 3
} cluster_slave_dma_e;

typedef enum int unsigned {
Expand Down
71 changes: 68 additions & 3 deletions hw/snitch_cluster/src/snitch_cluster.sv
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ module snitch_cluster
parameter int unsigned NarrowUserWidth = 1,
/// AXI: dma user width.
parameter int unsigned WideUserWidth = 1,
/// Address from which to fetch the first instructions.
/// Boot Address from which to fetch the first instructions.
/// Only used if `AliasRegionEnable` is not set.
parameter logic [31:0] BootAddr = 32'h0,
/// Number of Hives. Each Hive can hold 1-many cores.
parameter int unsigned NrHives = 1,
Expand All @@ -47,6 +48,8 @@ module snitch_cluster
parameter int unsigned TCDMDepth = 1024,
/// Zero memory address region size (in kB).
parameter int unsigned ZeroMemorySize = 64,
/// Bootrom memory address region size (in kB).
parameter int unsigned BootRomSize = 4,
/// Cluster peripheral address region size (in kB).
parameter int unsigned ClusterPeriphSize = 64,
/// Number of TCDM Banks. It is recommended to have twice the number of banks
Expand Down Expand Up @@ -280,7 +283,7 @@ module snitch_cluster
localparam int unsigned NrWideMasters = 1 + DMANumChannels + NrHives;
localparam int unsigned WideIdWidthOut = $clog2(NrWideMasters) + WideIdWidthIn;
// DMA X-BAR configuration
localparam int unsigned NrWideSlaves = 3;
localparam int unsigned NrWideSlaves = 4;
localparam int unsigned NrWideRuleIdcs = NrWideSlaves - 1;
localparam int unsigned NrWideRules = (1 + AliasRegionEnable) * NrWideRuleIdcs;

Expand Down Expand Up @@ -463,6 +466,10 @@ module snitch_cluster
assign cluster_periph_start_address = tcdm_end_address;
assign cluster_periph_end_address = tcdm_end_address + ClusterPeriphSize * 1024;

addr_t bootrom_start_address, bootrom_end_address;
assign bootrom_start_address = cluster_periph_start_address + 4 * 1024;
assign bootrom_end_address = cluster_periph_end_address;

addr_t zero_mem_start_address, zero_mem_end_address;
assign zero_mem_start_address = cluster_periph_end_address;
assign zero_mem_end_address = cluster_periph_end_address + ZeroMemorySize * 1024;
Expand All @@ -473,9 +480,13 @@ module snitch_cluster
localparam addr_t PeriphAliasStart = TCDMAliasEnd;
localparam addr_t PeriphAliasEnd = TCDMAliasEnd + ClusterPeriphSize * 1024;

localparam addr_t BootRomAliasStart = PeriphAliasStart + 4 * 1024;
localparam addr_t BootRomAliasEnd = PeriphAliasEnd;

localparam addr_t ZeroMemAliasStart = PeriphAliasEnd;
localparam addr_t ZeroMemAliasEnd = PeriphAliasEnd + ZeroMemorySize * 1024;


// ----------------
// Wire Definitions
// ----------------
Expand Down Expand Up @@ -585,6 +596,11 @@ module snitch_cluster
idx: ZeroMemory,
start_addr: zero_mem_start_address,
end_addr: zero_mem_end_address
},
'{
idx: BootRom,
start_addr: bootrom_start_address,
end_addr: bootrom_end_address
}
};
if (AliasRegionEnable) begin : gen_dma_xbar_alias
Expand All @@ -598,6 +614,11 @@ module snitch_cluster
idx: ZeroMemory,
start_addr: ZeroMemAliasStart,
end_addr: ZeroMemAliasEnd
},
'{
idx: BootRom,
start_addr: BootRomAliasStart,
end_addr: BootRomAliasEnd
}
};
end
Expand Down Expand Up @@ -857,6 +878,8 @@ module snitch_cluster

tcdm_req_t [TcdmPorts-1:0] tcdm_req_wo_user;

parameter logic [31:0] BootAddrInternal = AliasRegionEnable ? BootRomAliasStart : BootAddr;

snitch_cc #(
.AddrWidth (PhysicalAddrWidth),
.DataWidth (NarrowDataWidth),
Expand All @@ -881,7 +904,7 @@ module snitch_cluster
.acc_req_t (acc_req_t),
.acc_resp_t (acc_resp_t),
.dma_events_t (dma_events_t),
.BootAddr (BootAddr),
.BootAddr (BootAddrInternal),
.RVE (RVE[i]),
.RVF (RVF[i]),
.RVD (RVD[i]),
Expand Down Expand Up @@ -1236,6 +1259,37 @@ module snitch_cluster
.reg_rsp_i (reg_rsp)
);

addr_t bootrom_addr;
data_dma_t bootrom_data, bootrom_data_q;
logic bootrom_req, bootrom_req_q;

`FF(bootrom_data_q, bootrom_data, '0, clk_i, rst_ni)
`FF(bootrom_req_q, bootrom_req, '0, clk_i, rst_ni)

axi_to_mem #(
.axi_req_t (axi_slv_dma_req_t),
.axi_resp_t (axi_slv_dma_resp_t),
.AddrWidth (PhysicalAddrWidth),
.DataWidth (WideDataWidth),
.IdWidth (WideIdWidthOut),
.NumBanks (1)
) i_axi_to_mem (
.clk_i (clk_i),
.rst_ni (rst_ni),
.busy_o (),
.axi_req_i (wide_axi_slv_req[BootRom]),
.axi_resp_o (wide_axi_slv_rsp[BootRom]),
.mem_req_o (bootrom_req),
.mem_gnt_i (bootrom_req),
.mem_addr_o (bootrom_addr),
.mem_wdata_o (),
.mem_strb_o (),
.mem_atop_o (),
.mem_we_o (),
.mem_rvalid_i (bootrom_req_q),
.mem_rdata_i (bootrom_data_q)
);

snitch_cluster_peripheral #(
.reg_req_t (reg_req_t),
.reg_rsp_t (reg_rsp_t),
Expand All @@ -1256,6 +1310,17 @@ module snitch_cluster
.icache_events_i (icache_events)
);

snitch_bootrom #(
.AddrWidth (PhysicalAddrWidth),
.DataWidth (WideDataWidth),
.BootromSize (BootRomSize * 1024)
) i_bootrom (
.clk_i (clk_i),
.rst_ni (rst_ni),
.addr_i (bootrom_addr),
.data_o (bootrom_data)
);

// Optionally decouple the external narrow AXI master ports.
axi_cut #(
.Bypass ( !RegisterExtNarrow ),
Expand Down
27 changes: 27 additions & 0 deletions hw/snitch_cluster/src/snitch_cluster_peripheral/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 ETH Zurich and University of Bologna.
# Solderpad Hardware License, Version 0.51, see LICENSE for details.
# SPDX-License-Identifier: SHL-0.51
#
# Noah Huetter <[email protected]>

BENDER=$(shell which bender)
REGTOOL=$(shell $(BENDER) path register_interface)/vendor/lowrisc_opentitan/util/regtool.py
PYTHON3=$(shell which python)
CLANG_FORMAT=$(shell which clang-format-12.0.1)

SCHEMA=snitch_cluster_peripheral_reg.hjson

PKG=snitch_cluster_peripheral_reg_pkg.sv
TOP=snitch_cluster_peripheral_reg_top.sv
CDEF=../../../../target/snitch_cluster/sw/runtime/common/snitch_cluster_peripheral.h

all: $(PKG) $(TOP) $(CDEF)

$(PKG): $(SCHEMA)
$(PYTHON3) $(REGTOOL) -r -t $(dir $@) $<
$(TOP): $(SCHEMA)
$(PYTHON3) $(REGTOOL) -r -t $(dir $@) $<

%.h: $(SCHEMA)
$(PYTHON3) $(REGTOOL) -D -o $@ $<
$(CLANG_FORMAT) -i $@
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
// Licensed under Solderpad Hardware License, Version 0.51, see LICENSE for details.
{
param_list: [
{ name: "NumPerfCounters",
{
name: "NumPerfCounters",
desc: "Number of performance counters",
type: "int",
default: "16"
},
{
name: "NumCtrlScratch",
desc: "Number of scratch registers",
type: "int",
default: "4"
},
],
name: "snitch_cluster_peripheral",
clock_primary: "clk_i",
Expand Down Expand Up @@ -303,6 +310,22 @@
}]
}
},
{
multireg: {
name: "SCRATCH",
desc: '''Scratch registers. Used in the bootrom for various purposes.'''
swaccess: "rw",
hwaccess: "none",
count: "NumCtrlScratch",
cname: "ctrl_scratch",
compact: "false",
fields: [{
bits: "31:0",
name: "SCRATCH",
desc: "Scratch register"
}]
}
},
{
name: "CL_CLINT_SET",
desc: '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package snitch_cluster_peripheral_reg_pkg;

// Param list
parameter int NumPerfCounters = 16;
parameter int NumCtrlScratch = 4;

// Address widths within the block
parameter int BlockAw = 9;
Expand Down Expand Up @@ -128,9 +129,13 @@ package snitch_cluster_peripheral_reg_pkg;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_13_OFFSET = 9'h 168;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_14_OFFSET = 9'h 170;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_15_OFFSET = 9'h 178;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_SET_OFFSET = 9'h 180;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_CLEAR_OFFSET = 9'h 188;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_ICACHE_PREFETCH_ENABLE_OFFSET = 9'h 190;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_SCRATCH_0_OFFSET = 9'h 180;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_SCRATCH_1_OFFSET = 9'h 188;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_SCRATCH_2_OFFSET = 9'h 190;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_SCRATCH_3_OFFSET = 9'h 198;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_SET_OFFSET = 9'h 1a0;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_CLEAR_OFFSET = 9'h 1a8;
parameter logic [BlockAw-1:0] SNITCH_CLUSTER_PERIPHERAL_ICACHE_PREFETCH_ENABLE_OFFSET = 9'h 1b0;

// Reset values for hwext registers and their fields
parameter logic [31:0] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_SEL_0_RESVAL = 32'h 0;
Expand Down Expand Up @@ -218,13 +223,17 @@ package snitch_cluster_peripheral_reg_pkg;
SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_13,
SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_14,
SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_15,
SNITCH_CLUSTER_PERIPHERAL_SCRATCH_0,
SNITCH_CLUSTER_PERIPHERAL_SCRATCH_1,
SNITCH_CLUSTER_PERIPHERAL_SCRATCH_2,
SNITCH_CLUSTER_PERIPHERAL_SCRATCH_3,
SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_SET,
SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_CLEAR,
SNITCH_CLUSTER_PERIPHERAL_ICACHE_PREFETCH_ENABLE
} snitch_cluster_peripheral_id_e;

// Register width information to check illegal writes
parameter logic [3:0] SNITCH_CLUSTER_PERIPHERAL_PERMIT [51] = '{
parameter logic [3:0] SNITCH_CLUSTER_PERIPHERAL_PERMIT [55] = '{
4'b 0001, // index[ 0] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_EN_0
4'b 0001, // index[ 1] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_EN_1
4'b 0001, // index[ 2] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_EN_2
Expand Down Expand Up @@ -273,9 +282,13 @@ package snitch_cluster_peripheral_reg_pkg;
4'b 1111, // index[45] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_13
4'b 1111, // index[46] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_14
4'b 1111, // index[47] SNITCH_CLUSTER_PERIPHERAL_PERF_CNT_15
4'b 1111, // index[48] SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_SET
4'b 1111, // index[49] SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_CLEAR
4'b 0001 // index[50] SNITCH_CLUSTER_PERIPHERAL_ICACHE_PREFETCH_ENABLE
4'b 1111, // index[48] SNITCH_CLUSTER_PERIPHERAL_SCRATCH_0
4'b 1111, // index[49] SNITCH_CLUSTER_PERIPHERAL_SCRATCH_1
4'b 1111, // index[50] SNITCH_CLUSTER_PERIPHERAL_SCRATCH_2
4'b 1111, // index[51] SNITCH_CLUSTER_PERIPHERAL_SCRATCH_3
4'b 1111, // index[52] SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_SET
4'b 1111, // index[53] SNITCH_CLUSTER_PERIPHERAL_CL_CLINT_CLEAR
4'b 0001 // index[54] SNITCH_CLUSTER_PERIPHERAL_ICACHE_PREFETCH_ENABLE
};

endpackage
Expand Down
Loading
Loading