Skip to content

Commit

Permalink
Merge pull request #34 from pulp-platform/lv/standalone
Browse files Browse the repository at this point in the history
[TB] Standalone testbench for the cluster and minor `RTL` fix.
  • Loading branch information
OttG authored Mar 31, 2023
2 parents db2e173 + 25cc4cb commit 2d74a2b
Show file tree
Hide file tree
Showing 18 changed files with 2,424 additions and 18 deletions.
20 changes: 16 additions & 4 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ dependencies:
cluster_interconnect: { git: "https://github.com/pulp-platform/cluster_interconnect.git", version: 1.1.1 }
event_unit_flex: { git: "https://github.com/pulp-platform/event_unit_flex.git", rev: "1.4.1" }
mchan: { git: "https://github.com/pulp-platform/mchan.git", version: 1.2.3 }
hier-icache: { git: "https://github.com/pulp-platform/hier-icache.git", rev: "c82025995fbb18e045bb14ad2e94b35734994956" }
icache_mp_128_pf: { git: "https://github.com/pulp-platform/icache_mp_128_pf.git", rev: "6f2e54102001230db9c82432bf9e011842419a48" }
hier-icache: { git: "https://github.com/pulp-platform/hier-icache.git", rev: "fc231dfc9559c6715c3577049eae3d1887282cb0" }
# icache_mp_128_pf: { git: "https://github.com/pulp-platform/icache_mp_128_pf.git", rev: "6f2e54102001230db9c82432bf9e011842419a48" }
# icache_private: { git: "https://github.com/pulp-platform/icache_private.git", rev: "1d4cdbcbec3ab454c09d378fc55631b60450fccd" }
cluster_peripherals: { git: "https://github.com/pulp-platform/cluster_peripherals.git", version: 2.1.0 }
fpu_interco: { git: "https://github.com/pulp-platform/fpu_interco.git", rev: "66b4084117546d5b748c30b5500769805f489d2f" }
axi: { git: "https://github.com/pulp-platform/axi.git", version: 0.29.1 }
axi: { git: "https://github.com/pulp-platform/axi.git", version: =0.39.0-beta.4 }
axi_slice: { git: "https://github.com/pulp-platform/axi_slice.git", version: 1.1.4 } # deprecated, replaced by axi_cut (in axi repo)
timer_unit: { git: "https://github.com/pulp-platform/timer_unit.git", version: 1.0.2 }
common_cells: { git: "https://github.com/pulp-platform/common_cells.git", version: 1.21.0 }
tech_cells_generic: { git: "https://github.com/pulp-platform/tech_cells_generic.git", version: 0.2.3 }
cv32e40p: { git: "https://github.com/pulp-platform/cv32e40p.git", rev: "pulpissimo-v3.4.0-rev4"}
ibex: { git: "https://github.com/lowRISC/ibex.git", rev: "pulpissimo-v6.1.1" }
scm: { git: "https://github.com/pulp-platform/scm.git", version: 1.0.1}
scm: { git: "https://github.com/pulp-platform/scm.git", version: 1.1.0}
hwpe-datamover-example: { git: "https://github.com/pulp-platform/hwpe-datamover-example.git", version: 1.0.1 }
hci: { git: "https://github.com/pulp-platform/hci.git", version: 1.0.8 }

Expand Down Expand Up @@ -66,3 +66,15 @@ sources:
- rtl/core_region.sv
# Level 3
- rtl/pulp_cluster.sv

- target: test
files:
- tb/mock_uart.sv
- tb/axi2apb_64_32.sv
- tb/mock_uart_axi.sv
- tb/pulp_cluster_tb.sv

- target: cluster_standalone
files:
- include/pulp_interfaces.sv

61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
GIT ?= git
BENDER ?= bender
VSIM ?= vsim
top_level ?= pulp_cluster_tb
dpi-library ?= work-dpi
library ?= work
elf-bin ?= stimuli.riscv

ifndef QUESTASIM_HOME
$(error QUESTASIM_HOME not set - set the path to the QUESTASIM home folder)
endif

ifndef RISCV
$(error RISCV not set - please point RISC-V to your RISC-V installation, containing riscv-fesvr, needed by the testbench)
endif

CFLAGS ?= -I$(QUESTASIM_HOME)/include \
-I$(RISCV)/include/ \
-I/include -std=c++11 -I../tb/dpi -O3

dpi := $(patsubst tb/dpi/%.cc, ${dpi-library}/%.o, $(wildcard tb/dpi/*.cc))

VLOG_ARGS += -suppress vlog-2583 -suppress vlog-13314 -suppress vlog-13233 -timescale \"1 ns / 1 ps\" \"+incdir+$(shell pwd)/include\"
XVLOG_ARGS += -64bit -compile -vtimescale 1ns/1ns -quiet

define generate_vsim
echo 'set ROOT [file normalize [file dirname [info script]]/$3]' > $1
bender script $(VSIM) --vlog-arg="$(VLOG_ARGS)" $2 | grep -v "set ROOT" >> $1
echo >> $1
endef

sim_clean:
rm -rf scripts/compile.tcl
rm -rf work

scripts/compile.tcl: Bender.yml
$(call generate_vsim, $@, -t rtl -t test -t cluster_standalone,..)

# compile the elfloader.cpp
$(dpi-library)/%.o: tb/dpi/%.cc $(dpi_hdr)
mkdir -p $(dpi-library)
#echo hello
$(CXX) -shared -fPIC -std=c++0x -Bsymbolic $(CFLAGS) -c $< -o $@

$(dpi-library)/cl_dpi.so: $(dpi)
$(CXX) -shared -m64 -o $(dpi-library)/cl_dpi.so $? -L$(RISCV)/lib -L$(SPIKE_ROOT)/lib -Wl,-rpath,$(RISCV)/lib -Wl,-rpath,$(SPIKE_ROOT)/lib -lfesvr

$(library):
vlib${questa_version} $(library)

compile: $(library) $(dpi)
vsim -c -do 'source scripts/compile.tcl; quit'

build: compile $(dpi)
vopt $(compile_flag) -suppress 3053 -suppress 8885 -work $(library) $(top_level) -o $(top_level)_optimized +acc -check_synthesis


run:
vsim +permissive $(questa-flags) $(questa-cmd) -suppress 3053 -suppress 8885 -lib $(library) +MAX_CYCLES=$(max_cycles) +UVM_TESTNAME=$(test_case) +APP=$(elf-bin) +notimingchecks +nospecify -t 1ps \
$(uvm-flags) $(QUESTASIM_FLAGS) -sv_lib $(dpi-library)/cl_dpi \
${top_level}_optimized +permissive-off ++$(elf-bin) ++$(target-options) ++$(cl-bin) | tee sim.log
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pulp_cluster
# PULP Cluster

![pulp_cluster schematic](doc/PULP_CLUSTER.png)

Expand All @@ -7,3 +7,25 @@ For more details on the internal architecture, see the README.md in the
[`pulp` repository](https://github.com/pulp-platform/pulp).

The [`doc`](doc/) folder contains the draw.io schematic shown above, as well as the raw source to allow for updates, outlining the most important components in pulp_cluster, as well as the communication interfaces connecting these. While not a complete overview of all signals, this is meant as a slightly more detailed overview that can assist in development. Please be aware that the schematic may not be 100% accurate.

## Simulation

It is possible to run benchmarks on the cluster, either within [PULP](https://github.com/pulp-platform/pulp) or as a separate IP. For simulation within PULP, you can directly go to the PULP repo and follow the README.

To simulate the cluster on its own, you can perform the following steps:

1. Compile the hw:
```
bender update
make scripts/compile.tcl
make build
```
2. Compile the sw:
a. clone the `pulp-runtime` with `git clone https://github.com/pulp-platform/pulp-runtime -b lv/pulp_cluster`
b. export the path to Questasim's work directory with `source scripts/vsim.sh`
c. choose `pulp_cluster` as target for the `pulp-runtime` with `source configs/pulp_cluster.sh`
3. Run the tests:
a. clone the `regression_tests` with `git clone https://github.com/pulp-platform/regression_tests`
b. choose any test among the `parallel_bare_tests` and the `mchan_tests`, move into the related folder and do `make clena all run`
47 changes: 47 additions & 0 deletions include/cluster_bus_defines.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* pulp_cluster_defines.sv
*
* Copyright (C) 2013-2018 ETH Zurich, University of Bologna.
*
* Copyright and related rights are licensed under the Solderpad Hardware
* License, Version 0.51 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
* or agreed to in writing, software, hardware and materials distributed under
* this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
*/

/*
* Collection of legacy pulp cluster defines.
*
*/

`define NB_SLAVE 4
`define NB_MASTER 3

`define NB_REGION 1

// MSTER PORT TO TCDM
`define MASTER_0_START_ADDR 32'h1000_0000
`define MASTER_0_END_ADDR 32'h101F_FFFF

// MASTER PORT TO PERIPHERAL INTERCONNECT
`define MASTER_1_START_ADDR 32'h1020_0000
`define MASTER_1_END_ADDR 32'h103F_FFFF

`define TCDM_ASSIGN_MASTER(lhs, rhs) \
assign lhs.req = rhs.req; \
assign lhs.add = rhs.add; \
assign lhs.wen = rhs.wen; \
assign lhs.wdata = rhs.wdata; \
assign lhs.be = rhs.be; \
\
assign rhs.gnt = lhs.gnt; \
assign rhs.r_valid = lhs.r_valid; \
assign rhs.r_opc = lhs.r_opc; \
assign rhs.r_rdata = lhs.r_rdata;

`define TCDM_ASSIGN_SLAVE(lhs, rhs) `TCDM_ASSIGN_MASTER(rhs, lhs)
73 changes: 73 additions & 0 deletions include/periph_bus_defines.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* periph_bus_defines.sv
*
* Copyright (C) 2013-2018 ETH Zurich, University of Bologna.
*
* Copyright and related rights are licensed under the Solderpad Hardware
* License, Version 0.51 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
* or agreed to in writing, software, hardware and materials distributed under
* this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
*/

// SOC PERIPHERALS APB BUS PARAMETRES
`define NB_MASTER 11

// MASTER PORT TO FLL
`define FLL_START_ADDR 32'h1A10_0000
`define FLL_END_ADDR 32'h1A10_0FFF

// MASTER PORT TO GPIO
`define GPIO_START_ADDR 32'h1A10_1000
`define GPIO_END_ADDR 32'h1A10_1FFF

// MASTER PORT TO SPI MASTER
`define UDMA_START_ADDR 32'h1A10_2000
`define UDMA_END_ADDR 32'h1A10_3FFF

// MASTER PORT TO SOC CONTROL
`define SOC_CTRL_START_ADDR 32'h1A10_4000
`define SOC_CTRL_END_ADDR 32'h1A10_4FFF

// MASTER PORT TO ADV TIMER
`define ADV_TIMER_START_ADDR 32'h1A10_5000
`define ADV_TIMER_END_ADDR 32'h1A10_5FFF

// MASTER PORT TO SOC EVENT GEN
`define SOC_EVENT_GEN_START_ADDR 32'h1A10_6000
`define SOC_EVENT_GEN_END_ADDR 32'h1A10_6FFF

`define EU_START_ADDR 32'h1A10_9000
`define EU_END_ADDR 32'h1A10_AFFF

`define TIMER_START_ADDR 32'h1A10_B000
`define TIMER_END_ADDR 32'h1A10_BFFF

`define HWPE_START_ADDR 32'h1A10_C000
`define HWPE_END_ADDR 32'h1A10_CFFF

`define STDOUT_START_ADDR 32'h1A10_F000
`define STDOUT_END_ADDR 32'h1A10_FFFF

`define DEBUG_START_ADDR 32'h1A11_0000
`define DEBUG_END_ADDR 32'h1A11_FFFF

`define DUMMY_START_ADDR 32'h1A12_0000
`define DUMMY_END_ADDR 32'h1A12_0008


`define APB_ASSIGN_SLAVE(lhs, rhs) \
assign lhs.paddr = rhs.paddr; \
assign lhs.pwdata = rhs.pwdata; \
assign lhs.pwrite = rhs.pwrite; \
assign lhs.psel = rhs.psel; \
assign lhs.penable = rhs.penable; \
assign rhs.prdata = lhs.prdata; \
assign rhs.pready = lhs.pready; \
assign rhs.pslverr = lhs.pslverr

`define APB_ASSIGN_MASTER(lhs, rhs) `APB_ASSIGN_SLAVE(rhs, lhs)
Loading

0 comments on commit 2d74a2b

Please sign in to comment.