Skip to content

Commit

Permalink
Add SMP tests to Gitlab CI
Browse files Browse the repository at this point in the history
- Add dual-core configuration in testbench
- Add number of cores parameter for consistent CLINT/PLIC generation
- Add PLIC configuration file generation according to number of cores
- Bump nonfree to version with baremetal SMP tests
  • Loading branch information
ezelioli committed Dec 10, 2024
1 parent 7fc246a commit 9c32519
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
8 changes: 6 additions & 2 deletions 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 @@ -62,7 +63,7 @@ chs-clean-deps:
######################

CHS_NONFREE_REMOTE ?= [email protected]:pulp-restricted/cheshire-nonfree.git
CHS_NONFREE_COMMIT ?= fd3526f
CHS_NONFREE_COMMIT ?= 1deb6804931b6ded1ec282b0766d0501ff8ce734

CHS_PHONY += chs-nonfree-init
chs-nonfree-init:
Expand All @@ -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
2 changes: 2 additions & 0 deletions hw/rv_plic.cfg.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// 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",
Expand Down
2 changes: 2 additions & 0 deletions sw/link/rom.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
INCLUDE common.ldh

SECTIONS {
__stack_pointer$ = ORIGIN(spm) + LENGTH(spm) - 8;

/* Put all LOAD sections in one contiguous output section */
.misc : {
*(.text._start)
Expand Down
2 changes: 2 additions & 0 deletions sw/link/spm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
INCLUDE common.ldh

SECTIONS {
__stack_pointer$ = ORIGIN(spm) + LENGTH(spm) - 8;

.text : {
*(.text._start)
*(.text)
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 9c32519

Please sign in to comment.