Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:55

0001 /****************************************************************
0002  * MatchEngineUnit (MEU) is a single instance of the MatchEngine
0003  * section of the MatchProcessor (MP)
0004  * 
0005  * Manual pipelining is implemented to properly emulate the HLS
0006  * implementation (required to meet II=1)
0007  * 
0008  * A total of `nMatchEngines_` MEUs are used in the MP
0009  ****************************************************************/
0010 #ifndef L1Trigger_TrackFindingTracklet_interface_MatchEngineUnit_h
0011 #define L1Trigger_TrackFindingTracklet_interface_MatchEngineUnit_h
0012 
0013 #include "L1Trigger/TrackFindingTracklet/interface/VMStubsMEMemory.h"
0014 #include "L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h"
0015 #include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h"
0016 #include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h"
0017 
0018 #include <cassert>
0019 #include <vector>
0020 
0021 namespace trklet {
0022 
0023   class Settings;
0024   class Stub;
0025   class L1TStub;
0026   class TrackletLUT;
0027 
0028   class MatchEngineUnit {
0029   public:
0030     MatchEngineUnit(const Settings& settings, bool barrel, unsigned int layerdisk, const TrackletLUT& luttable);
0031 
0032     ~MatchEngineUnit() = default;
0033 
0034     void init(VMStubsMEMemory* vmstubsmemory,
0035               unsigned int nrzbin,
0036               unsigned int rzbin,
0037               unsigned int iphi,
0038               int shift,
0039               int projrinv,
0040               int projfinerz,
0041               int projfinephi,
0042               bool usefirstMinus,
0043               bool usefirstPlus,
0044               bool usesecondMinus,
0045               bool usesecondPlus,
0046               bool isPSseed,
0047               Tracklet* proj);
0048 
0049     bool empty() const { return candmatches_.empty(); }
0050 
0051     int TCID() const;
0052 
0053     std::pair<Tracklet*, const Stub*> read() { return candmatches_.read(); }
0054 
0055     std::pair<Tracklet*, const Stub*> peek() const { return candmatches_.peek(); }
0056 
0057     bool idle() const { return idle_; }
0058 
0059     bool active() const { return !idle_ || good__ || good____ || !empty(); }
0060 
0061     void setAlmostFull();
0062 
0063     void setimeu(int imeu) { imeu_ = imeu; }
0064 
0065     void setprint(bool print) { print_ = print; }
0066 
0067     void reset();
0068 
0069     unsigned int rptr() const { return candmatches_.rptr(); }
0070     unsigned int wptr() const { return candmatches_.wptr(); }
0071 
0072     void step();
0073 
0074     void processPipeline();
0075 
0076   private:
0077     //Provide access to constants
0078     const Settings& settings_;
0079 
0080     VMStubsMEMemory* vmstubsmemory_;
0081 
0082     unsigned int nrzbins_;
0083     unsigned int rzbin_, rzbin__, rzbin____, rzbin___;
0084     unsigned int phibin_;
0085     int shift_;
0086 
0087     unsigned int istub_;
0088     unsigned int iuse_;
0089 
0090     bool barrel_;
0091     int projrinv_;
0092     int projfinerz_;
0093     int projfinephi_;
0094     std::vector<std::pair<unsigned int, unsigned int>> use_;
0095     bool isPSseed_;
0096     Tracklet* proj_;
0097 
0098     bool idle_;
0099 
0100     unsigned int layerdisk_;
0101 
0102     //The minimum radius for 2s disks in projection bins
0103     unsigned int ir2smin_;
0104 
0105     //Save state at the start of istep
0106     bool almostfullsave_;
0107 
0108     //LUT for bend consistency with rinv
0109     const TrackletLUT& luttable_;
0110 
0111     //Various manually pipelined variables
0112     //Each _ represents a layer of pipelining
0113     //e.g., good__ is set and one iteration later good____ is updated
0114     VMStubME vmstub__, vmstub___, vmstub____;
0115     bool isPSseed__, isPSseed___, isPSseed____;
0116     bool good__, good___, good____;
0117     int projfinerz__, projfinerz___, projfinerz____;
0118     int projfinephi__, projfinephi___, projfinephi____;
0119     int projrinv__, projrinv___, projrinv____;
0120     Tracklet *proj__, *proj___, *proj____;
0121 
0122     //save the candidate matches
0123     CircularBuffer<std::pair<Tracklet*, const Stub*>> candmatches_;
0124 
0125     //debugging help
0126     int imeu_;
0127     bool print_;
0128   };
0129 
0130 };  // namespace trklet
0131 #endif