Skip to content

Commit

Permalink
Change ordering of phi and rz in binned memories - rz is more signifi…
Browse files Browse the repository at this point in the history
…cant bits
  • Loading branch information
Anders Ryd committed Nov 13, 2024
1 parent 8dbc34e commit 5b94010
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
6 changes: 3 additions & 3 deletions IntegrationTests/common/hdl/tf_mem_bin.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/common/script/impl.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/common/script/synth.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions TrackletAlgorithm/MatchEngineUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ inline void step(const VMStub<VMSType> stubmem[4][1<<(kNbitsrzbinMP+kNbitsphibin
auto secondSave = second_;

VMProjection<VMProjType> 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) {

Expand Down Expand Up @@ -153,7 +151,13 @@ inline void step(const VMStub<VMSType> stubmem[4][1<<(kNbitsrzbinMP+kNbitsphibin
projrinv__ = data.getRInv();

}
ap_uint<ProjectionRouterBufferBase<VMProjType, AllProjectionType>::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<ProjectionRouterBufferBase<VMProjType, AllProjectionType>::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<ProjectionRouterBufferBase<VMProjType, AllProjectionType>::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);
Expand Down
15 changes: 4 additions & 11 deletions TrackletAlgorithm/MemoryTemplateBinnedCM.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class MemoryTemplateBinnedCM{

ap_uint<kNBitsRZBinCM> ibin;
ap_uint<kNBitsphibinCM> ireg;
(ireg,ibin)=slot;
(ibin,ireg)=slot;

unsigned int nentry = nentries_[ibx*kNBinsRZ+ibin].range(ireg*4+3,ireg*4);

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions TrackletAlgorithm/TrackletProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Seed,iTC,innerASType,OuterRegion<Seed>()>::NSTUBS(0)):
(ireg_reg, ibin_reg, istub_tmp_reg));
(ibin_init, ireg_init, typename TrackletEngineUnit<Seed,iTC,innerASType,OuterRegion<Seed>()>::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;
Expand Down
3 changes: 2 additions & 1 deletion TrackletAlgorithm/VMRouterCM.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ inline T createVMStub(const InputStub<InType> 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
Expand Down
3 changes: 2 additions & 1 deletion TrackletAlgorithm/VMSMERouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ inline T createVMStubME(const AllStub<inType>& 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
Expand Down

0 comments on commit 5b94010

Please sign in to comment.