Skip to content

Commit

Permalink
Add dual-core configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ezelioli committed Dec 5, 2024
1 parent 7fc246a commit e826271
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
6 changes: 5 additions & 1 deletion cheshire.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ VLOG_ARGS ?= -suppress 2583 -suppress 13314 -timescale 1ns/1ps

# Common Bender flags for Cheshire RTL
CHS_BENDER_RTL_FLAGS ?= -t rtl -t cva6 -t cv64a6_imafdcsclic_sv39
NUM_CORES ?= 1

# Define used paths (prefixed to avoid name conflicts)
CHS_ROOT ?= $(shell $(BENDER) path cheshire)
Expand Down Expand Up @@ -86,12 +87,15 @@ $(CHS_ROOT)/hw/regs/cheshire_reg_pkg.sv $(CHS_ROOT)/hw/regs/cheshire_reg_top.sv:
$(REGTOOL) -r $< --outdir $(dir $@)

# CLINT
CLINTCORES ?= 1
CLINTCORES ?= $(NUM_CORES)
include $(CLINTROOT)/clint.mk
$(CLINTROOT)/.generated:
flock -x $@ $(MAKE) clint && touch $@

# OpenTitan peripherals
$(CHS_ROOT)/hw/rv_plic.cfg.hjson: $(CHS_ROOT)/util/gen_pliccfg.py
$(CHS_ROOT)/util/gen_pliccfg.py --num-cores $(NUM_CORES) > $@

include $(OTPROOT)/otp.mk
$(OTPROOT)/.generated: $(CHS_ROOT)/hw/rv_plic.cfg.hjson
flock -x $@ sh -c "cp $< $(dir $@)/src/rv_plic/; $(MAKE) -j1 otp" && touch $@
Expand Down
4 changes: 3 additions & 1 deletion hw/rv_plic.cfg.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
// SPDX-License-Identifier: Apache-2.0
//
// Paul Scheffler <[email protected]>
// Enrico Zelioli <[email protected]>
// AUTOMATICALLY GENERATED by gen_pliccfg.py; edit the script instead.

{
instance_name: "rv_plic",
param_values: {
src: 58,
target: 2, // We need *two targets* per hart: M and S modes
target: 4, // We need *two targets* per hart: M and S modes
prio: 7,
nonstd_regs: 0 // Do *not* include these: MSIPs are not used and we use a 64 MiB address space
},
Expand Down
16 changes: 12 additions & 4 deletions target/sim/src/tb_cheshire_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,22 @@ package tb_cheshire_pkg;
return ret;
endfunction

// A dedicated dual-core config
function automatic cheshire_cfg_t gen_cheshire_dualcore_cfg();
cheshire_cfg_t ret = DefaultCfg;
ret.NumCores = 2;
return ret;
endfunction

// Number of Cheshire configurations
localparam int unsigned NumCheshireConfigs = 32'd3;
localparam int unsigned NumCheshireConfigs = 32'd4;

// Assemble a configuration array indexed by a numeric parameter
localparam cheshire_cfg_t [NumCheshireConfigs-1:0] TbCheshireConfigs = {
gen_cheshire_clic_cfg(), // 2: CLIC-enabled configuration
gen_cheshire_rt_cfg(), // 1: RT-enabled configuration
DefaultCfg // 0: Default configuration
gen_cheshire_dualcore_cfg(), // 3: Dual-core configuration
gen_cheshire_clic_cfg(), // 2: CLIC-enabled configuration
gen_cheshire_rt_cfg(), // 1: RT-enabled configuration
DefaultCfg // 0: Default configuration
};

endpackage
61 changes: 61 additions & 0 deletions util/gen_pliccfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
#
# Copyright 2022 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Nicole Narr <[email protected]>
# Christopher Reinwardt <[email protected]>
#
# Fabian Schuiki <[email protected]>
# Florian Zaruba <[email protected]>
# Stefan Mach <[email protected]>
# Thomas Benz <[email protected]>
# Paul Scheffler <[email protected]>
# Wolfgang Roenninger <[email protected]>
# Gianna Paulin <[email protected]>
# Tim Fischer <[email protected]>
# Enrico Zelioli <[email protected]>

import os
import argparse

# Parse arguments.
parser = argparse.ArgumentParser(description="Generate rv_plic.cfg.hjson")
parser.add_argument(
"--num-cores",
"-n",
dest="num_cores",
default=1,
type=int,
help=
"Number of cores attached to the PLIC. The number of PLIC targets is set accordingly (2 * num-cores)"
)
args = parser.parse_args()

num_targets = args.num_cores * 2

# Emit the code.
print("""
// Copyright 2022 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Paul Scheffler <[email protected]>
// Enrico Zelioli <[email protected]>
// AUTOMATICALLY GENERATED by {script}; edit the script instead.
{{
instance_name: \"rv_plic\",
param_values: {{
src: 58,
target: {targets}, // We need *two targets* per hart: M and S modes
prio: 7,
nonstd_regs: 0 // Do *not* include these: MSIPs are not used and we use a 64 MiB address space
}},
}}
""".strip().format(
script=os.path.basename(__file__),
targets=num_targets
))

0 comments on commit e826271

Please sign in to comment.