Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP HLS agreement fixes #126

Merged
merged 7 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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