Skip to content

Commit 51deb23

Browse files
authored
Add cuts for timing fix in physical design (#19)
* [SRC][PD] Add cuts/pipeline registers to axi_in and xbar config registers for timing optimization. * [SRC] Cut timing for Spatz-Controller. * [CI] Improve CI parallelism. * [CI] Fix CI path and tag. * [CI] Enable conda env for CI. * [CI] Install missing py pkg * [CI] Force install with python3 * [CI] Add more missing packages * [CI][Makefile] Update makefile to let CI run simulation from different locations
1 parent c9dbae6 commit 51deb23

7 files changed

Lines changed: 172 additions & 58 deletions

File tree

.gitlab-ci.yml

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,90 @@ variables:
88
GIT_SUBMODULE_STRATEGY: none
99
ROOT_DIR: '$CI_PROJECT_DIR'
1010
APPS: "tests"
11-
PATH: '/home/gitlabci/.cargo/bin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/condor/bin:/usr/sepp/bin:$CI_PROJECT_DIR/install/verilator/bin:/home/gitlabci/.local/bin'
11+
PATH: '$HOME/.cargo/bin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/condor/bin:/usr/sepp/bin:$CI_PROJECT_DIR/install/verilator/bin:$HOME/.local/bin'
1212
OBJCACHE: ''
1313
CC: '/usr/pack/gcc-11.2.0-af/linux-x64/bin/gcc'
1414
CXX: '/usr/pack/gcc-11.2.0-af/linux-x64/bin/g++'
1515
CMAKE: 'cmake-3.28.3'
1616
python: 'python3'
1717
python3: 'python3'
18+
# Config to build and test
19+
CI_CONFIG: 'cachepool_fpu_512'
20+
SW_PREFIX: 'test-cachepool-'
1821

1922
default:
20-
tags: [dolent]
23+
tags: [shared]
2124

2225
stages:
2326
- build
27+
- test
2428

25-
.base:
26-
artifacts:
27-
when: always
28-
expire_in: 1 day
29-
30-
build-vsim:
31-
extends: .base
29+
# ---------------------------------------------------------------------------
30+
# Build stage: compile RTL and software for CI_CONFIG.
31+
# Parallel jobs within the same pipeline share $HOME, so the toolchain
32+
# installed by make quick-tool is automatically available to all test jobs.
33+
# ---------------------------------------------------------------------------
34+
build:
3235
stage: build
33-
timeout: 5h
36+
timeout: 4h 30m
3437
script:
3538
- echo "Using CC=$CC"
3639
- echo "Using CXX=$CXX"
3740
- test -x "$CC"
3841
- test -x "$CXX"
3942
- make quick-tool
43+
- python3 -m pip install --quiet dataclasses hjson jsonref jsonschema mako termcolor
4044
- make init
4145
- make dram-build
42-
- cd util/auto-benchmark
43-
- chmod +x ./run_ci.sh
44-
- ./run_ci.sh
46+
- make clean generate vsim config=$CI_CONFIG
47+
artifacts:
48+
when: always
49+
expire_in: 1 day
50+
paths:
51+
# QuestaSim compiled work library
52+
- sim/work/
53+
# vsim wrapper scripts (exclude sim/bin/logs/ — not needed by test jobs)
54+
- sim/bin/cachepool_cluster.vsim
55+
# DPI shared library
56+
- sim/work-dpi/
57+
# Software binaries for all kernels
58+
- software/build/CachePoolTests/
59+
# DRAMSys shared libraries and config files (referenced by vsim at runtime)
60+
- hardware/deps/dram_rtl_sim/dramsys_lib/DRAMSys/build/lib/
61+
- hardware/deps/dram_rtl_sim/dramsys_lib/DRAMSys/configs/
4562

63+
# ---------------------------------------------------------------------------
64+
# Test stage: run each kernel in parallel on a separate runner.
65+
# Each job downloads the build artifacts, runs one simulation, and checks
66+
# the output log for failures.
67+
# ---------------------------------------------------------------------------
68+
test:
69+
stage: test
70+
timeout: 1h
71+
needs: [build]
72+
parallel:
73+
matrix:
74+
- KERNEL:
75+
- spin-lock
76+
- load-store_M16
77+
- fdotp-32b_M32768
78+
- gemv_M512_N128_K32
79+
- fmatmul-32b_M32_N32_K32
80+
- fft-32b_M1024_N16
81+
- multi_producer_single_consumer_double_linked_list_M1_N1350_K10
82+
- byte-enable
83+
script:
84+
# The vsim script writes a .rtlbinary marker here; ensure the dir exists.
85+
- mkdir -p sim/bin/logs
86+
- chmod +x sim/bin/cachepool_cluster.vsim
87+
- BIN="${SW_PREFIX}${KERNEL}"
88+
- sim/bin/cachepool_cluster.vsim software/build/CachePoolTests/$BIN 2>&1 | tee test_${KERNEL}.log
89+
- python3 util/auto-benchmark/check-ci.py test_${KERNEL}.log
4690
artifacts:
91+
when: always
92+
expire_in: 1 day
4793
paths:
48-
- util/auto-benchmark/logs
94+
# Full simulation log
95+
- test_*.log
96+
# Performance-monitor trace files written by the simulator
97+
- sim/bin/logs/

hardware/bootrom/bootrom.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
/scratch2/diyou/cachepool/ManyRVData/hardware/bootrom/bootrom.elf: file format elf32-littleriscv
2+
/scratch/diyou/cachepool/4t16c/ManyRVData/hardware/bootrom/bootrom.elf: file format elf32-littleriscv
33

44

55
Disassembly of section .text:

hardware/bootrom/bootrom.elf

0 Bytes
Binary file not shown.

hardware/src/cachepool_cluster.sv

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@ module cachepool_cluster
860860
axi_narrow_req_t [NumTiles-1:0] axi_core_csr_req, axi_barrier_req;
861861
axi_narrow_resp_t [NumTiles-1:0] axi_core_csr_rsp, axi_barrier_rsp;
862862

863+
// Spill register signals to cut the AXI feedback path
864+
axi_in_req_t axi_in_req_reg;
865+
axi_in_resp_t axi_in_resp_reg;
863866

864867
for (genvar t = 0; t < NumTiles; t++) begin
865868
assign axi_barrier_req[t] = axi_out_req [t][ClusterPeriph];
@@ -877,6 +880,24 @@ module cachepool_cluster
877880
// TODO: Connect to CSR
878881
assign use_barrier = {NumTiles{1'b1}};
879882

883+
axi_cut #(
884+
.Bypass (0 ),
885+
.aw_chan_t (spatz_axi_in_aw_chan_t ),
886+
.w_chan_t (spatz_axi_in_w_chan_t ),
887+
.b_chan_t (spatz_axi_in_b_chan_t ),
888+
.ar_chan_t (spatz_axi_in_ar_chan_t ),
889+
.r_chan_t (spatz_axi_in_r_chan_t ),
890+
.axi_req_t (spatz_axi_in_req_t ),
891+
.axi_resp_t (spatz_axi_in_resp_t )
892+
) i_cut_ext_narrow_in (
893+
.clk_i (clk_i ),
894+
.rst_ni (rst_ni ),
895+
.slv_req_i (axi_in_req_i ),
896+
.slv_resp_o (axi_in_resp_o ),
897+
.mst_req_o (axi_in_req_reg ),
898+
.mst_resp_i (axi_in_resp_reg )
899+
);
900+
880901
cachepool_cluster_barrier #(
881902
.AddrWidth (AxiAddrWidth ),
882903
.NrPorts (NumTiles ),
@@ -895,7 +916,6 @@ module cachepool_cluster
895916
.cluster_periph_start_address_i ( tcdm_end_address )
896917
);
897918

898-
899919
axi_mux #(
900920
.SlvAxiIDWidth ( CsrAxiMstIdWidth ),
901921
.slv_aw_chan_t ( axi_csr_mst_aw_chan_t ), // AW Channel Type, slave ports
@@ -923,8 +943,8 @@ module cachepool_cluster
923943
.clk_i ( clk_i ), // Clock
924944
.rst_ni ( rst_ni ), // Asynchronous reset active low
925945
.test_i ('0 ), // Test Mode enable
926-
.slv_reqs_i ( {axi_in_req_i, axi_core_csr_req} ),
927-
.slv_resps_o ( {axi_in_resp_o, axi_core_csr_rsp} ),
946+
.slv_reqs_i ( {axi_in_req_reg, axi_core_csr_req} ),
947+
.slv_resps_o ( {axi_in_resp_reg, axi_core_csr_rsp} ),
928948
.mst_req_o ( axi_csr_req ),
929949
.mst_resp_i ( axi_csr_rsp )
930950
);

hardware/src/cachepool_tile.sv

Lines changed: 74 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,10 @@ module cachepool_tile
545545

546546
// Used to determine the mapping policy between different cache banks.
547547
// Set through CSR
548-
logic [$clog2(TCDMAddrWidth)-1:0] dynamic_offset;
549-
assign dynamic_offset = dynamic_offset_i;
548+
logic [$clog2(TCDMAddrWidth)-1:0] dynamic_offset_d, dynamic_offset_q;
549+
`FF(dynamic_offset_q, dynamic_offset_d, '0)
550+
assign dynamic_offset_d = dynamic_offset_i;
551+
550552
// One entry per flat remote port: flat index = j + r*NrTCDMPortsPerCore
551553
// where j is the xbar index and r is the remote slot within that xbar.
552554
logic [NumRemotePortTile-1:0] remote_out_pready, remote_in_pready;
@@ -626,19 +628,19 @@ module cachepool_tile
626628
.tcdm_req_chan_t (tcdm_req_chan_t ),
627629
.tcdm_rsp_chan_t (tcdm_rsp_chan_t )
628630
) i_cache_xbar (
629-
.clk_i ( clk_i ),
630-
.rst_ni ( rst_ni ),
631-
.tile_id_i ( tile_id_i ),
632-
.dynamic_offset_i ( dynamic_offset ),
633-
.private_start_addr_i ( private_start_addr_i ),
634-
.num_private_cache_i ( num_private_cache ),
635-
.core_req_i ({xbar_remote_req_gated, cache_req [j]} ),
636-
.core_rsp_ready_i ({xbar_remote_in_pready, cache_pready [j]} ),
637-
.core_rsp_o ({xbar_remote_rsp_xbar, cache_rsp [j]} ),
638-
.tile_sel_o ( xbar_remote_req_dst ),
639-
.mem_req_o ({xbar_remote_req_o, cache_xbar_req [j]} ),
640-
.mem_rsp_ready_o ({xbar_remote_out_pready, cache_xbar_pready[j]} ),
641-
.mem_rsp_i ({xbar_remote_rsp_i, cache_xbar_rsp [j]} )
631+
.clk_i ( clk_i ),
632+
.rst_ni ( rst_ni ),
633+
.tile_id_i ( tile_id_i ),
634+
.dynamic_offset_i ( dynamic_offset_q ),
635+
.private_start_addr_i ( private_start_addr_i ),
636+
.num_private_cache_i ( num_private_cache ),
637+
.core_req_i ({xbar_remote_req_gated, cache_req [j]} ),
638+
.core_rsp_ready_i ({xbar_remote_in_pready, cache_pready [j]} ),
639+
.core_rsp_o ({xbar_remote_rsp_xbar, cache_rsp [j]} ),
640+
.tile_sel_o ( xbar_remote_req_dst ),
641+
.mem_req_o ({xbar_remote_req_o, cache_xbar_req [j]} ),
642+
.mem_rsp_ready_o ({xbar_remote_out_pready, cache_xbar_pready[j]} ),
643+
.mem_rsp_i ({xbar_remote_rsp_i, cache_xbar_rsp [j]} )
642644
);
643645
end
644646

@@ -713,21 +715,56 @@ module cachepool_tile
713715
assign cache_rsp_reg.p.write = cache_rsp_write[cb][j];
714716

715717
end else begin : gen_no_amo
716-
// Bypass AMO and registers
717-
assign cache_req_valid[cb][j] = cache_xbar_req [j][cb].q_valid;
718-
assign cache_rsp_ready[cb][j] = cache_xbar_pready[j][cb];
719-
assign cache_req_addr [cb][j] = cache_xbar_req [j][cb].q.addr;
720-
assign cache_req_meta [cb][j] = cache_xbar_req [j][cb].q.user;
721-
assign cache_req_write[cb][j] = cache_xbar_req [j][cb].q.write;
722-
assign cache_req_data [cb][j] = cache_xbar_req [j][cb].q.data;
723-
assign cache_req_strb [cb][j] = cache_xbar_req [j][cb].q.strb;
724-
725-
assign cache_xbar_rsp[j][cb].p_valid = cache_rsp_valid[cb][j];
726-
assign cache_xbar_rsp[j][cb].q_ready = cache_req_ready[cb][j];
727-
assign cache_xbar_rsp[j][cb].p.data = cache_rsp_data [cb][j];
728-
assign cache_xbar_rsp[j][cb].p.user = cache_rsp_meta [cb][j];
729-
730-
assign cache_xbar_rsp[j][cb].p.write = cache_rsp_write[cb][j];
718+
// Spill register decoupling between xbar side and cache side.
719+
tcdm_req_t cache_req_reg;
720+
tcdm_rsp_t cache_rsp_reg;
721+
722+
// Extra wire for half-handshake: q_ready feedback from the response-side
723+
// spill register's downstream consumer back to the request-side spill
724+
// register's ready_i input.
725+
logic cache_req_ready_w;
726+
727+
spill_register #(
728+
.T ( tcdm_req_chan_t ),
729+
.Bypass ( 1'b0 )
730+
) i_spill_reg_cache_req (
731+
.clk_i ( clk_i ),
732+
.rst_ni ( rst_ni ),
733+
.valid_i ( cache_xbar_req [j][cb].q_valid ),
734+
.ready_o ( cache_xbar_rsp [j][cb].q_ready ),
735+
.data_i ( cache_xbar_req [j][cb].q ),
736+
.valid_o ( cache_req_reg.q_valid ),
737+
.ready_i ( cache_req_ready_w ),
738+
.data_o ( cache_req_reg.q )
739+
);
740+
741+
spill_register #(
742+
.T ( tcdm_rsp_chan_t ),
743+
.Bypass ( 1'b1 )
744+
) i_spill_reg_cache_rsp (
745+
.clk_i ( clk_i ),
746+
.rst_ni ( rst_ni ),
747+
.valid_i ( cache_rsp_reg.p_valid ),
748+
.ready_o ( cache_rsp_ready [cb][j] ),
749+
.data_i ( cache_rsp_reg.p ),
750+
.valid_o ( cache_xbar_rsp [j][cb].p_valid ),
751+
.ready_i ( cache_xbar_pready[j][cb] ),
752+
.data_o ( cache_xbar_rsp [j][cb].p )
753+
);
754+
755+
assign cache_req_ready_w = cache_req_ready[cb][j];
756+
757+
assign cache_req_valid[cb][j] = cache_req_reg.q_valid;
758+
assign cache_req_addr [cb][j] = cache_req_reg.q.addr;
759+
assign cache_req_meta [cb][j] = cache_req_reg.q.user;
760+
assign cache_req_write[cb][j] = cache_req_reg.q.write;
761+
assign cache_req_data [cb][j] = cache_req_reg.q.data;
762+
assign cache_req_strb [cb][j] = cache_req_reg.q.strb;
763+
764+
assign cache_rsp_reg.p_valid = cache_rsp_valid[cb][j];
765+
assign cache_rsp_reg.p.data = cache_rsp_data [cb][j];
766+
assign cache_rsp_reg.p.user = cache_rsp_meta [cb][j];
767+
assign cache_rsp_reg.p.write = cache_rsp_write[cb][j];
731768

732769
end
733770
end
@@ -757,12 +794,12 @@ module cachepool_tile
757794
$display(" NumDataBankPerCtrl: %0d", NumDataBankPerCtrl);
758795
$display(" CoalFactor : %0d", L1CoalFactor);
759796
$display(" RefillDataWidth: %0d", RefillDataWidth);
760-
$display(" DynamicOffset : %0d", dynamic_offset);
797+
$display(" DynamicOffset : %0d", dynamic_offset_q);
761798
end
762799

763-
// CL-offset mask: bits below dynamic_offset, verbatim in both directions.
800+
// CL-offset mask: bits below dynamic_offset_q, verbatim in both directions.
764801
logic [SpatzAxiAddrWidth-1:0] bitmask_lo;
765-
assign bitmask_lo = (SpatzAxiAddrWidth'(1) << dynamic_offset) - 1;
802+
assign bitmask_lo = (SpatzAxiAddrWidth'(1) << dynamic_offset_q) - 1;
766803

767804
cache_refill_req_chan_t [NumL1CtrlTile-1 : 0] cache_refill_req;
768805
burst_req_t [NumL1CtrlTile-1 : 0] cache_refill_burst;
@@ -1031,14 +1068,14 @@ module cachepool_tile
10311068

10321069
rot_field = addr_rot >> (SpatzAxiAddrWidth - refill_bits_to_rotate);
10331070

1034-
upper = (addr_rot >> dynamic_offset)
1071+
upper = (addr_rot >> dynamic_offset_q)
10351072
& ((SpatzAxiAddrWidth'(1) << (SpatzAxiAddrWidth
1036-
- dynamic_offset
1073+
- dynamic_offset_q
10371074
- refill_bits_to_rotate)) - 1);
10381075

10391076
cache_refill_req_o[cb].q.addr = lower
1040-
| (rot_field << dynamic_offset)
1041-
| (upper << (dynamic_offset
1077+
| (rot_field << dynamic_offset_q)
1078+
| (upper << (dynamic_offset_q
10421079
+ refill_bits_to_rotate));
10431080
end
10441081
end

sim/sim.mk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,24 @@ ${WORK_DIR}/compile.vsim.tcl: ${SNLIB_DIR}/rtl_lib.cc ${SNLIB_DIR}/common_lib.cc
100100
echo 'return 0' >> $@
101101

102102
# Wrapper script & GUI script
103+
# The generated scripts derive ROOT_DIR from their own location at runtime so
104+
# that they remain portable across different checkout paths (CI runners, moved
105+
# repos). All absolute paths baked in by make are replaced by a single sed pass.
103106
define QUESTASIM
104107
${VSIM} -c -do "source $<; quit" | tee $(dir $<)vsim.log
105108
@! grep -P "Errors: [1-9]*," $(dir $<)vsim.log
106109
@mkdir -p $(SIMBIN_DIR) $(SIMBIN_DIR)/logs
107-
@echo "#!/bin/bash" > $(SIMBIN_DIR)/cachepool_cluster.vsim
110+
@echo '#!/bin/bash' > $(SIMBIN_DIR)/cachepool_cluster.vsim
111+
@echo 'ROOT_DIR="$$(cd "$$(dirname "$$(readlink -f "$$0")")/../.." && pwd)"' >> $(SIMBIN_DIR)/cachepool_cluster.vsim
108112
@echo 'echo `realpath $$1` > ${SIMBIN_DIR}/logs/.rtlbinary' >> $(SIMBIN_DIR)/cachepool_cluster.vsim
109113
@echo '${VSIM} +permissive ${VSIM_FLAGS} -do "run -a" -work ${WORK_DIR} -c -ldflags "-Wl,-rpath,${GCC_LIB} -L${FESVR}/lib -lfesvr_vsim -lutil" $1 +permissive-off ++$$1 +PRELOAD=$$1' >> $(SIMBIN_DIR)/cachepool_cluster.vsim
114+
@sed -i 's|$(CACHEPOOL_DIR)|$${ROOT_DIR}|g' $(SIMBIN_DIR)/cachepool_cluster.vsim
110115
@chmod +x $(SIMBIN_DIR)/cachepool_cluster.vsim
111-
@echo "#!/bin/bash" > $(SIMBIN_DIR)/cachepool_cluster.vsim.gui
116+
@echo '#!/bin/bash' > $(SIMBIN_DIR)/cachepool_cluster.vsim.gui
117+
@echo 'ROOT_DIR="$$(cd "$$(dirname "$$(readlink -f "$$0")")/../.." && pwd)"' >> $(SIMBIN_DIR)/cachepool_cluster.vsim.gui
112118
@echo 'echo `realpath $$1` > ${SIMBIN_DIR}/logs/.rtlbinary' >> $(SIMBIN_DIR)/cachepool_cluster.vsim.gui
113119
@echo '${VSIM} +permissive ${VSIM_FLAGS} -do "log -r /*; source ${WAVE_FILE}; run -a" -work ${WORK_DIR} -ldflags "-Wl,-rpath,${GCC_LIB} -L${FESVR}/lib -lfesvr_vsim -lutil" $1 +permissive-off ++$$1 +PRELOAD=$$1' >> $(SIMBIN_DIR)/cachepool_cluster.vsim.gui
120+
@sed -i 's|$(CACHEPOOL_DIR)|$${ROOT_DIR}|g' $(SIMBIN_DIR)/cachepool_cluster.vsim.gui
114121
@chmod +x $(SIMBIN_DIR)/cachepool_cluster.vsim.gui
115122
endef
116123

software/tests/fft-32b/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ int main() {
162162
}
163163
}
164164

165-
printf ("r:%d,i:%d\n", rerror, ierror);
165+
if ((rerror + ierror) > 0)
166+
printf ("Error: r:%d,i:%d\n", rerror, ierror);
166167
}
167168
}
168169

0 commit comments

Comments
 (0)