From 173f76299fd34867e084a3337c819216c99fedb4 Mon Sep 17 00:00:00 2001 From: aryd Date: Fri, 6 Dec 2024 11:02:49 -0500 Subject: [PATCH] Unify the VMStubMEMemoryCM and VMStubTEOuterMemoryCM in VMStubMemory class (#350) * Unify the VMStubMEMemoryCM and VMStubTEOuterMemoryCM in common VMStubMemory class * Correct bug so that we have correct stub bend size for TE VMStubs * Change ordering of phi and rz in binned memories - rz is more significant bits * Updates to ordering pf phi and rz for binmask in vm memories * Some updates to get agreement between emulation and HLS in MP * Fix comments from A. Hart on PR * Remove some print statements * Add back D3PHI3 as it now agrees with emulation * Add more MP tests * Clean up some debug statement * Remove unused istep variable in MatchCalculator and zero nentry_mask_tmp in tf_mem_bin.vhd * Change to using head of project_generation_scripts * Add protection against writing too many projections to memory * Fixed is so that TB_D1D2 agrees with emulation --------- Co-authored-by: Anders Ryd --- IntegrationTests/common/hdl/tf_mem_bin.vhd | 13 +- IntegrationTests/common/script/impl.tcl | 3 +- IntegrationTests/common/script/synth.tcl | 3 +- TestBenches/MatchProcessor_test.cpp | 20 +-- TestBenches/TrackletProcessor_test.cpp | 144 +-------------- TestBenches/VMRouterCM_test.cpp | 6 +- TestBenches/VMStubMERouter_test.cpp | 4 +- TrackletAlgorithm/MatchEngineUnit.h | 31 ++-- TrackletAlgorithm/MatchProcessor.h | 47 ++--- TrackletAlgorithm/MemoryTemplateBinnedCM.h | 6 +- TrackletAlgorithm/MemoryTemplateTPROJ.h | 8 + TrackletAlgorithm/TrackBuilder.h | 20 ++- .../TrackletCalculator_calculate_LXD1.h | 155 ---------------- TrackletAlgorithm/TrackletEngineUnit.h | 8 +- TrackletAlgorithm/TrackletProcessor.h | 16 +- TrackletAlgorithm/VMRouterCM.h | 22 +-- TrackletAlgorithm/VMSMERouter.h | 15 +- TrackletAlgorithm/VMStubMEMemoryCM.h | 165 ------------------ TrackletAlgorithm/VMStubMemory.h | 165 ++++++++++++++++++ TrackletAlgorithm/VMStubTEOuterMemoryCM.h | 157 ----------------- emData/download.sh | 8 +- emData/generate_MP.py | 4 +- emData/generate_TP.py | 4 +- emData/generate_VMRCM.py | 8 +- emData/generate_VMSMER.py | 4 +- emData/project_generation_scripts | 2 +- project/script_MP.tcl | 25 +-- project/script_TB.tcl | 1 + 28 files changed, 327 insertions(+), 737 deletions(-) delete mode 100644 TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h delete mode 100644 TrackletAlgorithm/VMStubMEMemoryCM.h create mode 100644 TrackletAlgorithm/VMStubMemory.h delete mode 100644 TrackletAlgorithm/VMStubTEOuterMemoryCM.h diff --git a/IntegrationTests/common/hdl/tf_mem_bin.vhd b/IntegrationTests/common/hdl/tf_mem_bin.vhd index e7adf125f8e..63ac17c67b8 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'); @@ -244,13 +244,14 @@ begin init := '0'; slv_clk_cnt := (others => '0'); slv_page_cnt := (0 => '1', others => '0'); - --report "tf_mem_bin "&time'image(now)&" "&NAME&" setting nentry_mask_tmp to zero"; + nentry_mask_tmp <= (others => '0'); -- Do we need this??? FIXME + --report "tf_mem_bin "&time'image(now)&" "&NAME&" sync_nent set"; end if; if (init = '0' and to_integer(unsigned(slv_clk_cnt)) < MAX_ENTRIES-1) then -- ####### Counter nent slv_clk_cnt := std_logic_vector(unsigned(slv_clk_cnt)+1); elsif (to_integer(unsigned(slv_clk_cnt)) >= MAX_ENTRIES-1) then -- -1 not included slv_clk_cnt := (others => '0'); - nentry_mask_tmp <= (others => '0'); -- Why do we need this??? FIXME + nentry_mask_tmp <= (others => '0'); -- Do we need this??? FIXME --report "tf_mem_bin "&time'image(now)&" "&NAME&" setting nentry_mask_tmp to zero"; if (to_integer(unsigned(slv_page_cnt)) < NUM_PAGES-1) then slv_page_cnt := std_logic_vector(unsigned(slv_page_cnt)+1); @@ -266,7 +267,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; @@ -279,7 +280,7 @@ begin nentry_mask_tmp(to_integer(unsigned(vi_nent_idx))) <= '1'; writeaddr := slv_page_cnt_save & vi_nent_idx & std_logic_vector(binaddr); - --report "tf_mem_bin addra: " & NAME & " " & to_bstring(std_logic_vector(addra)); + --report "tf_mem_bin writeaddr data: " & NAME & " " & to_bstring(writeaddr) & " " & to_bstring(dina); for icopy in 0 to NUM_COPY-1 loop sa_RAM_data(icopy)(to_integer(unsigned(writeaddr))) <= dina; end loop; diff --git a/IntegrationTests/common/script/impl.tcl b/IntegrationTests/common/script/impl.tcl index 6ebdf24ab5e..58aced01019 100644 --- a/IntegrationTests/common/script/impl.tcl +++ b/IntegrationTests/common/script/impl.tcl @@ -20,7 +20,8 @@ reset_run impl_1 # Implementation update_compile_order -fileset sources_1 -launch_runs impl_1 -jobs 4 +set ncpus [exec nproc] +launch_runs impl_1 -jobs $ncpus wait_on_run impl_1 # Make reports diff --git a/IntegrationTests/common/script/synth.tcl b/IntegrationTests/common/script/synth.tcl index 20d52a07d0f..1aeb599b508 100644 --- a/IntegrationTests/common/script/synth.tcl +++ b/IntegrationTests/common/script/synth.tcl @@ -23,7 +23,8 @@ 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 +set ncpus [exec nproc] +launch_runs synth_1 -jobs $ncpus wait_on_run synth_1 # Make reports diff --git a/TestBenches/MatchProcessor_test.cpp b/TestBenches/MatchProcessor_test.cpp index 36cf962ee8f..6bd1d246a86 100644 --- a/TestBenches/MatchProcessor_test.cpp +++ b/TestBenches/MatchProcessor_test.cpp @@ -26,7 +26,7 @@ using namespace std; int main() { // Define memory patterns - const string trackletProjectionPattern = "TrackletProjections*"; + const string trackletProjectionPattern = "TrackletProjections_MPROJ*"; const string allStubPatternarray = "AllStub*"; const string vmStubPatternarray = "VMStubs_VMSME*"; const string fullMatchPattern = "FullMatches*"; @@ -48,7 +48,7 @@ int main() const auto nAllStub = tb.nFiles(allStubPatternarray); vector> allstub(nAllStub); const auto nVMStubs = tb.nFiles(vmStubPatternarray); - VMStubMEMemoryCM vmstub; // barrel + VMStubMemory vmstub; // barrel // output memories const auto nFullMatches = tb.nFiles(fullMatchPattern); @@ -71,6 +71,11 @@ int main() for (unsigned int ievt = 0; ievt < nevents; ++ievt) { cout << "Event: " << dec << ievt << endl; + // bx + BXType bx = ievt; + BXType bx_out; + + // read event and write to memories auto &fin_TrackletProjections = tb.files(trackletProjectionPattern); for (unsigned int i = 0; i < nTrackletProjections; i++) @@ -79,16 +84,12 @@ int main() for (unsigned int i = 0; i < nAllStub; i++) writeMemFromFile>(allstub[i], fin_AllStub.at(i), ievt); auto &fin_VMStubs = tb.files(vmStubPatternarray); - writeMemFromFile>(vmstub, fin_VMStubs.at(0), ievt); // barrel + writeMemFromFile>(vmstub, fin_VMStubs.at(0), ievt); // barrel // clear allarray, output memories before starting for (unsigned int i = 0; i < nFullMatches; i++) fullmatcharray[i].clear(); - // bx - BXType bx = ievt; - BXType bx_out; - // Unit Under Test TOP_FUNC_(bx, tprojarray.data(), vmstub, allstub.data(), bx_out, fullmatcharray.data()); @@ -106,10 +107,9 @@ int main() } // end of event loop - // This is necessary because HLS seems to only return an 8-bit error count, so if err%256==0, the test bench can falsely pass + // This is necessary because HLS seems to only return an 8-bit error count, + // so if err%256==0, the test bench can falsely pass if (err > 255) err = 255; -// cout << "Module actually has " << err << " errors." << endl; -// return 0; return err; } diff --git a/TestBenches/TrackletProcessor_test.cpp b/TestBenches/TrackletProcessor_test.cpp index 9908846b33b..bed3968e8f8 100644 --- a/TestBenches/TrackletProcessor_test.cpp +++ b/TestBenches/TrackletProcessor_test.cpp @@ -109,7 +109,7 @@ std::cout< > innerStubs(nInnerStubMems); vector > outerStubs(nOuterStubMems); - vector > outervmStubs(nOuterVMStubMems); + vector > outervmStubs(nOuterVMStubMems); // output memories TrackletParameterMemory tpar; @@ -122,8 +122,6 @@ std::cout< >(outerStubs[i], fin_outerStubs.at(i), ievt); for (unsigned i = 0; i < nOuterVMStubMems; i++) - writeMemFromFile>(outervmStubs[i], fin_outervmStubs.at(i), ievt); + writeMemFromFile>(outervmStubs[i], fin_outervmStubs.at(i), ievt); // clear all output memories before starting tpar.clear(); @@ -168,144 +166,6 @@ std::cout<(tpar, fout_tpar.at(0), ievt, "\nTrackletParameter", truncation); - for (unsigned i = 0; i < tproj_names.size(); i++) { - const auto &tproj_name = tproj_names.at(i); - auto &fout = fout_tproj.at(i); - if (tproj_name.find("_D1PHIA") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D1PHIA], fout, ievt, - "\nTrackletProjection (D1PHIA)", truncation); - else if (tproj_name.find("_D1PHIB") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D1PHIB], fout, ievt, - "\nTrackletProjection (D1PHIB)", truncation); - else if (tproj_name.find("_D1PHIC") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D1PHIC], fout, ievt, - "\nTrackletProjection (D1PHIC)", truncation); - else if (tproj_name.find("_D1PHID") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D1PHID], fout, ievt, - "\nTrackletProjection (D1PHID)", truncation); - else if (tproj_name.find("_D2PHIA") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D2PHIA], fout, ievt, - "\nTrackletProjection (D2PHIA)", truncation); - else if (tproj_name.find("_D2PHIB") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D2PHIB], fout, ievt, - "\nTrackletProjection (D2PHIB)", truncation); - else if (tproj_name.find("_D2PHIC") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D2PHIC], fout, ievt, - "\nTrackletProjection (D2PHIC)", truncation); - else if (tproj_name.find("_D2PHID") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D2PHID], fout, ievt, - "\nTrackletProjection (D2PHID)", truncation); - else if (tproj_name.find("_D3PHIA") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D3PHIA], fout, ievt, - "\nTrackletProjection (D3PHIA)", truncation); - else if (tproj_name.find("_D3PHIB") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D3PHIB], fout, ievt, - "\nTrackletProjection (D3PHIB)", truncation); - else if (tproj_name.find("_D3PHIC") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D3PHIC], fout, ievt, - "\nTrackletProjection (D3PHIC)", truncation); - else if (tproj_name.find("_D3PHID") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D3PHID], fout, ievt, - "\nTrackletProjection (D3PHID)", truncation); - else if (tproj_name.find("_D4PHIA") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D4PHIA], fout, ievt, - "\nTrackletProjection (D4PHIA)", truncation); - else if (tproj_name.find("_D4PHIB") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D4PHIB], fout, ievt, - "\nTrackletProjection (D4PHIB)", truncation); - else if (tproj_name.find("_D4PHIC") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D4PHIC], fout, ievt, - "\nTrackletProjection (D4PHIC)", truncation); - else if (tproj_name.find("_D4PHID") != string::npos) - err += compareMemWithFile >(tproj_disk[TP::D4PHID], fout, ievt, - "\nTrackletProjection (D4PHID)", truncation); - else if (tproj_name.find("_L1PHIA") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L1PHIA], fout, ievt, - "\nTrackletProjection (L1PHIA)", truncation); - else if (tproj_name.find("_L1PHIB") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L1PHIB], fout, ievt, - "\nTrackletProjection (L1PHIB)", truncation); - else if (tproj_name.find("_L1PHIC") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L1PHIC], fout, ievt, - "\nTrackletProjection (L1PHIC)", truncation); - else if (tproj_name.find("_L1PHID") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L1PHID], fout, ievt, - "\nTrackletProjection (L1PHID)", truncation); - else if (tproj_name.find("_L1PHIE") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L1PHIE], fout, ievt, - "\nTrackletProjection (L1PHIE)", truncation); - else if (tproj_name.find("_L1PHIF") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L1PHIF], fout, ievt, - "\nTrackletProjection (L1PHIF)", truncation); - else if (tproj_name.find("_L1PHIG") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L1PHIG], fout, ievt, - "\nTrackletProjection (L1PHIG)", truncation); - else if (tproj_name.find("_L1PHIH") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L1PHIH], fout, ievt, - "\nTrackletProjection (L1PHIH)", truncation); - else if (tproj_name.find("_L2PHIA") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L2PHIA], fout, ievt, - "\nTrackletProjection (L2PHIA)", truncation); - else if (tproj_name.find("_L2PHIB") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L2PHIB], fout, ievt, - "\nTrackletProjection (L2PHIB)", truncation); - else if (tproj_name.find("_L2PHIC") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L2PHIC], fout, ievt, - "\nTrackletProjection (L2PHIC)", truncation); - else if (tproj_name.find("_L2PHID") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L2PHID], fout, ievt, - "\nTrackletProjection (L2PHID)", truncation); - else if (tproj_name.find("_L3PHIA") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L3PHIA], fout, ievt, - "\nTrackletProjection (L3PHIA)", truncation); - else if (tproj_name.find("_L3PHIB") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L3PHIB], fout, ievt, - "\nTrackletProjection (L3PHIB)", truncation); - else if (tproj_name.find("_L3PHIC") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L3PHIC], fout, ievt, - "\nTrackletProjection (L3PHIC)", truncation); - else if (tproj_name.find("_L3PHID") != string::npos) - err += compareMemWithFile >(tproj_barrel_ps[TP::L3PHID], fout, ievt, - "\nTrackletProjection (L3PHID)", truncation); - - else if (tproj_name.find("_L4PHIA") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L4PHIA], fout, ievt, - "\nTrackletProjection (L4PHIA)", truncation); - else if (tproj_name.find("_L4PHIB") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L4PHIB], fout, ievt, - "\nTrackletProjection (L4PHIB)", truncation); - else if (tproj_name.find("_L4PHIC") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L4PHIC], fout, ievt, - "\nTrackletProjection (L4PHIC)", truncation); - else if (tproj_name.find("_L4PHID") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L4PHID], fout, ievt, - "\nTrackletProjection (L4PHID)", truncation); - else if (tproj_name.find("_L5PHIA") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L5PHIA], fout, ievt, - "\nTrackletProjection (L5PHIA)", truncation); - else if (tproj_name.find("_L5PHIB") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L5PHIB], fout, ievt, - "\nTrackletProjection (L5PHIB)", truncation); - else if (tproj_name.find("_L5PHIC") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L5PHIC], fout, ievt, - "\nTrackletProjection (L5PHIC)", truncation); - else if (tproj_name.find("_L5PHID") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L5PHID], fout, ievt, - "\nTrackletProjection (L5PHID)", truncation); - else if (tproj_name.find("_L6PHIA") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L6PHIA], fout, ievt, - "\nTrackletProjection (L6PHIA)", truncation); - else if (tproj_name.find("_L6PHIB") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L6PHIB], fout, ievt, - "\nTrackletProjection (L6PHIB)", truncation); - else if (tproj_name.find("_L6PHIC") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L6PHIC], fout, ievt, - "\nTrackletProjection (L6PHIC)", truncation); - else if (tproj_name.find("_L6PHID") != string::npos) - err += compareMemWithFile >(tproj_barrel_2s[TP::L6PHID], fout, ievt, - "\nTrackletProjection (L6PHID)", truncation); - - } cout << endl; } // end of event loop diff --git a/TestBenches/VMRouterCM_test.cpp b/TestBenches/VMRouterCM_test.cpp index 11d27f0a676..8399cd0a711 100644 --- a/TestBenches/VMRouterCM_test.cpp +++ b/TestBenches/VMRouterCM_test.cpp @@ -73,8 +73,8 @@ int main() { // Output memories static AllStubMemory memoriesAS[numASCopies]; static AllStubInnerMemory memoriesASInner[numASInnerCopies]; - static VMStubMEMemoryCM memoryME; - static VMStubTEOuterMemoryCM memoriesTEO[numTEOCopies]; + static VMStubMemory memoryME; + static VMStubMemory memoriesTEO[numTEOCopies]; /////////////////////////// @@ -147,7 +147,7 @@ int main() { //TE Outer memories if (nVMSTE) { for (unsigned int i = 0; i < nVMSTE; i++) { - err += compareBinnedMemCMWithFile>(memoriesTEO[i], fout_vmstubte[i], ievt, "VMStubTEOuter", truncation); + err += compareBinnedMemCMWithFile>(memoriesTEO[i], fout_vmstubte[i], ievt, "VMStubTEOuter", truncation); } } } // End of event loop diff --git a/TestBenches/VMStubMERouter_test.cpp b/TestBenches/VMStubMERouter_test.cpp index ef3f502e09b..4a3b3699ebc 100644 --- a/TestBenches/VMStubMERouter_test.cpp +++ b/TestBenches/VMStubMERouter_test.cpp @@ -52,7 +52,7 @@ int main() { static AllStubMemory memoriesAS; // Output memories - static VMStubMEMemoryCM memoryME; + static VMStubMemory memoryME; static AllStubMemory memoriesASCopy; /////////////////////////// @@ -94,7 +94,7 @@ int main() { // ME memories std::cout << "comparing memories for layer/disk: " << dec << kLAYER << "/" << kDISK << " and region: " << phiRegion << std::endl; - err += compareBinnedMemCMWithFile>(memoryME, fout_vmstubme[0], ievt, "VMStubME", truncation); + err += compareBinnedMemCMWithFile>(memoryME, fout_vmstubme[0], ievt, "VMStubME", truncation); } // End of event loop diff --git a/TrackletAlgorithm/MatchEngineUnit.h b/TrackletAlgorithm/MatchEngineUnit.h index 136e9dd570b..38ab7c5e1dc 100644 --- a/TrackletAlgorithm/MatchEngineUnit.h +++ b/TrackletAlgorithm/MatchEngineUnit.h @@ -3,7 +3,7 @@ #include "Constants.h" #include "TrackletProjectionMemory.h" -#include "VMStubMEMemoryCM.h" +#include "VMStubMemory.h" #include "VMProjectionMemory.h" #include "ProjectionRouterBuffer.h" #include "AllStubMemory.h" @@ -33,11 +33,11 @@ class MatchEngineUnitBase { }; }; -template +template class MatchEngineUnit : public MatchEngineUnitBase { public: - typedef ap_uint::kVMSMEIDSize> MATCH; + typedef ap_uint::kVMSIDSize> MATCH; typedef ap_uint NSTUB; typedef ap_uint NSTUBS; typedef ap_uint::kNBitsBuffer> INDEX; @@ -104,7 +104,7 @@ class MatchEngineUnit : public MatchEngineUnitBase { -inline void step(const VMStubMECM stubmem[4][1<<(kNbitsrzbinMP+kNbitsphibin+4)]) { +inline void step(const VMStub stubmem[4][1<<(kNbitsrzbinMP+kNbitsphibin+4)]) { #pragma HLS inline #pragma HLS array_partition variable=nstubsall_ complete dim=1 @@ -119,12 +119,10 @@ inline void step(const VMStubMECM stubmem[4][1<<(kNbitsrzbinMP+kNbits NSTUB istubtmp=istub_; ap_uint<2> iusetmp=iuse_; - ap_uint::kVMSMEFinePhiSize> iphiSave = iphi_ + use_[iusetmp].range(0,0); + ap_uint::kVMSFinePhiSize> iphiSave = iphi_ + use_[iusetmp].range(0,0); 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,8 +151,14 @@ inline void step(const VMStubMECM stubmem[4][1<<(kNbitsrzbinMP+kNbits 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); + //Read stub memory and extract data fields auto stubadd=(slot,istubtmp); stubdata__ = stubmem[bx_&1][stubadd]; @@ -254,7 +258,8 @@ inline void step(const VMStubMECM stubmem[4][1<<(kNbitsrzbinMP+kNbits //if (good___) { // std::cout << "CAndidateMatc: " << unit_ << " " << index << " " - // << table[index] << " " << pass << " " << passphi << std::endl; + // << table[index] << " " << pass << " " << passphi << " " + // << stubfinephi << " " << projfinephi___ << std::endl; //} good___ = good__; @@ -381,10 +386,10 @@ inline void advance() { ap_uint<1> phiPlus_; typename ProjectionRouterBuffer::PHIPROJBIN phiProjBin_; bool idle_; - ap_uint::kVMSMEFinePhiSize> iphi_; + ap_uint::kVMSFinePhiSize> iphi_; BXType bx_; bool empty_; - VMStubMECM stubdata__, stubdata___; + VMStub stubdata__, stubdata___; typename ProjectionRouterBuffer::TCID tcid_; ProjectionRouterBuffer projbuffer_; ap_uint projseq_; @@ -419,8 +424,8 @@ inline void advance() { static constexpr int projfinephibits = VMProjectionBase::kVMProjFinePhiWideSize; static constexpr int projfinezbits = VMProjectionBase::kVMProjFineZSize; - static constexpr int stubfinephibits = VMStubMECMBase::kVMSMEFinePhiSize; - static constexpr int stubfinezbits = VMStubMECMBase::kVMSMEFineZSize; + static constexpr int stubfinephibits = VMStubBase::kVMSFinePhiSize; + static constexpr int stubfinezbits = VMStubBase::kVMSFineZSize; #ifndef __SYNTHESIS__ diff --git a/TrackletAlgorithm/MatchProcessor.h b/TrackletAlgorithm/MatchProcessor.h index cf4780b4d20..4eefa42b5f1 100644 --- a/TrackletAlgorithm/MatchProcessor.h +++ b/TrackletAlgorithm/MatchProcessor.h @@ -3,7 +3,7 @@ #include "Constants.h" #include "TrackletProjectionMemory.h" -#include "VMStubMEMemoryCM.h" +#include "VMStubMemory.h" #include "VMProjectionMemory.h" #include "ProjectionRouterBuffer.h" #include "ProjectionRouterBufferArray.h" @@ -901,7 +901,7 @@ template constexpr uint32_t NPageSum(); #include "MatchProcessor_parameters.h" -template +template void MatchCalculator(BXType bx, ap_uint<1> newtracklet, ap_uint<1>& isMatch, @@ -912,7 +912,7 @@ void MatchCalculator(BXType bx, ap_uint& best_delta_r, const AllStubMemory* allstub, const AllProjection& proj, - ap_uint::kVMSMEIDSize> stubid, + ap_uint::kVMSIDSize> stubid, FullMatchMemory fullmatch[maxFullMatchVariants] ){ @@ -1127,7 +1127,7 @@ void MatchCalculator(BXType bx, goodmatch = true; } - if(goodmatch) { // Write out only the best match, based on the seeding + if(goodmatch) { // Write out only the best match, based on the seeding switch (proj_seed) { case 0: if(FMMask()) { @@ -1180,14 +1180,14 @@ constexpr unsigned kNbitsrzbinMPDisk = kNbitsrzbin + 1; ////////////////////////////// // MatchProcessor -template void MatchProcessor(BXType bx, // because Vivado HLS cannot synthesize an array of // pointers that point to stuff other than scalar or // array of scalar ... const TrackletProjectionMemory projin[nINMEM], - const VMStubMEMemoryCM& instubdata, + const VMStubMemory& instubdata, const AllStubMemory* allstub, BXType& bx_o, FullMatchMemory fullmatch[maxFullMatchVariants] @@ -1271,7 +1271,7 @@ void MatchProcessor(BXType bx, constexpr int nPRBAbits = 3; ProjectionRouterBufferArray projbufferarray; - MatchEngineUnit matchengine[kNMatchEngines]; + MatchEngineUnit matchengine[kNMatchEngines]; #pragma HLS ARRAY_PARTITION variable=matchengine complete #pragma HLS ARRAY_PARTITION variable=projin dim=1 @@ -1294,7 +1294,7 @@ void MatchProcessor(BXType bx, ap_uint<1> newtracklet_save; ap_uint<1> isMatch_save; AllProjection allproj_save; - ap_uint::kVMSMEIDSize> stubindex_save; + ap_uint::kVMSIDSize> stubindex_save; TrackletProjection projdata, projdata_; bool validin = false; @@ -1333,9 +1333,10 @@ void MatchProcessor(BXType bx, ap_uint::kAllProjectionSize> projBuffer[1< istep = 0; istep < kMaxProc - kMaxProcOffset(module::MP); istep++) { #pragma HLS PIPELINE II=1 rewind @@ -1351,14 +1352,15 @@ void MatchProcessor(BXType bx, auto readptr = projbufferarray.getReadPtr(); auto writeptr = projbufferarray.getWritePtr(); bool empty = emptyUnit()[(readptr,writeptr)]; + bool projBuffNearFull = nearFull4Unit()[(readptr,writeptr)]; - + ap_uint<3> iphi = 0; ap_uint idles; ap_uint emptys; - typename MatchEngineUnit::MATCH matches[kNMatchEngines]; + typename MatchEngineUnit::MATCH matches[kNMatchEngines]; #pragma HLS ARRAY_PARTITION variable=matches complete ap_uint projseqs[kNMatchEngines]; #pragma HLS ARRAY_PARTITION variable=projseqs complete @@ -1377,10 +1379,12 @@ void MatchProcessor(BXType bx, } //This printout exactly matches printout in emulation for tracking code differences - /* - for(int iMEU = 0; iMEU < kNMatchEngines; ++iMEU) { - std::cout << " MEU"< smallest = ~emptys; @@ -1458,7 +1460,8 @@ void MatchProcessor(BXType bx, if (hasMatch_save) { isMatch = newtracklet_save ? ap_uint<1>(0) : isMatch; - MatchCalculator + + MatchCalculator (bx, newtracklet_save, isMatch, savedMatch, best_delta_z, best_delta_phi, best_delta_rphi, best_delta_r, allstub, allproj_save, stubindex_save, fullmatch); } @@ -1468,7 +1471,7 @@ void MatchProcessor(BXType bx, if(hasMatch) { - ap_uint::kVMSMEIDSize> stubindex; + ap_uint::kVMSIDSize> stubindex; stubindex = matches[bestiMEU]; @@ -1507,7 +1510,7 @@ void MatchProcessor(BXType bx, // vmproj z // Separate the vm projections into zbins - // To determine which zbin in VMStubsME the ME should look in to match this VMProjection, + // To determine which zbin in VMStubs the ME should look in to match this VMProjection, // the purpose of these lines is to take the top MEBinsBits (3) bits of zproj and shift it // to make it positive, which gives the bin index. But there is a range of possible z values // over which we want to look for matched stubs, and there is therefore possibly 2 bins that diff --git a/TrackletAlgorithm/MemoryTemplateBinnedCM.h b/TrackletAlgorithm/MemoryTemplateBinnedCM.h index 1a52bd4fa3c..cf1a28d1a4d 100644 --- a/TrackletAlgorithm/MemoryTemplateBinnedCM.h +++ b/TrackletAlgorithm/MemoryTemplateBinnedCM.h @@ -147,7 +147,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); @@ -229,13 +229,13 @@ class MemoryTemplateBinnedCM{ ap_uint ibin; ap_uint ireg; - (ireg,ibin)=slot; + (ibin, ireg)=slot; ap_uint<4> nentry_ibx = nentries_[ibx*kNBinsRZ+ibin].range(ireg*4+3,ireg*4); DataType data(datastr.c_str(), base); bool success = write_mem(ibx, slot, data, nentry_ibx); - + return success; } diff --git a/TrackletAlgorithm/MemoryTemplateTPROJ.h b/TrackletAlgorithm/MemoryTemplateTPROJ.h index e388be88a03..c355ab55b73 100644 --- a/TrackletAlgorithm/MemoryTemplateTPROJ.h +++ b/TrackletAlgorithm/MemoryTemplateTPROJ.h @@ -57,6 +57,9 @@ class MemoryTemplateTPROJ static constexpr unsigned int DEPTH_BX = 1< BunchXingT; typedef ap_uint NEntryT; @@ -120,8 +123,13 @@ class MemoryTemplateTPROJ //The vhd memory implementation will write to the correct address!! dataarray_[ibx][DEPTH_ADDR*page+addr_index] = data; #else + //NBIT_BX==1 is to identify the projection memories + if (NBIT_BX==1 && nentries_[ibx*NPAGE+page]>=MAX_TPROJ_PAGE_SIZE) { + return false; + } dataarray_[ibx][DEPTH_ADDR*page+nentries_[ibx*NPAGE+page]++] = data; mask_[ibx].set(page); + #endif return true; diff --git a/TrackletAlgorithm/TrackBuilder.h b/TrackletAlgorithm/TrackBuilder.h index 7bccf6fd2c0..7af4c27d237 100644 --- a/TrackletAlgorithm/TrackBuilder.h +++ b/TrackletAlgorithm/TrackBuilder.h @@ -264,17 +264,25 @@ void TrackBuilder( // object. ap_uint<3> nMatches = 0; // there can be up to eight matches (3 bits) + //This is a hack to match the emulation where for D1D2 seeds + //We don't use both L2 and D3 matches + bool barrelD1D2Match1 = false; + barrel_stub_association : for (short j = 0; j < NBarrelStubs; j++) { const auto &barrel_stub = merger_L_top[j].peek(); const bool barrel_stub_valid = merger_L_top[j].valid() && smallest[j]; - if (barrel_stub_valid) nMatches++; + if (barrel_stub_valid) { + nMatches++; + barrelD1D2Match1 = Seed == TF::D1D2 && j == 1; + } const auto &barrel_stub_index = (barrel_stub_valid ? barrel_stub.getStubIndex() : FullMatch::FMSTUBINDEX(0)); const auto &barrel_stub_r = (barrel_stub_valid ? barrel_stub.getStubR() : FullMatch::FMSTUBR(0)); const auto &barrel_phi_res = (barrel_stub_valid ? barrel_stub.getPhiRes() : FullMatch::FMPHIRES(0)); const auto &barrel_z_res = (barrel_stub_valid ? barrel_stub.getZRes() : FullMatch::FMZRES(0)); + switch (j) { case 0: track.template setBarrelStub<0>(barrel_stub_valid, barrel_stub_index, barrel_stub_r, barrel_phi_res, barrel_z_res); @@ -313,8 +321,14 @@ void TrackBuilder( disk_stub_association : for (short j = 0; j < NDiskStubs; j++) { const auto &disk_stub = merger_D_top[j].peek(); - const bool disk_stub_valid = merger_D_top[j].valid() && smallest[j+NBarrelStubs]; - if (disk_stub_valid) nMatches++; + bool disk_stub_valid = merger_D_top[j].valid() && smallest[j+NBarrelStubs]; + if (disk_stub_valid) { + nMatches++; + if (Seed == TF::D1D2 and j==0 && barrelD1D2Match1) { + //Hack to not allow D1D2 seed with L2 and D3 match - skip disk match + nMatches--; + } + } const auto &disk_stub_index = (disk_stub_valid ? disk_stub.getStubIndex() : FullMatch::FMSTUBINDEX(0)); const auto &disk_stub_r = (disk_stub_valid ? disk_stub.getStubR() : FullMatch::FMSTUBR(0)); diff --git a/TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h b/TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h deleted file mode 100644 index 9986d79fe82..00000000000 --- a/TrackletAlgorithm/TrackletCalculator_calculate_LXD1.h +++ /dev/null @@ -1,155 +0,0 @@ -// -#include "ap_int.h" -#include "Constants.h" -#include "TrackletProjectionCalculator.h" -#include "TrackletLUTs.h" - -template -void TC::calculate_LXD1 ( - const typename AllStub::ASR r1_input, - const typename AllStub::ASPHI phi1_input, - const typename AllStub::ASZ z1_input, - const typename AllStub::ASR r2_input, - const typename AllStub::ASPHI phi2_input, - const typename AllStub::ASZ z2_input, - - bool * const valid_radii, - TC::Types::rinv * const rinv_output, - TrackletParameters::PHI0PAR * const phi0_output, - TrackletParameters::TPAR * const t_output, - TC::Types::z0 * const z0_output, - TC::Types::phiL * const phiL_0_output, - TC::Types::phiL * const phiL_1_output, - TC::Types::phiL * const phiL_2_output, - TC::Types::zL * const zL_0_output, - TC::Types::zL * const zL_1_output, - TC::Types::zL * const zL_2_output, - TC::Types::der_phiL * const der_phiL_output, - TC::Types::der_zL * const der_zL_output, - TC::Types::phiD * const phiD_0_output, - TC::Types::phiD * const phiD_1_output, - TC::Types::phiD * const phiD_2_output, - TC::Types::phiD * const phiD_3_output, - TC::Types::rD * const rD_0_output, - TC::Types::rD * const rD_1_output, - TC::Types::rD * const rD_2_output, - TC::Types::rD * const rD_3_output, - TC::Types::der_phiD * const der_phiD_output, - TC::Types::der_rD * const der_rD_output) -{ -#pragma HLS pipeline II=1 -#pragma HLS latency max=25 - - //First convert input to right bits - ap_uint<12> ir1c = (ap_int<10>(r1_input) << 1) + rmean[seedLayers[Seed][0]]; - ap_uint<12> ir2c = r2_input; - - const ap_int<18> phi1c = ap_int<18>(phi1_input)<<3; - const ap_int<18> phi2c = ap_int<18>(phi2_input)<<3; - - const TC::Types::zmean z2mean = zmean[seedLayers[Seed][1]]; - - const ap_int<14> z1c = z1_input; - const ap_int<14> z2c = ap_int<7>(z2_input) + (z1c > 0 ? ap_int<14>(z2mean) : ap_int<14>(-z2mean)); - - ap_int<12> idz = z2c - z1c; - - ap_uint<12> idr = (ap_int<12>(ir2c - ir1c)); - - static const InvdrLUT lut_idrinv; - ap_uint<18> invdr = lut_idrinv.lookup(idr); - - *valid_radii = idr > floatToInt(((Seed == TF::L1D1)?1.5:2.0),kr); - //FIXME this 1.5 and 2.0 is a magic number - - ap_int<18> idelta0 = ((phi2c - phi1c)*invdr) >> n_delta0_Overlap_; - ap_int<18> ideltaz = (idz*invdr) >> n_deltaz_Overlap_; - - ap_int<20> idelta1 = (ir1c*idelta0) >> n_delta1_; - ap_int<20> idelta2 = (ir2c*idelta0) >> n_delta2_; - - ap_int<20> idelta12 = (idelta1*idelta2) >> n_delta12_; - - constexpr int iHG = phiHG_*phiHG_*(1 << n_HG_); - - ap_uint ia = ((1 << n_a_Overlap_) - ((idelta12*iHG) >> (2*n_Deltar_Overlap_ + 2*n_phi_ + n_HG_ - 2*n_delta0_Overlap_ - n_delta1_ - n_delta2_ - n_delta12_ + 1 - n_a_Overlap_))); - - constexpr int ir6fact = (1< ir6 = (ir1c+ir2c)*ir6fact; - - ap_int<18> idelta02 = (idelta0*idelta2) >> n_delta02_; - - ap_int ix6 = (-(1 << n_x6_)+((ir6*idelta02) >> (n_r6_Overlap_ + 2*n_Deltar_Overlap_ + 2*n_phi_ - n_x6_ - n_delta2_- n_delta02_ - 2*n_delta0_Overlap_))); - - ap_int<18> it1 = (ir1c*ideltaz) >> (n_Deltar_Overlap_ - n_deltaz_Overlap_); - - - ap_int<15> irinv_new = ((-idelta0*ia) >> (n_phi_ + n_a_Overlap_ - n_rinv_ + n_Deltar_Overlap_ - n_delta0_Overlap_ - n_r_ - 1)); - - ap_int<18> iphi0_new = (phi1c >> (n_phi_ - n_phi0_))+((idelta1*ix6) >> (n_Deltar_Overlap_ + n_x6_ + n_phi_ - n_delta0_Overlap_ - n_delta1_ - n_phi0_)); - - ap_int<14> it_new = ((ideltaz*ia) >> (n_Deltar_Overlap_ + n_a_Overlap_ + n_z_ - n_t_ - n_deltaz_Overlap_ - n_r_)); - - ap_int<11> iz0_new = z1c + ((it1*ix6) >> n_x6_); - - constexpr int irproj0 = rmean[projectionLayers[Seed][0]]; - constexpr int irproj1 = rmean[projectionLayers[Seed][1]]; - constexpr int irproj2 = rmean[projectionLayers[Seed][2]]; - - constexpr int irprojtilde0 = irproj0*phiHG_/sqrtsix + 0.5; - constexpr int irprojtilde1 = irproj1*phiHG_/sqrtsix + 0.5; - constexpr int irprojtilde2 = irproj2*phiHG_/sqrtsix + 0.5; - - const ap_int<13> rproj0 = irproj0; - const ap_int<13> rproj1 = irproj1; - const ap_int<13> rproj2 = irproj2; - - const ap_int<13> rprojtilde0 = irprojtilde0; - const ap_int<13> rprojtilde1 = irprojtilde1; - const ap_int<13> rprojtilde2 = irprojtilde2; - - projToLayer(rproj0, rprojtilde0, irinv_new, iphi0_new, it_new, iz0_new, *zL_0_output, *phiL_0_output); - projToLayer(rproj1, rprojtilde1, irinv_new, iphi0_new, it_new, iz0_new, *zL_1_output, *phiL_1_output); - projToLayer(rproj2, rprojtilde2, irinv_new, iphi0_new, it_new, iz0_new, *zL_2_output, *phiL_2_output); - - *der_phiL_output = -(irinv_new >> (1+3)); - *der_zL_output = it_new >> 3; - - static const InvtLUT lut_itinv; - - ap_uint<20> itinv = lut_itinv.lookup(abs(it_new)&4095); - - constexpr int izproj0 = zmean[projectionDisks[Seed][0]]; - constexpr int izproj1 = zmean[projectionDisks[Seed][1]]; - constexpr int izproj2 = zmean[projectionDisks[Seed][2]]; - constexpr int izproj3 = zmean[projectionDisks[Seed][3]]; - - const ap_int<14> zproj0 = izproj0; - const ap_int<14> zproj1 = izproj1; - const ap_int<14> zproj2 = izproj2; - const ap_int<14> zproj3 = izproj3; - - projToDisk(zproj0, itinv, irinv_new, iphi0_new, it_new, iz0_new, *rD_0_output, *phiD_0_output); - projToDisk(zproj1, itinv, irinv_new, iphi0_new, it_new, iz0_new, *rD_1_output, *phiD_1_output); - projToDisk(zproj2, itinv, irinv_new, iphi0_new, it_new, iz0_new, *rD_2_output, *phiD_2_output); - projToDisk(zproj3, itinv, irinv_new, iphi0_new, it_new, iz0_new, *rD_3_output, *phiD_3_output); - - *der_phiD_output = (-irinv_new*itinv) >> 17; - *der_rD_output = itinv >> 5; - - if (it_new < 0 ) { - *der_phiD_output = - *der_phiD_output; - *der_rD_output = - *der_rD_output; - } - - // - // wiring the outputs - // - *rinv_output = irinv_new; - *phi0_output = iphi0_new; - *t_output = it_new; - *z0_output = iz0_new; - - - -} diff --git a/TrackletAlgorithm/TrackletEngineUnit.h b/TrackletAlgorithm/TrackletEngineUnit.h index be8693309b7..446393e18f8 100644 --- a/TrackletAlgorithm/TrackletEngineUnit.h +++ b/TrackletAlgorithm/TrackletEngineUnit.h @@ -2,11 +2,11 @@ #define TRACKLETENGINEUNIT_H #include "Constants.h" -#include "VMStubTEOuterMemoryCM.h" +#include "VMStubMemory.h" #include "TrackletProcessor_parameters.h" #include "TrackletParameterMemory.h" -template +template class TrackletEngineUnit { public: @@ -20,7 +20,7 @@ class TrackletEngineUnit { kNBitsPTLutOuter=(Seed==TF::L5L6||Seed==TF::L1D1||Seed==TF::L2D1||Seed==TF::D1D2||Seed==TF::D3D4)?1024:(Seed==TF::L1L2||Seed==TF::L2L3)?256:512 }; - typedef ap_uint::kVMSTEOIDSize+AllStub::kAllStubSize+TrackletParameters::kTParPhiRegionSize+kNBits_MemAddr> STUBID; + typedef ap_uint::kVMSIDSize+AllStub::kAllStubSize+TrackletParameters::kTParPhiRegionSize+kNBits_MemAddr> STUBID; typedef ap_uint NEGDISK; typedef ap_uint NSTUBS; typedef ap_uint INDEX; @@ -178,7 +178,7 @@ void write(STUBID stubs) { ap_uint<1> next__, next___; PHIBIN ireg__, ireg___; - VMStubTEOuter outervmstub__, outervmstub___; + VMStub outervmstub__, outervmstub___; NSTUBS ns[16]; diff --git a/TrackletAlgorithm/TrackletProcessor.h b/TrackletAlgorithm/TrackletProcessor.h index 120a99f2174..1ee9317f3ff 100644 --- a/TrackletAlgorithm/TrackletProcessor.h +++ b/TrackletAlgorithm/TrackletProcessor.h @@ -8,7 +8,7 @@ #include "AllStubInnerMemory.h" #include "TrackletParameterMemory.h" #include "TrackletProjectionMemory.h" -#include "VMStubTEOuterMemoryCM.h" +#include "VMStubMemory.h" #include "TEBuffer.h" #include "TrackletEngineUnit.h" #include "TrackletProcessor_parameters.h" @@ -688,7 +688,7 @@ TF::seed Seed, // seed layer combination (TP::L1L2, TP::L3L4, etc.) uint16_t N // maximum number of steps > void TrackletProcessor( - const BXType bx, BXType& bx_o, const LUTTYPE lut[lutsize], const AllStubInnerMemory()> innerStubs[NASMemInner], const AllStubMemory()>* outerStubs, const VMStubTEOuterMemoryCM(),kNbitsrzbin,kNbitsphibin,NVMSTECopy>* outerVMStubs, TrackletParameterMemory * const trackletParameters, TrackletProjectionMemory projout_barrel_ps[TP::N_PROJOUT_BARRELPS], TrackletProjectionMemory projout_barrel_2s[TP::N_PROJOUT_BARREL2S], TrackletProjectionMemory projout_disk[TP::N_PROJOUT_DISK] + const BXType bx, BXType& bx_o, const LUTTYPE lut[lutsize], const AllStubInnerMemory()> innerStubs[NASMemInner], const AllStubMemory()>* outerStubs, const VMStubMemory(),kNbitsrzbin,kNbitsphibin,NVMSTECopy, true>* outerVMStubs, TrackletParameterMemory * const trackletParameters, TrackletProjectionMemory projout_barrel_ps[TP::N_PROJOUT_BARRELPS], TrackletProjectionMemory projout_barrel_2s[TP::N_PROJOUT_BARREL2S], TrackletProjectionMemory projout_disk[TP::N_PROJOUT_DISK] ) { constexpr bool diskSeed = (Seed == TF::D1D2 || Seed == TF::D3D4); @@ -728,7 +728,7 @@ TF::seed Seed, // seed layer combination (TP::L1L2, TP::L3L4, etc.) const ap_uint<1>* stubptinnertmp = TP::getPTInnerLUT(); static const TPRegionLUT regionLUT(stubptinnertmp, iAllstub); - constexpr unsigned int NfinephiBits=NBitsPhiRegion+TrackletEngineUnit()>::kNBitsPhiBins+VMStubTEOuterBase()>::kVMSTEOFinePhiSize; + constexpr unsigned int NfinephiBits=NBitsPhiRegion+TrackletEngineUnit()>::kNBitsPhiBins+VMStubBase(), true>::kVMSFinePhiSize; static TEBuffer()> tebuffer; static_assert(TP::nASMemInner() <= 3, "Only handling up to three inner AS memories"); @@ -801,7 +801,7 @@ TF::seed Seed, // seed layer combination (TP::L1L2, TP::L3L4, etc.) teureadindex[k] = 0; } //quantities looked up in LUT - typename VMStubTEOuter()>::VMSTEOFINEZ rzfinebinfirst,rzdiffmax; + typename VMStub(), true>::VMSFINEZ rzfinebinfirst,rzdiffmax; typename TrackletEngineUnit()>::RZBIN start; ap_uint<1> usenext; istep_loop: for(unsigned istep=0;istep()>::INDEX writeindexnext=teuwriteindex[k]+1; - const typename VMStubTEOuter()>::VMSTEOFINEPHI& finephi = teunits[k].outervmstub___.getFinePhi(); - const ap_uint<1+VMStubTEOuterBase()>::kVMSTEOFineZSize>& rzbin = (teunits[k].next___, teunits[k].outervmstub___.getFineZ()); + const typename VMStub(), true>::VMSFINEPHI& finephi = teunits[k].outervmstub___.getFinePhi(); + const ap_uint<1+VMStubBase(), true>::kVMSFineZSize>& rzbin = (teunits[k].next___, teunits[k].outervmstub___.getFineZ()); ap_uint outerfinephi = (iAllstub, teunits[k].ireg___, finephi); @@ -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 edd8c6216e2..d89b8012d18 100644 --- a/TrackletAlgorithm/VMRouterCM.h +++ b/TrackletAlgorithm/VMRouterCM.h @@ -17,8 +17,7 @@ #include "InputStubMemory.h" #include "AllStubMemory.h" #include "AllStubInnerMemory.h" -#include "VMStubMEMemoryCM.h" -#include "VMStubTEOuterMemoryCM.h" +#include "VMStubMemory.h" #ifndef __SYNTHESIS__ #ifdef CMSSW_GIT_HASH #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -156,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 @@ -186,9 +186,9 @@ void VMRouterCM(const BXType bx, BXType& bx_o, const ap_uint& maskASI, AllStubInnerMemory memoriesASInner[], // ME memories - VMStubMEMemoryCM *memoryME, + VMStubMemory *memoryME, // TE Outer memories - VMStubTEOuterMemoryCM memoriesTEO[]) { + VMStubMemory memoriesTEO[]) { #pragma HLS inline #pragma HLS array_partition variable=inputStubs complete dim=1 @@ -391,9 +391,9 @@ void VMRouterCM(const BXType bx, BXType& bx_o, int slotME; // The bin the stub is going to be put in, in the memory // Create the ME stub to save - VMStubMECM stubME = (disk2S) ? - createVMStub, DISK2S, OutType, Layer, Disk, true>(stubDisk2S, i, negDisk,METable, phiCorrTable, slotME) : - createVMStub, InType, OutType, Layer, Disk, true>(stub, i, negDisk, METable, phiCorrTable, slotME); + VMStub stubME = (disk2S) ? + createVMStub, DISK2S, OutType, Layer, Disk, true>(stubDisk2S, i, negDisk,METable, phiCorrTable, slotME) : + createVMStub, InType, OutType, Layer, Disk, true>(stub, i, negDisk, METable, phiCorrTable, slotME); // Write the ME stub memoryME->write_mem(bx, slotME, stubME, addrCountME[slotME]); @@ -412,9 +412,9 @@ void VMRouterCM(const BXType bx, BXType& bx_o, int slotTE; // The bin the stub is going to be put in, in the memory // Create the TE Outer stub to save - VMStubTEOuter stubTEO = (Layer) ? - createVMStub, InType, OutType, Layer, Disk, false>(stub, i, negDisk, METable, phiCorrTable, slotTE) : - createVMStub, InType, OutType, Layer, Disk, false>(stub, i, negDisk, TEDiskTable, phiCorrTable, slotTE); + VMStub stubTEO = (Layer) ? + createVMStub, InType, OutType, Layer, Disk, false>(stub, i, negDisk, METable, phiCorrTable, slotTE) : + createVMStub, InType, OutType, Layer, Disk, false>(stub, i, negDisk, TEDiskTable, phiCorrTable, slotTE); // Write stub to all TE memory copies for (int n = 0; n < nTEOCopies; n++) { diff --git a/TrackletAlgorithm/VMSMERouter.h b/TrackletAlgorithm/VMSMERouter.h index 46759c935c0..55d3be2f379 100644 --- a/TrackletAlgorithm/VMSMERouter.h +++ b/TrackletAlgorithm/VMSMERouter.h @@ -12,7 +12,7 @@ #include "Constants.h" #include "AllStubMemory.h" -#include "VMStubMEMemoryCM.h" +#include "VMStubMemory.h" #ifndef __SYNTHESIS__ #ifdef CMSSW_GIT_HASH #include "FWCore/MessageLogger/interface/MessageLogger.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 @@ -156,7 +157,7 @@ void VMSMERouter(const BXType bx, BXType& bx_o, const int phiCorrTable[], // Input memories AllStub& allStub, - VMStubMEMemoryCM *memoryME, + VMStubMemory *memoryME, AllStubMemory& memoriesAS, // Array to count how many VMStubs written in each slot unsigned int index, @@ -203,10 +204,10 @@ void VMSMERouter(const BXType bx, BXType& bx_o, // Create the ME stub to save if (valid) { - VMStubMECM stubME = (disk2S) ? - createVMStubME, DISK2S, Layer, Disk>(stub_2s, index, negDisk, METable, phiCorrTable, slotME) : (isDisk) ? - createVMStubME, DISKPS, Layer, Disk>(stub_ps, index, negDisk, METable, phiCorrTable, slotME) : - createVMStubME, InType, Layer, Disk>(allStub, index, negDisk, METable, phiCorrTable, slotME); + VMStub stubME = (disk2S) ? + createVMStubME, DISK2S, Layer, Disk>(stub_2s, index, negDisk, METable, phiCorrTable, slotME) : (isDisk) ? + createVMStubME, DISKPS, Layer, Disk>(stub_ps, index, negDisk, METable, phiCorrTable, slotME) : + createVMStubME, InType, Layer, Disk>(allStub, index, negDisk, METable, phiCorrTable, slotME); // Write the ME stub memoryME->write_mem(bx, slotME, stubME, 0); diff --git a/TrackletAlgorithm/VMStubMEMemoryCM.h b/TrackletAlgorithm/VMStubMEMemoryCM.h deleted file mode 100644 index d65b4d11009..00000000000 --- a/TrackletAlgorithm/VMStubMEMemoryCM.h +++ /dev/null @@ -1,165 +0,0 @@ -#ifndef TrackletAlgorithm_VMStubMEMemoryCM_h -#define TrackletAlgorithm_VMStubMEMemoryCM_h - -#include "Constants.h" -#include "MemoryTemplateBinnedCM.h" -#include "globalFunctions.h" - -// Memory containing stub data written by the VMRouter, consisting of coarse -// stub data + a pointer to the full precision stub data in the AllStubMemory. - -// VMStubMECMBase is where we define the bit widths, which depend on the class template parameter. -template class VMStubMECMBase {}; - -template<> -class VMStubMECMBase -{ -public: - enum BitWidths { - // Bit sizes for VMStubMEMemoryCM fields - kVMSMEFineZSize = 3, - kVMSMEFinePhiSize = 3, - kVMSMEBendSize = 3, - kVMSMEIDSize = 7, - // Bit size for full VMStubMEMemoryCM - kVMStubMECMSize = kVMSMEFineZSize + kVMSMEFinePhiSize + kVMSMEBendSize + kVMSMEIDSize - }; -}; - -template<> -class VMStubMECMBase -{ -public: - enum BitWidths { - // Bit sizes for VMStubMEMemoryCM fields - kVMSMEFineZSize = 3, - kVMSMEFinePhiSize = 3, - kVMSMEBendSize = 4, - kVMSMEIDSize = 7, - // Bit size for full VMStubMEMemoryCM - kVMStubMECMSize = kVMSMEFineZSize + kVMSMEFinePhiSize + kVMSMEBendSize + kVMSMEIDSize - }; -}; - -template<> -class VMStubMECMBase -{ -public: - enum BitWidths { - // Bit sizes for VMStubMEMemoryCM fields - kVMSMEFineZSize = 3, - kVMSMEFinePhiSize = 3, - kVMSMEBendSize = 4, - kVMSMEIDSize = 7, - // Bit size for full VMStubMEMemoryCM - kVMStubMECMSize = kVMSMEFineZSize + kVMSMEFinePhiSize + kVMSMEBendSize + kVMSMEIDSize - }; -}; - -// Data object definition -template -class VMStubMECM : public VMStubMECMBase -{ -public: - enum BitLocations { - // The location of the least significant bit (LSB) and most significant bit (MSB) in the VMStubMEMemoryCM word for different fields - kVMSMEFineZLSB = 0, - kVMSMEFineZMSB = kVMSMEFineZLSB + VMStubMECMBase::kVMSMEFineZSize - 1, - kVMSMEFinePhiLSB = kVMSMEFineZMSB + 1, - kVMSMEFinePhiMSB = kVMSMEFinePhiLSB + VMStubMECMBase::kVMSMEFinePhiSize - 1, - kVMSMEBendLSB = kVMSMEFinePhiMSB + 1, - kVMSMEBendMSB = kVMSMEBendLSB + VMStubMECMBase::kVMSMEBendSize - 1, - kVMSMEIDLSB = kVMSMEBendMSB + 1, - kVMSMEIDMSB = kVMSMEIDLSB + VMStubMECMBase::kVMSMEIDSize - 1 - }; - - typedef ap_uint::kVMSMEIDSize> VMSMEID; - typedef ap_uint::kVMSMEBendSize> VMSMEBEND; - typedef ap_uint::kVMSMEBendSize - 1> VMSMEBENDPSDISK; - typedef ap_uint::kVMSMEFineZSize> VMSMEFINEZ; - typedef ap_uint::kVMSMEFinePhiSize> VMSMEFINEPHI; - - typedef ap_uint::kVMStubMECMSize> VMStubMECMData; - - // Constructors - VMStubMECM(const VMStubMECMData& newdata): - data_(newdata) - {} - - VMStubMECM(const VMSMEID id, const VMSMEBEND bend, const VMSMEFINEPHI finephi, const VMSMEFINEZ finez): - data_( (id, bend,finephi, finez) ) - {} - - VMStubMECM() - {} - - #ifndef __SYNTHESIS__ - VMStubMECM(const char* datastr, int base=16) - { - VMStubMECMData newdata(datastr, base); - data_ = newdata; - } - #endif - - // Getter - static constexpr int getWidth() {return VMStubMECMBase::kVMStubMECMSize;} - - VMStubMECMData raw() const {return data_;} - - VMSMEID getIndex() const { - return data_.range(kVMSMEIDMSB,kVMSMEIDLSB); - } - - VMSMEBEND getBend() const { - return data_.range(kVMSMEBendMSB,kVMSMEBendLSB); - } - - VMSMEBENDPSDISK getBendPSDisk() const { - return data_.range(kVMSMEBendMSB - 1,kVMSMEBendLSB); - } - - VMSMEFINEPHI getFinePhi() const { - return data_.range(kVMSMEFinePhiMSB, kVMSMEFinePhiLSB); - } - - VMSMEFINEZ getFineZ() const { - return data_.range(kVMSMEFineZMSB,kVMSMEFineZLSB); - } - - // Setter - void setIndex(const VMSMEID id) { - data_.range(kVMSMEIDMSB,kVMSMEIDLSB) = id; - } - - void setBend(const VMSMEBEND bend) { - data_.range(kVMSMEBendMSB,kVMSMEBendLSB) = bend; - } - - void setFinePhi(const VMSMEFINEPHI finephi) { - data_.range(kVMSMEFinePhiMSB,kVMSMEFinePhiLSB) = finephi; - } - - void setFineZ(const VMSMEFINEZ finez) { - data_.range(kVMSMEFineZMSB,kVMSMEFineZLSB) = finez; - } - -#ifdef CMSSW_GIT_HASH - std::string getBitStr() const { - std::string str = decodeToBits(getIndex()); - str += "|"+decodeToBits(getBend()); - str += "|"+decodeToBits(getFinePhi()); - str += "|"+decodeToBits(getFineZ()); - return str; - } -#endif - -private: - - VMStubMECMData data_; - -}; - -// Memory definition -template using VMStubMEMemoryCM = MemoryTemplateBinnedCM, 1, 4+RZSize+PhiRegSize, RZSize+PhiRegSize, PhiRegSize, NCOPY>; - -#endif diff --git a/TrackletAlgorithm/VMStubMemory.h b/TrackletAlgorithm/VMStubMemory.h new file mode 100644 index 00000000000..4d1a1c1e763 --- /dev/null +++ b/TrackletAlgorithm/VMStubMemory.h @@ -0,0 +1,165 @@ +#ifndef TrackletAlgorithm_VMStubMemory_h +#define TrackletAlgorithm_VMStubMemory_h + +#include "Constants.h" +#include "MemoryTemplateBinnedCM.h" +#include "globalFunctions.h" + +// Memory containing stub data written by the VMRouter, consisting of coarse +// stub data + a pointer to the full precision stub data in the AllStubMemory. + +// VMStubBase is where we define the bit widths, which depend on the class template parameter. +template class VMStubBase {}; + +template +class VMStubBase +{ +public: + enum BitWidths { + // Bit sizes for VMStubMemory fields + kVMSFineZSize = 3, + kVMSFinePhiSize = 3, + kVMSBendSize = 3, + kVMSIDSize = 7, + // Bit size for full VMStubMemory + kVMStubSize = kVMSFineZSize + kVMSFinePhiSize + kVMSBendSize + kVMSIDSize + }; +}; + +template +class VMStubBase +{ +public: + enum BitWidths { + // Bit sizes for VMStubMemory fields + kVMSFineZSize = 3, + kVMSFinePhiSize = 3, + kVMSBendSize = 4, + kVMSIDSize = 7, + // Bit size for full VMStubMemory + kVMStubSize = kVMSFineZSize + kVMSFinePhiSize + kVMSBendSize + kVMSIDSize + }; +}; + +template +class VMStubBase +{ +public: + enum BitWidths { + // Bit sizes for VMStubMemory fields + kVMSFineZSize = 3, + kVMSFinePhiSize = 3, + kVMSBendSize = TE ? 3 : 4, + kVMSIDSize = 7, + // Bit size for full VMStubMemory + kVMStubSize = kVMSFineZSize + kVMSFinePhiSize + kVMSBendSize + kVMSIDSize + }; +}; + +// Data object definition +template +class VMStub : public VMStubBase +{ +public: + enum BitLocations { + // The location of the least significant bit (LSB) and most significant bit (MSB) in the VMStubMemory word for different fields + kVMSFineZLSB = 0, + kVMSFineZMSB = kVMSFineZLSB + VMStubBase::kVMSFineZSize - 1, + kVMSFinePhiLSB = kVMSFineZMSB + 1, + kVMSFinePhiMSB = kVMSFinePhiLSB + VMStubBase::kVMSFinePhiSize - 1, + kVMSBendLSB = kVMSFinePhiMSB + 1, + kVMSBendMSB = kVMSBendLSB + VMStubBase::kVMSBendSize - 1, + kVMSIDLSB = kVMSBendMSB + 1, + kVMSIDMSB = kVMSIDLSB + VMStubBase::kVMSIDSize - 1 + }; + + typedef ap_uint::kVMSIDSize> VMSID; + typedef ap_uint::kVMSBendSize> VMSBEND; + typedef ap_uint::kVMSBendSize - 1> VMSBENDPSDISK; + typedef ap_uint::kVMSFineZSize> VMSFINEZ; + typedef ap_uint::kVMSFinePhiSize> VMSFINEPHI; + + typedef ap_uint::kVMStubSize> VMStubData; + + // Constructors + VMStub(const VMStubData& newdata): + data_(newdata) + {} + + VMStub(const VMSID id, const VMSBEND bend, const VMSFINEPHI finephi, const VMSFINEZ finez): + data_( (id, bend,finephi, finez) ) + {} + + VMStub() + {} + + #ifndef __SYNTHESIS__ + VMStub(const char* datastr, int base=16) + { + VMStubData newdata(datastr, base); + data_ = newdata; + } + #endif + + // Getter + static constexpr int getWidth() {return VMStubBase::kVMStubSize;} + + VMStubData raw() const {return data_;} + + VMSID getIndex() const { + return data_.range(kVMSIDMSB,kVMSIDLSB); + } + + VMSBEND getBend() const { + return data_.range(kVMSBendMSB,kVMSBendLSB); + } + + VMSBENDPSDISK getBendPSDisk() const { + return data_.range(kVMSBendMSB - 1,kVMSBendLSB); + } + + VMSFINEPHI getFinePhi() const { + return data_.range(kVMSFinePhiMSB, kVMSFinePhiLSB); + } + + VMSFINEZ getFineZ() const { + return data_.range(kVMSFineZMSB,kVMSFineZLSB); + } + + // Setter + void setIndex(const VMSID id) { + data_.range(kVMSIDMSB,kVMSIDLSB) = id; + } + + void setBend(const VMSBEND bend) { + data_.range(kVMSBendMSB,kVMSBendLSB) = bend; + } + + void setFinePhi(const VMSFINEPHI finephi) { + data_.range(kVMSFinePhiMSB,kVMSFinePhiLSB) = finephi; + } + + void setFineZ(const VMSFINEZ finez) { + data_.range(kVMSFineZMSB,kVMSFineZLSB) = finez; + } + +#ifdef CMSSW_GIT_HASH + std::string getBitStr() const { + std::string str = decodeToBits(getIndex()); + str += "|"+decodeToBits(getBend()); + str += "|"+decodeToBits(getFinePhi()); + str += "|"+decodeToBits(getFineZ()); + return str; + } +#endif + +private: + + VMStubData data_; + +}; + +// Memory definition +template using VMStubMemory = MemoryTemplateBinnedCM, 1, 4+RZSize+PhiRegSize, RZSize+PhiRegSize, PhiRegSize, NCOPY>; + +#endif diff --git a/TrackletAlgorithm/VMStubTEOuterMemoryCM.h b/TrackletAlgorithm/VMStubTEOuterMemoryCM.h deleted file mode 100644 index df2c4cfd659..00000000000 --- a/TrackletAlgorithm/VMStubTEOuterMemoryCM.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef TrackletAlgorithm_VMStubTEOuterMemory_h -#define TrackletAlgorithm_VMStubTEOuterMemory_h - -#include "Constants.h" -#include "MemoryTemplateBinnedCM.h" -#include "globalFunctions.h" - -// VMStubTEOuterBase is where we define the bit widths, which depend on the class template parameter. -template class VMStubTEOuterBase {}; - -template<> -class VMStubTEOuterBase -{ -public: - enum BitWidths { - // Bit sizes for VMStubTEOuterMemory fields - kVMSTEOFineZSize = 3, - kVMSTEOFinePhiSize = 3, - kVMSTEOBendSize = 3, - kVMSTEOIDSize = 7, - // Bit size for full VMStubTEOuterMemory - kVMStubTEOuterSize = kVMSTEOFineZSize + kVMSTEOFinePhiSize + kVMSTEOBendSize + kVMSTEOIDSize - }; -}; - -template<> -class VMStubTEOuterBase -{ -public: - enum BitWidths { - // Bit sizes for VMStubTEOuterMemory fields - kVMSTEOFineZSize = 3, - kVMSTEOFinePhiSize = 3, - kVMSTEOBendSize = 4, - kVMSTEOIDSize = 7, - // Bit size for full VMStubTEOuterMemory - kVMStubTEOuterSize = kVMSTEOFineZSize + kVMSTEOFinePhiSize + kVMSTEOBendSize + kVMSTEOIDSize - }; -}; - -template<> -class VMStubTEOuterBase -{ -public: - enum BitWidths { - // Bit sizes for VMStubTEOuterMemory fields - kVMSTEOFineZSize = 3, - kVMSTEOFinePhiSize = 3, - kVMSTEOBendSize = 3, - kVMSTEOIDSize = 7, - // Bit size for full VMStubTEOuterMemory - kVMStubTEOuterSize = kVMSTEOFineZSize + kVMSTEOFinePhiSize + kVMSTEOBendSize + kVMSTEOIDSize - }; -}; - -// Data object definition -template -class VMStubTEOuter : public VMStubTEOuterBase -{ -public: - enum BitLocations { - // The location of the least significant bit (LSB) and most significant bit (MSB) in the VMStubTEOuterMemory word for different fields - kVMSTEOFineZLSB = 0, - kVMSTEOFineZMSB = kVMSTEOFineZLSB + VMStubTEOuterBase::kVMSTEOFineZSize - 1, - kVMSTEOFinePhiLSB = kVMSTEOFineZMSB + 1, - kVMSTEOFinePhiMSB = kVMSTEOFinePhiLSB + VMStubTEOuterBase::kVMSTEOFinePhiSize - 1, - kVMSTEOBendLSB = kVMSTEOFinePhiMSB + 1, - kVMSTEOBendMSB = kVMSTEOBendLSB + VMStubTEOuterBase::kVMSTEOBendSize - 1, - kVMSTEOIDLSB = kVMSTEOBendMSB + 1, - kVMSTEOIDMSB = kVMSTEOIDLSB + VMStubTEOuterBase::kVMSTEOIDSize - 1 - }; - - typedef ap_uint::kVMSTEOIDSize> VMSTEOID; - typedef ap_uint::kVMSTEOBendSize> VMSTEOBEND; - typedef ap_uint::kVMSTEOFinePhiSize> VMSTEOFINEPHI; - typedef ap_uint::kVMSTEOFineZSize> VMSTEOFINEZ; - - typedef ap_uint::kVMStubTEOuterSize> VMStubTEOuterData; - - // Constructors - VMStubTEOuter(const VMStubTEOuterData& newdata): - data_(newdata) - {} - - VMStubTEOuter(const VMSTEOID id, const VMSTEOBEND bend, const VMSTEOFINEPHI finephi, const VMSTEOFINEZ finez): - data_( (((id,bend),finephi),finez) ) - {} - - VMStubTEOuter() - {} - - #ifndef __SYNTHESIS__ - VMStubTEOuter(const char* datastr, int base=16) - { - VMStubTEOuterData newdata(datastr, base); - data_ = newdata; - } - #endif - - // Getter - static constexpr int getWidth() {return VMStubTEOuterBase::kVMStubTEOuterSize;} - - VMStubTEOuterData raw() const {return data_;} - - VMSTEOID getIndex() const { - return data_.range(kVMSTEOIDMSB,kVMSTEOIDLSB); - } - - VMSTEOBEND getBend() const { - return data_.range(kVMSTEOBendMSB,kVMSTEOBendLSB); - } - - VMSTEOFINEPHI getFinePhi() const { - return data_.range(kVMSTEOFinePhiMSB,kVMSTEOFinePhiLSB); - } - - VMSTEOFINEZ getFineZ() const { - return data_.range(kVMSTEOFineZMSB,kVMSTEOFineZLSB); - } - - // Setter - void setIndex(const VMSTEOID id) { - data_.range(kVMSTEOIDMSB,kVMSTEOIDLSB) = id; - } - - void setBend(const VMSTEOBEND bend) { - data_.range(kVMSTEOBendMSB,kVMSTEOBendLSB) = bend; - } - - void setFinePhi(const VMSTEOFINEPHI finephi) { - data_.range(kVMSTEOFinePhiMSB,kVMSTEOFinePhiLSB) = finephi; - } - - void setFineZ(const VMSTEOFINEZ finez) { - data_.range(kVMSTEOFineZMSB,kVMSTEOFineZLSB) = finez; - } - -#ifdef CMSSW_GIT_HASH - std::string getBitStr() const { - std::string str = decodeToBits(getIndex()); - str += "|"+decodeToBits(getBend()); - str += "|"+decodeToBits(getFinePhi()); - str += "|"+decodeToBits(getFineZ()); - return str; - } -#endif - -private: - - VMStubTEOuterData data_; - -}; - -// Memory definition -template using VMStubTEOuterMemoryCM = MemoryTemplateBinnedCM, 1, 4+RZSize+PhiRegSize, RZSize+PhiRegSize, PhiRegSize, NCOPY>; - -#endif diff --git a/emData/download.sh b/emData/download.sh index 865d9e55027..fa91268ddd4 100755 --- a/emData/download.sh +++ b/emData/download.sh @@ -1,14 +1,13 @@ #!/usr/bin/env bash set -e - #### generated with branch VMSMERouterCMSSW13, commit a2c799d #### # Combined modules memprints_url_cm="https://cernbox.cern.ch/remote.php/dav/public-files/P2URd03nlGDfpDt/MemPrints.tar.gz" luts_url_cm="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_Combined_231208.tgz" # Split modules - i.e. with PC and VMSMER -memprints_url_split="https://ahart.web.cern.ch/ahart/tf/test_vectors/MemPrints_Split_240607.tgz" -luts_url_split="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_Split_240607.tgz" +memprints_url_split="https://cernbox.cern.ch/remote.php/dav/public-files/MUMRM6yWEBSDWiQ/MemPrints_Split_241116.tgz" +luts_url_split="https://cernbox.cern.ch/remote.php/dav/public-files/lKAs7GNBTXKfR9d/LUTs_Split_241116.tgz" # Reduced Combined modules memprints_url_reducedcm="https://cernbox.cern.ch/remote.php/dav/public-files/kv2U49bw93chvZG/MemPrints_CMReduced_040424.tar.gz" luts_url_reducedcm="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_CMReduced_240121.tgz" @@ -19,6 +18,7 @@ luts_url_cm2="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_CMReduced2_24 memprints_url_cmbarrel="https://cernbox.cern.ch/remote.php/dav/public-files/lVII5Ho0VX7nwFA/MemPrints_Barrel_040424.tar.gz" luts_url_cmbarrel="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_Barrel_240121.tgz" + # Function that prints information regarding the usage of this command function usage() { echo "$(basename $0) [-h|--help] [-t|--tables]" @@ -67,6 +67,7 @@ fi # Download and unpack LUTs.tar.gz, # unless LUTS directory already exists (due to previous "download.sh -t" run). + if [ ! -d "LUTs" ] then wget --no-check-certificate -O LUTs.tgz --quiet ${luts_url_split} @@ -91,6 +92,7 @@ then rm -f LUTs.tgz fi + # Run scripts to generate top functions in TopFunctions/ ### combined config mkdir -p ../TopFunctions/CombinedConfig diff --git a/emData/generate_MP.py b/emData/generate_MP.py index 1648ff3a82b..6f940f8ba4d 100755 --- a/emData/generate_MP.py +++ b/emData/generate_MP.py @@ -199,7 +199,7 @@ def FMRegion(region): "void MatchProcessor_" + seed + "PHI" + iMP + "(\n" " const BXType bx,\n" " const TrackletProjectionMemory<" + TProjRegion + "> projin[" + seed + "PHI" + iMP + "maxTrackletProjections],\n" - " const VMStubMEMemoryCM<" + VMStubMERegion(seed) + ", " + nrz + ", kNbitsphibin, kNMatchEngines>& instubdata,\n" + " const VMStubMemory<" + VMStubMERegion(seed) + ", " + nrz + ", kNbitsphibin, kNMatchEngines>& instubdata,\n" " const AllStubMemory<" + ASRegion(seed) + ">* allstub,\n" " BXType& bx_o,\n" " FullMatchMemory<" + FMRegion(seed) + "> fullmatch[" + seed + "PHI" + iMP + "maxFullMatchCopies]\n" @@ -212,7 +212,7 @@ def FMRegion(region): "void MatchProcessor_" + seed + "PHI" + iMP + "(\n" " const BXType bx,\n" " const TrackletProjectionMemory<" + TProjRegion + "> projin[" + seed + "PHI" + iMP + "maxTrackletProjections],\n" - " const VMStubMEMemoryCM<" + VMStubMERegion(seed) + ", " + nrz + ", kNbitsphibin, kNMatchEngines>& instubdata,\n" + " const VMStubMemory<" + VMStubMERegion(seed) + ", " + nrz + ", kNbitsphibin, kNMatchEngines>& instubdata,\n" " const AllStubMemory<" + ASRegion(seed) + ">* allstub,\n" " BXType& bx_o,\n" " FullMatchMemory<" + FMRegion(seed) + "> fullmatch[" + seed + "PHI" + iMP + "maxFullMatchCopies]\n" diff --git a/emData/generate_TP.py b/emData/generate_TP.py index 8539fa60efb..9f1e730e03e 100755 --- a/emData/generate_TP.py +++ b/emData/generate_TP.py @@ -300,7 +300,7 @@ class ProjoutIndexDisk(Enum): " BXType& bx_o,\n" " const AllStubInnerMemory()> innerStubs[TP::nASMemInner()],\n" " const AllStubMemory()>* outerStubs,\n" - " const VMStubTEOuterMemoryCM(), kNbitsrzbin, kNbitsphibin, kNTEUnitsLayerDisk[TF::"+seed[2:]+"]>* outerVMStubs,\n" + " const VMStubMemory(), kNbitsrzbin, kNbitsphibin, kNTEUnitsLayerDisk[TF::"+seed[2:]+"], true>* outerVMStubs,\n" " TrackletParameterMemory * trackletParameters,\n" " TrackletProjectionMemory projout_barrel_ps[],\n" " TrackletProjectionMemory projout_barrel_2s[],\n" @@ -316,7 +316,7 @@ class ProjoutIndexDisk(Enum): " BXType& bx_o,\n" " const AllStubInnerMemory()> innerStubs[TP::nASMemInner()],\n" " const AllStubMemory()>* outerStubs ,\n" - " const VMStubTEOuterMemoryCM(), kNbitsrzbin, kNbitsphibin, kNTEUnitsLayerDisk[TF::"+ seed[2:] +"]>* outerVMStubs,\n" + " const VMStubMemory(), kNbitsrzbin, kNbitsphibin, kNTEUnitsLayerDisk[TF::"+ seed[2:] +"], true>* outerVMStubs,\n" " TrackletParameterMemory * trackletParameters,\n" " TrackletProjectionMemory projout_barrel_ps[TP::N_PROJOUT_BARRELPS],\n" " TrackletProjectionMemory projout_barrel_2s[TP::N_PROJOUT_BARREL2S],\n" diff --git a/emData/generate_VMRCM.py b/emData/generate_VMRCM.py index 326bf09e237..60068197071 100755 --- a/emData/generate_VMRCM.py +++ b/emData/generate_VMRCM.py @@ -380,8 +380,8 @@ def writeTopHeader(vmr, output_dir): " // Output memories\n" " AllStubMemory memoriesAS[numASCopies],\n" + (" AllStubInnerMemory memoriesASInner[numASInnerCopies],\n" if has_allstub_inner[layerdisk] else "") +\ - " VMStubMEMemoryCM *memoryME" + (",\n" if has_vmste_outer[layerdisk] else "") - + (" VMStubTEOuterMemoryCM memoriesTEO[numTEOCopies]\n" if has_vmste_outer[layerdisk] else "") +\ + " VMStubMemory *memoryME" + (",\n" if has_vmste_outer[layerdisk] else "") + + (" VMStubMemory memoriesTEO[numTEOCopies]\n" if has_vmste_outer[layerdisk] else "") +\ " );\n" "\n" "#endif // TopFunctions_%s_h\n" % file_name @@ -417,8 +417,8 @@ def writeTopFile(vmr, num_inputs, num_inputs_disk2s, output_dir): " // Output memories\n" " AllStubMemory memoriesAS[numASCopies],\n" + (" AllStubInnerMemory memoriesASInner[numASInnerCopies],\n" if has_allstub_inner[layerdisk] else "") +\ - " VMStubMEMemoryCM *memoryME" + (",\n" if has_vmste_outer[layerdisk] else "") - + (" VMStubTEOuterMemoryCM memoriesTEO[numTEOCopies]\n" if has_vmste_outer[layerdisk] else "") +\ + " VMStubMemory *memoryME" + (",\n" if has_vmste_outer[layerdisk] else "") + + (" VMStubMemory memoriesTEO[numTEOCopies]\n" if has_vmste_outer[layerdisk] else "") +\ " ) {\n" "\n" "// Takes 2 clock cycles before one gets data, used at high frequencies\n" diff --git a/emData/generate_VMSMER.py b/emData/generate_VMSMER.py index c061be151e5..d40b3af54fd 100755 --- a/emData/generate_VMSMER.py +++ b/emData/generate_VMSMER.py @@ -90,7 +90,7 @@ def writeTopHeader(vmr, output_dir): " // Input memories\n" " AllStub& allStub,\n" " // Output memories\n" - " VMStubMEMemoryCM *memoryME,\n" + " VMStubMemory *memoryME,\n" " AllStubMemory& memoriesAS,\n" " // Index of AllStub\n" " unsigned int index,\n" @@ -130,7 +130,7 @@ def writeTopFile(vmr, output_dir): " // Input memories\n" " AllStub& allStub,\n" " // Output memories\n" - " VMStubMEMemoryCM *memoryME,\n" + " VMStubMemory *memoryME,\n" " AllStubMemory& memoriesAS,\n" " // Index of AllStub\n" " unsigned int index,\n" diff --git a/emData/project_generation_scripts b/emData/project_generation_scripts index 0706ea88797..91256ad3c11 160000 --- a/emData/project_generation_scripts +++ b/emData/project_generation_scripts @@ -1 +1 @@ -Subproject commit 0706ea88797cc1f2c2493a2bf528c973a67408b5 +Subproject commit 91256ad3c11e5322fa019a484a4f7781756db9fe diff --git a/project/script_MP.tcl b/project/script_MP.tcl index e241e101f30..8536b95bf81 100644 --- a/project/script_MP.tcl +++ b/project/script_MP.tcl @@ -7,25 +7,30 @@ source env_hls.tcl set modules_to_test { + {MP_L1PHIB} + {MP_L2PHIB} + {MP_L3PHIB} + {MP_L4PHIB} + {MP_L5PHIB} + {MP_L6PHIB} + {MP_D1PHIB} + {MP_D2PHIB} + {MP_D3PHIB} + {MP_D4PHIB} + {MP_D5PHIB} {MP_L1PHIC} {MP_L2PHIC} + {MP_L3PHIC} {MP_L4PHIC} + {MP_L5PHIC} {MP_L6PHIC} {MP_D1PHIC} + {MP_D2PHIC} + {MP_D3PHIC} {MP_D4PHIC} {MP_D5PHIC} } -# Skipping L3 because of inconsistency in L3 -# {MP_L3PHIC} -# Skipping these because of diagreement due to truncation with the extra -# pipelining step before the match calculator. Will undo once the emulation -# is upddated -# {MP_L5PHIC} -# {MP_D2PHIC} -# {MP_D3PHIC} - - # module_to_export must correspond to the default macros set at the top of the # test bench; otherwise, the C/RTL cosimulation will fail set module_to_export MP_D1PHIC diff --git a/project/script_TB.tcl b/project/script_TB.tcl index eca29515868..ff7064ea036 100644 --- a/project/script_TB.tcl +++ b/project/script_TB.tcl @@ -13,6 +13,7 @@ set modules_to_test { {FT_L2L3} {FT_L3L4} {FT_L5L6} + {FT_D1D2} {FT_D3D4} {FT_L1D1} {FT_L2D1}