Skip to content

Commit

Permalink
ci: verify script is not used on gvsoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain Haugou committed Dec 5, 2024
1 parent f6a7a03 commit 0ef7b2c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 6 deletions.
2 changes: 2 additions & 0 deletions target/common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ SED_SRCS := sed -e ${MATCH_END} -e ${MATCH_BGN} -e ${MATCH_DEF}

COMMON_BENDER_FLAGS += -t rtl

GVSOC_BUILDDIR ?= work-gvsoc

VSIM_BENDER += $(COMMON_BENDER_FLAGS) -t test -t simulation -t vsim
VSIM_SOURCES = $(shell ${BENDER} script flist-plus ${VSIM_BENDER} | ${SED_SRCS})
VSIM_BUILDDIR ?= work-vsim
Expand Down
17 changes: 17 additions & 0 deletions target/common/gvsoc.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

$(BIN_DIR)/$(TARGET).gvsoc:
@echo "#!/bin/bash" > $@
@echo 'binary=$$(realpath $$1)' >> $@
@echo 'echo $$binary > .rtlbinary' >> $@
@echo 'gvsoc --target=snitch --binary $$binary \
--control-script=$(GVSOC_BUILDDIR)/pulp/pulp/snitch/utils/gvcontrol.py $$2 run' >> $@
@chmod +x $@

.PHONY: clean-gvsoc
clean-gvsoc:
rm -rf $(BIN_DIR)/$(TARGET).gvsoc $(GVSOC_BUILDDIR)

clean: clean-gvsoc
6 changes: 6 additions & 0 deletions target/snitch_cluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ $(BIN_DIR)/$(TARGET).vcs: ${VCS_SOURCES} ${TB_SRCS} $(TB_CC_SOURCES) $(RTL_CC_SO
-assert disable_cover -override_timescale=1ns/1ps -full64 tb_bin $(TB_CC_SOURCES) $(RTL_CC_SOURCES) \
-CFLAGS "$(TB_CC_FLAGS)" -LDFLAGS "-L${FESVR}/lib" -lfesvr

#########
# GVSOC #
#########

include $(ROOT)/target/common/gvsoc.mk

########
# Util #
########
Expand Down
2 changes: 1 addition & 1 deletion target/snitch_cluster/util/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'vcs': VCSSimulator(Path(__file__).parent.resolve() / '../bin/snitch_cluster.vcs'),
'verilator': VerilatorSimulator(Path(__file__).parent.resolve() / '../bin/snitch_cluster.vlt'),
'banshee': BansheeSimulator(Path(__file__).parent.resolve() / '../src/banshee.yaml'),
'gvsoc': GvsocSimulator(Path(__file__).parent.resolve())
'gvsoc': GvsocSimulator(Path(__file__).parent.resolve() / '../bin/snitch_cluster.gvsoc')
}


Expand Down
13 changes: 11 additions & 2 deletions util/sim/Simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,17 @@ class GvsocSimulation(Simulation):
def __init__(self, sim_bin=None, cmd=None, **kwargs):
super().__init__(**kwargs)

self.cmd = ['gvsoc', '--target', os.environ.get('GVSOC_TARGET'), '--binary',
str(self.elf), 'run']
if cmd is None:
self.cmd = ['gvsoc', '--target', os.environ.get('GVSOC_TARGET'), '--binary',
str(self.elf), 'run']
else:
self.dynamic_args = {
'sim_bin': str(sim_bin),
'elf': str(self.elf),
'run_dir': str(self.run_dir)
}
self.cmd = [Template(arg).render(**self.dynamic_args) for arg in cmd]
self.cmd.append('--simulator=gvsoc')

def successful(self):
"""Return whether the simulation was successful."""
Expand Down
10 changes: 8 additions & 2 deletions util/sim/SnitchSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@

class SnitchSim:

def __init__(self, sim_bin: str, snitch_bin: str, log: str = None):
def __init__(self, sim_bin: str, snitch_bin: str, simulator: str = None, log: str = None):
self.sim_bin = sim_bin
self.snitch_bin = snitch_bin
self.sim = None
self.tmpdir = None
self.simulator = simulator
self.log = open(log, 'w+') if log else log

def start(self):
Expand All @@ -40,10 +41,15 @@ def start(self):
rx_fd = os.path.join(self.tmpdir.name, 'rx')
os.mkfifo(rx_fd)
# Start simulator process
ipc_arg = f'--ipc,{tx_fd},{rx_fd}'
if self.simulator == 'gvsoc':
ipc_arg = f'--ipc {tx_fd},{rx_fd}'
else:
ipc_arg = f'--ipc,{tx_fd},{rx_fd}'

self.sim = subprocess.Popen([self.sim_bin, self.snitch_bin, ipc_arg], stdout=self.log)
# Open FIFOs
self.tx = open(tx_fd, 'wb', buffering=0) # Unbuffered

self.rx = open(rx_fd, 'rb')
# Create thread to monitor simulation
self.stop_sim_monitor = threading.Event()
Expand Down
6 changes: 5 additions & 1 deletion util/sim/verif_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def parser(self):
parser.add_argument(
'--log',
help='Redirect simulation output to this log file')
parser.add_argument(
'--simulator',
help='Specifies simulator')
parser.add_argument(
'--dump-results',
action='store_true',
Expand Down Expand Up @@ -144,7 +147,8 @@ def simulate(self):
elf = Elf(self.args.snitch_bin)

# Start simulation
sim = SnitchSim(self.args.sim_bin, self.args.snitch_bin, log=self.args.log)
sim = SnitchSim(self.args.sim_bin, self.args.snitch_bin, simulator=self.args.simulator,
log=self.args.log)
sim.start()

# Wait for kernel execution to be over
Expand Down

0 comments on commit 0ef7b2c

Please sign in to comment.