Skip to content

Commit

Permalink
Merge pull request #39 from pulp-platform/priv-fpu
Browse files Browse the repository at this point in the history
Added private FPUs.
  • Loading branch information
yvantor authored Jan 26, 2024
2 parents bd2cd62 + 388261e commit 2c9ff46
Show file tree
Hide file tree
Showing 10 changed files with 388 additions and 269 deletions.
1 change: 1 addition & 0 deletions Bender.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
overrides:
hci : { git: "https://github.com/pulp-platform/hci.git" , rev: 3cb3d99b2cebfeed55cb6ab9d98fce7b99e97cb9 } # branch: master
axi : { git: "https://github.com/pulp-platform/axi.git" , version: =0.39.1-beta }
register_interface : { git: "https://github.com/pulp-platform/register_interface.git" , rev: 19163bb5191d2669a8cbc267cdd4ce8e60f20746 } # branch: master
cluster_interconnect: { git: "https://github.com/pulp-platform/cluster_interconnect.git", rev: 89e1019d64a86425211be6200770576cbdf3e8b3 } # branch: assertion-fix
8 changes: 4 additions & 4 deletions Bender.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ packages:
dependencies:
- common_cells
hci:
revision: 78fb8fc8a6f2c376554562c47755b4d0febaba25
revision: 3cb3d99b2cebfeed55cb6ab9d98fce7b99e97cb9
version: null
source:
Git: https://github.com/pulp-platform/hci.git
Expand Down Expand Up @@ -133,8 +133,8 @@ packages:
dependencies:
- tech_cells_generic
hwpe-stream:
revision: ddc154424187dff42a8fcec946c768ceb13f13de
version: 1.6.4
revision: 389bd7fb1975d2df1546910c5f220c668122e646
version: 1.6.5
source:
Git: https://github.com/pulp-platform/hwpe-stream.git
dependencies:
Expand Down Expand Up @@ -216,7 +216,7 @@ packages:
- common_cells
- common_verification
riscv:
revision: a1dcae35edae6092ddbf92c424690cb903b678d5
revision: c760db14dbd6cc3ec3b8ae8274df2eac7225bcac
version: null
source:
Git: git@github.com:AlSaqr-platform/riscv_nn.git
Expand Down
5 changes: 2 additions & 3 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ dependencies:
idma: { git: "https://github.com/pulp-platform/iDMA.git", rev: 437ffa9dac5dea0daccfd3e8ae604d4f6ae2cdf1 } # branch: master
hier-icache: { git: "https://github.com/pulp-platform/hier-icache.git", rev: "a971e364bf8090cf77fafad995b480c1ac7ea4e0" } # branch: yt/carfield
cluster_peripherals: { git: "https://github.com/pulp-platform/cluster_peripherals.git", rev: c015839816938a790c8da5fd5829cfc536f1ca9c } # branch: yt/return-reg
# fpu_interco: { git: "https://github.com/pulp-platform/fpu_interco.git", rev: "4aec4b68424947b0c4cf25fd7c4b907cb9ec3dfa" } # branch: yt/carfield
axi: { git: "https://github.com/pulp-platform/axi.git", version: =0.39.1-beta }
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 }
riscv: { git: "git@github.com:AlSaqr-platform/riscv_nn.git", rev: a1dcae35edae6092ddbf92c424690cb903b678d5 } # branch: yt/hmr
riscv: { git: "git@github.com:AlSaqr-platform/riscv_nn.git", rev: astral-v1.0 }
cv32e40p: { git: "https://github.com/pulp-platform/cv32e40p.git", rev: e863f576699815b38cc9d80dbdede8ed5efd5991 } # `michaero/safety-island-clic` branch
ibex: { git: "https://github.com/pulp-platform/ibex.git", rev: "pulpissimo-v6.1.2" }
scm: { git: "https://github.com/pulp-platform/scm.git", rev: 74426dee36f28ae1c02f7635cf844a0156145320 } # branch: yt/bump-clkgating
hci: { git: "https://github.com/pulp-platform/hci.git", rev: b2e6f391aa6c10c03f45b693d80a0aaddecf169b } # branch: master
hci: { git: "https://github.com/pulp-platform/hci.git", rev: 3cb3d99b2cebfeed55cb6ab9d98fce7b99e97cb9 } # branch: test_mode_fix
register_interface: { git: "https://github.com/pulp-platform/register_interface.git", rev: 19163bb5191d2669a8cbc267cdd4ce8e60f20746 } # branch: master
common_cells: { git: "https://github.com/pulp-platform/common_cells.git", version: 1.29.0 }
redundancy_cells: { git: "https://github.com/pulp-platform/redundancy_cells.git", rev: 32023555679cfdb8a0a073ad4c17fc3a5d1ddea5 } # branch: yt/rapidrecovery
Expand Down
29 changes: 11 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

ROOT_DIR = $(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))

QUESTA ?= questa-2022.3
GIT ?= git
BENDER ?= bender
VSIM ?= vsim
VOPT ?= vopt
VSIM ?= $(QUESTA) vsim
VOPT ?= $(QUESTA) vopt
top_level ?= pulp_cluster_tb
dpi-library ?= work-dpi
library ?= work
Expand Down Expand Up @@ -76,11 +77,11 @@ Bender.lock:

## Clone pulp-runtime as SW stack
pulp-runtime:
git clone git@github.com:pulp-platform/pulp-runtime.git -b yt/carfield $@
git clone git@github.com:pulp-platform/pulp-runtime.git -b astral $@

## Clone regression tests for bare-metal verification
regression-tests:
git clone git@github.com:pulp-platform/regression_tests.git -b yt/carfield $@
git clone git@github.com:pulp-platform/regression_tests.git -b astral $@

########################
# Build and simulation #
Expand All @@ -92,30 +93,22 @@ sim_clean:

scripts/compile.tcl: | Bender.lock
$(call generate_vsim, $@, $(bender_defs) $(bender_targs),..)

# compile the elfloader.cpp
$(dpi-library)/%.o: tb/dpi/%.cc $(dpi_hdr)
mkdir -p $(dpi-library)
$(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
echo 'vlog "$(realpath $(ROOT_DIR))/tb/dpi/elfloader.cpp" -ccflags "-std=c++11"' >> $@
echo 'vopt +permissive -suppress 3053 -suppress 8885 +UVM_NO_RELNOTES $(top_level) -o $(top_level)_optimized'

$(library):
$(QUESTA) vlib $(library)

compile: $(library) $(dpi) $(dpi-library)/cl_dpi.so
compile: $(library)
@test -f Bender.lock || { echo "ERROR: Bender.lock file does not exist. Did you run make checkout in bender mode?"; exit 1; }
@test -f scripts/compile.tcl || { echo "ERROR: scripts/compile.tcl file does not exist. Did you run make scripts in bender mode?"; exit 1; }
$(VSIM) -c -do 'source scripts/compile.tcl; quit'
$(VSIM) -c -do 'quit -code [source scripts/compile.tcl]'

build: compile $(dpi)
build: compile
$(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 \
$(VSIM) +permissive $(questa-flags) $(uvm-flags) $(QUESTASIM_FLAGS) $(questa-cmd) -suppress 3053 -suppress 8885 -lib $(library) +MAX_CYCLES=$(max_cycles) +UVM_TESTNAME=$(test_case) +APP=$(elf-bin) +notimingchecks +nospecify -t 1ps \
${top_level}_optimized +permissive-off ++$(elf-bin) ++$(target-options) ++$(cl-bin) | tee sim.log

.PHONY: test-rt-par-bare
Expand Down
2 changes: 1 addition & 1 deletion rtl/core_region.sv
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ import rapid_recovery_pkg::*;
.PULP_CLUSTER ( 1 ),
.FPU ( FPU ),
.N_EXT_PERF_COUNTERS ( N_EXT_PERF_COUNTERS_ACTUAL ),
.Zfinx ( 0 ),
.Zfinx ( FPU ),
.WAPUTYPE ( WAPUTYPE ),
.DM_HaltAddress ( DEBUG_START_ADDR + 16'h0800 )
) RI5CY_CORE (
Expand Down
117 changes: 13 additions & 104 deletions rtl/pulp_cluster.sv
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module pulp_cluster
import pulp_cluster_package::*;
import hci_package::*;
import rapid_recovery_pkg::*;
import fpnew_pkg::*;
#(
// cluster parameters
parameter CORE_TYPE_CL = 1, // 0 for CV32, 1 for RI5CY, 2 for IBEX RV32IMC
Expand Down Expand Up @@ -69,7 +70,8 @@ module pulp_cluster
parameter BOOT_ADDR = 32'h78000000,
parameter INSTR_RDATA_WIDTH = 32,

parameter CLUST_FPU = 0,
parameter bit CLUST_FPU = 1,
parameter int unsigned NumFpus = NB_CORES,
parameter CLUST_FP_DIVSQRT = 0,
parameter CLUST_SHARED_FP = 0,
parameter CLUST_SHARED_FP_DIVSQRT = 0,
Expand Down Expand Up @@ -422,21 +424,6 @@ hci_core_intf #(
// cores -> event unit ctrl
XBAR_PERIPH_BUS s_core_euctrl_bus[NB_CORES-1:0]();

// apu-interconnect
// handshake signals
logic [NB_CORES-1:0] s_apu_master_req;
logic [NB_CORES-1:0] s_apu_master_gnt;
// request channel
logic [NB_CORES-1:0][APU_NARGS_CPU-1:0][31:0] s_apu_master_operands;
logic [NB_CORES-1:0][APU_WOP_CPU-1:0] s_apu_master_op;
logic [NB_CORES-1:0][WAPUTYPE-1:0] s_apu_master_type;
logic [NB_CORES-1:0][APU_NDSFLAGS_CPU-1:0] s_apu_master_flags;
// response channel
logic [NB_CORES-1:0] s_apu_master_rready;
logic [NB_CORES-1:0] s_apu_master_rvalid;
logic [NB_CORES-1:0][31:0] s_apu_master_rdata;
logic [NB_CORES-1:0][APU_NUSFLAGS_CPU-1:0] s_apu_master_rflags;

//----------------------------------------------------------------------//
// Interfaces between ICache - L0 - Icache_Interco and Icache_ctrl_unit //
// //
Expand Down Expand Up @@ -954,16 +941,16 @@ generate
.pc_backup_o ( backup_bus[i].pc_backup ),
.csr_backup_o ( backup_bus[i].csr_backup ),
//apu interface
.apu_master_req_o ( s_apu_master_req [i] ),
.apu_master_gnt_i ( s_apu_master_gnt [i] ),
.apu_master_type_o ( s_apu_master_type [i] ),
.apu_master_operands_o ( s_apu_master_operands[i] ),
.apu_master_op_o ( s_apu_master_op [i] ),
.apu_master_flags_o ( s_apu_master_flags [i] ),
.apu_master_valid_i ( s_apu_master_rvalid [i] ),
.apu_master_ready_o ( s_apu_master_rready [i] ),
.apu_master_result_i ( s_apu_master_rdata [i] ),
.apu_master_flags_i ( s_apu_master_rflags [i] )
.apu_master_req_o ( ),
.apu_master_gnt_i ( '0 ),
.apu_master_type_o ( ),
.apu_master_operands_o ( ),
.apu_master_op_o ( ),
.apu_master_flags_o ( ),
.apu_master_valid_i ( '0 ),
.apu_master_ready_o ( ),
.apu_master_result_i ( '0 ),
.apu_master_flags_i ( '0 )
);

assign dbg_core_halted[i] = core2hmr[i].debug_halted;
Expand Down Expand Up @@ -1111,84 +1098,6 @@ hmr_unit #(
.core_bus_outputs_i ( '0 )
);

//****************************************************
//**** Shared FPU cluster - Shared execution units ***
//****************************************************
// request channel
logic [NB_CORES-1:0][2:0][31:0] s_apu__operands;
logic [NB_CORES-1:0][5:0] s_apu__op;
logic [NB_CORES-1:0][2:0] s_apu__type;
logic [NB_CORES-1:0][14:0] s_apu__flags;
// response channel
logic [NB_CORES-1:0][4:0] s_apu__rflags;

genvar k;
for(k=0;k<NB_CORES;k++)
begin
assign s_apu__operands[k][2:0] = s_apu_master_operands[k][2:0];
assign s_apu__op[k][5:0] = s_apu_master_op[k][5:0];
assign s_apu__type[k][2:0] = s_apu_master_type[k][2:0];
assign s_apu__flags[k][14:0] = s_apu_master_flags[k][14:0];
assign s_apu_master_rflags[k][4:0] = s_apu__rflags[k][4:0];
end

generate
if (CLUST_FPU) begin
shared_fpu_cluster #(
.NB_CORES ( NB_CORES ),
.NB_APUS ( 1 ),
.NB_FPNEW ( 4 ),
.FP_TYPE_WIDTH ( 3 ),

.NB_CORE_ARGS ( 3 ),
.CORE_DATA_WIDTH ( 32 ),
.CORE_OPCODE_WIDTH ( 6 ),
.CORE_DSFLAGS_CPU ( 15 ),
.CORE_USFLAGS_CPU ( 5 ),

.NB_APU_ARGS ( 2 ),
.APU_OPCODE_WIDTH ( 6 ),
.APU_DSFLAGS_CPU ( 15 ),
.APU_USFLAGS_CPU ( 5 ),

.NB_FPNEW_ARGS ( 3 ), //= 3,
.FPNEW_OPCODE_WIDTH ( 6 ), //= 6,
.FPNEW_DSFLAGS_CPU ( 15 ), //= 15,
.FPNEW_USFLAGS_CPU ( 5 ), //= 5,

.APUTYPE_ID ( 1 ),
.FPNEWTYPE_ID ( 0 ),

.C_FPNEW_FMTBITS (fpnew_pkg::FP_FORMAT_BITS ),
.C_FPNEW_IFMTBITS (fpnew_pkg::INT_FORMAT_BITS ),
.C_ROUND_BITS (3 ),
.C_FPNEW_OPBITS (fpnew_pkg::OP_BITS ),
.USE_FPU_OPT_ALLOC ("FALSE"),
.USE_FPNEW_OPT_ALLOC ("TRUE"),
.FPNEW_INTECO_TYPE ("SINGLE_INTERCO")
) i_shared_fpu_cluster (
.clk ( clk_i ),
.rst_n ( rst_ni ),
.test_mode_i ( test_mode_i ),
.core_slave_req_i ( s_apu_master_req ),
.core_slave_gnt_o ( s_apu_master_gnt ),
.core_slave_type_i ( s_apu__type ),
.core_slave_operands_i ( s_apu__operands ),
.core_slave_op_i ( s_apu__op ),
.core_slave_flags_i ( s_apu__flags ),
.core_slave_rready_i ( s_apu_master_rready ),
.core_slave_rvalid_o ( s_apu_master_rvalid ),
.core_slave_rdata_o ( s_apu_master_rdata ),
.core_slave_rflags_o ( s_apu__rflags )
);
end else begin
assign s_apu_master_gnt = '0;
assign s_apu_master_rvalid = '0;
assign s_apu_master_rdata = '0;
assign s_apu__rflags = '0;
end
endgenerate

//**************************************************************
//**** HW Processing Engines / Cluster-Coupled Accelerators ****
//**************************************************************
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if {![info exists VSIM_PATH ]} {
set VSIM_PATH ""
}

vsim +permissive -suppress 3053 -suppress 8885 -lib $VSIM_PATH/work +APP=./build/test/test +notimingchecks +nospecify -t 1ps -sv_lib $VSIM_PATH/work-dpi/cl_dpi pulp_cluster_tb_optimized +permissive-off ++./build/test/test
vsim +permissive -suppress 3053 -suppress 8885 +UVM_NO_RELNOTES -lib $VSIM_PATH/work +APP=./build/test/test +notimingchecks +nospecify -t 1ps pulp_cluster_tb_optimized +permissive-off ++./build/test/test

add log -r /*
run -all
Loading

0 comments on commit 2c9ff46

Please sign in to comment.