Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-14 01:43:59

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_;
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     //Save state at the start of istep
0103     bool almostfullsave_;
0104 
0105     //LUT for bend consistency with rinv
0106     const TrackletLUT& luttable_;
0107 
0108     //Various manually pipelined variables
0109     //Each _ represents a layer of pipelining
0110     //e.g., good__ is set and one iteration later good___ is updated
0111     VMStubME vmstub__, vmstub___;
0112     bool isPSseed__, isPSseed___;
0113     bool good__, good___;
0114     int projfinerz__, projfinerz___;
0115     int projfinephi__, projfinephi___;
0116     int projrinv__, projrinv___;
0117     Tracklet *proj__, *proj___;
0118 
0119     //save the candidate matches
0120     CircularBuffer<std::pair<Tracklet*, const Stub*>> candmatches_;
0121 
0122     //debugging help
0123     int imeu_;
0124     bool print_;
0125   };
0126 
0127 };  // namespace trklet
0128 #endif