diff --git a/.gitignore b/.gitignore index 6551a7a6..a2dc6bf9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ scripts/compile.tcl regression_tests/ pulp-runtime/ fault_injection_sim/ +venv/ +.venv/ diff --git a/Bender.lock b/Bender.lock index 34ed4ae2..2172aee6 100644 --- a/Bender.lock +++ b/Bender.lock @@ -62,7 +62,7 @@ packages: dependencies: - common_cells cluster_peripherals: - revision: 072ddd876c88324ef28856d4b2697424aaa231ce + revision: a3be530fccdcef4733d57163c6d979ff77ed554d version: null source: Git: https://github.com/pulp-platform/cluster_peripherals.git @@ -128,7 +128,7 @@ packages: dependencies: - common_cells hci: - revision: 2a5a5081a2b32f1a04e7e28c00d3762d92602b84 + revision: a42bd8bbf61eb4700b98d51af1b74603c278239e version: null source: Git: https://github.com/pulp-platform/hci.git @@ -159,8 +159,8 @@ packages: dependencies: - tech_cells_generic hwpe-stream: - revision: b3d33afdd27e79bcda1348d0ab5f4afd52c03106 - version: 1.9.0 + revision: 05cb8303693065812e9d6bfe10976220fb455666 + version: 1.10.0 source: Git: https://github.com/pulp-platform/hwpe-stream.git dependencies: @@ -182,7 +182,7 @@ packages: revision: 6be43a77c81e86c53e821dfbc618522c375ff28c version: null source: - Git: https://github.com/pulp-platform/iDMA.git + Git: https://github.com/pulp-platform/idma.git dependencies: - axi - axi_stream @@ -204,7 +204,7 @@ packages: dependencies: - common_cells neureka: - revision: 2e076f7d25cdfba38821ee95595bb27aec53c764 + revision: 9edd85ed16861a9b85eabbe87454bd3bdf73c69c version: null source: Git: https://github.com/pulp-platform/neureka.git @@ -212,7 +212,6 @@ packages: - hci - hwpe-ctrl - hwpe-stream - - register_interface - zeroriscy obi: revision: 0155fc34e900c7c884e081c0a1114a247937ff69 @@ -230,7 +229,7 @@ packages: dependencies: - axi_slice redmule: - revision: dbcba6b1efda24dc909ebdd4ace132f798c8c12b + revision: 466bc59a9c5b263b08535a8e6f1d0637a9bcff34 version: null source: Git: https://github.com/pulp-platform/redmule.git @@ -257,8 +256,8 @@ packages: - register_interface - tech_cells_generic register_interface: - revision: 5daa85d164cf6b54ad061ea1e4c6f3624556e467 - version: 0.4.5 + revision: 8e8c209ea559d3b54f45cf30fcce95ce70ff5e49 + version: 0.4.6 source: Git: https://github.com/pulp-platform/register_interface.git dependencies: @@ -274,10 +273,10 @@ packages: dependencies: - tech_cells_generic softex: - revision: 11dd29e85d40e29fea0481b471f1c0cc967df1a4 + revision: cda21ff7793a481bac079ab28cc5af209621ae45 version: null source: - Git: https://github.com/belanoa/softex.git + Git: https://github.com/pulp-platform/softex.git dependencies: - common_cells - fpnew diff --git a/Bender.yml b/Bender.yml index 393903e4..e70d5c50 100644 --- a/Bender.yml +++ b/Bender.yml @@ -22,7 +22,7 @@ dependencies: obi: { git: "https://github.com/pulp-platform/obi.git", version: =0.1.7 } hier-icache: { git: "https://github.com/pulp-platform/hier-icache.git", version: =1.3.0 } cluster_icache: { git: "https://github.com/pulp-platform/cluster_icache.git", version: =0.2.0 } - cluster_peripherals: { git: "https://github.com/pulp-platform/cluster_peripherals.git", rev: "072ddd876c88324ef28856d4b2697424aaa231ce" } + cluster_peripherals: { git: "https://github.com/pulp-platform/cluster_peripherals.git", rev: "a3be530fccdcef4733d57163c6d979ff77ed554d" } axi: { git: "https://github.com/pulp-platform/axi.git", version: =0.39.8 } 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.38.0 } @@ -31,12 +31,13 @@ dependencies: cv32e40p: { git: "https://github.com/pulp-platform/cv32e40p.git", rev: astral-v1.0 } ibex: { git: "https://github.com/pulp-platform/ibex.git", rev: "pulpissimo-v6.1.2" } scm: { git: "https://github.com/pulp-platform/scm.git", rev: v1.2.0 } - hci: { git: "https://github.com/pulp-platform/hci.git", rev: 2a5a508 } # yt/wen-filter + hci: { git: "https://github.com/pulp-platform/hci.git", rev: a42bd8bbf61eb4700b98d51af1b74603c278239e } register_interface: { git: "https://github.com/pulp-platform/register_interface.git", version: 0.4.4 } redundancy_cells: { git: "https://github.com/pulp-platform/redundancy_cells.git", rev: 6ba6f41 } # yt/redmule-v2 - redmule: { git: "https://github.com/pulp-platform/redmule.git", version: =2.0.4 } - neureka: { git: "https://github.com/pulp-platform/neureka.git", rev: f4e131c } # branch: lg/astral-v1.1 - softex: { git: "https://github.com/belanoa/softex.git" , rev: astral-v1.0 } + redmule: { git: "https://github.com/pulp-platform/redmule.git", rev: 466bc59a9c5b263b08535a8e6f1d0637a9bcff34 } # branch: yt/hci-structs + neureka: { git: "https://github.com/pulp-platform/neureka.git", rev: 9edd85ed16861a9b85eabbe87454bd3bdf73c69c } # branch: yt/hci-structs + softex: { git: "https://github.com/belanoa/softex.git" , rev: cda21ff7793a481bac079ab28cc5af209621ae45 } # branch: master + obi: { git: "https://github.com/pulp-platform/obi.git", rev: v0.1.3 } export_include_dirs: - include @@ -96,4 +97,3 @@ sources: files: - nonfree/gf12/sourcecode/tc_sram.sv - nonfree/gf12/sourcecode/tc_clk.sv - diff --git a/Makefile b/Makefile index 215d5f0b..9a602519 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ QUESTA ?= endif BENDER ?= bender +PYTHON ?= python3 BENDER_SUPPRESS_WARNINGS ?= E24 export BENDER_SUPPRESS_WARNINGS @@ -37,6 +38,12 @@ REGRESSIONS := $(ROOT_DIR)/regression_tests VLOG_ARGS_LINT += -suppress vlog-2583 -suppress vlog-13314 -suppress vlog-13233 \"+incdir+$(shell pwd)/include\" VLOG_ARGS += -suppress vlog-2583 -suppress vlog-13314 -suppress vlog-13233 -timescale \"1ns / 1ps\" \"+incdir+$(shell pwd)/include\" +# TB's wide DMA port toggle override +export TB_ENABLE_WIDE_PORT +ifneq ($(strip $(TB_ENABLE_WIDE_PORT)),) +VLOG_ARGS += +define+TB_ENABLE_WIDE_PORT=$(TB_ENABLE_WIDE_PORT) +endif + 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 @@ -51,6 +58,7 @@ NONFREE_REMOTE ?= git@iis-git.ee.ethz.ch:pulp-restricted/pulp-cluster-nonfree.gi NONFREE_COMMIT ?= aad59d36bfef6b74f03ffed28903a44cb86b9497 nonfree-init: + rm -rf nonfree; git clone $(NONFREE_REMOTE) nonfree cd nonfree && git checkout $(NONFREE_COMMIT) @@ -72,6 +80,8 @@ Bender.lock: $(BENDER) checkout touch Bender.lock +update: + $(BENDER) update ###### # SW # @@ -88,33 +98,85 @@ PULP_RUNTIME_REMOTE ?= https://github.com/pulp-platform/pulp-runtime.git PULP_RUNTIME_COMMIT ?= 3b48b0c6872cc01ba169a2c9c886ebb815d22cdc pulp-runtime: + rm -rf $@ git clone $(PULP_RUNTIME_REMOTE) $@ cd $@ && git checkout $(PULP_RUNTIME_COMMIT) +lock-runtime: + @git -C $(PULP_RUNTIME_DIR) rev-parse HEAD > $(PULP_RUNTIME_LOCK_FILE) && \ + echo "Locked pulp-runtime to $$(cat $(PULP_RUNTIME_LOCK_FILE))" + +unlock-runtime: + @rm -f $(PULP_RUNTIME_LOCK_FILE) && echo "Unlocked pulp-runtime (will track $(PULP_RUNTIME_REF))" + ## Clone fault injection scripts FAULT_SIM_REMOTE ?= https://github.com/pulp-platform/InjectaFault.git FAULT_SIM_COMMIT ?= 84ddcff # branch: rt/rename-var fault_injection_sim: + rm -rf $@ git clone $(FAULT_SIM_REMOTE) $@ cd $@ && git checkout $(FAULT_SIM_COMMIT) +lock-fault-sim: + @git -C $(FAULT_SIM_DIR) rev-parse HEAD > $(FAULT_SIM_LOCK_FILE) && \ + echo "Locked fault_injection_sim to $$(cat $(FAULT_SIM_LOCK_FILE))" + +unlock-fault-sim: + @rm -f $(FAULT_SIM_LOCK_FILE) && echo "Unlocked fault_injection_sim (will track $(FAULT_SIM_BRANCH))" + ## Clone regression tests REGRESSION_TESTS_REMOTE ?= https://github.com/pulp-platform/regression_tests.git REGRESSION_TESTS_COMMIT ?= f173611e3e8f15e7f526d40712135e7ff976f805 # branch: lg/upstream regression_tests: + rm -rf $@ git clone $(REGRESSION_TESTS_REMOTE) $@ cd $@ && git checkout $(REGRESSION_TESTS_COMMIT) cd $@ && git submodule update --init --recursive +lock-regression-tests: + @git -C $(REGRESSION_TESTS_DIR) rev-parse HEAD > $(REGRESSION_TESTS_LOCK_FILE) && \ + echo "Locked regression_tests to $$(cat $(REGRESSION_TESTS_LOCK_FILE))" + +unlock-regression-tests: + @rm -f $(REGRESSION_TESTS_LOCK_FILE) && echo "Unlocked regression_tests (will track $(REGRESSION_TESTS_BRANCH))" + +######################### +# Hardware dependencies # +######################### + +# Set dependency paths only if dependencies have already been cloned +# This avoids running `bender checkout` at every make command +ifeq ($(shell test -d $(ROOT_DIR)/.bender || echo 1),) +IDMA_ROOT := $(shell $(BENDER) path idma) +endif + +# Fall back to safe defaults if dependencies are not cloned yet +IDMA_ROOT ?= . + +# Python requirements (version and packages) coming from iDMA repository +gen_idma_hw: $(IDMA_ROOT)/.idma_generated +$(IDMA_ROOT)/.idma_generated: + @$(PYTHON) --version >/dev/null 2>&1 || { echo "ERROR: Python not found. Python 3.8 or higher is required."; exit 1; } && \ + $(PYTHON) -c "import sys; assert sys.version_info >= (3, 8)" || { echo "ERROR: Python version must be 3.8 or higher"; exit 1; } && \ + rm -rf venv && $(PYTHON) -m venv venv && \ + . venv/bin/activate && \ + pip install --upgrade pip && \ + pip install -r $(IDMA_ROOT)/requirements.txt && \ + make -C $(IDMA_ROOT) idma_hw_all && \ + touch $@ + +clean_idma_hw: + make -C $(IDMA_ROOT) idma_clean_all + ######################## # Build and simulation # ######################## .PHONY: sim-clean compile build run -sim-clean: +sim-clean: clean_idma_hw rm -rf scripts/compile.tcl rm -rf work @@ -184,6 +246,13 @@ run: $(VSIM) +permissive -suppress 3053 -suppress 8885 -lib $(library) +MAX_CYCLES=$(max_cycles) +UVM_TESTNAME=$(test_case) +APP=$(elf-bin) +notimingchecks +nospecify -t 1ps \ ${top_level}_tb_optimized +permissive-off ++$(elf-bin) ++$(target-options) ++$(cl-bin) | tee sim.log +.PHONY: clean + +clean: + rm -rf scripts/synth-compile.tcl + rm -rf scripts/compile.tcl + rm -rf transcript + rm -rf *.log #################### # Regression tests # #################### diff --git a/README.md b/README.md index 714b030c..cec098b3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PULP Cluster -![pulp_cluster schematic](doc/PULP_CLUSTER.png) +![pulp_cluster schematic](doc/PULP_CLUSTER_updateOct2024.png) The `pulp_cluster` repository contains the structure of the cluster subsystem used in PULP chips. For more details on the internal architecture, see the diff --git a/bender-common.mk b/bender-common.mk index 75c48018..4297d044 100644 --- a/bender-common.mk +++ b/bender-common.mk @@ -11,6 +11,16 @@ common_defs += -D CLUSTER_ALIAS common_defs += -D USE_PULP_PARAMETERS common_targs += -t rtl +# DMA configuration +DMA_TYPE ?= idma + +ifeq ($(DMA_TYPE),mchan) + common_targs += -t mchan + common_defs += -D TARGET_MCHAN +else + # Default to iDMA +endif + common_targs += -t cluster_standalone common_targs += -t scm_use_fpga_scm common_targs += -t cv32e40p_use_ff_regfile \ No newline at end of file diff --git a/doc/PULP_CLUSTER_updateOct2024.drawio b/doc/PULP_CLUSTER_updateOct2024.drawio new file mode 100644 index 00000000..c3a4afb4 --- /dev/null +++ b/doc/PULP_CLUSTER_updateOct2024.drawio @@ -0,0 +1,1643 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/PULP_CLUSTER_updateOct2024.png b/doc/PULP_CLUSTER_updateOct2024.png new file mode 100644 index 00000000..de562a75 Binary files /dev/null and b/doc/PULP_CLUSTER_updateOct2024.png differ diff --git a/include/cluster_bus_defines.sv b/include/cluster_bus_defines.sv index 487e2629..928ae829 100644 --- a/include/cluster_bus_defines.sv +++ b/include/cluster_bus_defines.sv @@ -13,7 +13,7 @@ * */ -`define NB_SLAVE 4 +`define NB_SLAVE 3 `define NB_MASTER 3 `define NB_REGION 1 diff --git a/include/pulp_soc_defines.sv b/include/pulp_soc_defines.sv index 965fef4a..58444cdc 100644 --- a/include/pulp_soc_defines.sv +++ b/include/pulp_soc_defines.sv @@ -16,7 +16,6 @@ /* * Collection of legacy pulp cluster defines. - * */ `define CLUSTER_ALIAS @@ -43,11 +42,19 @@ `define CLUST_FP_DIVSQRT 1 `define CLUST_SHARED_FP 2 `define CLUST_SHARED_FP_DIVSQRT 2 -`endif +`endif //PARAMETRES `define NB_CLUSTERS 1 `define NB_CORES 8 -`define NB_DMAS 4 +`define NB_EXT 4 `define NB_MPERIPHS 1 `define NB_SPERIPHS 12 + +`ifdef TARGET_MCHAN + `define NB_DMAS 4 + `define DMA_USE_HWPE_PORT 0 +`else + `define NB_DMAS 2 + `define DMA_USE_HWPE_PORT 1 +`endif diff --git a/packages/pulp_cluster_package.sv b/packages/pulp_cluster_package.sv index 33467fa9..af9cd74a 100644 --- a/packages/pulp_cluster_package.sv +++ b/packages/pulp_cluster_package.sv @@ -41,23 +41,28 @@ package pulp_cluster_package; localparam int unsigned MAX_NUM_HWPES = 8; - typedef struct { + typedef struct packed { hwpe_type_e [MAX_NUM_HWPES-1:0] HwpeList; byte_t NumHwpes; + byte_t FifoDepth; } hwpe_subsystem_cfg_t; // PULP cluster configuration - typedef struct { + typedef struct packed { // Type of core in the cluster core_type_e CoreType; // Number of cores in the cluster byte_t NumCores; // Number of DMA TCDM plugs + // If using MCHAN, must be 4. If using iDMA, can vary in multiples of 2 or 3 byte_t DmaNumPlugs; // Number of DMA outstanding transactions byte_t DmaNumOutstandingBursts; // DMA burst length in bits word_t DmaBurstLength; + // If the DMA should use a HWPE port, set to 1 + // This makes sense only when using a DMA_TCDM_DATA_WIDTH close to the HWP + bit DmaUseHwpePort; // Number of masters in crossbar peripherals byte_t NumMstPeriphs; // Number of slaves in crossbar peripherals @@ -144,12 +149,16 @@ package pulp_cluster_package; byte_t AxiIdInWidth; // AXI ID width of crossbar manager ports byte_t AxiIdOutWidth; + // AXI ID width of wide external to cluster port + byte_t AxiIdOutWideWidth; // AXI address width byte_t AxiAddrWidth; - // AXI data width from external to cluster + // AXI data width from external to cluster (narrow) byte_t AxiDataInWidth; - // AXI data width from cluster to external + // AXI data width from cluster to external (narrow) byte_t AxiDataOutWidth; + // AXI data width from cluster to external (wide) + word_t AxiDataOutWideWidth; // AXI user width byte_t AxiUserWidth; // AXI maximum subordinate transaction per ID @@ -170,6 +179,8 @@ package pulp_cluster_package; doub_t ClusterExternalOffs; // Address remap for virtualization bit EnableRemapAddress; + // Enable wide AXI master port for high-bandwidth DMA transfers + bit EnableWidePort; // Enable Snitch ICache bit SnitchICache; } pulp_cluster_cfg_t; @@ -196,7 +207,7 @@ package pulp_cluster_package; localparam int unsigned SPER_ERROR_ID = 12; // -> unmapped, directed to error // The following parameters refer to the cluster AXI crossbar - localparam byte_t NumAxiSubordinatePorts = 4; + localparam byte_t NumAxiSubordinatePorts = 3; localparam byte_t NumAxiManagerPorts = 3; localparam byte_t AxiSubordinateIdwidth = 4; localparam byte_t AxiManagerIdwidth = AxiSubordinateIdwidth + $clog2(NumAxiSubordinatePorts); @@ -209,6 +220,7 @@ package pulp_cluster_package; DmaNumPlugs: NumDmas, DmaNumOutstandingBursts: 8, DmaBurstLength: 5, // Means bursts of 256 bytes: passed as 256 to mchan top, later computed inside iDMA + DmaUseHwpePort: `DMA_USE_HWPE_PORT, NumMstPeriphs: NB_MPERIPHS, NumSlvPeriphs: NB_SPERIPHS, ClusterAlias: 1, @@ -218,7 +230,7 @@ package pulp_cluster_package; TcdmSize: 128*1024, TcdmNumBank: 16, HwpePresent: 1, - HwpeCfg: '{NumHwpes: 3, HwpeList: {SOFTEX, NEUREKA, REDMULE}}, + HwpeCfg: '{NumHwpes: 3, HwpeList: {SOFTEX, NEUREKA, REDMULE}, FifoDepth: 2}, HwpeNumPorts: 9, HMRPresent: 1, HMRDmrEnabled: 1, @@ -249,9 +261,11 @@ package pulp_cluster_package; NumAxiOut: NumAxiManagerPorts, AxiIdInWidth: AxiSubordinateIdwidth, AxiIdOutWidth:AxiManagerIdwidth, + AxiIdOutWideWidth: 1, AxiAddrWidth: 32, AxiDataInWidth: 64, AxiDataOutWidth: 64, + AxiDataOutWideWidth: 128, AxiUserWidth: 10, AxiMaxInTrans: 64, AxiMaxOutTrans: 64, @@ -262,6 +276,7 @@ package pulp_cluster_package; ClusterPeriphOffs: 'h00200000, ClusterExternalOffs: 'h00400000, EnableRemapAddress: 0, + EnableWidePort: 1, SnitchICache: 0, default: '0 }; diff --git a/rtl/cluster_bus_wrap.sv b/rtl/cluster_bus_wrap.sv index 51f64712..61837a49 100644 --- a/rtl/cluster_bus_wrap.sv +++ b/rtl/cluster_bus_wrap.sv @@ -59,8 +59,6 @@ module cluster_bus_wrap output slave_resp_t data_slave_resp_o, input slave_req_t instr_slave_req_i, output slave_resp_t instr_slave_resp_o, - input slave_req_t dma_slave_req_i, - output slave_resp_t dma_slave_resp_o, input slave_req_t ext_slave_req_i, output slave_resp_t ext_slave_resp_o, //INITIATOR @@ -92,10 +90,8 @@ module cluster_bus_wrap `AXI_ASSIGN_RESP_STRUCT(data_slave_resp_o, axi_slave_resps[0]) `AXI_ASSIGN_REQ_STRUCT(axi_slave_reqs[1], instr_slave_req_i) `AXI_ASSIGN_RESP_STRUCT(instr_slave_resp_o, axi_slave_resps[1]) - `AXI_ASSIGN_REQ_STRUCT(axi_slave_reqs[2], dma_slave_req_i) - `AXI_ASSIGN_RESP_STRUCT(dma_slave_resp_o, axi_slave_resps[2]) - `AXI_ASSIGN_REQ_STRUCT(axi_slave_reqs[3], ext_slave_req_i) - `AXI_ASSIGN_RESP_STRUCT(ext_slave_resp_o, axi_slave_resps[3]) + `AXI_ASSIGN_REQ_STRUCT(axi_slave_reqs[2], ext_slave_req_i) + `AXI_ASSIGN_RESP_STRUCT(ext_slave_resp_o, axi_slave_resps[2]) master_req_t [NB_MASTER-1:0] axi_master_reqs; master_resp_t [NB_MASTER-1:0] axi_master_resps; diff --git a/rtl/cluster_interconnect_wrap.sv b/rtl/cluster_interconnect_wrap.sv index b5527d56..b2c55d6a 100644 --- a/rtl/cluster_interconnect_wrap.sv +++ b/rtl/cluster_interconnect_wrap.sv @@ -4,7 +4,7 @@ * * This code is under development and not yet released to the public. * Until it is released, the code is under the copyright of ETH Zurich and - * the University of Bologna, and may contain confidential and/or unpublished + * the University of Bologna, and may contain confidential and/or unpublished * work. Any reuse/redistribution is strictly forbidden without written * permission from ETH Zurich. * @@ -15,14 +15,17 @@ */ `include "hci_helpers.svh" +`include "pulp_soc_defines.sv" import hci_package::*; module cluster_interconnect_wrap #( parameter int unsigned NB_CORES = 8, - parameter int unsigned HWPE_PRESENT = 1, - parameter int unsigned NB_HWPE_PORTS = 9, + parameter int unsigned NB_HWPE = 1, + // how many times wider a HWPE port is than DATA_WIDTH + parameter int unsigned HWPE_WIDTH_FAC = 4, + parameter bit DMA_USE_HWPE_PORT = 1'b0, parameter int unsigned NB_DMAS = 4, parameter int unsigned NB_MPERIPHS = 1, parameter int unsigned NB_TCDM_BANKS = 16, @@ -31,6 +34,7 @@ module cluster_interconnect_wrap parameter int unsigned DATA_WIDTH = 32, parameter int unsigned ADDR_WIDTH = 32, parameter int unsigned BE_WIDTH = DATA_WIDTH/8, + parameter int unsigned TCDM_ID_WIDTH = NB_DMAS + NB_CORES + 4 + HWPE_WIDTH_FAC, parameter logic [ADDR_WIDTH-1:0] ClusterBaseAddr = 'h10000000, parameter logic [ADDR_WIDTH-1:0] ClusterPeripheralsOffs = 'h00200000, parameter logic [ADDR_WIDTH-1:0] ClusterExternalOffs = 'h00400000, @@ -48,6 +52,7 @@ module cluster_interconnect_wrap parameter int unsigned USE_ECC_INTERCONNECT = 0, parameter hci_package::hci_size_parameter_t HCI_CORE_SIZE = '0, parameter hci_package::hci_size_parameter_t HCI_HWPE_SIZE = '0, + parameter hci_package::hci_size_parameter_t HCI_DMA_SIZE = '0, parameter hci_package::hci_size_parameter_t HCI_MEM_SIZE = '0 ) ( @@ -56,9 +61,9 @@ module cluster_interconnect_wrap input logic [5:0] cluster_id_i, XBAR_PERIPH_BUS.Slave hci_ecc_periph_slave, hci_core_intf.target core_tcdm_slave [0 : NB_CORES-1 ], - hci_core_intf.target hwpe_tcdm_slave [0 : 0 ], + hci_core_intf.target hwpe_tcdm_slave [0 : NB_HWPE-1 ], XBAR_PERIPH_BUS.Slave core_periph_slave [NB_CORES-1 : 0 ], - hci_core_intf.target ext_slave [0 : 3 ], + hci_core_intf.target ext_slave [0 : `NB_EXT-1 ], hci_core_intf.target dma_slave [0 : NB_DMAS-1 ], XBAR_TCDM_BUS.Slave mperiph_slave [NB_MPERIPHS-1 : 0 ], hci_core_intf.initiator tcdm_sram_master [0 : NB_TCDM_BANKS-1], @@ -67,7 +72,10 @@ module cluster_interconnect_wrap input logic [1:0] TCDM_arb_policy_i ); - localparam TCDM_ID_WIDTH = NB_CORES+NB_DMAS+4+NB_HWPE_PORTS; + // if DMA uses HWPE ports, ID width must be increased correspondingly + localparam N_HCI_DMA_PORTS = DMA_USE_HWPE_PORT ? 0 : NB_DMAS; + localparam N_HCI_HWPE_PORTS = DMA_USE_HWPE_PORT ? NB_HWPE + NB_DMAS : NB_HWPE; + localparam int unsigned HCI_FILTER_WRITE_R_VALID[0:N_HCI_HWPE_PORTS-1] = '{default: 1}; //-******************************************************** @@ -75,16 +83,70 @@ module cluster_interconnect_wrap //-******************************************************** // Wraps the Logarithmic Interconnect + a HWPE Interconnect generate - if( USE_HETEROGENEOUS_INTERCONNECT || !HWPE_PRESENT ) begin : hci_gen + if( USE_HETEROGENEOUS_INTERCONNECT || (NB_HWPE == 0) ) begin : hci_gen + // HWPEs interface + hci_core_intf #( + .DW(HCI_HWPE_SIZE.DW), + .AW(HCI_HWPE_SIZE.AW), + .BW(HCI_HWPE_SIZE.BW), + .UW(HCI_HWPE_SIZE.UW), + .IW(HCI_HWPE_SIZE.IW), + .EW(HCI_HWPE_SIZE.EW), + .EHW(HCI_HWPE_SIZE.EHW), + .FD(HCI_HWPE_SIZE.FD) + ) + s_hwpe_intc [0:N_HCI_HWPE_PORTS-1] ( + .clk(clk_i) + ); + // DMA interface (only if !DMA_USE_HWPE_PORT) + hci_core_intf #( + .DW(HCI_CORE_SIZE.DW), + .AW(HCI_CORE_SIZE.AW), + .BW(HCI_HWPE_SIZE.BW), + .UW(HCI_HWPE_SIZE.UW), + .IW(HCI_HWPE_SIZE.IW), + .EW(HCI_HWPE_SIZE.EW), + .EHW(HCI_CORE_SIZE.EHW), + .FD(HCI_DMA_SIZE.FD) + ) + s_dma_intc [0:N_HCI_DMA_PORTS-1] ( + .clk(clk_i) + ); + // assign HWPE interfaces to s_hwpe_intc[:] + for (genvar i=0; i 1) ? $clog2(N_HWPES) : 1, parameter hci_package::hci_size_parameter_t HCI_HWPE_SIZE = '0 ) ( @@ -30,6 +32,7 @@ module hwpe_subsystem input logic rst_n, input logic test_mode, input logic hwpe_en_i, + //input logic [HWPE_SEL_BITS-1:0] hwpe_sel_i, input logic [$clog2(MAX_NUM_HWPES)-1:0] hwpe_sel_i, hci_core_intf.initiator hwpe_xbar_master, @@ -43,7 +46,9 @@ module hwpe_subsystem localparam int unsigned AW = HCI_HWPE_SIZE.AW; localparam int unsigned EW = HCI_HWPE_SIZE.EW; localparam int unsigned EHW = HCI_HWPE_SIZE.EHW; + localparam int unsigned FD = HCI_HWPE_SIZE.FD; + // TODO: remove this once we have a proper way to get the number of HWPEs localparam int unsigned N_HWPES = HWPE_CFG.NumHwpes; localparam int unsigned HWPE_SEL_BITS = (N_HWPES > 1) ? $clog2(N_HWPES) : 1; @@ -65,7 +70,8 @@ module hwpe_subsystem .DW ( DW ), .AW ( AW ), .EW ( EW ), - .EHW ( EHW ) + .EHW ( EHW ), + .FD ( FD ) ) tcdm [0:N_HWPES-1] (.clk(clk)); for (genvar i = 0; i < N_HWPES; i++) begin : gen_hwpe diff --git a/rtl/idma_wrap.sv b/rtl/idma_wrap.sv index 26c787d9..73da2e51 100644 --- a/rtl/idma_wrap.sv +++ b/rtl/idma_wrap.sv @@ -52,7 +52,7 @@ module dmac_wrap #( input logic test_mode_i, XBAR_PERIPH_BUS.Slave pe_ctrl_slave[NB_PE_PORTS-1:0], hci_core_intf.target ctrl_slave[0:NB_CORES-1], - hci_core_intf.initiator tcdm_master[0:3], + hci_core_intf.initiator tcdm_master[NB_TCDM_PORTS_PER_STRM*NUM_BIDIR_STREAMS-1:0], output axi_req_t [NUM_BIDIR_STREAMS-1:0] ext_master_req_o, input axi_resp_t [NUM_BIDIR_STREAMS-1:0] ext_master_resp_i, output logic [NB_CORES-1:0] term_event_o, @@ -739,7 +739,7 @@ module dmac_wrap #( .RejectZeroTransfers (1'b1), .ErrorHandling (1'b0) ) i_idma_backend_r_axi_rw_init_rw_obi ( - .clk_i ( datapath_clk_gated ), + .clk_i ( datapath_clk_gated ), .rst_ni ( rst_ni ), .test_i ( test_mode_i ), .req_valid_i ( be_valid[s] ), diff --git a/rtl/pulp_cluster.sv b/rtl/pulp_cluster.sv index e00c0774..50f899c4 100644 --- a/rtl/pulp_cluster.sv +++ b/rtl/pulp_cluster.sv @@ -22,6 +22,8 @@ `include "cluster_bus_defines.sv" `include "pulp_interfaces.sv" `include "register_interface/typedef.svh" +`include "pulp_soc_defines.sv" + module pulp_cluster import pulp_cluster_package::*; @@ -29,13 +31,14 @@ module pulp_cluster import rapid_recovery_pkg::*; import fpnew_pkg::*; #( - parameter pulp_cluster_package::pulp_cluster_cfg_t Cfg = pulp_cluster_package::PulpClusterDefaultCfg, + parameter pulp_cluster_package::pulp_cluster_cfg_t Cfg = + pulp_cluster_package::PulpClusterDefaultCfg, localparam int unsigned TcdmBankSize = Cfg.TcdmSize/Cfg.TcdmNumBank, localparam int unsigned TcdmNumRows = TcdmBankSize/4, localparam int unsigned MaxUniqId = 1, localparam int unsigned AxiIdInWidth = pulp_cluster_package::AxiSubordinateIdwidth, localparam int unsigned AxiIdOutWidth = pulp_cluster_package::AxiManagerIdwidth, - // CDC AXI parameters (external to cluster) + // CDC AXI parameters (external to cluster, narrow) localparam int unsigned AwInWidth = axi_pkg::aw_width(Cfg.AxiAddrWidth, Cfg.AxiIdInWidth, Cfg.AxiUserWidth), @@ -54,7 +57,7 @@ module pulp_cluster localparam int unsigned AsyncInBDataWidth = (2**Cfg.AxiCdcLogDepth)*BInWidth, localparam int unsigned AsyncInArDatawidth = (2**Cfg.AxiCdcLogDepth)*ArInWidth, localparam int unsigned AsyncInRDataWidth = (2**Cfg.AxiCdcLogDepth)*RInWidth, - // CDC AXI parameters (cluster to external) + // CDC AXI parameters (cluster to external, narrow) localparam int unsigned AwOutWidth = axi_pkg::aw_width(Cfg.AxiAddrWidth, Cfg.AxiIdOutWidth, Cfg.AxiUserWidth), @@ -73,6 +76,25 @@ module pulp_cluster localparam int unsigned AsyncOutBDataWidth = (2**Cfg.AxiCdcLogDepth)*BOutWidth, localparam int unsigned AsyncOutArDataWidth = (2**Cfg.AxiCdcLogDepth)*ArOutWidth, localparam int unsigned AsyncOutRDataWidth = (2**Cfg.AxiCdcLogDepth)*ROutWidth, + // CDC AXI parameters (cluster to external, wide) + localparam int unsigned AwOutWideWidth = axi_pkg::aw_width(Cfg.AxiAddrWidth, + Cfg.AxiIdOutWideWidth, + Cfg.AxiUserWidth), + localparam int unsigned WOutWideWidth = axi_pkg::w_width(Cfg.AxiDataOutWideWidth, + Cfg.AxiUserWidth), + localparam int unsigned BOutWideWidth = axi_pkg::b_width(Cfg.AxiIdOutWideWidth, + Cfg.AxiUserWidth), + localparam int unsigned ArOutWideWidth = axi_pkg::ar_width(Cfg.AxiAddrWidth, + Cfg.AxiIdOutWideWidth, + Cfg.AxiUserWidth), + localparam int unsigned ROutWideWidth = axi_pkg::r_width(Cfg.AxiDataOutWideWidth, + Cfg.AxiIdOutWideWidth, + Cfg.AxiUserWidth), + localparam int unsigned AsyncOutAwWideDataWidth = (2**Cfg.AxiCdcLogDepth)*AwOutWideWidth, + localparam int unsigned AsyncOutWWideDataWidth = (2**Cfg.AxiCdcLogDepth)*WOutWideWidth, + localparam int unsigned AsyncOutBWideDataWidth = (2**Cfg.AxiCdcLogDepth)*BOutWideWidth, + localparam int unsigned AsyncOutArWideDataWidth = (2**Cfg.AxiCdcLogDepth)*ArOutWideWidth, + localparam int unsigned AsyncOutRWideDataWidth = (2**Cfg.AxiCdcLogDepth)*ROutWideWidth, // Internal bus parameters // TCDM data bus width (never changes) localparam int unsigned DataWidth = 32, @@ -105,7 +127,9 @@ module pulp_cluster // TCDM banks data width extended with parity for ECCs localparam int unsigned ProtectedTcdmWidth = DataWidth + ParityWidth, // Number of parity bits for ECC-extended HCI HWPE branch - localparam int unsigned HWPEParityWidth = ($clog2(DataWidth)+2)*Cfg.HwpeNumPorts + ($clog2(AddrWidth+(Cfg.HwpeNumPorts*DataWidth)/8+1)+2) + localparam int unsigned HWPEParityWidth = + ($clog2(DataWidth) + 2) * Cfg.HwpeNumPorts + + ($clog2(AddrWidth + (Cfg.HwpeNumPorts * DataWidth) / 8 + 1) + 2) )( input logic clk_i, input logic rst_ni, @@ -127,6 +151,7 @@ module pulp_cluster input logic axi_isolate_i, output logic axi_isolated_o, + output logic axi_isolated_wide_o, input logic dma_pe_evt_ack_i, output logic dma_pe_evt_valid_o, @@ -146,7 +171,7 @@ module pulp_cluster input logic [AsyncEventDataWidth-1:0] async_cluster_events_data_i, - // AXI4 SLAVE + // AXI4 SLAVE Narrow //*************************************** // WRITE ADDRESS CHANNEL input logic [Cfg.AxiCdcLogDepth:0] async_data_slave_aw_wptr_i, @@ -172,7 +197,7 @@ module pulp_cluster output logic [Cfg.AxiCdcLogDepth:0] async_data_slave_b_wptr_o, output logic [AsyncInBDataWidth-1:0] async_data_slave_b_data_o, input logic [Cfg.AxiCdcLogDepth:0] async_data_slave_b_rptr_i, - // AXI4 MASTER + // AXI4 MASTER Narrow //*************************************** // WRITE ADDRESS CHANNEL output logic [Cfg.AxiCdcLogDepth:0] async_data_master_aw_wptr_o, @@ -197,12 +222,39 @@ module pulp_cluster // WRITE RESPONSE CHANNEL input logic [Cfg.AxiCdcLogDepth:0] async_data_master_b_wptr_i, input logic [AsyncOutBDataWidth-1:0] async_data_master_b_data_i, - output logic [Cfg.AxiCdcLogDepth:0] async_data_master_b_rptr_o + output logic [Cfg.AxiCdcLogDepth:0] async_data_master_b_rptr_o, + // AXI4 MASTER Wide + //************************************** + // WRITE ADDRESS CHANNEL + output logic [Cfg.AxiCdcLogDepth:0] async_wide_master_aw_wptr_o, + output logic [AsyncOutAwWideDataWidth-1:0] async_wide_master_aw_data_o, + input logic [Cfg.AxiCdcLogDepth:0] async_wide_master_aw_rptr_i, + + // READ ADDRESS CHANNEL + output logic [Cfg.AxiCdcLogDepth:0] async_wide_master_ar_wptr_o, + output logic [AsyncOutArWideDataWidth-1:0] async_wide_master_ar_data_o, + input logic [Cfg.AxiCdcLogDepth:0] async_wide_master_ar_rptr_i, + + // WRITE DATA CHANNEL + output logic [Cfg.AxiCdcLogDepth:0] async_wide_master_w_wptr_o, + output logic [AsyncOutWWideDataWidth-1:0] async_wide_master_w_data_o, + input logic [Cfg.AxiCdcLogDepth:0] async_wide_master_w_rptr_i, + + // READ DATA CHANNEL + input logic [Cfg.AxiCdcLogDepth:0] async_wide_master_r_wptr_i, + input logic [AsyncOutRWideDataWidth-1:0] async_wide_master_r_data_i, + output logic [Cfg.AxiCdcLogDepth:0] async_wide_master_r_rptr_o, + + // WRITE RESPONSE CHANNEL + input logic [Cfg.AxiCdcLogDepth:0] async_wide_master_b_wptr_i, + input logic [AsyncOutBWideDataWidth-1:0] async_wide_master_b_data_i, + output logic [Cfg.AxiCdcLogDepth:0] async_wide_master_b_rptr_o ); //Ensure that the input AXI ID width is big enough to accomodate the IDs of internal wiring if (Cfg.AxiIdInWidth < 1 + $clog2(Cfg.iCacheNumBanks)) - $info("AXI input ID width must be larger than 1+$clog2(Cfg.iCacheNumBanks) which is %d but was %d", 1 + $clog2(Cfg.iCacheNumBanks), Cfg.AxiIdInWidth); + $info("AXI input ID width must be larger than 1+$clog2(Cfg.iCacheNumBanks) which is %d but was %d" + , 1 + $clog2(Cfg.iCacheNumBanks), Cfg.AxiIdInWidth); localparam int unsigned NB_L1_CUTS = 16; localparam int unsigned RW_MARGIN_WIDTH = 4; @@ -227,6 +279,8 @@ logic [Cfg.NumCores-1:0] dbg_core_running; logic [Cfg.NumCores-1:0] s_dbg_irq; logic s_hwpe_en; logic [$clog2(MAX_NUM_HWPES)-1:0] s_hwpe_sel; +// localparam int unsigned HWPE_SEL_BITS = (Cfg.HwpeCfg.NumHwpes > 1) ? $clog2(Cfg.HwpeCfg.NumHwpes) : 1; +// logic [HWPE_SEL_BITS-1:0] s_hwpe_sel; logic s_idma_en; @@ -290,10 +344,37 @@ logic s_dma_cl_irq; logic s_dma_fc_event; logic s_dma_fc_irq; +// Determine if wide AXI port should be enabled based on DMA type and configuration +// - MCHAN: Always disable wide port (uses narrow port only) +// - iDMA: Use Cfg.EnableWidePort parameter +// `ifdef TARGET_MCHAN +// localparam bit EnableWidePort = 1'b0; // MCHAN never needs wide ports +// `else +// localparam bit EnableWidePort = Cfg.EnableWidePort; // User-configurable for iDMA +// `endif + +// Wide AXI infrastructure: Conditional implementation based on EnableWidePort +// - MCHAN: Always uses narrow transfers (EnableWidePort = 0) +// - iDMA with EnableWidePort=1: Uses wide transfers (256-bit AXI) +// - iDMA with EnableWidePort=0: Uses narrow transfers (64-bit AXI) +// - Wide infrastructure present for interface compatibility +// - Narrow DMA master merged with cluster bus master when wide disabled + logic [Cfg.NumCores-1:0] hmr_barrier_matched; logic [Cfg.NumCores-1:0] hmr_dmr_sw_resynch_req, hmr_tmr_sw_resynch_req; logic [Cfg.NumCores-1:0] hmr_dmr_sw_synch_req, hmr_tmr_sw_synch_req; +// number of log interconnect ports per DMA HCI port - i.e., how many times the +// DMA ports are wider than the intc ports +// DMA ports are currently muxed together with HWPE ports to a single port. +// Thus they don't contribute to the ID width +// TODO Arpan correct this if needed +localparam DMA_IW_CONTRIB_FAC = Cfg.DmaUseHwpePort ? 0 : 1; +// data width of the TCDM master ports coming from the DMA. +// if using MCHAN, must be 32 +localparam int unsigned DMA_HCI_DATA_WIDTH = Cfg.DmaUseHwpePort ? Cfg.AxiDataOutWideWidth : DataWidth; + + localparam hci_package::hci_size_parameter_t HciCoreSizeParam = '{ DW: DataWidth, AW: AddrWidth, @@ -301,7 +382,8 @@ localparam hci_package::hci_size_parameter_t HciCoreSizeParam = '{ UW: DEFAULT_UW, IW: DEFAULT_IW, EW: DEFAULT_EW, - EHW: DEFAULT_EHW + EHW: DEFAULT_EHW, + FD: DEFAULT_FD }; localparam hci_package::hci_size_parameter_t HciHwpeSizeParam = '{ DW: (Cfg.HwpePresent) ? Cfg.HwpeNumPorts * DataWidth : 1, @@ -310,14 +392,27 @@ localparam hci_package::hci_size_parameter_t HciHwpeSizeParam = '{ UW: DEFAULT_UW, IW: DEFAULT_IW, EW: (Cfg.ECCInterco) ? HWPEParityWidth : DEFAULT_EW, - EHW: DEFAULT_EHW + EHW: DEFAULT_EHW, + FD: Cfg.HwpeCfg.FifoDepth +}; +localparam hci_package::hci_size_parameter_t HciDmaSizeParam = '{ + DW: DMA_HCI_DATA_WIDTH, + AW: AddrWidth, + BW: DEFAULT_BW, + UW: DEFAULT_UW, + IW: DEFAULT_IW, + EW: DEFAULT_EW, + EHW: DEFAULT_EHW, + FD: DEFAULT_FD }; + /* logarithmic and peripheral interconnect interfaces */ // ext -> log interconnect hci_core_intf #( .DW ( HciCoreSizeParam.DW ), - .AW ( HciCoreSizeParam.AW ) -) s_hci_ext[0:Cfg.DmaNumPlugs-1] ( + .AW ( HciCoreSizeParam.AW ), + .FD ( HciCoreSizeParam.FD ) +) s_hci_ext[0:`NB_EXT-1] ( .clk ( clk_i ) ); @@ -327,14 +422,14 @@ XBAR_PERIPH_BUS s_xbar_speriph_bus[Cfg.NumSlvPeriphs-1:0](); // periph interconnect -> HWPE subsystem XBAR_PERIPH_BUS s_hwpe_cfg_bus(); -// DMA -> log interconnect +// DMA -> (optionally) size converter hci_core_intf #( - .DW ( HciCoreSizeParam.DW ), - .AW ( HciCoreSizeParam.AW ) + .DW ( HciDmaSizeParam.DW ), + .AW ( HciDmaSizeParam.AW ), + .FD ( HciDmaSizeParam.FD ) ) s_hci_dma[0:Cfg.DmaNumPlugs-1] ( .clk ( clk_i ) ); -XBAR_TCDM_BUS s_dma_plugin_xbar_bus[Cfg.DmaNumPlugs-1:0](); // ext -> xbar periphs FIXME XBAR_TCDM_BUS s_mperiph_xbar_bus[Cfg.NumMstPeriphs-1:0](); @@ -347,13 +442,15 @@ hci_core_intf #( .DW ( HciHwpeSizeParam.DW ), .AW ( HciHwpeSizeParam.AW ), .EW ( HciHwpeSizeParam.EW ), - .EHW ( HciHwpeSizeParam.EHW ) + .EHW ( HciHwpeSizeParam.EHW ), + .FD ( HciHwpeSizeParam.FD ) ) s_hci_hwpe [0:0] ( .clk ( clk_i ) ); hci_core_intf #( .DW ( HciCoreSizeParam.DW ), - .AW ( HciCoreSizeParam.AW ) + .AW ( HciCoreSizeParam.AW ), + .FD ( HciCoreSizeParam.FD ) ) s_hci_core [0:Cfg.NumCores-1] ( .clk ( clk_i ) ); @@ -381,7 +478,8 @@ XBAR_TCDM_BUS s_debug_bus[Cfg.NumCores-1:0](); // FIXME: iDMA hci_core_intf #( .DW ( HciCoreSizeParam.DW ), - .AW ( HciCoreSizeParam.AW ) + .AW ( HciCoreSizeParam.AW ), + .FD ( HciCoreSizeParam.FD ) ) s_core_dmactrl_bus [0:Cfg.NumCores-1] ( .clk ( clk_i ) ); @@ -415,7 +513,11 @@ snitch_icache_pkg::icache_l0_events_t [Cfg.NumCores-1:0] s_icache_l0_events; snitch_icache_pkg::icache_l1_events_t s_icache_l1_events; //----------------------------------------------------------------------// -localparam TCDM_ID_WIDTH = Cfg.NumCores + Cfg.DmaNumPlugs + 4 + Cfg.HwpeNumPorts; +// DMA ports do not need ID extension if mapped to HWPE ports as they are +// currently muxed +// TODO Arpan fix if needed +localparam TCDM_ID_WIDTH = Cfg.NumCores + Cfg.DmaNumPlugs*DMA_IW_CONTRIB_FAC + `NB_EXT + Cfg.HwpeNumPorts; + localparam hci_package::hci_size_parameter_t HciMemSizeParam = '{ DW: DataWidth, AW: AddrMemWidth+2, // AddrMemWidth is word-wise, +2 for byte-wise @@ -423,7 +525,8 @@ localparam hci_package::hci_size_parameter_t HciMemSizeParam = '{ UW: DEFAULT_UW, IW: TCDM_ID_WIDTH, EW: (Cfg.ECCInterco) ? ParityWidth+MetaParityWidth : DEFAULT_EW, - EHW: DEFAULT_EHW + EHW: DEFAULT_EHW, + FD: DEFAULT_FD }; // log interconnect -> TCDM memory banks (SRAM) @@ -448,6 +551,7 @@ hci_core_intf #( // ***********************************************************************************************+ // ***********************************************************************************************+ + //*************************************************** /* synchronous AXI interfaces internal to the cluster */ //*************************************************** @@ -472,6 +576,16 @@ hci_core_intf #( `AXI_TYPEDEF_REQ_T(c2s_out_int_req_t,c2s_out_int_aw_chan_t,c2s_out_int_w_chan_t,c2s_out_int_ar_chan_t) `AXI_TYPEDEF_RESP_T(c2s_out_int_resp_t,c2s_out_int_b_chan_t,c2s_out_int_r_chan_t) + // CLUSTER TO SOC Wide + `AXI_TYPEDEF_AW_CHAN_T(c2s_wide_aw_chan_t,logic[Cfg.AxiAddrWidth-1:0],logic[Cfg.AxiIdOutWideWidth-1:0],logic[Cfg.AxiUserWidth-1:0]) + `AXI_TYPEDEF_W_CHAN_T(c2s_wide_w_chan_t,logic[Cfg.AxiDataOutWideWidth-1:0],logic[Cfg.AxiDataOutWideWidth/8-1:0],logic[Cfg.AxiUserWidth-1:0]) + `AXI_TYPEDEF_B_CHAN_T(c2s_wide_b_chan_t,logic[Cfg.AxiIdOutWideWidth-1:0],logic[Cfg.AxiUserWidth-1:0]) + `AXI_TYPEDEF_AR_CHAN_T(c2s_wide_ar_chan_t,logic[Cfg.AxiAddrWidth-1:0],logic[Cfg.AxiIdOutWideWidth-1:0],logic[Cfg.AxiUserWidth-1:0]) + `AXI_TYPEDEF_R_CHAN_T(c2s_wide_r_chan_t,logic[Cfg.AxiDataOutWideWidth-1:0],logic[Cfg.AxiIdOutWideWidth-1:0],logic[Cfg.AxiUserWidth-1:0]) + + `AXI_TYPEDEF_REQ_T(c2s_wide_req_t, c2s_wide_aw_chan_t, c2s_wide_w_chan_t, c2s_wide_ar_chan_t) + `AXI_TYPEDEF_RESP_T(c2s_wide_resp_t, c2s_wide_b_chan_t, c2s_wide_r_chan_t) + typedef s2c_in_int_aw_chan_t c2s_in_int_aw_chan_t; typedef c2s_out_int_w_chan_t c2s_in_int_w_chan_t; typedef s2c_in_int_b_chan_t c2s_in_int_b_chan_t; @@ -496,15 +610,17 @@ hci_core_intf #( c2s_in_int_req_t s_core_instr_bus_req; c2s_in_int_resp_t s_core_instr_bus_resp; + // DMA master signals - always declared, conditionally connected + c2s_wide_req_t s_dma_master_req; // Wide DMA master (256-bit) + c2s_wide_resp_t s_dma_master_resp; + c2s_out_int_req_t s_dma_narrow_master_req; // Narrow DMA master (64-bit) + c2s_out_int_resp_t s_dma_narrow_master_resp; + // core per2axi -> ext c2s_in_int_req_t s_core_ext_bus_req; c2s_in_int_resp_t s_core_ext_bus_resp; - // DMA -> ext - c2s_in_int_req_t s_dma_ext_bus_req; - c2s_in_int_resp_t s_dma_ext_bus_resp; - // ext -> axi2mem c2s_out_int_req_t s_ext_tcdm_bus_req; c2s_out_int_resp_t s_ext_tcdm_bus_resp; @@ -532,7 +648,6 @@ cluster_bus_wrap #( .NB_MASTER ( Cfg.NumAxiOut ), .NB_SLAVE ( Cfg.NumAxiIn ), .NB_CORES ( Cfg.NumCores ), - .DMA_NB_OUTSND_BURSTS ( Cfg.DmaNumOutstandingBursts ), .TCDM_SIZE ( Cfg.TcdmSize ), .AXI_ADDR_WIDTH ( Cfg.AxiAddrWidth ), .AXI_DATA_WIDTH ( Cfg.AxiDataOutWidth ), @@ -564,8 +679,6 @@ cluster_bus_wrap #( .data_slave_resp_o ( s_core_ext_bus_resp ), .instr_slave_req_i ( s_core_instr_bus_req ), .instr_slave_resp_o ( s_core_instr_bus_resp ), - .dma_slave_req_i ( s_dma_ext_bus_req ), - .dma_slave_resp_o ( s_dma_ext_bus_resp ), .ext_slave_req_i ( s_data_slave_64_req ), .ext_slave_resp_o ( s_data_slave_64_resp ), .tcdm_master_req_o ( s_ext_tcdm_bus_req ), @@ -577,7 +690,7 @@ cluster_bus_wrap #( ); axi2mem_wrap #( - .NB_DMAS ( Cfg.DmaNumPlugs ), + .NB_DMAS ( `NB_EXT ), .AXI_ADDR_WIDTH ( Cfg.AxiAddrWidth ), .AXI_DATA_WIDTH ( Cfg.AxiDataOutWidth ), .AXI_USER_WIDTH ( Cfg.AxiUserWidth ), @@ -656,8 +769,9 @@ per2axi_wrap #( cluster_interconnect_wrap #( .NB_CORES ( Cfg.NumCores ), - .HWPE_PRESENT ( Cfg.HwpePresent ), - .NB_HWPE_PORTS ( Cfg.HwpeNumPorts ), + .NB_HWPE ( Cfg.HwpePresent ), + .HWPE_WIDTH_FAC ( Cfg.HwpeNumPorts ), + .DMA_USE_HWPE_PORT ( Cfg.DmaUseHwpePort ), .NB_DMAS ( Cfg.DmaNumPlugs ), .NB_MPERIPHS ( Cfg.NumMstPeriphs ), .NB_TCDM_BANKS ( Cfg.TcdmNumBank ), @@ -679,8 +793,8 @@ cluster_interconnect_wrap #( .USE_ECC_INTERCONNECT ( Cfg.EnableECC && Cfg.ECCInterco ), .HCI_CORE_SIZE ( HciCoreSizeParam ), .HCI_HWPE_SIZE ( HciHwpeSizeParam ), + .HCI_DMA_SIZE ( HciDmaSizeParam ), .HCI_MEM_SIZE ( HciMemSizeParam ) - ) cluster_interconnect_wrap_i ( .clk_i ( clk_i ), .rst_ni ( rst_ni ), @@ -726,52 +840,93 @@ cluster_clock_gating idma_ctrl_ckgate ( //*************************************************** //*********************DMAC WRAP********************* //*************************************************** -dmac_wrap #( - .NB_CORES ( Cfg.NumCores ), - .NB_OUTSND_BURSTS ( Cfg.DmaNumOutstandingBursts ), - .AXI_ADDR_WIDTH ( Cfg.AxiAddrWidth ), - .AXI_DATA_WIDTH ( Cfg.AxiDataOutWidth ), - .AXI_ID_WIDTH ( AxiIdInWidth ), - .AXI_USER_WIDTH ( Cfg.AxiUserWidth ), - .PE_ID_WIDTH ( Cfg.NumCores + 1 ), - .DATA_WIDTH ( DataWidth ), - .ADDR_WIDTH ( AddrWidth ), - .BE_WIDTH ( BeWidth ), - .axi_req_t ( c2s_in_int_req_t ), - .axi_resp_t ( c2s_in_int_resp_t ), -`ifdef TARGET_MCHAN - .NB_CTRLS ( Cfg.NumCores + 2 ), - .MCHAN_BURST_LENGTH ( 8 * (1 << Cfg.DmaBurstLength) ), - .TCDM_ADD_WIDTH ( TcdmAddrWidth ) -`else - .NB_PE_PORTS ( 2 ), - .NUM_BIDIR_STREAMS ( 1 ), - .GLOBAL_QUEUE_DEPTH ( 8 ), - .MUX_READ ( 1'b1 ), - .TCDM_MEM2BANKS ( 1 ), - .IDMA_BURST_LENGTH ( Cfg.DmaBurstLength ) -`endif -) dmac_wrap_i ( -`ifdef TARGET_IDMA - .clk_i ( idma_clk_gated ), -`else - .clk_i ( clk_i ), -`endif - .rst_ni ( rst_ni ), - .test_mode_i ( test_mode_i ), - .pe_ctrl_slave ( s_periph_dma_bus[1:0] ), - .ctrl_slave ( s_core_dmactrl_bus ), - .tcdm_master ( s_hci_dma ), - - .ext_master_req_o ( s_dma_ext_bus_req ), - .ext_master_resp_i ( s_dma_ext_bus_resp ), - - .term_event_o ( s_dma_event ), - .term_irq_o ( s_dma_irq ), - .term_event_pe_o ( {s_dma_fc_event, s_dma_cl_event} ), - .term_irq_pe_o ( {s_dma_fc_irq, s_dma_cl_irq} ), - .busy_o ( s_dmac_busy ) -); +if (Cfg.EnableWidePort) begin : gen_wide_port_idma + dmac_wrap #( + .NB_CORES ( Cfg.NumCores ), + .NB_OUTSND_BURSTS ( Cfg.DmaNumOutstandingBursts ), + .AXI_ADDR_WIDTH ( Cfg.AxiAddrWidth ), + .AXI_DATA_WIDTH ( Cfg.AxiDataOutWideWidth ), + .AXI_ID_WIDTH ( Cfg.AxiIdOutWideWidth ), + .AXI_USER_WIDTH ( Cfg.AxiUserWidth ), + .PE_ID_WIDTH ( Cfg.NumCores + 1 ), + .DATA_WIDTH ( DataWidth ), + .ADDR_WIDTH ( AddrWidth ), + .BE_WIDTH ( BeWidth ), + .axi_req_t ( c2s_wide_req_t ), + .axi_resp_t ( c2s_wide_resp_t ), + `ifdef TARGET_MCHAN + .NB_CTRLS ( Cfg.NumCores + 2 ), + .MCHAN_BURST_LENGTH ( Cfg.DmaBurstLength ), + .TCDM_ADD_WIDTH ( TcdmAddrWidth ) + `else + .NB_PE_PORTS ( 2 ), + .NUM_BIDIR_STREAMS ( 1 ), + .GLOBAL_QUEUE_DEPTH ( 2 ), + .MUX_READ ( 1'b1 ), + .TCDM_MEM2BANKS ( !Cfg.DmaUseHwpePort ) + `endif + ) dmac_wrap_i ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .test_mode_i ( test_mode_i ), + .pe_ctrl_slave ( s_periph_dma_bus[1:0] ), + .ctrl_slave ( s_core_dmactrl_bus ), + .tcdm_master ( s_hci_dma ), + `ifdef TARGET_MCHAN + .ext_master_req_o ( /* MCHAN uses narrow port - not connected to wide */ ), + .ext_master_resp_i ( '0 ), + `else + .ext_master_req_o ( {s_dma_master_req} ), + .ext_master_resp_i ( {s_dma_master_resp} ), + `endif + .term_event_o ( s_dma_event ), + .term_irq_o ( s_dma_irq ), + .term_event_pe_o ( {s_dma_fc_event, s_dma_cl_event} ), + .term_irq_pe_o ( {s_dma_fc_irq, s_dma_cl_irq} ), + .busy_o ( s_dmac_busy ) + ); +end else begin : gen_narrow_port_idma + dmac_wrap #( + .NB_CORES ( Cfg.NumCores ), + .NB_OUTSND_BURSTS ( Cfg.DmaNumOutstandingBursts ), + .AXI_ADDR_WIDTH ( Cfg.AxiAddrWidth ), + .AXI_DATA_WIDTH ( Cfg.AxiDataOutWidth ), + .AXI_ID_WIDTH ( AxiIdOutWidth ), + .AXI_USER_WIDTH ( Cfg.AxiUserWidth ), + .PE_ID_WIDTH ( Cfg.NumCores + 1 ), + .DATA_WIDTH ( DataWidth ), + .ADDR_WIDTH ( AddrWidth ), + .BE_WIDTH ( BeWidth ), + .axi_req_t ( c2s_out_int_req_t ), + .axi_resp_t ( c2s_out_int_resp_t ), + `ifdef TARGET_MCHAN + .NB_CTRLS ( Cfg.NumCores + 2 ), + .MCHAN_BURST_LENGTH ( Cfg.DmaBurstLength ), + .TCDM_ADD_WIDTH ( TcdmAddrWidth ) + `else + .NB_PE_PORTS ( 2 ), + .NUM_BIDIR_STREAMS ( 1 ), + .GLOBAL_QUEUE_DEPTH ( 2 ), + .MUX_READ ( 1'b1 ), + .TCDM_MEM2BANKS ( !Cfg.DmaUseHwpePort ) + `endif + ) dmac_wrap_i ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .test_mode_i ( test_mode_i ), + .pe_ctrl_slave ( s_periph_dma_bus[1:0] ), + .ctrl_slave ( s_core_dmactrl_bus ), + .tcdm_master ( s_hci_dma ), + .ext_master_req_o ( {s_dma_narrow_master_req} ), + .ext_master_resp_i ( {s_dma_narrow_master_resp} ), + .term_event_o ( s_dma_event ), + .term_irq_o ( s_dma_irq ), + .term_event_pe_o ( {s_dma_fc_event, s_dma_cl_event} ), + .term_irq_pe_o ( {s_dma_fc_irq, s_dma_cl_irq} ), + .busy_o ( s_dmac_busy ) + ); +end + //*************************************************** //**************CLUSTER PERIPHERALS****************** @@ -779,6 +934,7 @@ dmac_wrap #( cluster_peripherals #( .NB_CORES ( Cfg.NumCores ), .NB_HWPES ( MAX_NUM_HWPES ), + //.NB_HWPES ( Cfg.HwpeCfg.NumHwpes ), .NB_MPERIPHS ( Cfg.NumMstPeriphs ), .NB_CACHE_BANKS ( Cfg.iCacheNumBanks), .NB_SPERIPHS ( Cfg.NumSlvPeriphs ), @@ -1244,6 +1400,8 @@ generate .HWPE_CFG ( Cfg.HwpeCfg ), .N_CORES ( Cfg.NumCores ), .N_MASTER_PORT ( Cfg.HwpeNumPorts ), + //.N_HWPES ( Cfg.HwpeCfg.NumHwpes ), + //.HWPE_SEL_BITS ( HWPE_SEL_BITS ), .ID_WIDTH ( Cfg.NumCores + Cfg.NumMstPeriphs ), .HCI_HWPE_SIZE ( HciHwpeSizeParam ) ) hwpe_subsystem_i ( @@ -1548,6 +1706,7 @@ tcdm_banks_wrap #( //******************************************************** //**************** AXI REGISTER SLICES ******************* //******************************************************** + // CLUSTER TO SOC `AXI_TYPEDEF_AW_CHAN_T(c2s_aw_chan_t,logic[Cfg.AxiAddrWidth-1:0],logic[Cfg.AxiIdOutWidth-1:0],logic[Cfg.AxiUserWidth-1:0]) `AXI_TYPEDEF_W_CHAN_T(c2s_w_chan_t,logic[Cfg.AxiDataOutWidth-1:0],logic[Cfg.AxiDataOutWidth/8-1:0],logic[Cfg.AxiUserWidth-1:0]) @@ -1558,9 +1717,6 @@ tcdm_banks_wrap #( `AXI_TYPEDEF_REQ_T(c2s_req_t,c2s_aw_chan_t,c2s_w_chan_t,c2s_ar_chan_t) `AXI_TYPEDEF_RESP_T(c2s_resp_t,c2s_b_chan_t,c2s_r_chan_t) -c2s_req_t src_req, isolate_src_req ; -c2s_resp_t src_resp, isolate_src_resp; - sync #( .STAGES ( Cfg.SyncStages ), .ResetValue ( 1'b1 ) @@ -1611,6 +1767,10 @@ sync #( .serial_o ( mbox_irq_synch ) ); +// Cluster to Soc (narrow) +c2s_req_t src_req, isolate_src_req; +c2s_resp_t src_resp, isolate_src_resp; + `AXI_TYPEDEF_AW_CHAN_T(c2s_remap_aw_chan_t,logic[Cfg.AxiAddrWidth-1:0],logic[AxiIdOutWidth-1:0],logic[Cfg.AxiUserWidth-1:0]) `AXI_TYPEDEF_W_CHAN_T(c2s_remap_w_chan_t,logic[Cfg.AxiDataOutWidth-1:0],logic[Cfg.AxiDataOutWidth/8-1:0],logic[Cfg.AxiUserWidth-1:0]) `AXI_TYPEDEF_B_CHAN_T(c2s_remap_b_chan_t,logic[AxiIdOutWidth-1:0],logic[Cfg.AxiUserWidth-1:0]) @@ -1623,8 +1783,79 @@ sync #( c2s_remap_req_t src_remap_req; c2s_remap_resp_t src_remap_resp; -`AXI_ASSIGN_REQ_STRUCT(src_remap_req,s_data_master_req) -`AXI_ASSIGN_RESP_STRUCT(s_data_master_resp,src_remap_resp) +// Connect DMA narrow master when wide port disabled, otherwise cluster bus master +if (Cfg.EnableWidePort) begin : gen_cluster_bus_narrow_master + `AXI_ASSIGN_REQ_STRUCT(src_remap_req, s_data_master_req) + `AXI_ASSIGN_RESP_STRUCT(s_data_master_resp, src_remap_resp) +end else begin : gen_dma_narrow_master + // Merge cluster bus master and DMA narrow master via AXI multiplexer + localparam int SlvIdWidth = AxiIdOutWidth; + localparam int MstIdWidth = AxiIdOutWidth + 1; + + // Widened AW channel for mux output + `AXI_TYPEDEF_AW_CHAN_T(c2s_mux_aw_chan_t, logic[Cfg.AxiAddrWidth-1:0], logic[MstIdWidth-1:0], logic[Cfg.AxiUserWidth-1:0]) + `AXI_TYPEDEF_W_CHAN_T(c2s_mux_w_chan_t, logic[Cfg.AxiDataOutWidth-1:0], logic[Cfg.AxiDataOutWidth/8-1:0], logic[Cfg.AxiUserWidth-1:0]) + `AXI_TYPEDEF_B_CHAN_T(c2s_mux_b_chan_t, logic[MstIdWidth-1:0], logic[Cfg.AxiUserWidth-1:0]) + `AXI_TYPEDEF_AR_CHAN_T(c2s_mux_ar_chan_t, logic[Cfg.AxiAddrWidth-1:0], logic[MstIdWidth-1:0], logic[Cfg.AxiUserWidth-1:0]) + `AXI_TYPEDEF_R_CHAN_T(c2s_mux_r_chan_t, logic[Cfg.AxiDataOutWidth-1:0], logic[MstIdWidth-1:0], logic[Cfg.AxiUserWidth-1:0]) + + `AXI_TYPEDEF_REQ_T(c2s_mux_req_t, c2s_mux_aw_chan_t, c2s_mux_w_chan_t, c2s_mux_ar_chan_t) + `AXI_TYPEDEF_RESP_T(c2s_mux_resp_t, c2s_mux_b_chan_t, c2s_mux_r_chan_t) + + // Arrays for the two slave ports + c2s_remap_req_t [1:0] narrow_master_reqs; + c2s_remap_resp_t [1:0] narrow_master_resps; + c2s_mux_req_t mux_req; + c2s_mux_resp_t mux_resp; + + // Bind cluster-bus and DMA inputs + `AXI_ASSIGN_REQ_STRUCT(narrow_master_reqs[0], s_data_master_req) + `AXI_ASSIGN_REQ_STRUCT(narrow_master_reqs[1], s_dma_narrow_master_req) + + // 2-to-1 AXI multiplexer (prepending ID bit) + axi_mux #( + .SlvAxiIDWidth ( AxiIdOutWidth ), + .slv_aw_chan_t ( c2s_remap_aw_chan_t ), .mst_aw_chan_t ( c2s_mux_aw_chan_t ), + .w_chan_t ( c2s_remap_w_chan_t ), + .slv_b_chan_t ( c2s_remap_b_chan_t ), .mst_b_chan_t ( c2s_mux_b_chan_t ), + .slv_ar_chan_t ( c2s_remap_ar_chan_t ), .mst_ar_chan_t ( c2s_mux_ar_chan_t ), + .slv_r_chan_t ( c2s_remap_r_chan_t ), .mst_r_chan_t ( c2s_mux_r_chan_t ), + .slv_req_t ( c2s_remap_req_t ), .slv_resp_t ( c2s_remap_resp_t ), + .mst_req_t ( c2s_mux_req_t ), .mst_resp_t ( c2s_mux_resp_t ), + .NoSlvPorts ( 2 ), .FallThrough(1'b1) + ) i_idma_narrow_mux ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .test_i ( test_mode_i ), + // Inputs: cluster-bus first, then DMA narrow + .slv_reqs_i ( narrow_master_reqs ), + .slv_resps_o ( narrow_master_resps ), + // Output of mux feeds ID shrink stage + .mst_req_o ( mux_req ), + .mst_resp_i ( mux_resp ) + ); + + axi_id_remap #( + .AxiSlvPortIdWidth ( MstIdWidth ), // ID width = AxiIdOutWidth + 1 + .AxiSlvPortMaxUniqIds ( 4 ), + .AxiMaxTxnsPerId ( Cfg.AxiMaxOutTrans ), + .AxiMstPortIdWidth ( AxiIdOutWidth ), + .slv_req_t ( c2s_mux_req_t ), + .slv_resp_t ( c2s_mux_resp_t ), + .mst_req_t ( c2s_remap_req_t ), + .mst_resp_t ( c2s_remap_resp_t ) + ) i_idma_narrow_id_shrink ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .slv_req_i ( mux_req ), + .slv_resp_o ( mux_resp ), + .mst_req_o ( src_remap_req ), + .mst_resp_i ( src_remap_resp ) + ); + // Drive external responses from narrow_master_resps + `AXI_ASSIGN_RESP_STRUCT(s_data_master_resp, narrow_master_resps[0]) + `AXI_ASSIGN_RESP_STRUCT(s_dma_narrow_master_resp, narrow_master_resps[1]) +end if (Cfg.AxiIdOutWidth != AxiIdOutWidth) begin : gen_c2s_idwremap axi_id_remap #( @@ -1671,37 +1902,103 @@ axi_isolate #( ); axi_cdc_src #( - .aw_chan_t ( c2s_aw_chan_t ), - .w_chan_t ( c2s_w_chan_t ), - .b_chan_t ( c2s_b_chan_t ), - .r_chan_t ( c2s_r_chan_t ), - .ar_chan_t ( c2s_ar_chan_t ), - .axi_req_t ( c2s_req_t ), - .axi_resp_t ( c2s_resp_t ), - .LogDepth ( Cfg.AxiCdcLogDepth ), - .SyncStages ( Cfg.AxiCdcSyncStages ) + .aw_chan_t ( c2s_aw_chan_t ), + .w_chan_t ( c2s_w_chan_t ), + .b_chan_t ( c2s_b_chan_t ), + .r_chan_t ( c2s_r_chan_t ), + .ar_chan_t ( c2s_ar_chan_t ), + .axi_req_t ( c2s_req_t ), + .axi_resp_t ( c2s_resp_t ), + .LogDepth ( Cfg.AxiCdcLogDepth ), + .SyncStages ( Cfg.AxiCdcSyncStages ) ) axi_master_cdc_i ( - .src_rst_ni ( pwr_on_rst_ni ), - .src_clk_i ( clk_i ), - .src_req_i ( src_req ), - .src_resp_o ( src_resp ), - .async_data_master_aw_wptr_o ( async_data_master_aw_wptr_o ), - .async_data_master_aw_rptr_i ( async_data_master_aw_rptr_i ), - .async_data_master_aw_data_o ( async_data_master_aw_data_o ), - .async_data_master_w_wptr_o ( async_data_master_w_wptr_o ), - .async_data_master_w_rptr_i ( async_data_master_w_rptr_i ), - .async_data_master_w_data_o ( async_data_master_w_data_o ), - .async_data_master_ar_wptr_o ( async_data_master_ar_wptr_o ), - .async_data_master_ar_rptr_i ( async_data_master_ar_rptr_i ), - .async_data_master_ar_data_o ( async_data_master_ar_data_o ), - .async_data_master_b_wptr_i ( async_data_master_b_wptr_i ), - .async_data_master_b_rptr_o ( async_data_master_b_rptr_o ), - .async_data_master_b_data_i ( async_data_master_b_data_i ), - .async_data_master_r_wptr_i ( async_data_master_r_wptr_i ), - .async_data_master_r_rptr_o ( async_data_master_r_rptr_o ), - .async_data_master_r_data_i ( async_data_master_r_data_i ) + .src_rst_ni ( pwr_on_rst_ni ), + .src_clk_i ( clk_i ), + .src_req_i ( src_req ), + .src_resp_o ( src_resp ), + .async_data_master_aw_wptr_o ( async_data_master_aw_wptr_o ), + .async_data_master_aw_rptr_i ( async_data_master_aw_rptr_i ), + .async_data_master_aw_data_o ( async_data_master_aw_data_o ), + .async_data_master_w_wptr_o ( async_data_master_w_wptr_o ), + .async_data_master_w_rptr_i ( async_data_master_w_rptr_i ), + .async_data_master_w_data_o ( async_data_master_w_data_o ), + .async_data_master_ar_wptr_o ( async_data_master_ar_wptr_o ), + .async_data_master_ar_rptr_i ( async_data_master_ar_rptr_i ), + .async_data_master_ar_data_o ( async_data_master_ar_data_o ), + .async_data_master_b_wptr_i ( async_data_master_b_wptr_i ), + .async_data_master_b_rptr_o ( async_data_master_b_rptr_o ), + .async_data_master_b_data_i ( async_data_master_b_data_i ), + .async_data_master_r_wptr_i ( async_data_master_r_wptr_i ), + .async_data_master_r_rptr_o ( async_data_master_r_rptr_o ), + .async_data_master_r_data_i ( async_data_master_r_data_i ) ); +// Cluster to Soc (wide) +c2s_wide_req_t src_wide_req, isolate_src_wide_req; +c2s_wide_resp_t src_wide_resp, isolate_src_wide_resp; + +// Route DMA master request/response based on EnableWidePort +assign isolate_src_wide_req = Cfg.EnableWidePort ? s_dma_master_req : s_dma_narrow_master_req; +assign s_dma_master_resp = Cfg.EnableWidePort ? isolate_src_wide_resp : s_dma_narrow_master_resp; + +// Instantiate wide port isolation and CDC only when enabled +generate + if (Cfg.EnableWidePort) begin : gen_wide_port + axi_isolate #( + .NumPending ( 8 ), + .TerminateTransaction ( 1 ), + .AtopSupport ( 1 ), + .AxiAddrWidth ( Cfg.AxiAddrWidth ), + .AxiDataWidth ( Cfg.AxiDataOutWideWidth ), + .AxiIdWidth ( Cfg.AxiIdOutWideWidth ), + .AxiUserWidth ( Cfg.AxiUserWidth ), + .axi_req_t ( c2s_wide_req_t ), + .axi_resp_t ( c2s_wide_resp_t ) + ) i_axi_wide_master_isolate ( + .clk_i ( clk_i ), + .rst_ni ( rst_ni ), + .slv_req_i ( isolate_src_wide_req ), + .slv_resp_o ( isolate_src_wide_resp ), + .mst_req_o ( src_wide_req ), + .mst_resp_i ( src_wide_resp ), + .isolate_i ( axi_isolate_synch ), + .isolated_o ( axi_isolated_wide_o ) + ); + + axi_cdc_src #( + .aw_chan_t ( c2s_wide_aw_chan_t ), + .w_chan_t ( c2s_wide_w_chan_t ), + .b_chan_t ( c2s_wide_b_chan_t ), + .r_chan_t ( c2s_wide_r_chan_t ), + .ar_chan_t ( c2s_wide_ar_chan_t ), + .axi_req_t ( c2s_wide_req_t ), + .axi_resp_t ( c2s_wide_resp_t ), + .LogDepth ( Cfg.AxiCdcLogDepth ), + .SyncStages ( Cfg.AxiCdcSyncStages ) + ) axi_wide_master_cdc_i ( + .src_rst_ni ( pwr_on_rst_ni ), + .src_clk_i ( clk_i ), + .src_req_i ( src_wide_req ), + .src_resp_o ( src_wide_resp ), + .async_data_master_aw_wptr_o ( async_wide_master_aw_wptr_o ), + .async_data_master_aw_rptr_i ( async_wide_master_aw_rptr_i ), + .async_data_master_aw_data_o ( async_wide_master_aw_data_o ), + .async_data_master_w_wptr_o ( async_wide_master_w_wptr_o ), + .async_data_master_w_rptr_i ( async_wide_master_w_rptr_i ), + .async_data_master_w_data_o ( async_wide_master_w_data_o ), + .async_data_master_ar_wptr_o ( async_wide_master_ar_wptr_o ), + .async_data_master_ar_rptr_i ( async_wide_master_ar_rptr_i ), + .async_data_master_ar_data_o ( async_wide_master_ar_data_o ), + .async_data_master_b_wptr_i ( async_wide_master_b_wptr_i ), + .async_data_master_b_rptr_o ( async_wide_master_b_rptr_o ), + .async_data_master_b_data_i ( async_wide_master_b_data_i ), + .async_data_master_r_wptr_i ( async_wide_master_r_wptr_i ), + .async_data_master_r_rptr_o ( async_wide_master_r_rptr_o ), + .async_data_master_r_data_i ( async_wide_master_r_data_i ) + ); + end +endgenerate + // SOC TO CLUSTER `AXI_TYPEDEF_AW_CHAN_T(s2c_aw_chan_t,logic[Cfg.AxiAddrWidth-1:0],logic[Cfg.AxiIdInWidth-1:0],logic[Cfg.AxiUserWidth-1:0]) `AXI_TYPEDEF_W_CHAN_T(s2c_w_chan_t,logic[Cfg.AxiDataInWidth-1:0],logic[Cfg.AxiDataInWidth/8-1:0],logic[Cfg.AxiUserWidth-1:0]) @@ -1712,6 +2009,7 @@ axi_cdc_src #( `AXI_TYPEDEF_REQ_T(s2c_req_t,s2c_aw_chan_t,s2c_w_chan_t,s2c_ar_chan_t) `AXI_TYPEDEF_RESP_T(s2c_resp_t,s2c_b_chan_t,s2c_r_chan_t) +// Soc to Cluster (narrow) s2c_req_t dst_req; s2c_resp_t dst_resp; @@ -1853,4 +2151,31 @@ edge_propagator_tx ep_dma_pe_irq_i ( .valid_o ( dma_pe_irq_valid_o ) ); +// pragma translate_off +`ifndef VERILATOR +initial begin : p_assert + `ifdef TARGET_MCHAN + assert(DMA_HCI_DATA_WIDTH == 32) + else $fatal(1, "When using MCHAN, DMA_HCI_DATA_WIDTH must be 32!"); + assert(Cfg.DmaNumPlugs == 4) + else $fatal(1, "When using MCHAN, Cfg.DmaNumPlugs must be 4!"); + assert(!Cfg.DmaUseHwpePort) + else $fatal(1, "When using MCHAN, Cfg.DmaUseHwpePort must be 0!"); + assert(!Cfg.EnableWidePort) + else $fatal(1, "When using MCHAN, wide port should be disabled!"); + `else + if (!Cfg.DmaUseHwpePort) begin + // The DMA can have wide access to TCDM only when sharing the master port to HCI with the HWPE + assert(DMA_HCI_DATA_WIDTH == DataWidth) + else $fatal(1, "When Cfg.DmaUseHwpePort is 0, DMA_HCI_DATA_WIDTH must be equal to DataWidth!"); + end + // Note: iDMA now uses conditional data width and AXI path selection + // EnableWidePort=0: iDMA uses 64-bit narrow transfers via cluster bus AXI path + // EnableWidePort=1: iDMA uses 256-bit wide transfers via dedicated wide AXI path + `endif +end +`endif +// pragma translate_on + + endmodule diff --git a/rtl/pulp_cluster_wrap.sv b/rtl/pulp_cluster_wrap.sv index b71b242b..db625f2b 100644 --- a/rtl/pulp_cluster_wrap.sv +++ b/rtl/pulp_cluster_wrap.sv @@ -19,7 +19,7 @@ package pulp_cluster_wrap_package; localparam int unsigned AxiIdInWidth = pulp_cluster_package::AxiSubordinateIdwidth; localparam int unsigned AxiIdOutWidth = pulp_cluster_package::AxiManagerIdwidth; - // CDC AXI parameters (external to cluster) + // CDC AXI parameters (external to cluster, narrow) localparam int unsigned AwInWidth = axi_pkg::aw_width(Cfg.AxiAddrWidth, Cfg.AxiIdInWidth, Cfg.AxiUserWidth); @@ -38,7 +38,7 @@ package pulp_cluster_wrap_package; localparam int unsigned AsyncInBDataWidth = (2**Cfg.AxiCdcLogDepth)*BInWidth; localparam int unsigned AsyncInArDatawidth = (2**Cfg.AxiCdcLogDepth)*ArInWidth; localparam int unsigned AsyncInRDataWidth = (2**Cfg.AxiCdcLogDepth)*RInWidth; - // CDC AXI parameters (cluster to external) + // CDC AXI parameters (cluster to external, narrow) localparam int unsigned AwOutWidth = axi_pkg::aw_width(Cfg.AxiAddrWidth, Cfg.AxiIdOutWidth, Cfg.AxiUserWidth); @@ -58,6 +58,25 @@ package pulp_cluster_wrap_package; localparam int unsigned AsyncOutArDataWidth = (2**Cfg.AxiCdcLogDepth)*ArOutWidth; localparam int unsigned AsyncOutRDataWidth = (2**Cfg.AxiCdcLogDepth)*ROutWidth; localparam int unsigned AsyncEventDataWidth = (2**Cfg.AxiCdcLogDepth)*EventWidth; + // CDC AXI parameters (cluster to external, wide) + localparam int unsigned AwOutWideWidth = axi_pkg::aw_width(Cfg.AxiAddrWidth, + Cfg.AxiIdOutWideWidth, + Cfg.AxiUserWidth); + localparam int unsigned WOutWideWidth = axi_pkg::w_width(Cfg.AxiDataOutWideWidth, + Cfg.AxiUserWidth); + localparam int unsigned BOutWideWidth = axi_pkg::b_width(Cfg.AxiIdOutWideWidth, + Cfg.AxiUserWidth); + localparam int unsigned ArOutWideWidth = axi_pkg::ar_width(Cfg.AxiAddrWidth, + Cfg.AxiIdOutWideWidth, + Cfg.AxiUserWidth); + localparam int unsigned ROutWideWidth = axi_pkg::r_width(Cfg.AxiDataOutWideWidth, + Cfg.AxiIdOutWideWidth, + Cfg.AxiUserWidth); + localparam int unsigned AsyncOutAwWideDataWidth = (2**Cfg.AxiCdcLogDepth)*AwOutWideWidth; + localparam int unsigned AsyncOutWWideDataWidth = (2**Cfg.AxiCdcLogDepth)*WOutWideWidth; + localparam int unsigned AsyncOutBWideDataWidth = (2**Cfg.AxiCdcLogDepth)*BOutWideWidth; + localparam int unsigned AsyncOutArWideDataWidth = (2**Cfg.AxiCdcLogDepth)*ArOutWideWidth; + localparam int unsigned AsyncOutRWideDataWidth = (2**Cfg.AxiCdcLogDepth)*ROutWideWidth; endpackage module pulp_cluster_wrap ( @@ -74,6 +93,7 @@ module pulp_cluster_wrap ( output logic busy_o, input logic axi_isolate_i, output logic axi_isolated_o, + output logic axi_isolated_wide_o, input logic dma_pe_evt_ack_i, output logic dma_pe_evt_valid_o, input logic dma_pe_irq_ack_i, @@ -85,7 +105,7 @@ module pulp_cluster_wrap ( input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_cluster_events_wptr_i, output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_cluster_events_rptr_o, input logic [pulp_cluster_wrap_package::AsyncEventDataWidth-1:0] async_cluster_events_data_i, - // AXI4 SLAVE + // AXI4 SLAVE Narrow //*************************************** // WRITE ADDRESS CHANNEL input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_data_slave_aw_wptr_i, @@ -107,7 +127,7 @@ module pulp_cluster_wrap ( output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_data_slave_b_wptr_o, output logic [pulp_cluster_wrap_package::AsyncInBDataWidth-1:0] async_data_slave_b_data_o, input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_data_slave_b_rptr_i, - // AXI4 MASTER + // AXI4 MASTER Narrow //*************************************** // WRITE ADDRESS CHANNEL output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_data_master_aw_wptr_o, @@ -128,7 +148,33 @@ module pulp_cluster_wrap ( // WRITE RESPONSE CHANNEL input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_data_master_b_wptr_i, input logic [pulp_cluster_wrap_package::AsyncOutBDataWidth-1:0] async_data_master_b_data_i, - output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_data_master_b_rptr_o + output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_data_master_b_rptr_o, + // AXI4 MASTER Wide + //************************************** + // WRITE ADDRESS CHANNEL + output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_aw_wptr_o, + output logic [pulp_cluster_wrap_package::AsyncOutAwWideDataWidth-1:0] async_wide_master_aw_data_o, + input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_aw_rptr_i, + + // READ ADDRESS CHANNEL + output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_ar_wptr_o, + output logic [pulp_cluster_wrap_package::AsyncOutArWideDataWidth-1:0] async_wide_master_ar_data_o, + input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_ar_rptr_i, + + // WRITE DATA CHANNEL + output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_w_wptr_o, + output logic [pulp_cluster_wrap_package::AsyncOutWWideDataWidth-1:0] async_wide_master_w_data_o, + input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_w_rptr_i, + + // READ DATA CHANNEL + input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_r_wptr_i, + input logic [pulp_cluster_wrap_package::AsyncOutRWideDataWidth-1:0] async_wide_master_r_data_i, + output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_r_rptr_o, + + // WRITE RESPONSE CHANNEL + input logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_b_wptr_i, + input logic [pulp_cluster_wrap_package::AsyncOutBWideDataWidth-1:0] async_wide_master_b_data_i, + output logic [pulp_cluster_wrap_package::Cfg.AxiCdcLogDepth:0] async_wide_master_b_rptr_o ); pulp_cluster #( .Cfg(pulp_cluster_wrap_package::Cfg) ) pulp_cluster_i ( @@ -138,6 +184,7 @@ module pulp_cluster_wrap ( .ref_clk_i, .axi_isolate_i ( '0 ), .axi_isolated_o, + .axi_isolated_wide_o, .pmu_mem_pwdn_i ( 1'b0 ), .dma_pe_evt_ack_i ( '1 ), .dma_pe_evt_valid_o, @@ -187,6 +234,21 @@ module pulp_cluster_wrap ( .async_data_slave_r_data_o, .async_data_slave_b_wptr_o, .async_data_slave_b_rptr_i, - .async_data_slave_b_data_o + .async_data_slave_b_data_o, + .async_wide_master_aw_wptr_o, + .async_wide_master_aw_data_o, + .async_wide_master_aw_rptr_i, + .async_wide_master_ar_wptr_o, + .async_wide_master_ar_data_o, + .async_wide_master_ar_rptr_i, + .async_wide_master_w_wptr_o, + .async_wide_master_w_data_o, + .async_wide_master_w_rptr_i, + .async_wide_master_r_wptr_i, + .async_wide_master_r_data_i, + .async_wide_master_r_rptr_o, + .async_wide_master_b_wptr_i, + .async_wide_master_b_data_i, + .async_wide_master_b_rptr_o ); endmodule diff --git a/scripts/wave.tcl b/scripts/wave.tcl index 09f55650..8689538f 100644 --- a/scripts/wave.tcl +++ b/scripts/wave.tcl @@ -7,32 +7,56 @@ onerror {resume} quietly WaveActivateNextPane {} 0 -set CORE_TYPE [examine sim:/pulp_cluster_tb/PulpClusterCfg.CoreType] -set NUM_CORES [examine -radix dec sim:/pulp_cluster_tb/PulpClusterCfg.NumCores] -set HMR_PRESENT [examine sim:/pulp_cluster_tb/PulpClusterCfg.HMRPresent] -set HWPE_PRESENT [examine sim:/pulp_cluster_tb/PulpClusterCfg.HwpePresent] -set HWPE_LIST [examine sim:/pulp_cluster_tb/PulpClusterCfg.HwpeCfg.HwpeList] -set NUM_HWPE [examine -radix dec sim:/pulp_cluster_tb/PulpClusterCfg.HwpeCfg.NumHwpes] +set CORE_TYPE [examine -radix symbolic sim:/pulp_cluster_tb/PulpClusterCfgVis.CoreType] +set NUM_CORES [examine -radix dec sim:/pulp_cluster_tb/PulpClusterCfgVis.NumCores] +set HMR_PRESENT [examine -radix hex sim:/pulp_cluster_tb/PulpClusterCfgVis.HMRPresent] +set HWPE_PRESENT [examine -radix hex sim:/pulp_cluster_tb/PulpClusterCfgVis.HwpePresent] +set HWPE_LIST [examine sim:/pulp_cluster_tb/PulpClusterCfgVis.HwpeCfg.HwpeList] +set NUM_HWPE [examine -radix dec sim:/pulp_cluster_tb/PulpClusterCfgVis.HwpeCfg.NumHwpes] + +set ENABLE_WIDE [examine -radix hex sim:/pulp_cluster_tb/PulpClusterCfgVis.EnableWidePort] +if { $ENABLE_WIDE == 1 } { + set CLUSTER_PATH /pulp_cluster_tb/gen_dma_buses/cluster_i +} else { + set CLUSTER_PATH /pulp_cluster_tb/gen_dma_stubs/cluster_i +} # Cluster -add wave -noupdate -group cluster /pulp_cluster_tb/cluster_i/* -# HMR -add wave -noupdate -group hmr /pulp_cluster_tb/cluster_i/gen_hmr_unit/i_hmr_unit/* +add wave -noupdate -group cluster $CLUSTER_PATH/* + +# HMR (if present) +if { $HMR_PRESENT != 0 } { + set hmr_path "$CLUSTER_PATH/gen_hmr_unit/i_hmr_unit/*" + set hmr_matches [find signals $hmr_path] + if { [llength $hmr_matches] > 0 } { + add wave -noupdate -group hmr $hmr_path + } +} + # Peripherals -add wave -noupdate -group cluster_peripherals /pulp_cluster_tb/cluster_i/cluster_peripherals_i/* +add wave -noupdate -group cluster_peripherals $CLUSTER_PATH/cluster_peripherals_i/* # Control Unit -add wave -noupdate -group cluster_control_unit /pulp_cluster_tb/cluster_i/cluster_peripherals_i/cluster_control_unit_i/* -# HWPE Subsystem -add wave -noupdate -group hwpe_subsystem /pulp_cluster_tb/cluster_i/hwpe_gen/hwpe_subsystem_i/* +add wave -noupdate -group cluster_control_unit $CLUSTER_PATH/cluster_peripherals_i/cluster_control_unit_i/* +# HWPE Subsystem (if present) +if { $HWPE_PRESENT != 0 } { + add wave -noupdate -group hwpe_subsystem $CLUSTER_PATH/hwpe_gen/hwpe_subsystem_i/* +} for {set i 0} {$i < $NUM_HWPE} {incr i} { - #set HWPE_NAME [tolower $HWPE_LIST($i)] - set HWPE_NAME [string tolower [examine sim:/pulp_cluster_tb/PulpClusterCfg.HwpeCfg.HwpeList[$i]]] - add wave -noupdate -group hwpe_subsystem -group $HWPE_NAME /pulp_cluster_tb/cluster_i/hwpe_gen/hwpe_subsystem_i/gen_hwpe[$i]/gen_$HWPE_NAME/i_$HWPE_NAME/* + if { $HWPE_PRESENT != 0 } { + # Try for different HWPEs + foreach hwpe_kind {redmule neureka softex} { + set inst_path "$CLUSTER_PATH/hwpe_gen/hwpe_subsystem_i/gen_hwpe[$i]/gen_${hwpe_kind}/i_${hwpe_kind}/*" + set matches [find signals $inst_path] + if { [llength $matches] > 0 } { + add wave -noupdate -group hwpe_subsystem -group $hwpe_kind $inst_path + } + } + } } # Cores for {set i 0} {$i < $NUM_CORES} {incr i} { - add wave -noupdate -group Core[$i] -group core_region /pulp_cluster_tb/cluster_i/CORE[$i]/core_region_i/* - add wave -noupdate -group Core[$i] -group core_region -group core /pulp_cluster_tb/cluster_i/CORE[$i]/core_region_i/${CORE_TYPE}_CORE/${CORE_TYPE}_CORE/* + add wave -noupdate -group Core[$i] -group core_region $CLUSTER_PATH/CORE[$i]/core_region_i/* + add wave -noupdate -group Core[$i] -group core_region -group core $CLUSTER_PATH/CORE[$i]/core_region_i/${CORE_TYPE}_CORE/${CORE_TYPE}_CORE/* } configure wave -timelineunits ns diff --git a/tb/pulp_cluster_tb.sv b/tb/pulp_cluster_tb.sv index 74babb36..500fae8a 100644 --- a/tb/pulp_cluster_tb.sv +++ b/tb/pulp_cluster_tb.sv @@ -25,7 +25,13 @@ import "DPI-C" function get_entry(output longint entry_ret); import "DPI-C" function byte get_section(output longint address, output longint len); import "DPI-C" context function byte read_section(input longint address, inout byte buffer[], input longint len); +// PULP Cluster flavors +`ifndef TB_ENABLE_WIDE_PORT + `define TB_ENABLE_WIDE_PORT 1 +`endif + module pulp_cluster_tb; + localparam bit EnableWidePort = `TB_ENABLE_WIDE_PORT; import pulp_cluster_package::*; import uvm_pkg::*; @@ -50,13 +56,16 @@ module pulp_cluster_tb; localparam AxiAw = 32; localparam AxiDw = 64; localparam AxiIw = 6; - localparam NMst = 2; + localparam NMst = 3; localparam NSlv = 3; localparam AxiIwMst = AxiIw + $clog2(NMst); localparam AxiWideBeWidth = AxiDw/8; localparam AxiWideByteOffset = $clog2(AxiWideBeWidth); localparam AxiUw = 10; + localparam DmaAxiDw = EnableWidePort ? 256 : 64; + localparam DmaAxiIw = EnableWidePort ? 1 : AxiIw; + localparam bit[AxiAw-1:0] ClustBase = 'h10000000; localparam bit[AxiAw-1:0] ClustPeriphOffs = 'h00200000; localparam bit[AxiAw-1:0] ClustExtOffs = 'h00400000; @@ -76,23 +85,42 @@ module pulp_cluster_tb; typedef logic [AxiIw-1:0] axi_id_t; typedef logic [AxiIwMst-1:0] axi_m_id_t; + typedef logic [DmaAxiDw-1:0] dma_axi_data_t; + typedef logic [DmaAxiDw/8-1:0] dma_axi_strb_t; + typedef logic [DmaAxiIw-1:0] dma_axi_id_t; + + // Narrow AXI port type `AXI_TYPEDEF_W_CHAN_T(w_chan_t, axi_data_t, axi_strb_t, axi_user_t) `AXI_TYPEDEF_AW_CHAN_T(aw_chan_t, axi_addr_t, axi_id_t, axi_user_t) `AXI_TYPEDEF_B_CHAN_T(b_chan_t, axi_id_t, axi_user_t) `AXI_TYPEDEF_AR_CHAN_T(ar_chan_t, axi_addr_t, axi_id_t, axi_user_t) `AXI_TYPEDEF_R_CHAN_T(r_chan_t, axi_data_t, axi_id_t, axi_user_t) + `AXI_TYPEDEF_REQ_T(axi_req_t, aw_chan_t, w_chan_t, ar_chan_t) `AXI_TYPEDEF_RESP_T(axi_resp_t, b_chan_t, r_chan_t) + // Wide AXI port type + `AXI_TYPEDEF_W_CHAN_T(dma_w_chan_t, dma_axi_data_t, dma_axi_strb_t, axi_user_t) + `AXI_TYPEDEF_AW_CHAN_T(dma_aw_chan_t, axi_addr_t, dma_axi_id_t, axi_user_t) + `AXI_TYPEDEF_B_CHAN_T(dma_b_chan_t, dma_axi_id_t, axi_user_t) + `AXI_TYPEDEF_AR_CHAN_T(dma_ar_chan_t, axi_addr_t, dma_axi_id_t, axi_user_t) + `AXI_TYPEDEF_R_CHAN_T(dma_r_chan_t, dma_axi_data_t, dma_axi_id_t, axi_user_t) + + `AXI_TYPEDEF_REQ_T(dma_axi_req_t, aw_chan_t, dma_w_chan_t, ar_chan_t) + `AXI_TYPEDEF_RESP_T(dma_axi_resp_t, b_chan_t, dma_r_chan_t) + + // Memory-side AXI port type `AXI_TYPEDEF_AW_CHAN_T(aw_m_chan_t, axi_addr_t, axi_m_id_t, axi_user_t) `AXI_TYPEDEF_B_CHAN_T(b_m_chan_t, axi_m_id_t, axi_user_t) `AXI_TYPEDEF_AR_CHAN_T(ar_m_chan_t, axi_addr_t, axi_m_id_t, axi_user_t) `AXI_TYPEDEF_R_CHAN_T(r_m_chan_t, axi_data_t, axi_m_id_t, axi_user_t) + `AXI_TYPEDEF_REQ_T(axi_m_req_t, aw_m_chan_t, w_chan_t, ar_m_chan_t) `AXI_TYPEDEF_RESP_T(axi_m_resp_t, b_m_chan_t, r_m_chan_t) typedef logic [AxiAw-1:0] addr_t; typedef logic [AxiDw-1:0] data_t; + typedef logic [DmaAxiDw-1:0] dma_data_t; data_t memory [bit [31:0]]; int sections [bit [31:0]]; @@ -115,13 +143,245 @@ module pulp_cluster_tb; .AXI_DATA_WIDTH( AxiDw ), .AXI_ID_WIDTH ( AxiIw ), .AXI_USER_WIDTH( AxiUw ) - ) axi_slave[NMst-1:0](); + ) axi_slave[NMst-1:0](); + + localparam pulp_cluster_cfg_t PulpClusterCfg = '{ + CoreType: pulp_cluster_package::RI5CY, + NumCores: `NB_CORES, + DmaNumPlugs: `NB_DMAS, + DmaNumOutstandingBursts: 8, + DmaBurstLength: 256, + DmaUseHwpePort: `DMA_USE_HWPE_PORT, + NumMstPeriphs: `NB_MPERIPHS, + NumSlvPeriphs: `NB_SPERIPHS, + ClusterAlias: 1, + ClusterAliasBase: 'h0, + NumSyncStages: 3, + UseHci: 1, + TcdmSize: 128*1024, + TcdmNumBank: 16, + HwpePresent: 1, + HwpeCfg: '{NumHwpes: 3, HwpeList: {SOFTEX, NEUREKA, REDMULE}, FifoDepth: 2}, + HwpeNumPorts: 9, + HMRPresent: 1, + HMRDmrEnabled: 1, + HMRTmrEnabled: 1, + HMRDmrFIxed: 0, + HMRTmrFIxed: 0, + HMRInterleaveGrps: 1, + HMREnableRapidRecovery: 1, + HMRSeparateDataVoters: 1, + HMRSeparateAxiBus: 0, + HMRNumBusVoters: 1, + EnableECC: 1, + ECCInterco: 1, + iCacheNumBanks: 2, + iCacheNumLines: 1, + iCacheNumWays: 4, + iCacheSharedSize: 4*1024, + iCachePrivateSize: 512, + iCachePrivateDataWidth: 32, + EnableReducedTag: 1, + L2Size: 1000*1024, + DmBaseAddr: 'h60203000, + BootRomBaseAddr: BootAddr, + BootAddr: BootAddr, + EnablePrivateFpu: 1, + EnablePrivateFpDivSqrt: 0, + NumAxiIn: NumAxiSubordinatePorts, + NumAxiOut: NumAxiManagerPorts, + AxiIdInWidth: AxiIw-2, + AxiIdOutWidth: AxiIw, + AxiIdOutWideWidth: 1, + AxiAddrWidth: AxiAw, + AxiDataInWidth: AxiDw, + AxiDataOutWidth: AxiDw, + AxiDataOutWideWidth: DmaAxiDw, + AxiUserWidth: AxiUw, + AxiMaxInTrans: 64, + AxiMaxOutTrans: 64, + AxiCdcLogDepth: 3, + AxiCdcSyncStages: 3, + SyncStages: 3, + ClusterBaseAddr: ClustBaseAddr, + ClusterPeriphOffs: ClustPeriphOffs, + ClusterExternalOffs: ClustExtOffs, + EnableRemapAddress: 0, + EnableWidePort: EnableWidePort, + SnitchICache: 0, + default: '0 + }; + + // Questasim visible; keep true to avoid optimization + (* keep = "true" *) pulp_cluster_package::pulp_cluster_cfg_t PulpClusterCfgVis = PulpClusterCfg; + + initial begin + if (EnableWidePort) begin + $display("[TB] Instantiating cluster with wide ports"); + end else begin + $display("[TB] Instantiating cluster with narrow ports"); + end + end + + AXI_BUS #( + .AXI_ADDR_WIDTH( AxiAw ), + .AXI_DATA_WIDTH( DmaAxiDw ), + .AXI_ID_WIDTH ( DmaAxiIw ), + .AXI_USER_WIDTH( AxiUw ) + ) dma_slave(); + + AXI_BUS #( + .AXI_ADDR_WIDTH( AxiAw ), + .AXI_DATA_WIDTH( DmaAxiDw ), + .AXI_ID_WIDTH ( AxiIw ), + .AXI_USER_WIDTH( AxiUw ) + ) dma_slave_iw(); + + AXI_BUS_ASYNC_GRAY #( + .AXI_ADDR_WIDTH ( AxiAw ), + .AXI_DATA_WIDTH ( DmaAxiDw ), + .AXI_ID_WIDTH ( DmaAxiIw ), + .AXI_USER_WIDTH ( AxiUw ), + .LOG_DEPTH ( 3 ) + ) async_dma_axi_bus(); + + axi_dw_converter_intf #( + .AXI_ID_WIDTH ( AxiIw ), + .AXI_ADDR_WIDTH ( AxiAw ), + .AXI_SLV_PORT_DATA_WIDTH ( DmaAxiDw ), + .AXI_MST_PORT_DATA_WIDTH ( AxiDw ), + .AXI_USER_WIDTH ( AxiUw ), + .AXI_MAX_READS ( 3 ) + ) i_dma_dw_conv ( + .clk_i ( s_clk ), + .rst_ni ( s_rstn ), + .slv ( dma_slave_iw ), + .mst ( axi_slave[2] ) + ); + + axi_iw_converter_intf #( + .AXI_SLV_PORT_ID_WIDTH ( DmaAxiIw ), + .AXI_MST_PORT_ID_WIDTH ( AxiIw ), + .AXI_SLV_PORT_MAX_UNIQ_IDS ( 5 ), + .AXI_SLV_PORT_MAX_TXNS_PER_ID ( 5 ), + .AXI_SLV_PORT_MAX_TXNS ( 5 ), + .AXI_MST_PORT_MAX_UNIQ_IDS ( 5 ), + .AXI_MST_PORT_MAX_TXNS_PER_ID ( 5 ), + .AXI_ADDR_WIDTH ( AxiAw ), + .AXI_DATA_WIDTH ( DmaAxiDw ), + .AXI_USER_WIDTH ( AxiUw ) + ) i_dma_iw_conv ( + .clk_i ( s_clk ), + .rst_ni ( s_rstn ), + .slv ( dma_slave ), + .mst ( dma_slave_iw ) + ); + + axi_cdc_dst_intf #( + .AXI_ADDR_WIDTH ( AxiAw ), + .AXI_DATA_WIDTH ( DmaAxiDw ), + .AXI_ID_WIDTH ( DmaAxiIw ), + .AXI_USER_WIDTH ( AxiUw ), + .LOG_DEPTH ( 3 ) + ) cluster_to_soc_dma_dst_cdc_fifo_i ( + .dst_clk_i ( s_clk ), + .dst_rst_ni ( s_rstn ), + .src ( async_dma_axi_bus ), + .dst ( dma_slave ) + ); + + pulp_cluster + `ifdef USE_PULP_PARAMETERS + #( .Cfg ( PulpClusterCfg ) ) + `endif + cluster_i ( + .clk_i ( s_clk ), + .rst_ni ( s_rstn ), + .pwr_on_rst_ni ( s_rstn ), + .ref_clk_i ( s_clk ), + .axi_isolate_i ( '0 ), + .axi_isolated_o ( ), + .axi_isolated_wide_o ( ), + + .pmu_mem_pwdn_i ( 1'b0 ), + + .dma_pe_evt_ack_i ( '1 ), + .dma_pe_evt_valid_o ( ), + + .dma_pe_irq_ack_i ( 1'b1 ), + .dma_pe_irq_valid_o ( ), + + .dbg_irq_valid_i ( '0 ), + .mbox_irq_i ( '0 ), + + .pf_evt_ack_i ( 1'b1 ), + .pf_evt_valid_o ( ), + + .async_cluster_events_wptr_i ( '0 ), + .async_cluster_events_rptr_o ( ), + .async_cluster_events_data_i ( '0 ), + + .en_sa_boot_i ( s_cluster_en_sa_boot ), + .test_mode_i ( 1'b0 ), + .fetch_en_i ( s_cluster_fetch_en ), + .eoc_o ( s_cluster_eoc ), + .busy_o ( s_cluster_busy ), + .cluster_id_i ( ClustIdx ), + + .async_data_master_aw_wptr_o ( async_cluster_to_soc_axi_bus.aw_wptr ), + .async_data_master_aw_rptr_i ( async_cluster_to_soc_axi_bus.aw_rptr ), + .async_data_master_aw_data_o ( async_cluster_to_soc_axi_bus.aw_data ), + .async_data_master_ar_wptr_o ( async_cluster_to_soc_axi_bus.ar_wptr ), + .async_data_master_ar_rptr_i ( async_cluster_to_soc_axi_bus.ar_rptr ), + .async_data_master_ar_data_o ( async_cluster_to_soc_axi_bus.ar_data ), + .async_data_master_w_data_o ( async_cluster_to_soc_axi_bus.w_data ), + .async_data_master_w_wptr_o ( async_cluster_to_soc_axi_bus.w_wptr ), + .async_data_master_w_rptr_i ( async_cluster_to_soc_axi_bus.w_rptr ), + .async_data_master_r_wptr_i ( async_cluster_to_soc_axi_bus.r_wptr ), + .async_data_master_r_rptr_o ( async_cluster_to_soc_axi_bus.r_rptr ), + .async_data_master_r_data_i ( async_cluster_to_soc_axi_bus.r_data ), + .async_data_master_b_wptr_i ( async_cluster_to_soc_axi_bus.b_wptr ), + .async_data_master_b_rptr_o ( async_cluster_to_soc_axi_bus.b_rptr ), + .async_data_master_b_data_i ( async_cluster_to_soc_axi_bus.b_data ), + + .async_wide_master_aw_wptr_o ( async_dma_axi_bus.aw_wptr ), + .async_wide_master_aw_rptr_i ( async_dma_axi_bus.aw_rptr ), + .async_wide_master_aw_data_o ( async_dma_axi_bus.aw_data ), + .async_wide_master_ar_wptr_o ( async_dma_axi_bus.ar_wptr ), + .async_wide_master_ar_rptr_i ( async_dma_axi_bus.ar_rptr ), + .async_wide_master_ar_data_o ( async_dma_axi_bus.ar_data ), + .async_wide_master_w_data_o ( async_dma_axi_bus.w_data ), + .async_wide_master_w_wptr_o ( async_dma_axi_bus.w_wptr ), + .async_wide_master_w_rptr_i ( async_dma_axi_bus.w_rptr ), + .async_wide_master_r_wptr_i ( async_dma_axi_bus.r_wptr ), + .async_wide_master_r_rptr_o ( async_dma_axi_bus.r_rptr ), + .async_wide_master_r_data_i ( async_dma_axi_bus.r_data ), + .async_wide_master_b_wptr_i ( async_dma_axi_bus.b_wptr ), + .async_wide_master_b_rptr_o ( async_dma_axi_bus.b_rptr ), + .async_wide_master_b_data_i ( async_dma_axi_bus.b_data ), + + .async_data_slave_aw_wptr_i ( async_soc_to_cluster_axi_bus.aw_wptr ), + .async_data_slave_aw_rptr_o ( async_soc_to_cluster_axi_bus.aw_rptr ), + .async_data_slave_aw_data_i ( async_soc_to_cluster_axi_bus.aw_data ), + .async_data_slave_ar_wptr_i ( async_soc_to_cluster_axi_bus.ar_wptr ), + .async_data_slave_ar_rptr_o ( async_soc_to_cluster_axi_bus.ar_rptr ), + .async_data_slave_ar_data_i ( async_soc_to_cluster_axi_bus.ar_data ), + .async_data_slave_w_data_i ( async_soc_to_cluster_axi_bus.w_data ), + .async_data_slave_w_wptr_i ( async_soc_to_cluster_axi_bus.w_wptr ), + .async_data_slave_w_rptr_o ( async_soc_to_cluster_axi_bus.w_rptr ), + .async_data_slave_r_wptr_o ( async_soc_to_cluster_axi_bus.r_wptr ), + .async_data_slave_r_rptr_i ( async_soc_to_cluster_axi_bus.r_rptr ), + .async_data_slave_r_data_o ( async_soc_to_cluster_axi_bus.r_data ), + .async_data_slave_b_wptr_o ( async_soc_to_cluster_axi_bus.b_wptr ), + .async_data_slave_b_rptr_i ( async_soc_to_cluster_axi_bus.b_rptr ), + .async_data_slave_b_data_o ( async_soc_to_cluster_axi_bus.b_data ) + ); AXI_BUS #( - .AXI_ADDR_WIDTH( AxiAw ), - .AXI_DATA_WIDTH( AxiDw ), - .AXI_ID_WIDTH ( AxiIw-2 ), - .AXI_USER_WIDTH( AxiUw ) + .AXI_ADDR_WIDTH( AxiAw ), + .AXI_DATA_WIDTH( AxiDw ), + .AXI_ID_WIDTH ( AxiIw-2 ), + .AXI_USER_WIDTH( AxiUw ) ) soc_to_cluster_axi_bus(); AXI_BUS_ASYNC_GRAY #( @@ -133,11 +393,11 @@ module pulp_cluster_tb; ) async_soc_to_cluster_axi_bus(); AXI_BUS_ASYNC_GRAY #( - .AXI_ADDR_WIDTH ( AxiAw ), - .AXI_DATA_WIDTH ( AxiDw ), - .AXI_ID_WIDTH ( AxiIw ), - .AXI_USER_WIDTH ( AxiUw ), - .LOG_DEPTH ( 3 ) + .AXI_ADDR_WIDTH ( AxiAw ), + .AXI_DATA_WIDTH ( AxiDw ), + .AXI_ID_WIDTH ( AxiIw ), + .AXI_USER_WIDTH ( AxiUw ), + .LOG_DEPTH ( 3 ) ) async_cluster_to_soc_axi_bus(); // Behavioural slaves @@ -282,156 +542,20 @@ module pulp_cluster_tb; .AXI_ID_WIDTH ( AxiIw ), .AXI_USER_WIDTH ( AxiUw ), .LOG_DEPTH ( 3 ) - ) cluster_to_soc_dst_cdc_fifo_i ( + ) cluster_to_soc_dst_cdc_fifo_i ( .dst_clk_i ( s_clk ), .dst_rst_ni ( s_rstn ), .src ( async_cluster_to_soc_axi_bus ), .dst ( axi_slave[1] ) ); - localparam pulp_cluster_cfg_t PulpClusterCfg = '{ - CoreType: pulp_cluster_package::RI5CY, - NumCores: `NB_CORES, - DmaNumPlugs: `NB_DMAS, - DmaNumOutstandingBursts: 8, - DmaBurstLength: 5, - NumMstPeriphs: `NB_MPERIPHS, - NumSlvPeriphs: `NB_SPERIPHS, - ClusterAlias: 1, - ClusterAliasBase: 'h0, - NumSyncStages: 3, - UseHci: 1, - TcdmSize: 256*1024, - TcdmNumBank: 16, - HwpePresent: 1, - HwpeCfg: '{NumHwpes: 3, HwpeList: {SOFTEX, NEUREKA, REDMULE}}, - HwpeNumPorts: 9, - HMRPresent: 1, - HMRDmrEnabled: 1, - HMRTmrEnabled: 1, - HMRDmrFIxed: 0, - HMRTmrFIxed: 0, - HMRInterleaveGrps: 1, - HMREnableRapidRecovery: 1, - HMRSeparateDataVoters: 1, - HMRSeparateAxiBus: 0, - HMRNumBusVoters: 1, - EnableECC: 1, - ECCInterco: 1, - iCacheNumBanks: 2, - iCacheNumLines: 1, - iCacheNumWays: 4, - iCacheSharedSize: 4*1024, - iCachePrivateSize: 512, - iCachePrivateDataWidth: 32, - EnableReducedTag: 1, - L2Size: 512*1024, - DmBaseAddr: 'h60203000, - BootRomBaseAddr: BootAddr, - BootAddr: BootAddr, - EnablePrivateFpu: 1, - EnablePrivateFpDivSqrt: 0, - NumAxiIn: NumAxiSubordinatePorts, - NumAxiOut: NumAxiManagerPorts, - AxiIdInWidth: AxiIw-2, - AxiIdOutWidth:AxiIw, - AxiAddrWidth: AxiAw, - AxiDataInWidth: AxiDw, - AxiDataOutWidth: AxiDw, - AxiUserWidth: AxiUw, - AxiMaxInTrans: 64, - AxiMaxOutTrans: 64, - AxiCdcLogDepth: 3, - AxiCdcSyncStages: 3, - SyncStages: 3, - ClusterBaseAddr: ClustBaseAddr, - ClusterPeriphOffs: ClustPeriphOffs, - ClusterExternalOffs: ClustExtOffs, - EnableRemapAddress: 0, - SnitchICache: 0, - default: '0 - }; - - pulp_cluster -`ifndef CLUSTER_NETLIST -`ifdef USE_PULP_PARAMETERS - #( - .Cfg ( PulpClusterCfg ) - ) -`endif -`endif - cluster_i ( - .clk_i ( s_clk ), - .rst_ni ( s_rstn ), - .pwr_on_rst_ni ( s_rstn ), - .ref_clk_i ( s_clk ), - .axi_isolate_i ( '0 ), - .axi_isolated_o ( ), - - .pmu_mem_pwdn_i ( 1'b0 ), - - .dma_pe_evt_ack_i ( '1 ), - .dma_pe_evt_valid_o ( ), - - .dma_pe_irq_ack_i ( 1'b1 ), - .dma_pe_irq_valid_o ( ), - - .dbg_irq_valid_i ( '0 ), - .mbox_irq_i ( '0 ), - - .pf_evt_ack_i ( 1'b1 ), - .pf_evt_valid_o ( ), - - .async_cluster_events_wptr_i ( '0 ), - .async_cluster_events_rptr_o ( ), - .async_cluster_events_data_i ( '0 ), - - .en_sa_boot_i ( s_cluster_en_sa_boot ), - .test_mode_i ( 1'b0 ), - .fetch_en_i ( s_cluster_fetch_en ), - .eoc_o ( s_cluster_eoc ), - .busy_o ( s_cluster_busy ), - .cluster_id_i ( ClustIdx ), - - .async_data_master_aw_wptr_o ( async_cluster_to_soc_axi_bus.aw_wptr ), - .async_data_master_aw_rptr_i ( async_cluster_to_soc_axi_bus.aw_rptr ), - .async_data_master_aw_data_o ( async_cluster_to_soc_axi_bus.aw_data ), - .async_data_master_ar_wptr_o ( async_cluster_to_soc_axi_bus.ar_wptr ), - .async_data_master_ar_rptr_i ( async_cluster_to_soc_axi_bus.ar_rptr ), - .async_data_master_ar_data_o ( async_cluster_to_soc_axi_bus.ar_data ), - .async_data_master_w_data_o ( async_cluster_to_soc_axi_bus.w_data ), - .async_data_master_w_wptr_o ( async_cluster_to_soc_axi_bus.w_wptr ), - .async_data_master_w_rptr_i ( async_cluster_to_soc_axi_bus.w_rptr ), - .async_data_master_r_wptr_i ( async_cluster_to_soc_axi_bus.r_wptr ), - .async_data_master_r_rptr_o ( async_cluster_to_soc_axi_bus.r_rptr ), - .async_data_master_r_data_i ( async_cluster_to_soc_axi_bus.r_data ), - .async_data_master_b_wptr_i ( async_cluster_to_soc_axi_bus.b_wptr ), - .async_data_master_b_rptr_o ( async_cluster_to_soc_axi_bus.b_rptr ), - .async_data_master_b_data_i ( async_cluster_to_soc_axi_bus.b_data ), - - .async_data_slave_aw_wptr_i ( async_soc_to_cluster_axi_bus.aw_wptr ), - .async_data_slave_aw_rptr_o ( async_soc_to_cluster_axi_bus.aw_rptr ), - .async_data_slave_aw_data_i ( async_soc_to_cluster_axi_bus.aw_data ), - .async_data_slave_ar_wptr_i ( async_soc_to_cluster_axi_bus.ar_wptr ), - .async_data_slave_ar_rptr_o ( async_soc_to_cluster_axi_bus.ar_rptr ), - .async_data_slave_ar_data_i ( async_soc_to_cluster_axi_bus.ar_data ), - .async_data_slave_w_data_i ( async_soc_to_cluster_axi_bus.w_data ), - .async_data_slave_w_wptr_i ( async_soc_to_cluster_axi_bus.w_wptr ), - .async_data_slave_w_rptr_o ( async_soc_to_cluster_axi_bus.w_rptr ), - .async_data_slave_r_wptr_o ( async_soc_to_cluster_axi_bus.r_wptr ), - .async_data_slave_r_rptr_i ( async_soc_to_cluster_axi_bus.r_rptr ), - .async_data_slave_r_data_o ( async_soc_to_cluster_axi_bus.r_data ), - .async_data_slave_b_wptr_o ( async_soc_to_cluster_axi_bus.b_wptr ), - .async_data_slave_b_rptr_i ( async_soc_to_cluster_axi_bus.b_rptr ), - .async_data_slave_b_data_o ( async_soc_to_cluster_axi_bus.b_data ) - ); - // Load ELF binary file task load_binary; input string binary; // File name output addr_t entry_point; addr_t section_addr, section_len; byte buffer[]; + addr_t section_addr_offset; // Read ELF void'(read_elf(binary)); @@ -439,16 +563,21 @@ module pulp_cluster_tb; $display("[TB] Reading %s", binary); while (get_section(section_addr, section_len)) begin // Read Sections - automatic int num_words = (section_len + AxiWideBeWidth - 1)/AxiWideBeWidth; - $display("[TB] Reading section %x with %0d words", section_addr, num_words); + automatic int num_start_unaligned_bytes = section_addr%AxiWideBeWidth; + automatic int num_wide_words = (num_start_unaligned_bytes + section_len + AxiWideBeWidth - 1)/AxiWideBeWidth; + + $display("[TB] Reading section %x with %0d words", section_addr, num_wide_words); - sections[section_addr >> AxiWideByteOffset] = num_words; - buffer = new[num_words * AxiWideBeWidth]; + sections[section_addr >> AxiWideByteOffset] = num_wide_words; + buffer = new[num_wide_words * AxiWideBeWidth]; void'(read_section(section_addr, buffer, section_len)); - for (int i = 0; i < num_words; i++) begin + for (int i = 0; i < num_wide_words; i++) begin automatic logic [AxiWideBeWidth-1:0][7:0] word = '0; for (int j = 0; j < AxiWideBeWidth; j++) begin - word[j] = buffer[i * AxiWideBeWidth + j]; + automatic int index = i * AxiWideBeWidth + j - num_start_unaligned_bytes; + if(index >= 0) begin + word[j] = buffer[index]; + end end memory[section_addr/AxiWideBeWidth + i] = word; end