Skip to content

Commit

Permalink
MP HLS agreement fixes (cms-sw#126)
Browse files Browse the repository at this point in the history
* Fixing `zmatchcut_` for L1 and L2

* Undo the -0.06 in Settings.h as there is a cleaner fix to the overflows

* Fixes to get agreement with HLS code

* fixing integer range check in FPGAWord.

* Fixing `zmatchcut_` for L1 and L2

* Undo the -0.06 in Settings.h as there is a cleaner fix to the overflows

* Slight rewerite to use <= instead < and not do subtracktion

Co-authored-by: Brent R. Yates <brentRyates@gmail.com>
Co-authored-by: Thomas Schuh <thomas.schuh@stfc.ac.uk>
  • Loading branch information
3 people authored and tomalin committed Jun 10, 2022
1 parent 6a517a5 commit 4390d90
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
9 changes: 8 additions & 1 deletion L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ namespace trklet {
bool usesecondPlus,
bool isPSseed,
Tracklet* proj,
bool print);
bool print,
int imeu);

bool empty() const { return candmatches_.empty(); }

Expand All @@ -55,6 +56,8 @@ namespace trklet {
//needed for consistency with HLS FW version ("_" vs "__" indicating different pipelining stages)
bool have_() const { return havepair_; }

void setAlmostFull();

void reset();

unsigned int rptr() const { return candmatches_.rptr(); }
Expand All @@ -69,6 +72,7 @@ namespace trklet {
unsigned int rzbin_;
unsigned int phibin_;
int shift_;
int imeu_;

unsigned int istub_;
unsigned int iuse_;
Expand All @@ -85,6 +89,9 @@ namespace trklet {

unsigned int layerdisk_;

//Save state at the start of istep
bool almostfullsave_;

//LUT for bend consistency with rinv
const TrackletLUT& luttable_;

Expand Down
11 changes: 8 additions & 3 deletions L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory,
bool usesecondPlus,
bool isPSseed,
Tracklet* proj,
bool print) {
bool print,
int imeu) {
vmstubsmemory_ = vmstubsmemory;
idle_ = false;
imeu_ = imeu;
nrzbins_ = nrzbins;
rzbin_ = rzbin;
phibin_ = phibin;
Expand Down Expand Up @@ -69,8 +71,11 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory,
goodpair_ = false;
}

void MatchEngineUnit::setAlmostFull() {
almostfullsave_ = candmatches_.nearfull();
}

void MatchEngineUnit::step(bool print) {
bool almostfull = candmatches_.nearfull();

if (goodpair_) {
if (print)
Expand All @@ -82,7 +87,7 @@ void MatchEngineUnit::step(bool print) {
havepair_ = false;
goodpair_ = false;

if (idle() || almostfull)
if (idle() || almostfullsave_)
return;

unsigned int slot = (phibin_ + use_[iuse_].second) * nrzbins_ + rzbin_ + use_[iuse_].first;
Expand Down
16 changes: 10 additions & 6 deletions L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) {

/*
The code is organized in three 'steps' corresponding to the PR, ME, and MC functions. The output from
the PR step is buffered in a 'circular' buffer, and similarly the ME output is put in a circular buffer.
the PR step is buffered in a 'circular' buffer, and similarly the ME output is put in a circular buffer.
The implementation is done in steps, emulating what can be done in firmware. One each step we do:
1) A projection is read and if there is space it is insert into the inputProjBuffer_
Expand Down Expand Up @@ -192,7 +191,6 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) {
for (auto& matchengine : matchengines_) {
cout <<" MEU"<<iMEU<<": "<<matchengine.rptr()<<" "<<matchengine.wptr()
<<" "<<matchengine.idle()<<" "<<matchengine.empty()
<<" "<<matchengine.have_()<<matchengine.have__()
<<" "<<matchengine.TCID();
iMEU++;
}
Expand All @@ -202,6 +200,10 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) {

bool projdone = false;

for (unsigned int iME = 0; iME < nMatchEngines_; iME++) {
matchengines_[iME].setAlmostFull();
}

//Step 3
//Check if we have candidate match to process

Expand Down Expand Up @@ -276,7 +278,9 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) {
tmpProj.use(1, 1),
tmpProj.isPSseed(),
tmpProj.proj(),
print);
print,
iME);
meactive = true;
addedProjection = true;
} else {
matchengines_[iME].step(print);
Expand Down Expand Up @@ -313,7 +317,7 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) {
int nextrabits = 2;
int overlapbits = nvmbits_ + nextrabits;

unsigned int extrabits = fpgaphi.bits(fpgaphi.nbits() - overlapbits, nextrabits);
unsigned int extrabits = fpgaphi.bits(fpgaphi.nbits() - overlapbits - nextrabits, nextrabits);

unsigned int ivmPlus = iphi;

Expand Down Expand Up @@ -416,7 +420,7 @@ void MatchProcessor::execute(unsigned int iSector, double phimin) {
//
//

if ((projdone && !meactive) || (istep == settings_.maxStep("MP") - 1)) {
if ((projdone && !meactive && inputProjBuffer_.rptr()==inputProjBuffer_.wptr() ) || (istep == settings_.maxStep("MP") - 1)) {
if (settings_.writeMonitorData("MP")) {
globals_->ofstream("matchprocessor.txt") << getName() << " " << istep << " " << countall << " " << countsel
<< " " << countme << " " << countinputproj << endl;
Expand Down

0 comments on commit 4390d90

Please sign in to comment.