diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 60f77c875d3..082d3474223 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,8 +66,8 @@ stages: # --------------------------------------------------------------------- - cd IntegrationTests/${PROJ_NAME}/script - pwd; ls -la; #debug - vivado_hls -f ./compileHLS.tcl - - vivado -mode batch -source ./makeProject.tcl - - vivado -mode batch -source ./runSim.tcl + - vivado -mode batch -source ./makeProject.tcl | awk 'BEGIN{IGNORECASE=1} /^error/ {exit_code=1;} // {print $0;} END{exit exit_code}' + - vivado -mode batch -source ./runSim.tcl | awk 'BEGIN{IGNORECASE=1} /^error/ {exit_code=1;} // {print $0;} END{exit exit_code}' artifacts: when: on_success name: "$CI_JOB_NAME-$CI_JOB_STAGE-$CI_COMMIT_REF_NAME" @@ -95,7 +95,7 @@ stages: # --------------------------------------------------------------------- script: - cd IntegrationTests/${PROJ_NAME}/script - pwd; ls -la; #debug - - vivado -mode batch -source common/script/synth.tcl + - vivado -mode batch -source common/script/synth.tcl | awk 'BEGIN{IGNORECASE=1} /^error/ {exit_code=1;} // {print $0;} END{exit exit_code}' artifacts: when: on_success name: "$CI_JOB_NAME-$CI_JOB_STAGE-$CI_COMMIT_REF_NAME" @@ -262,7 +262,6 @@ MC-vivado-hls-build: PROJ_NAME: "MC" MP-vivado-hls-build: <<: *template_hls-build - allow_failure: true needs: ["download", "MP-quality-check"] variables: EXECUTABLE: 'vivado_hls' @@ -357,7 +356,6 @@ topPRMEMC-check-results: - topPRMEMC-sim topTETC-check-results: <<: *template_check-results - allow_failure: true # FIXME: remove after all errors are fixed variables: VIVADO_VERSION: "2019.2" # Vivado not needed but it is part of the path that is called PROJ_NAME: "TETC" @@ -366,7 +364,6 @@ topTETC-check-results: - topTETC-sim topIRVMR-check-results: <<: *template_check-results - allow_failure: true # FIXME: remove after all errors are fixed variables: VIVADO_VERSION: "2019.2" # Vivado not needed but it is part of the path that is called PROJ_NAME: "IRVMR" diff --git a/IntegrationTests/common/hdl/FileReader.vhd b/IntegrationTests/common/hdl/FileReader.vhd index d31c5af35ed..b57d85dff89 100644 --- a/IntegrationTests/common/hdl/FileReader.vhd +++ b/IntegrationTests/common/hdl/FileReader.vhd @@ -159,10 +159,16 @@ begin if (NUM_BINS > 1) then -- Get memory bin - read(LINE_IN, CHAR); + read(LINE_IN, CHAR); -- 0 + read(LINE_IN, CHAR); -- x + read(LINE_IN, CHAR); -- 0 + read(LINE_IN, CHAR); -- digit char2int(CHAR, MEM_BIN); - read(LINE_IN, CHAR); - read(LINE_IN, CHAR); + read(LINE_IN, CHAR); -- space + read(LINE_IN, CHAR); -- 0 + read(LINE_IN, CHAR); -- x + read(LINE_IN, CHAR); -- 0 + read(LINE_IN, CHAR); -- digit char2int(CHAR, POS_IN_MEM_BIN); end if; @@ -171,7 +177,6 @@ begin if (CHAR = 'x') then -- ... until the next x CNT_X_CHAR := CNT_X_CHAR + 1; if ((NUM_BINS > 1 and CNT_X_CHAR = NUM_X_CHAR_BINNED) or - (NUM_BINS = 1 and CNT_X_CHAR = 1 and RAM_WIDTH = 36 and NUM_PAGES = 2) or -- Bodge for IL as they are unbinned but only contain one 'x' (NUM_BINS = 1 and CNT_X_CHAR = NUM_X_CHAR_UNBINNED)) then -- No. of 'x' chars reached -- Found data word. FOUND_WORD := true; diff --git a/IntegrationTests/common/hdl/FileReaderFIFO.vhd b/IntegrationTests/common/hdl/FileReaderFIFO.vhd index a716dac6da4..d449d9b6306 100644 --- a/IntegrationTests/common/hdl/FileReaderFIFO.vhd +++ b/IntegrationTests/common/hdl/FileReaderFIFO.vhd @@ -53,12 +53,16 @@ procFile : process(CLK) variable LINE_IN : line; variable BX_CNT : integer := -1; --! Event counter variable DATA_CNT : natural := MAX_ENTRIES; --! Current count of data from within current page. + constant NUM_X_CHAR : natural := 2; --! Count of 'x' characters in line, before value to read + variable CNT_X_CHAR : natural := 0; --! Current count of 'x' characters variable CHAR : character; --! Character variable FOUND_WORD : boolean := false; variable emDATA : std_logic_vector(EMDATA_WIDTH-1 downto 0) := (others => '0'); variable LOOPING : boolean := true; --! Need another loop to make output. variable CREATE_DUMMY_DATA : boolean := false; --! Inventing null data. variable line_is_read : boolean := true; -- LINE_IN has been read by external module + + begin if rising_edge(CLK) then @@ -147,13 +151,17 @@ begin FOUND_WORD := false; EMPTY_NEG <= '1'; -- There is stub to be read + CNT_X_CHAR := 0; -- Reset 'x' character counter rd_col : while (LINE_IN'length > 0) loop -- Loop over the columns read(LINE_IN, CHAR); -- Read chars ... if (CHAR = 'x') then -- ... until the x - -- Found data word. - FOUND_WORD := true; - hread(line_in, emDATA(LINE_IN'length*4-1 downto 0)); -- Read remainer of line as hex. + CNT_X_CHAR := CNT_X_CHAR + 1; + if (CNT_X_CHAR = NUM_X_CHAR) then + -- Found data word. + FOUND_WORD := true; + hread(line_in, emDATA(LINE_IN'length*4-1 downto 0)); -- Read remainer of line as hex. + end if; end if; end loop rd_col; diff --git a/IntegrationTests/common/script/CompareMemPrintsFW.py b/IntegrationTests/common/script/CompareMemPrintsFW.py index 427c3487f54..7f74b55638e 100644 --- a/IntegrationTests/common/script/CompareMemPrintsFW.py +++ b/IntegrationTests/common/script/CompareMemPrintsFW.py @@ -196,6 +196,7 @@ def compare(comparison_filename="", fail_on_error=False, file_location='./', pre if is_binned: bin, data = val + bin = bin.replace("0x","") else: data = val diff --git a/README.md b/README.md index 42761c2d56d..178050b16d7 100644 --- a/README.md +++ b/README.md @@ -80,46 +80,35 @@ These correspond to LUT used internally by the algo steps. The files that are downloaded by emData/download.sh were created by the CMSSSW L1 track emulation, with the the following recipe (adapted from the [L1TrackSoftware TWiki](https://twiki.cern.ch/twiki/bin/view/CMS/L1TrackSoftware)). ```bash -cmsrel CMSSW_11_3_0_pre3 -cd CMSSW_11_3_0_pre3/src/ -cmsenv -git cms-checkout-topic -u cms-L1TK:fw_synch_210611 -git clone https://github.com/cms-data/L1Trigger-TrackFindingTracklet.git L1Trigger/TrackFindingTracklet/data +cmsrel CMSSW_12_0_0_pre4 +cd CMSSW_12_0_0_pre4/src/ +cmsenv +git cms-checkout-topic -u cms-L1TK:fw_synch_220220 ``` -A few cfg changes were made in order to output test vectors & lookup tables, adjust truncation, and to disable multiple matches in the MatchCalculator. This required editing parameter values in L1Trigger/TrackFindingTracklet/interface/Settings.h to match the following excerpts: +A few configuration changes were made in order to output test vectors and lookup tables and adjust truncation. This required editing parameter values in L1Trigger/TrackFindingTracklet/interface/Settings.h to match the following excerpts: ```c++ … - //--- These used to create files needed by HLS code. - bool writeMem_{true}; //If true will print out content of memories (between algo steps) to files - bool writeTable_{true}; //If true will print out content of LUTs to files - bool writeConfig_{true}; //If true will print out the autogenerated configuration as files + //IR should be set to 108 to match the FW for the summer chain, but ultimately should be at 156 + std::unordered_map maxstep_{{"IR", 156}, //IR will run at a higher clock speed to handle + //input links running at 25 Gbits/s + //Set to 108 to match firmware project 240 MHz clock … - bool writeHLSInvTable_{true}; //Write out tables of drinv and invt in tracklet calculator for HLS module + //--- These used to create files needed by HLS code. + bool writeMem_{false}; //If true will print out content of memories (between algo steps) to files + bool writeTable_{false}; //If true will print out content of LUTs to files + bool writeConfig_{false}; //If true will print out the autogenerated configuration as files … - // When false, match calculator does not save multiple matches, even when doKF=true. - // This is a temporary fix for compatibilty with HLS. We will need to implement multiple match - // printing in emulator eventually, possibly after CMSSW-integration inspired rewrites - // Use false when generating HLS files, use true when doing full hybrid tracking - bool doMultipleMatches_{false}; + bool writeHLSInvTable_{false}; //Write out tables of drinv and invt in tracklet calculator for HLS module … ``` -N.B. In future, better agreement with FW can be achieved by also setting the following parameter values in L1Trigger/TrackFindingTracklet/interface/Settings.h . This was *not done* for the existing emData/ files, but is recommended if generating new ones: - -```c++ -… - //Number of processing steps for one event (108=18TM*240MHz/40MHz) - // Change IR & TE from default values -- leave others unchanged. - std::unordered_map maxstep_{{"IR", 108}, ... , {"TE", 107}}, ...}' -… -``` +In addition, if you would like to run the configuration with the combined modules (i.e., the TrackletProcessor and MatchProcessor), you can do this by setting -In addition, if you'd like to run the Summer Chain configuration, you can do this by setting ```c++ … - bool reduced_{true}; // use reduced (Summer Chain) config + bool combined_{true}; // use combined TP (TE+TC) and MP (PR+ME+MC) configuration … ``` @@ -129,7 +118,7 @@ Then compilation was done with the usual command: scram b -j8 ``` -Finally, the maximum number of events in L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py was set to 100: +The maximum number of events in L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker_cfg.py was set to 100: ```python … @@ -137,7 +126,35 @@ process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(100)) … ``` -and the emulation run: +Also, the following customization is needed: + +```python +… +# HYBRID: prompt tracking +if (L1TRKALGO == 'HYBRID'): + process.TTTracksEmulation = cms.Path(process.L1HybridTracks) + process.TTTracksEmulationWithTruth = cms.Path(process.L1HybridTracksWithAssociators) + + # Add the following two lines + from L1Trigger.TrackFindingTracklet.Customize_cff import * + fwConfig( process ) +… +``` + +Finally, if you would like to run the reduced configuration used for the summer/skinny chain, change the algorithm to HYBRID_REDUCED: + +```python +… +# Set L1 tracking algorithm: +# 'HYBRID' (baseline, 4par fit) or 'HYBRID_DISPLACED' (extended, 5par fit). +# 'HYBRID_NEWKF' (baseline, 4par fit, with bit-accurate KF emulation), +# 'HYBRID_REDUCED' to use the "Summer Chain" configuration with reduced inputs. +# (Or legacy algos 'TMTT' or 'TRACKLET'). +L1TRKALGO = 'HYBRID_REDUCED' +… +``` + +The emulation is then run with: ```bash cd L1Trigger/TrackFindingTracklet/test/ diff --git a/TrackletAlgorithm/MatchCalculator.h b/TrackletAlgorithm/MatchCalculator.h index d38ca48a531..1b8b814d1d5 100644 --- a/TrackletAlgorithm/MatchCalculator.h +++ b/TrackletAlgorithm/MatchCalculator.h @@ -360,16 +360,6 @@ void MatchCalculator(BXType bx, read[i] = false; } - // MC_L3PHIC mask {1: on, 0: off} - //static const uint16_t FML1L2 = 1 << shift_L1L2; - //static const uint16_t FML2L3 = 0 << shift_L2L3; - //static const uint16_t FML3L4 = 0 << shift_L3L4; - //static const uint16_t FML5L6 = 1 << shift_L5L6; - //static const uint16_t FMD1D2 = 0 << shift_D1D2; - //static const uint16_t FMD3D4 = 0 << shift_D3D4; - //static const uint16_t FML1D1 = 0 << shift_L1D1; - //static const uint16_t FML2D1 = 0 << shift_L2D1; - // Variables for the merger // layer 1 variables bool read_L1_1 = false; @@ -446,6 +436,8 @@ void MatchCalculator(BXType bx, FullMatch bestmatch; bool goodmatch = false; + ap_uint<1> inc_fm = 1; + //----------------------------------------------------------------------------------------------------------- //-------------------------------- DATA PROCESSING STARTS --------------------------------------------------- @@ -461,7 +453,7 @@ void MatchCalculator(BXType bx, ap_uint nmcout8 = 0; MC_LOOP: for (ap_uint istep = 0; istep < kMaxProc - kMaxProcOffset(module::MC); istep++) { - + #pragma HLS PIPELINE II=1 // Pick up number of candidate matches for each CM memory @@ -763,6 +755,11 @@ void MatchCalculator(BXType bx, id_next = projid; bool newtracklet = (istep==0 || (id_next != id))? true : false; + //increment full match memories + if (newtracklet) { + inc_fm = 1; + } + // Stub parameters typename AllStub::ASR stub_r = stub.getR(); typename AllStub::ASZ stub_z = stub.getZ(); @@ -778,6 +775,7 @@ void MatchCalculator(BXType bx, typename AllProjection::AProjPHIDER proj_phid = proj.getPhiDer(); typename AllProjection::AProjRZDER proj_zd = proj.getRZDer(); + // Calculate residuals // Get phi and z correction ap_int<22> full_phi_corr = stub_r * proj_phid; // full corr has enough bits for full multiplication @@ -798,7 +796,6 @@ void MatchCalculator(BXType bx, ap_int<18> shiftstubphi = stub_phi_long << kPhi0_shift; // shift ap_int<18> shiftprojphi = proj_phi_long << (kShift_phi0bit - 1 + kPhi0_shift); // shift ap_int<17> delta_phi = shiftstubphi - shiftprojphi; - ap_uint<13> abs_delta_z = iabs<13>( delta_z_fact ); // absolute value of delta z ap_uint<17> abs_delta_phi = iabs<17>( delta_phi ); // absolute value of delta phi // Full match parameters @@ -825,7 +822,7 @@ void MatchCalculator(BXType bx, best_delta_phi = (newtracklet)? LUT_matchcut_phi[proj_seed] : best_delta_phi; // Check that matches fall within the selection window of the projection - if ((abs_delta_z <= LUT_matchcut_z[proj_seed]) && (abs_delta_phi <= best_delta_phi)){ + if ((delta_z_fact < LUT_matchcut_z[proj_seed]) && (delta_z_fact >= -LUT_matchcut_z[proj_seed]) && (abs_delta_phi <= best_delta_phi)){ // Update values of best phi parameters, so that the next match // will be compared to this value instead of the original selection cut best_delta_phi = abs_delta_phi; @@ -835,68 +832,60 @@ void MatchCalculator(BXType bx, goodmatch_next = true; projseed_next = proj_seed; } - else if (newtracklet){ // if is a new tracklet, do not make a match because it didn't pass the cuts - bestmatch_next = FullMatch(); - goodmatch_next = false; - projseed_next = -1; - } - else { // if current match did not pass, but it is not a new tracklet, keep the previous best match for that tracklet - bestmatch_next = bestmatch; - goodmatch_next = goodmatch; - projseed_next = projseed; - } - if(newtracklet && goodmatch==true) { // Write out only the best match, based on the seeding - switch (projseed) { + if(goodmatch_next&&valid_L3) { + + switch (projseed_next) { case 0: if(FMMask()) { - fullmatch[FMCount()].write_mem(bx,bestmatch,nmcout1); // L1L2 seed - nmcout1++; + fullmatch[FMCount()].write_mem(bx,bestmatch_next,nmcout1+inc_fm-1); // L1L2 seed + nmcout1+=inc_fm; } break; case 1: if(FMMask()) { - fullmatch[FMCount()].write_mem(bx,bestmatch,nmcout2); // L2L3 seed - nmcout2++; + fullmatch[FMCount()].write_mem(bx,bestmatch_next,nmcout2+inc_fm-1); // L2L3 seed + nmcout2+=inc_fm; } break; case 2: if(FMMask()) { - fullmatch[FMCount()].write_mem(bx,bestmatch,nmcout3); // L3L4 seed - nmcout3++; + fullmatch[FMCount()].write_mem(bx,bestmatch_next,nmcout3+inc_fm-1); // L3L4 seed + nmcout3+=inc_fm; } break; case 3: if(FMMask()) { - fullmatch[FMCount()].write_mem(bx,bestmatch,nmcout4); // L5L6 seed - nmcout4++; + fullmatch[FMCount()].write_mem(bx,bestmatch_next,nmcout4+inc_fm-1); // L5L6 seed + nmcout4+=inc_fm; } break; case 4: if(FMMask()) { - fullmatch[FMCount()].write_mem(bx,bestmatch,nmcout5); // D1D2 seed - nmcout5++; + fullmatch[FMCount()].write_mem(bx,bestmatch_next,nmcout5+inc_fm-1); // D1D2 seed + nmcout5+=inc_fm; } break; case 5: if(FMMask()) { - fullmatch[FMCount()].write_mem(bx,bestmatch,nmcout6); // D3D4 seed - nmcout6++; + fullmatch[FMCount()].write_mem(bx,bestmatch_next,nmcout6+inc_fm-1); // D3D4 seed + nmcout6+=inc_fm; } break; case 6: if(FMMask()) { - fullmatch[FMCount()].write_mem(bx,bestmatch,nmcout7); // L1D1 seed - nmcout7++; + fullmatch[FMCount()].write_mem(bx,bestmatch_next,nmcout7+inc_fm-1); // L1D1 seed + nmcout7+=inc_fm; } break; case 7: if(FMMask()) { - fullmatch[FMCount()].write_mem(bx,bestmatch,nmcout8); // L2D1 seed - nmcout8++; + fullmatch[FMCount()].write_mem(bx,bestmatch_next,nmcout8+inc_fm-1); // L2D1 seed + nmcout8+=inc_fm; } break; } + inc_fm=0; } // pipeline the bestmatch registers diff --git a/TrackletAlgorithm/MatchEngineUnit.h b/TrackletAlgorithm/MatchEngineUnit.h index c19a0475f02..abdac52f1c9 100644 --- a/TrackletAlgorithm/MatchEngineUnit.h +++ b/TrackletAlgorithm/MatchEngineUnit.h @@ -15,12 +15,6 @@ #include #include "MatchEngineUnit_parameters.h" -template -static const ap_uint<1 << nbits> hasOneStub() { - ap_uint<1 << nbits> onlyOneStub(0); - onlyOneStub[1] = 1; - return onlyOneStub; -} template class MatchEngineUnitBase {}; @@ -48,51 +42,20 @@ class MatchEngineUnit : public MatchEngineUnitBase { nstubs_ = 0; idle_ = true; empty_ = true; - good_ = false; good__ = false; + good___ = false; } - inline void processPipeLine(ap_uint<1> *table) { -#pragma HLS inline - if (good__) { - auto stubindex=stubdata__.getIndex(); - auto stubfinez=stubdata__.getFineZ(); - auto stubfinephi=stubdata__.getFinePhi(); - auto stubbend=stubdata__.getBend(); - - bool passphi = isLessThanSize<5,3,false,5,3>()[(projfinephi___,stubfinephi)]; - - //Check if stub z position consistent - bool pass = isPSseed__ ? isLessThanSize<5,1,true,3,5>()[(stubfinez,projfinezadj__)] : isLessThanSize<5,5,true,3,5>()[(stubfinez,projfinezadj__)]; - - auto const index=projrinv__.concat(stubbend); - //Check if stub bend and proj rinv consistent - if (passphi&&pass&&table[index]) { - matches_[writeindex_++]=(stubindex,projbuffer___.getAllProj()); - } - } - - good__ = good_; - stubdata__ = stubdata_; - projfinephi___ = projfinephi__; - projfinezadj__ = projfinezadj_; - isPSseed__ = isPSseed_; - projrinv__ = projrinv_; - projbuffer___ = projbuffer__; - } - - - inline void init(BXType bxin, ProjectionRouterBuffer projbuffer, int iphi, int unit) { + inline void init(BXType bxin, ProjectionRouterBuffer projbuffer, ap_uint projseq) { #pragma HLS inline #pragma HLS array_partition variable=nstubsall_ complete dim=1 idle_ = false; - bx = bxin; + bx_ = bxin; istub_ = 0; - unit_ = unit; - AllProjection aProj(projbuffer.getAllProj()); + projbuffer_ = projbuffer; - projindex = projbuffer.getIndex(); + projseq_ = projseq; (nstubsall_[3], nstubsall_[2], nstubsall_[1], nstubsall_[0]) = projbuffer.getNStubs(); shift_ = projbuffer.shift(); stubmask_[0] = nstubsall_[0]!=0; @@ -101,18 +64,146 @@ class MatchEngineUnit : public MatchEngineUnitBase { stubmask_[3] = nstubsall_[3]!=0; ap_uint<2> index = __builtin_ctz(stubmask_); stubmask_[index]=0; - second_ = isSecond[index]; - phiPlus_ = isPhiPlus[index]; + second_ = index[0]; + phiPlus_ = index[1]; nstubs_ = nstubsall_[index]; - ivmphi = projbuffer.getPhi(); - iphi_ = iphi; - auto const qdata=projbuffer_; - tcid=qdata.getTCID(); + iphi_ = projbuffer.getPhi(); + tcid_ = projbuffer.getTCID(); - good_ = false; + good__ = false; } + + +inline void step(const VMStubMECM stubmem[2][1024]) { +#pragma HLS inline +#pragma HLS array_partition variable=nstubsall_ complete dim=1 + + bool nearfull = nearFull(); + + good__ = (!idle_) && (!nearfull); + + // Buffer still has projections to read out + //If the buffer is not empty we have a projection that we need to + //process. + + NSTUBS istubtmp=istub_; + + ap_uint::kVMSMEFinePhiSize> iphiSave = iphi_ + phiPlus_; + auto secondSave = second_; + + if(istub_ == 0) { + + //Need to read the information about the proj in the buffer + VMProjection data(projbuffer_.getProjection()); + + //FIXME is this valid? Only using range(3,1) instead of full range, zfirst in MatchProcessor.h + zbin = data.getZBinNoFlag(); + + auto projfinez = data.getFineZ(); + projfinephi__ = data.getFinePhi(); + + //Calculate fine z position + const int detectorshift(8); + if (second_) { + projfinezadj__ = projfinez-detectorshift; + zbin=zbin+1; + } else { + projfinezadj__ = projfinez; + } + + if (!phiPlus_) { + if (shift_==-1) { + projfinephi__ -= detectorshift; + } + } else { + //When we get here shift_ is either 1 or -1 + if (shift_==1) { + projfinephi__ += detectorshift; + } + } + + isPSseed__ = data.getIsPSSeed(); + projrinv__ = data.getRInv(); + + } + + //Check if last stub, if so, go to next buffer entry + if (good__) { + if (istub_+1>=nstubs_){ + istub_=0; + if (!stubmask_) { + idle_ = true; + } else { + ap_uint<2> index = __builtin_ctz(stubmask_); + stubmask_[index]=0; + second_ = index[0]; + phiPlus_ = index[1]; + nstubs_ = nstubsall_[index]; + } + } else { + istub_++; + } + } + + //Read stub memory and extract data fields + auto stubadd=(iphiSave,zbin,istubtmp); + stubdata__ = stubmem[bx_&1][stubadd]; + projbuffer__ = projbuffer_; + projseq__ = projseq_; + + +} // end step + + + + + inline void processPipeLine(ap_uint<1> *table) { +#pragma HLS inline + + auto stubindex=stubdata___.getIndex(); + auto stubfinez=stubdata___.getFineZ(); + auto stubfinephi=stubdata___.getFinePhi(); + auto stubbend=stubdata___.getBend(); + + const int projfinebits(VMProjectionBase::kVMProjFinePhiWideSize); + const int stubfinebits(VMStubMECMBase::kVMSMEFinePhiSize); + bool passphi = isLessThanSize()[(projfinephi___,stubfinephi)]; + + //Check if stub z position consistent + const int stub2Sfinebits(1); + bool pass = isPSseed___ ? isLessThanSize()[(stubfinez,projfinezadj___)] : isLessThanSize()[(stubfinez,projfinezadj___)]; + + auto const index=projrinv___.concat(stubbend); + + //Check if stub bend and proj rinv consistent + projseqs_[writeindex_] = projseq___; + matches_[writeindex_] = (stubindex,projbuffer___.getAllProj()); + INDEX writeindexnext = writeindex_ + 1; + + //Though we did write to matches_ above only now do we increment + //the writeindex_ if we had a good stub that pass the various cuts + writeindex_ = (good___&passphi&pass&table[index]) ? writeindexnext : writeindex_; + + //update pipeline variables + good___ = good__; + stubdata___ = stubdata__; + projfinephi___ = projfinephi__; + projfinezadj___ = projfinezadj__; + isPSseed___ = isPSseed__; + projrinv___ = projrinv__; + projbuffer___ = projbuffer__; + projseq___ = projseq__; + } + +#ifndef __SYNTHESIS__ + inline void setUnit(int unit) { + unit_ = unit; + } + +#endif + inline void set_empty() { empty_ = emptyUnit::kNBitsBuffer>()[(readindex_,writeindex_)]; } @@ -123,7 +214,7 @@ class MatchEngineUnit : public MatchEngineUnitBase { } inline bool nearFull() { - return nearFullLUT[(readindex_,writeindex_)]; + return nearFull3Unit::kNBitsBuffer>()[(readindex_,writeindex_)]; } inline bool idle() { @@ -142,9 +233,10 @@ class MatchEngineUnit : public MatchEngineUnitBase { inline bool processing() { #pragma HLS inline - return !idle_||good_||good__; + return !idle_||good__||good___; } +// This method is no longer used, but kept for possible debugging etc. inline typename ProjectionRouterBuffer::TCID getTCID() { #pragma HLS inline if (!empty()) { @@ -154,15 +246,19 @@ inline typename ProjectionRouterBuffer::TCID getTCID( AllProjection allproj(allprojdata); return allproj.getTCID(); } - if (good__) { + if (good___) { return projbuffer___.getTCID(); } - if (good_) { + if (good__) { return projbuffer__.getTCID(); } - return tcid; + return tcid_; } + + + + inline typename ProjectionRouterBuffer::TRKID getTrkID() { #pragma HLS inline if (!empty()) { @@ -172,20 +268,38 @@ inline typename ProjectionRouterBuffer::TRKID getTrkI AllProjection allproj(allprojdata); return (allproj.getTCID(), allproj.getTrackletIndex()); } - if (idle_&&!good_&&!good__) { + if (idle_&&!good__&&!good___) { typename ProjectionRouterBuffer::TRKID tmp(0); return ~tmp; } - if (good__) { + if (good___) { AllProjection allproj(projbuffer___.getAllProj()); return (projbuffer___.getTCID(), allproj.getTrackletIndex()); } - if (good_) { + if (good__) { AllProjection allproj(projbuffer__.getAllProj()); return (projbuffer__.getTCID(), allproj.getTrackletIndex()); } AllProjection allproj(projbuffer_.getAllProj()); - return (tcid, allproj.getTrackletIndex()); + return (tcid_, allproj.getTrackletIndex()); +} + +inline ap_uint getProjSeq() { +#pragma HLS inline + if (!empty()) { + return projseqs_[readindex_]; + } + if (idle_&&!good__&&!good___) { + ap_uint tmp(0); + return ~tmp; + } + if (good___) { + return projseq___; + } + if (good__) { + return projseq__; + } + return projseq_; } inline VMProjection::VMPID getProjindex() { @@ -205,138 +319,60 @@ inline int getIPhi() { inline MATCH read() { #pragma HLS inline return matches_[readindex_++]; - } - inline void step(const VMStubMECM stubmem[2][1024]) { -#pragma HLS inline -#pragma HLS array_partition variable=nstubsall_ complete dim=1 - - bool nearfull = nearFull(); - - good_ = idle_ ? false : good_; - good_ = nearfull ? false : good_; - - - - bool process = (!idle_) && (!nearfull); - - // Buffer still has projections to read out - //If the buffer is not empty we have a projection that we need to - //process. - - NSTUBS istubtmp=istub_; - - ap_uint<3> iphiSave = iphi_ + phiPlus_; - auto secondSave = second_; - - if(emptyUnit()[istub_]) { - - //Need to read the information about the proj in the buffer - //FIXME - should this not be in init method? - auto const qdata=projbuffer_; - tcid=qdata.getTCID(); - VMProjection data(qdata.getProjection()); - zbin=data.getZBin().range(3,1); //FIXME is this valid? Only using range(3,1) instead of full range, zfirst in MatchProcessor.h - - projindex=data.getIndex(); - auto projfinez=data.getFineZ(); - projfinephi_=data.getFinePhi(); - projrinv=data.getRInv(); - isPSseed=data.getIsPSSeed(); - - //Calculate fine z position - if (second_) { - projfinezadj=projfinez-8; - zbin=zbin+1; - } else { - projfinezadj=projfinez; - } - - if (!phiPlus_) { - if (shift_==-1) { - projfinephi_ -= 8; - } - } else { - //When we get here shift_ is either 1 or -1 - if (shift_==1) { - projfinephi_ += 8; - } - } - - } - - //Check if last stub, if so, go to next buffer entry - if (process) { - if (istub_+1>=nstubs_){ - istub_=0; - if (!stubmask_) { - idle_ = true; - } else { - ap_uint<2> index = __builtin_ctz(stubmask_); - stubmask_[index]=0; - second_ = index[0]; - phiPlus_ = index[1]; - nstubs_ = nstubsall_[index]; - } - } else { - istub_++; - } - } - - //Read stub memory and extract data fields - ap_uint<10> stubadd=(iphiSave,zbin,istubtmp); - stubdata_ = stubmem[bx&1][stubadd]; - projfinephi__ = projfinephi_; - projfinezadj_ = projfinezadj; - isPSseed_ = isPSseed; - projrinv_ = projrinv; - projbuffer__ = projbuffer_; - good_ = process; +inline MATCH peek() { +#pragma HLS inline + return matches_[readindex_]; +} + +inline void advance() { +#pragma HLS inline + readindex_++; +} - - } // end step + private: - bool Good_() const { return good_;} - bool Good__() const { return good__;} + //Buffers for the matches + INDEX writeindex_, readindex_; + MATCH matches_[1<::kNBitsBuffer]; + ap_uint projseqs_[1<::kNBitsBuffer]; - private: - INDEX writeindex_; - INDEX readindex_; + //Current projection ap_uint<4> nstubsall_[4]; - NSTUBS nstubs_; + NSTUBS nstubs_, istub_; ap_uint<4> stubmask_; ap_uint<1> second_; ap_uint<1> phiPlus_; ap_int<2> shift_; bool idle_; - int ivmphi; - int unit_; // only used for debugging to identify MEU - ap_uint<3> iphi_; - BXType bx; + ap_uint::kVMSMEFinePhiSize> iphi_; + BXType bx_; bool empty_; - NSTUBS istub_=0; - VMStubMECM stubdata_, stubdata__; - bool good_, good__; - ap_int<5> projfinephi__, projfinephi___; - ap_int<5> projfinezadj_, projfinezadj__; - bool isPSseed_, isPSseed__; - VMProjection::VMPRINV projrinv_, projrinv__; - ProjectionRouterBuffer projbuffer__, projbuffer___; + VMStubMECM stubdata__, stubdata___; + typename ProjectionRouterBuffer::TCID tcid_; + ProjectionRouterBuffer projbuffer_; + ap_uint projseq_; + bool isPSseed_; + - MATCH matches_[1<::kNBitsBuffer]; - ap_int<5> projfinezadj; //FIXME Need replace 5 with const - ap_int<5> projfinephi_; //FIXME Need replace 5 with const - typename ProjectionRouterBuffer::TCID tcid; - bool isPSseed; typename ProjectionRouterBuffer::VMPZBINNOFLAG zbin; - VMProjection::VMPRINV projrinv; - VMProjection::VMPID projindex; - ProjectionRouterBuffer projbuffer_; - ap_uint<(1 << (2 * MatchEngineUnitBase::kNBitsBuffer))> nearFullLUT = nearFull3Unit::kNBitsBuffer>(); - bool isSecond[4] = {false, true, false, true}; - bool isPhiPlus[4] = {false, false, true, true}; - ap_uint<1<<(kNBits_MemAddrBinned+2)> onlyOneStub = hasOneStub(); + + //Pipeline variables + bool good__, good___; + ap_uint::kVMProjFinePhiWideSize> projfinephi__, projfinephi___; + ap_uint::kVMProjFinePhiWideSize> projfinezadj__, projfinezadj___; + bool isPSseed__, isPSseed___; + VMProjection::VMPRINV projrinv__, projrinv___; + ProjectionRouterBuffer projbuffer__, projbuffer___; + ap_uint projseq__, projseq___; + + +#ifndef __SYNTHESIS__ + // only used for debugging to identify MEU + int unit_; +#endif + }; // end class diff --git a/TrackletAlgorithm/MatchProcessor.h b/TrackletAlgorithm/MatchProcessor.h index 6ff47c89851..8e96f44c001 100644 --- a/TrackletAlgorithm/MatchProcessor.h +++ b/TrackletAlgorithm/MatchProcessor.h @@ -314,7 +314,6 @@ void MatchCalculator(BXType bx, ap_uint<17>& best_delta_phi, const AllStubMemory* allstub, const AllProjection& proj, - ap_uint::kVMProjIndexSize> projid, ap_uint::kVMSMEIDSize> stubid, BXType& bx_o, int &nmcout1, @@ -368,8 +367,6 @@ void MatchCalculator(BXType bx, bool goodmatch = false; - CandidateMatch cmatch(projid.concat(stubid)); - // Use the stub and projection indices to pick up the stub and projection AllStub stub = allstub->read_mem(bx,stubid); @@ -409,7 +406,6 @@ void MatchCalculator(BXType bx, ap_int<18> shiftstubphi = stub_phi_long << kPhi0_shift; // shift ap_int<18> shiftprojphi = proj_phi_long << (kShift_phi0bit - 1 + kPhi0_shift); // shift ap_int<17> delta_phi = shiftstubphi - shiftprojphi; - ap_uint<13> abs_delta_z = iabs<13>( delta_z_fact ); // absolute value of delta z ap_uint<17> abs_delta_phi = iabs<17>( delta_phi ); // absolute value of delta phi // Full match parameters @@ -437,7 +433,7 @@ void MatchCalculator(BXType bx, best_delta_phi = (newtracklet)? LUT_matchcut_phi[proj_seed] : best_delta_phi; // Check that matches fall within the selection window of the projection - if ((abs_delta_z <= LUT_matchcut_z[proj_seed]) && (abs_delta_phi <= best_delta_phi)){ + if ((delta_z_fact < LUT_matchcut_z[proj_seed]) && (delta_z_fact >= -LUT_matchcut_z[proj_seed]) && (abs_delta_phi <= best_delta_phi)){ // Update values of best phi parameters, so that the next match // will be compared to this value instead of the original selection cut best_delta_phi = abs_delta_phi; @@ -547,7 +543,8 @@ void MatchProcessor(BXType bx, constexpr unsigned int kNBitsBuffer=3; - // declare counters for each of the 8 output VMProj // !!! + // declare counters for each of the 8 different seeds. + //FIXME should have propoer seven bit type int nmcout1 = 0; int nmcout2 = 0; int nmcout3 = 0; @@ -557,18 +554,7 @@ void MatchProcessor(BXType bx, int nmcout7 = 0; int nmcout8 = 0; - ap_uint nallproj; - - //////////////////////////////////////////// - //Some ME stuff - //////////////////////////////////////////// - ap_uint zbin=0; - VMProjection::VMPFINEZ projfinez; - ap_int<5> projfinezadj; //FIXME Need replace 5 with const - VMProjection::VMPRINV projrinv; - bool isPSseed; - bool second; - ap_uint istub=0; + ap_uint nallproj = 0; ap_uint iproj=0; //counter @@ -583,8 +569,12 @@ void MatchProcessor(BXType bx, #pragma HLS ARRAY_PARTITION variable=instubdata complete dim=1 #pragma HLS ARRAY_PARTITION variable=projin dim=1 #pragma HLS ARRAY_PARTITION variable=numbersin complete dim=0 -#pragma HLS dependence variable=istub inter false +#ifndef __SYNTHESIS__ + for(unsigned int iMEU = 0; iMEU < kNMatchEngines; ++iMEU) { + matchengine[iMEU].setUnit(iMEU); + } +#endif //These are used inside the MatchCalculator method and needs to be retained between iterations ap_uint<1> savedMatch; @@ -617,14 +607,14 @@ void MatchProcessor(BXType bx, bool projBuffNearFull = nearFull3Unit()[(readptr,writeptr)]; ap_uint<3> iphi = 0; - if (istep == 0) { - nallproj = 0; - } ap_uint idles; ap_uint emptys; - typename ProjectionRouterBuffer::TRKID trkids[kNMatchEngines]; -#pragma HLS ARRAY_PARTITION variable=trkids complete dim=0 + + typename MatchEngineUnit::MATCH matches[kNMatchEngines]; + #pragma HLS ARRAY_PARTITION variable=matches complete dim=0 + ap_uint projseqs[kNMatchEngines]; +#pragma HLS ARRAY_PARTITION variable=projseqs complete dim=0 bool anyidle = false; @@ -635,7 +625,9 @@ void MatchProcessor(BXType bx, idles[iMEU] = matchengine[iMEU].idle(); anyidle = idles[iMEU] ? true : anyidle; emptys[iMEU] = matchengine[iMEU].empty(); - trkids[iMEU] = matchengine[iMEU].getTrkID(); + + projseqs[iMEU] = matchengine[iMEU].getProjSeq(); + matches[iMEU] = matchengine[iMEU].peek(); } //This printout exactly matches printout in emulation for tracking code differences @@ -647,7 +639,24 @@ void MatchProcessor(BXType bx, } std::cout << std::endl; */ + + ap_uint projseq01tmp, projseq23tmp, projseq0123tmp; + ap_uint<1> Bit01 = projseqs[0] Bit23 = projseqs[2] Bit0123 = projseq01tmp < projseq23tmp; + + projseq0123tmp = Bit0123 ? projseq01tmp : projseq23tmp; + + auto bestiMEU = (~Bit0123, Bit0123 ? ~Bit01 : ~Bit23 ); + + ap_uint<1> hasMatch = !emptys[bestiMEU]; + + /* old code - keep for now ap_uint smallest = ~emptys; #pragma HLS ARRAY_PARTITION variable=trkids complete dim=0 MEU_smallest1: for(int iMEU1 = 0; iMEU1 < kNMatchEngines-1; ++iMEU1) { @@ -661,11 +670,11 @@ void MatchProcessor(BXType bx, ap_uint<1> hasMatch = smallest.or_reduce(); ap_uint<3> bestiMEU = __builtin_ctz(smallest); + */ - - ProjectionRouterBuffer tmpprojbuff; + ProjectionRouterBuffer tmpprojbuff = projbufferarray.peek();; if (anyidle && !empty) { - tmpprojbuff = projbufferarray.read(); + projbufferarray.advance(); } bool init = false; @@ -677,8 +686,7 @@ void MatchProcessor(BXType bx, if(idle && !empty && !init) { init = true; - auto iphi = tmpprojbuff.getPhi(); - meu.init(bx, tmpprojbuff, iphi, iMEU); + meu.init(bx, tmpprojbuff, istep); } else meu.step(instubdata.getMem(iMEU)); @@ -688,22 +696,22 @@ void MatchProcessor(BXType bx, } //end MEU loop if(hasMatch) { - - auto trkindex=matchengine[bestiMEU].getTrkID(); - - typename VMProjection::VMPID projindex; - + ap_uint::kVMSMEIDSize> stubindex; - ap_uint::kAllProjectionSize> allproj; - - (stubindex,allproj) = matchengine[bestiMEU].read(); + ap_uint::kAllProjectionSize> allprojdata; + (stubindex,allprojdata) = matches[bestiMEU]; + matchengine[bestiMEU].advance(); + AllProjection allproj(allprojdata); + + auto trkindex=(allproj.getTCID(), allproj.getTrackletIndex()); + ap_uint<1> newtracklet = lastTrkID != trkindex; lastTrkID = trkindex; MatchCalculator - (bx, newtracklet, savedMatch, best_delta_phi, allstub, allproj, projindex, stubindex, bx_o, + (bx, newtracklet, savedMatch, best_delta_phi, allstub, allproj, stubindex, bx_o, nmcout1, nmcout2, nmcout3, nmcout4, nmcout5, nmcout6, nmcout7, nmcout8, fullmatch); } //end MC if @@ -712,7 +720,7 @@ void MatchProcessor(BXType bx, if (validin_) { auto iphiproj = projdata_.getPhi(); - auto izproj = projdata_.getRZ(); + auto izproj = projdata_.getZ(); auto iphider = projdata_.getPhiDer(); auto trackletid = projdata_.getTCID(); @@ -727,8 +735,6 @@ void MatchProcessor(BXType bx, // All seeding pairs are PS modules except L3L4 and L5L6 bool psseed = not(iseed==TF::L3L4 or iseed==TF::L5L6); - ////////////////////////// - // hourglass configuration // vmproj index const typename VMProjection::VMPID &index = nallproj; @@ -818,10 +824,13 @@ void MatchProcessor(BXType bx, VMProjection vmproj(index, zbin, finez, finephi, rinv, psseed); AllProjection allproj(projdata_.getTCID(), projdata_.getTrackletIndex(), projdata_.getPhi(), - projdata_.getRZ(), projdata_.getPhiDer(), projdata_.getRZDer()); + projdata_.getZ(), projdata_.getPhiDer(), projdata_.getRZDer()); + + ProjectionRouterBuffer projbuffertmp(allproj.raw(), ivmMinus, shift, trackletid, nstubs, zfirst, vmproj, psseed); + projbufferarray.saveProjection(projbuffertmp); + if (nstubs!=0) { - ProjectionRouterBuffer projbuffertmp(allproj.raw(), ivmMinus, shift, trackletid, nstubs, zfirst, vmproj, psseed); - projbufferarray.addProjection(projbuffertmp); + projbufferarray.incProjection(); } } // end if(validin) @@ -837,8 +846,6 @@ void MatchProcessor(BXType bx, nINMEM, kNBits_MemAddr+1> (bx, mem_hasdata, numbersin, mem_read_addr, projin, projdata, nproj); - - } else { validin = false; diff --git a/TrackletAlgorithm/ProjectionRouter.h b/TrackletAlgorithm/ProjectionRouter.h index 0bebc61ce02..a1b1d5f9c2a 100644 --- a/TrackletAlgorithm/ProjectionRouter.h +++ b/TrackletAlgorithm/ProjectionRouter.h @@ -112,7 +112,7 @@ void ProjectionRouter(BXType bx, if (validin) { auto iphiproj = tproj.getPhi(); - auto izproj = tproj.getRZ(); + auto izproj = tproj.getZ(); auto iphider = tproj.getPhiDer(); auto iseed = tproj.getSeed(); diff --git a/TrackletAlgorithm/ProjectionRouterBufferArray.h b/TrackletAlgorithm/ProjectionRouterBufferArray.h index 1ff2bd4b35f..fb2d90cef11 100644 --- a/TrackletAlgorithm/ProjectionRouterBufferArray.h +++ b/TrackletAlgorithm/ProjectionRouterBufferArray.h @@ -12,10 +12,29 @@ template class ProjectionRouterBufferArr return projbuffer_[readptr_++]; } - inline void addProjection(ProjectionRouterBuffer &proj) { + inline ProjectionRouterBuffer peek() { +#pragma HLS inline +#pragma HLS ARRAY_PARTITION variable=projbuffer_ complete + return projbuffer_[readptr_]; + } + + inline void advance() { +#pragma HLS inline +#pragma HLS ARRAY_PARTITION variable=projbuffer_ complete + readptr_++; + } + + + + inline void saveProjection(ProjectionRouterBuffer &proj) { #pragma HLS inline #pragma HLS array_partition variable=projbuffer_ complete - projbuffer_[writeptr_++] = proj; + projbuffer_[writeptr_] = proj; + } + + inline void incProjection() { +#pragma HLS inline + writeptr_++; } inline bool empty() { diff --git a/TrackletAlgorithm/TrackletCalculator.h b/TrackletAlgorithm/TrackletCalculator.h index d2d72bce942..f07aaaecd73 100644 --- a/TrackletAlgorithm/TrackletCalculator.h +++ b/TrackletAlgorithm/TrackletCalculator.h @@ -44,7 +44,7 @@ namespace TC { typedef ap_int<11> der_phiL; typedef ap_int<10> der_zL; typedef ap_uint<16> phiD; - typedef ap_int<14> rD; + typedef ap_uint<14> rD; typedef ap_int<10> der_phiD; typedef ap_int<10> der_rD; typedef ap_uint<1> flag; @@ -311,13 +311,13 @@ TC::barrelSeeding(const AllStub()> &innerStub, const AllStub i = 0; i < trklet::N_DISK - 1; i++) { valid_proj_disk[i] = true; - if (abs(*t) < floatToInt(1.0, kt)) // disk projections are invalid if |t| < 1 + if (abs(*t) <= floatToInt(1.0, kt)) // disk projections are invalid if |t| <= 1 valid_proj_disk[i] = false; if (phiD[i] <= 0) valid_proj_disk[i] = false; if (phiD[i] >= (1 << TrackletProjection::kTProjPhiSize) - 1) valid_proj_disk[i] = false; - if (rD[i] <= floatToInt(rmindisk, krprojdisk) || rD[i] > floatToInt(rmaxdisk, krprojdisk)) + if (rD[i] < floatToInt(rmindisk, krprojdisk) || rD[i] >= floatToInt(rmaxdisk, krprojdisk)) valid_proj_disk[i] = false; } @@ -351,13 +351,13 @@ TC::addProj(const TrackletProjection &proj, const BXType bx, Tracklet // Reject projections with extreme r/z values. if (TProjType != DISK) { - if ((proj.getRZ() == (-(1 << (TrackletProjection::kTProjRZSize - 1))) || (proj.getRZ() == ((1 << (TrackletProjection::kTProjRZSize - 1)) - 1)))) + if ((proj.getZ() == (-(1 << (TrackletProjection::kTProjRZSize - 1))) || (proj.getZ() == ((1 << (TrackletProjection::kTProjRZSize - 1)) - 1)))) proj_success = false; - if (abs(proj.getRZ()) > floatToInt(zlength, kz)) + if (abs(proj.getZ()) > floatToInt(zlength, kz)) proj_success = false; } else { - if (proj.getRZ() < floatToInt(rmindiskvm, krprojdisk) || proj.getRZ() > floatToInt(rmaxdisk, krprojdisk)) + if (proj.getR() < floatToInt(rmindiskvm, krprojdisk) || proj.getR() >= floatToInt(rmaxdisk, krprojdisk)) proj_success = false; } diff --git a/TrackletAlgorithm/TrackletProcessor.h b/TrackletAlgorithm/TrackletProcessor.h index f3ff173aee2..5e7e1f832c4 100644 --- a/TrackletAlgorithm/TrackletProcessor.h +++ b/TrackletAlgorithm/TrackletProcessor.h @@ -28,7 +28,7 @@ namespace TC { typedef ap_int<11> der_phiL; typedef ap_int<10> der_zL; typedef ap_uint<16> phiD; - typedef ap_int<14> rD; + typedef ap_uint<14> rD; typedef ap_int<10> der_phiD; typedef ap_int<10> der_rD; typedef ap_uint<1> flag; @@ -299,7 +299,7 @@ ::rinv * const rinv, TrackletParameters::PHI0PAR * const phi0, TC::Types::z0 * c bool valid_t=abs(*t)>floatToInt(1.0, kt); bool valid_phimin=phiD[i]>0; bool valid_phimax=phiD[i]<(1 << TrackletProjection::kTProjPhiSize) - 1; - bool valid_r=rD[i] >= 342 && rD[i] <= 2048; + bool valid_r=rD[i] >= 342 && rD[i] < 2048; valid_proj_disk[i] = valid_t && valid_phimin && valid_phimax && valid_r; } @@ -331,13 +331,13 @@ TC::addProj(const TrackletProjection &proj, const BXType bx, Tracklet // Reject projections with extreme r/z values. if (TProjType != DISK) { - if ((proj.getRZ() == (-(1 << (TrackletProjection::kTProjRZSize - 1))) || (proj.getRZ() == ((1 << (TrackletProjection::kTProjRZSize - 1)) - 1)))) + if ((proj.getZ() == (-(1 << (TrackletProjection::kTProjRZSize - 1))) || (proj.getZ() == ((1 << (TrackletProjection::kTProjRZSize - 1)) - 1)))) proj_success = false; - if (abs(proj.getRZ()) > 2048) + if (abs(proj.getZ()) > 2048) proj_success = false; } else { - if (proj.getRZ() < 20.0/(2*kr) || proj.getRZ() > 120.0/(2*kr)) + if (proj.getR() < floatToInt(20.0, 2*kr) || proj.getR() >= floatToInt(120.0, 2*kr)) proj_success = false; } TC::Types::phiL phi = proj.getPhi() >> (TrackletProjection::kTProjPhiSize - 5); diff --git a/TrackletAlgorithm/TrackletProjectionMemory.h b/TrackletAlgorithm/TrackletProjectionMemory.h index c941b0e4ceb..80a2cdba2c8 100644 --- a/TrackletAlgorithm/TrackletProjectionMemory.h +++ b/TrackletAlgorithm/TrackletProjectionMemory.h @@ -99,7 +99,8 @@ class TrackletProjection : public TrackletProjectionBase typedef ap_uint::kTProjITCSize> TProjITC; typedef ap_uint::kTProjTrackletIndexSize> TProjTrackletIndex; typedef ap_uint::kTProjPhiSize> TProjPHI; - typedef ap_int::kTProjRZSize> TProjRZ; + typedef ap_int::kTProjRZSize> TProjZ; + typedef ap_uint::kTProjRZSize> TProjR; typedef ap_int::kTProjPhiDSize> TProjPHIDER; typedef ap_int::kTProjRZDSize> TProjRZDER; @@ -110,10 +111,10 @@ class TrackletProjection : public TrackletProjectionBase data_(newdata) {} - TrackletProjection(const TProjTCID tcid, const TProjTrackletIndex trackletIndex, const TProjPHI phi, const TProjRZ z, const TProjPHIDER phider, const TProjRZDER zder): + TrackletProjection(const TProjTCID tcid, const TProjTrackletIndex trackletIndex, const TProjPHI phi, const TProjZ z, const TProjPHIDER phider, const TProjRZDER zder): data_( (((((tcid,trackletIndex),phi),z),phider),zder) ) {} - + TrackletProjection() {} @@ -173,7 +174,11 @@ class TrackletProjection : public TrackletProjectionBase return data_.range(kTProjPhiMSB,kTProjPhiLSB); } - TProjRZ getRZ() const { + TProjZ getZ() const { + return data_.range(kTProjRZMSB,kTProjRZLSB); + } + + TProjR getR() const { return data_.range(kTProjRZMSB,kTProjRZLSB); } @@ -201,7 +206,7 @@ class TrackletProjection : public TrackletProjectionBase data_.range(kTProjPhiMSB,kTProjPhiLSB) = phi; } - void setRZ(const TProjRZ z) { + void setRZ(const TProjZ z) { data_.range(kTProjRZMSB,kTProjRZLSB) = z; } @@ -218,7 +223,10 @@ class TrackletProjection : public TrackletProjectionBase std::string str = decodeToBits(getTCID()); str += "|"+decodeToBits(getTrackletIndex()); str += "|"+decodeToBits(getPhi()); - str += "|"+decodeToBits(getRZ()); + if (TProjType != DISK) + str += "|"+decodeToBits(getZ()); + else + str += "|"+decodeToBits(getR()); str += "|"+decodeToBits(getPhiDer()); str += "|"+decodeToBits(getRZDer()); return str; diff --git a/TrackletAlgorithm/VMProjectionMemory.h b/TrackletAlgorithm/VMProjectionMemory.h index 89fe1bb522c..94400b61033 100644 --- a/TrackletAlgorithm/VMProjectionMemory.h +++ b/TrackletAlgorithm/VMProjectionMemory.h @@ -16,6 +16,7 @@ class VMProjectionBase kVMProjIsPSSeedSize = 1, kVMProjRinvSize = 5, kVMProjFinePhiSize = 3, + kVMProjFinePhiWideSize = 5, kVMProjFineZSize = 4, kVMProjZBinSize = MEBinsBits+1, kVMProjIndexSize = 7, @@ -33,6 +34,7 @@ class VMProjectionBase kVMProjIsPSSeedSize = 0, kVMProjRinvSize = 5, kVMProjFinePhiSize = 3, + kVMProjFinePhiWideSize = 5, kVMProjFineZSize = 4, kVMProjZBinSize = MEBinsBits+1+1, kVMProjIndexSize = 7, @@ -115,6 +117,10 @@ class VMProjection : public VMProjectionBase return data_.range(kVMProjZBinMSB,kVMProjZBinLSB); } + VMPZBIN getZBinNoFlag() const { + return data_.range(kVMProjZBinMSB,kVMProjZBinLSB+1); + } + VMPFINEZ getFineZ() const { return data_.range(kVMProjFineZMSB,kVMProjFineZLSB); } diff --git a/emData/download.sh b/emData/download.sh index ffb155405de..ff4d3c1a838 100755 --- a/emData/download.sh +++ b/emData/download.sh @@ -1,47 +1,16 @@ #!/usr/bin/env bash set -e -#### reduced config #### -#### https://github.com/trholmes/cmssw/tree/7fa70ef966862a47357263173e482bc102511037 #### -# 1 event -#memprints_url_reduced="https://cernbox.cern.ch/index.php/s/lzpcKjd1oekoYBI/download" -# 100 events -memprints_url_reduced="https://cernbox.cern.ch/index.php/s/LkVZR8WRYGPJcPe/download" -luts_url_reduced="https://cernbox.cern.ch/index.php/s/2zppC0iJ3eEy5C9/download" - -#### test 211005/211217 #### -# Standard configuration -#memprints_url="https://aryd.web.cern.ch/aryd/MemPrints_Standard_211005.tgz" -#luts_url="https://aryd.web.cern.ch/aryd/LUTs_Standard_211005.tgz" -# Combined modules -#memprints_url_cm="https://aryd.web.cern.ch/aryd/MemPrints_Combined_211217.tgz" -#luts_url_cm="https://aryd.web.cern.ch/aryd/LUTs_Combined_211217.tgz" - - - -#### fw_synch_210611 #### -# Standard configuration -memprints_url="https://cernbox.cern.ch/index.php/s/hUJUsqvCnKv2YdQ/download" -luts_url="https://cernbox.cern.ch/index.php/s/9Yms3LCKJsg7UmF/download" -# Combined modules -memprints_url_cm="https://cernbox.cern.ch/index.php/s/RFpmFiSnFC84x0O/download" -luts_url_cm="https://cernbox.cern.ch/index.php/s/kqZu8R7Ftu0YPoO/download" - -#### fw_synch_210503 #### +#### fw_synch_220220 #### # Standard configuration -#memprints_url="https://cernbox.cern.ch/index.php/s/CipX7CfTXIj1lcK/download" -#luts_url="https://cernbox.cern.ch/index.php/s/UDSvClVZksBr1Pq/download" +memprints_url="https://cernbox.cern.ch/index.php/s/7H3StfracwrVUAe/download" +luts_url="https://cernbox.cern.ch/index.php/s/SUd6tEO970wKNnZ/download" +# Reduced configuration +memprints_url_reduced="https://cernbox.cern.ch/index.php/s/qBKvAmfu83SpAGD/download" +luts_url_reduced="https://cernbox.cern.ch/index.php/s/GJZA1zLnWg3hP4y/download" # Combined modules -#memprints_url_cm="https://www.dropbox.com/s/lf088lvyvg2t6jh/MemPrintsCombined_210319.tgz?dl=0" -#luts_url_cm="https://www.dropbox.com/s/legrvm3gyu5hrth/LUTsCombined_210319.tgz?dl=0" - -#### fw_synch_201005 #### -#memprints_url="https://cernbox.cern.ch/index.php/s/y7IWeDG4x7Sg7Im/download" -#luts_url="https://cernbox.cern.ch/index.php/s/DuhCjcykSHZLRhM/download" - -#### fw_synch_200515 #### -#memprints_url="https://cernbox.cern.ch/index.php/s/QvV86Qcc8n9R4sg/download" -#luts_url="https://cernbox.cern.ch/index.php/s/YSER9ne7WVxiKXI/download" +memprints_url_cm="https://cernbox.cern.ch/index.php/s/YcqX3KUgFdZyMG6/download" +luts_url_cm="https://cernbox.cern.ch/index.php/s/lKrxzKJ0XmelE0j/download" # The following modules will have dedicated directories of test-bench files # prepared for them. @@ -151,32 +120,64 @@ declare -a processing_modules=( "ME_D5PHIC12" # MatchCalculator + "MC_L1PHIA" "MC_L1PHIB" - "MC_L2PHIB" - "MC_L3PHIB" - "MC_L4PHIB" - "MC_L5PHIB" - "MC_L6PHIB" "MC_L1PHIC" + "MC_L1PHID" + "MC_L1PHIE" + "MC_L1PHIF" + "MC_L1PHIG" + "MC_L1PHIH" + "MC_L2PHIA" + "MC_L2PHIB" "MC_L2PHIC" + "MC_L2PHID" + "MC_L3PHIA" + "MC_L3PHIB" "MC_L3PHIC" + "MC_L3PHID" + "MC_L4PHIA" + "MC_L4PHIB" "MC_L4PHIC" + "MC_L4PHID" + "MC_L5PHIA" + "MC_L5PHIB" "MC_L5PHIC" + "MC_L5PHID" + "MC_L6PHIA" + "MC_L6PHIB" "MC_L6PHIC" + "MC_L6PHID" # MatchProcessor + "MP_L1PHIA" "MP_L1PHIB" - "MP_L2PHIB" - "MP_L3PHIB" - "MP_L4PHIB" - "MP_L5PHIB" - "MP_L6PHIB" "MP_L1PHIC" + "MP_L1PHID" + "MP_L1PHIE" + "MP_L1PHIF" + "MP_L1PHIG" + "MP_L1PHIH" + "MP_L2PHIA" + "MP_L2PHIB" "MP_L2PHIC" + "MP_L2PHID" + "MP_L3PHIA" + "MP_L3PHIB" "MP_L3PHIC" + "MP_L3PHID" + "MP_L4PHIA" + "MP_L4PHIB" "MP_L4PHIC" + "MP_L4PHID" + "MP_L5PHIA" + "MP_L5PHIB" "MP_L5PHIC" + "MP_L5PHID" + "MP_L6PHIA" + "MP_L6PHIB" "MP_L6PHIC" + "MP_L6PHID" # TrackBuilder (aka FitTrack) "FT_L1L2" @@ -314,11 +315,6 @@ tar -xzf MemPrints.tgz mv MemPrints MemPrintsReduced rm -f MemPrints.tgz -### Ugly hack to remove initial "0x" from input stub test vectors, in order to -### be consistent with other sets of test vectors. -### FIXME: Remove after next FW sync -sed -i "s/^0x//g" MemPrintsReduced/InputStubs/InputStubs_*.dat - wget -O MemPrints.tgz --quiet ${memprints_url_cm} tar -xzf MemPrints.tgz mv MemPrints MemPrintsCM diff --git a/emData/generate_MP.py b/emData/generate_MP.py index fd0408a9f9b..514a09a00a3 100755 --- a/emData/generate_MP.py +++ b/emData/generate_MP.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # This script generates MatchProcessor_parameters.h, # MatchProcessorTop.h, and MatchProcessorTop.cc in the diff --git a/project/script_MC.tcl b/project/script_MC.tcl index 1f8c794ab3d..60fc409b7d1 100644 --- a/project/script_MC.tcl +++ b/project/script_MC.tcl @@ -7,7 +7,12 @@ source env_hls.tcl set modules_to_test { + {MC_L1PHIC} + {MC_L2PHIC} {MC_L3PHIC} + {MC_L4PHIC} + {MC_L5PHIC} + {MC_L6PHIC} } # module_to_export must correspond to the default macros set at the top of the # test bench; otherwise, the C/RTL cosimulation will fail diff --git a/project/script_MP.tcl b/project/script_MP.tcl index c1dbb15c5d2..f638dc642fd 100644 --- a/project/script_MP.tcl +++ b/project/script_MP.tcl @@ -7,12 +7,12 @@ source env_hls.tcl set modules_to_test { - {MP_L1PHIC} - {MP_L2PHIC} - {MP_L3PHIC} - {MP_L4PHIC} - {MP_L5PHIC} - {MP_L6PHIC} + {MP_L1PHIC} + {MP_L2PHIC} + {MP_L3PHIC} + {MP_L4PHIC} + {MP_L5PHIC} + {MP_L6PHIC} } # module_to_export must correspond to the default macros set at the top of the # test bench; otherwise, the C/RTL cosimulation will fail diff --git a/project/script_TC.tcl b/project/script_TC.tcl index 52553d91e53..9d18be20b6b 100644 --- a/project/script_TC.tcl +++ b/project/script_TC.tcl @@ -6,10 +6,6 @@ # get some information about the executable and environment source env_hls.tcl -# FIXME: debug following modules and add to list of modules to test: -# TC_L2L3D -# TC_L3L4C -# TC_L3L4D set modules_to_test { {TC_L1L2A} {TC_L1L2B} @@ -26,8 +22,11 @@ set modules_to_test { {TC_L2L3A} {TC_L2L3B} {TC_L2L3C} + {TC_L2L3D} {TC_L3L4A} {TC_L3L4B} + {TC_L3L4C} + {TC_L3L4D} {TC_L5L6A} {TC_L5L6B} {TC_L5L6C}