From 5b940100d1d8d36da78b046155a8a8e38a61ac43 Mon Sep 17 00:00:00 2001 From: Anders Ryd Date: Wed, 13 Nov 2024 17:55:52 -0500 Subject: [PATCH] Change ordering of phi and rz in binned memories - rz is more significant bits --- IntegrationTests/common/hdl/tf_mem_bin.vhd | 6 +++--- IntegrationTests/common/script/impl.tcl | 2 +- IntegrationTests/common/script/synth.tcl | 2 +- TrackletAlgorithm/MatchEngineUnit.h | 10 +++++++--- TrackletAlgorithm/MemoryTemplateBinnedCM.h | 15 ++++----------- TrackletAlgorithm/TrackletProcessor.h | 4 ++-- TrackletAlgorithm/VMRouterCM.h | 3 ++- TrackletAlgorithm/VMSMERouter.h | 3 ++- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/IntegrationTests/common/hdl/tf_mem_bin.vhd b/IntegrationTests/common/hdl/tf_mem_bin.vhd index e7adf125f8e..3516edd57c4 100644 --- a/IntegrationTests/common/hdl/tf_mem_bin.vhd +++ b/IntegrationTests/common/hdl/tf_mem_bin.vhd @@ -227,10 +227,10 @@ process(clka) alias vi_nent_idx : std_logic_vector(NUM_PHI_BITS+NUM_RZ_BITS-1 downto 0) is addra(ADDR_WIDTH + NUM_PHI_BITS + NUM_RZ_BITS - 1 downto ADDR_WIDTH); --! Extract phi bin from bin address - alias phibits: std_logic_vector(NUM_PHI_BITS-1 downto 0) is vi_nent_idx(NUM_PHI_BITS + NUM_RZ_BITS - 1 downto NUM_RZ_BITS); + alias phibits: std_logic_vector(NUM_PHI_BITS-1 downto 0) is vi_nent_idx(NUM_PHI_BITS - 1 downto 0); --! Extract rz bin from binaddress - alias rzbits: std_logic_vector(NUM_RZ_BITS-1 downto 0) is vi_nent_idx(NUM_RZ_BITS-1 downto 0); --rz position + alias rzbits: std_logic_vector(NUM_RZ_BITS-1 downto 0) is vi_nent_idx(NUM_PHI_BITS + NUM_RZ_BITS-1 downto NUM_PHI_BITS); --rz position variable binaddr : unsigned(ADDR_WIDTH-1 downto 0) := (others => '0'); variable nentry : unsigned(ADDR_WIDTH-1 downto 0) := (others => '0'); @@ -266,7 +266,7 @@ begin -- Write data to all copies --report "tf_mem_bin vi_nent_idx vi_nent_idx_new: " & to_bstring(vi_nent_idx) & " " & to_bstring(vi_nent_idx_new) & " " & to_bstring(rzbits) & " " & to_bstring(phibits); - + binaddr := unsigned(nentry_tmp(to_integer(unsigned(vi_nent_idx)))); nentry := binaddr+1; diff --git a/IntegrationTests/common/script/impl.tcl b/IntegrationTests/common/script/impl.tcl index 6ebdf24ab5e..a985a27464d 100644 --- a/IntegrationTests/common/script/impl.tcl +++ b/IntegrationTests/common/script/impl.tcl @@ -20,7 +20,7 @@ reset_run impl_1 # Implementation update_compile_order -fileset sources_1 -launch_runs impl_1 -jobs 4 +launch_runs impl_1 -jobs 64 wait_on_run impl_1 # Make reports diff --git a/IntegrationTests/common/script/synth.tcl b/IntegrationTests/common/script/synth.tcl index 20d52a07d0f..6f4ac6ea3ba 100644 --- a/IntegrationTests/common/script/synth.tcl +++ b/IntegrationTests/common/script/synth.tcl @@ -23,7 +23,7 @@ set_property -name {STEPS.SYNTH_DESIGN.ARGS.MORE OPTIONS} -value {-mode out_of_c # Synthesis update_compile_order -fileset sources_1 -launch_runs synth_1 -jobs 4 +launch_runs synth_1 -jobs 64 wait_on_run synth_1 # Make reports diff --git a/TrackletAlgorithm/MatchEngineUnit.h b/TrackletAlgorithm/MatchEngineUnit.h index c50b9118a45..0726eccd490 100644 --- a/TrackletAlgorithm/MatchEngineUnit.h +++ b/TrackletAlgorithm/MatchEngineUnit.h @@ -123,8 +123,6 @@ inline void step(const VMStub stubmem[4][1<<(kNbitsrzbinMP+kNbitsphibin auto secondSave = second_; VMProjection data(projbuffer_.getProjection()); - constexpr bool isDisk = LAYER > TF::L6; - constexpr int nbins = isDisk ? (1 << kNbitsrzbin)*2 : (1 << kNbitsrzbin); //twice as many bins in disks (since there are two disks) if(istub_ == 0) { @@ -153,7 +151,13 @@ inline void step(const VMStub stubmem[4][1<<(kNbitsrzbinMP+kNbitsphibin projrinv__ = data.getRInv(); } - ap_uint::kPRBufferZBinSize -1 + kNBits_MemAddrBinned> slot = (iphi_ + use_[iusetmp].range(0,0)) * nbins + zbin_ + use_[iusetmp].range(1,1); + const int nphibins = 3; //number of bits for phi bins in VM memory not that L1 actually only uses 2 bits + ap_uint::kPRBufferZBinSize -1 + kNBits_MemAddrBinned> slot = iphi_ + use_[iusetmp].range(0,0) + (zbin_ + use_[iusetmp].range(1,1)) * (1 << nphibins); + + //The previous line should be like below after L1 is fixed to use four phi bins in the memories + //ap_uint::kPRBufferZBinSize -1 + kNBits_MemAddrBinned> slot = iphi_ + use_[iusetmp].range(0,0) + (zbin_ + use_[iusetmp].range(1,1)) * (1 << nbits_vmmeall[LAYER]); + + zbin__ = zbin_ + use_[iusetmp].range(1,1); zbin__ = zbin_ + use_[iusetmp].range(1,1); //Read stub memory and extract data fields auto stubadd=(slot,istubtmp); diff --git a/TrackletAlgorithm/MemoryTemplateBinnedCM.h b/TrackletAlgorithm/MemoryTemplateBinnedCM.h index 62b853b495f..8a012f99cbe 100644 --- a/TrackletAlgorithm/MemoryTemplateBinnedCM.h +++ b/TrackletAlgorithm/MemoryTemplateBinnedCM.h @@ -144,7 +144,7 @@ class MemoryTemplateBinnedCM{ ap_uint ibin; ap_uint ireg; - (ireg,ibin)=slot; + (ibin,ireg)=slot; unsigned int nentry = nentries_[ibx*kNBinsRZ+ibin].range(ireg*4+3,ireg*4); @@ -243,17 +243,10 @@ class MemoryTemplateBinnedCM{ DataType data(datastr.c_str(), base); - bool success = write_mem(ibx, slot, data, nentry_ibx); - #ifndef CMSSW_GIT_HASH - if (success) { - nentries_[ibx*kNBinsRZ+ibin].range(ireg*4+3,ireg*4)=nentry_ibx+1; - if (ibin!=0) { - nentries_[ibx*kNBinsRZ+ibin-1].range((ireg+8)*4+3,(ireg+8)*4)=nentry_ibx+1; - } - binmask8_[ibx][ibin].set_bit(ireg,true); - } - #endif + int slot2 = (ibin,ireg); //swap order, should be changed in the input files + bool success = write_mem(ibx, slot2, data, nentry_ibx); + return success; } diff --git a/TrackletAlgorithm/TrackletProcessor.h b/TrackletAlgorithm/TrackletProcessor.h index 9a9ce62fb01..1ee9317f3ff 100644 --- a/TrackletAlgorithm/TrackletProcessor.h +++ b/TrackletAlgorithm/TrackletProcessor.h @@ -1020,8 +1020,8 @@ teunits[k].idle_; //Fill the result teunits[k].outervmstub__ = outerVMStubs->read_mem(k, bx, init? - (ireg_init, ibin_init,typename TrackletEngineUnit()>::NSTUBS(0)): - (ireg_reg, ibin_reg, istub_tmp_reg)); + (ibin_init, ireg_init, typename TrackletEngineUnit()>::NSTUBS(0)): + (ibin_reg, ireg_reg, istub_tmp_reg)); teunits[k].next__ = init?next_init:next_reg; teunits[k].ireg__ = init?ireg_init:ireg_reg; teunits[k].good__ = init?good_init:good_reg; diff --git a/TrackletAlgorithm/VMRouterCM.h b/TrackletAlgorithm/VMRouterCM.h index 2431e9c84d6..7ec6616aaa2 100644 --- a/TrackletAlgorithm/VMRouterCM.h +++ b/TrackletAlgorithm/VMRouterCM.h @@ -155,7 +155,8 @@ inline T createVMStub(const InputStub inputStub, if (negDisk) bin += 1 << (nbitsbin-1); // The upper half of the bins are for negative disks auto ivm = phicorr.range(phicorr.length() - nbitsall - 1, phicorr.length() - (nbitsall + vmbits)); //get the phi bits that corresponds to the old vms - slot = ivm * (1 << nbitsbin) + bin; + const int nbinsphi = 3; + slot = (bin << nbinsphi) + ivm; // Set rzfine, i.e. the r/z bits within a coarse r/z region auto rzfine = lutValue & ((1 << nbitsfinerz) - 1); // the 3 LSB as rzfine diff --git a/TrackletAlgorithm/VMSMERouter.h b/TrackletAlgorithm/VMSMERouter.h index 8623077aa73..55d3be2f379 100644 --- a/TrackletAlgorithm/VMSMERouter.h +++ b/TrackletAlgorithm/VMSMERouter.h @@ -133,7 +133,8 @@ inline T createVMStubME(const AllStub& allStub, if (negDisk) bin += 1 << (nbitsbin-1); // The upper half of the bins are for negative disks auto ivm = phicorr.range(phicorr.length() - nbitsall - 1, phicorr.length() - (nbitsall + vmbits)); //get the phi bits that corresponds to the old vms - slot = ivm * (1 << nbitsbin) + bin; + const int nbinsphi = 3; + slot = (bin << nbinsphi) + ivm; // Set rzfine, i.e. the r/z bits within a coarse r/z region auto rzfine = lutValue & ((1 << nbitsfinerz) - 1); // the 3 LSB as rzfine