Commit eb93db5d authored by dauncey's avatar dauncey

Add more HGCROC paras and 32-bit buffering

parent af9d65b5
......@@ -34,9 +34,9 @@ public:
hTotalChannels=new TH1D((sout.str()+"TotalChannels").c_str(),
";ECON total number of channels",1300,0,1300);
hTotalWords=new TH1D((sout.str()+"TotalWords").c_str(),
";ECON total number of words",1000,0,1000);
*/
hTotalEventWords=new TH1D((sout.str()+"TotalEventWords").c_str(),
";Total number of bytes per event",250,0,4000);
const SlinkArch &slinkArch(*(fBeSlinkSim->fSlinkArch));
for(unsigned e(0);e<slinkArch.numberOfEcons();e++) {
......@@ -96,6 +96,10 @@ public:
hEventBufferUsedHistory[e][b]->Fill(bx,fBeSlinkSim->fEventBuffer[e][b].used());
}
}
if(fBeSlinkSim->fL1AcceptEoe) {
hTotalEventWords->Fill(16*fBeSlinkSim->fTotalNumberOfEventWords);
}
}
void eoj() {
......@@ -118,6 +122,8 @@ private:
//TH1D *hBlockTotalChannels[7];
//TH1D *hBlockTotalWords[7];
TH1D *hTotalEventWords;
TH1D *hEventBufferUsed[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
TH1I *hEventBufferUsedHistory[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
};
......
......@@ -5,7 +5,7 @@
#include <iomanip>
#include <cassert>
#include "Buffering/CircularBufferUR.hh"
#include "Buffering/CircularBufferUR32.hh"
#include "Buffering/SlinkBoe.hh"
#include "Buffering/SlinkEoe.hh"
#include "Buffering/SlinkArch.hh"
......@@ -73,29 +73,34 @@ public:
uint64_t d[2];
SlinkBoe sBoe(0xce00,bx&0xffffffff,l1a&0xffffffff,0xab);
sBoe.words(d);
assert(fSlinkBoeCb.writeAndIncrementPtr(d[0]));
assert(fSlinkBoeCb.writeAndIncrementPtr(d[1]));
if(fPrintLevel>4) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processL1Accept(" << bx << "," << l1a << ") "
<< "Saving Slink BOE" << std::endl;
sBoe.print();
}
assert(fSlinkBoeCb.writeAndIncrementPtr(d[0]));
assert(fSlinkBoeCb.writeAndIncrementPtr(d[1]));
}
void processBx(uint64_t bx, const SlinkElinkData &d) {
//#define OLD_METHOD
#ifdef OLD_METHOD
if((bx%2)==0) {
fSlinkElinkData=d;
} else {
uint64_t word,word2;
#endif
for(unsigned e(0);e<fSlinkArch->numberOfEcons();e++) {
const EconArch &econArch(fSlinkArch->econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
const std::vector<unsigned> &elinkNumber(econArch.elinkNumber(b));
#ifdef OLD_METHOD
unsigned eo(0);
for(unsigned w(0);w<elinkNumber.size();w++) {
if((eo%2)==0) {
......@@ -138,6 +143,13 @@ public:
*/
}
#else
uint32_t word;
for(unsigned w(0);w<elinkNumber.size();w++) {
word=d.fData[e][elinkNumber[w]];
if(word!=0 || fEventBuffer[e][b].isCachedWriteWord()) assert(fEventBuffer[e][b].halfWriteAndIncrementPtr(word));
}
#endif
......@@ -147,6 +159,9 @@ public:
// Output to Slink
fL1AcceptBoe=false;
fL1AcceptEoe=false;
bool done(false);
uint128_t w;
fNumberOfSlinkWords=0;
......@@ -177,7 +192,8 @@ public:
fBlockRead=0;
fNumberOfEventWords=0;
fEventActive=true;
fL1AcceptBoe=true;
} else {
done=true;
}
......@@ -196,10 +212,20 @@ public:
}
fEventActive=false;
fL1AcceptEoe=true;
fTotalNumberOfEventWords=fNumberOfEventWords;
} else {
if(fPrintLevel>4) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() "
<< "Reading from ECON " << fEconRead
<< ", block " << fBlockRead
<< std::endl;
}
for(unsigned i(0);/*i<4 &&*/ !done && fEconRead<fSlinkArch->numberOfEcons() && fArrayWrite<4;i++) {
#ifdef OLD_METHOD
if(!(fEventBuffer[fEconRead][fBlockRead].empty() && fBlockPair[fEconRead][fBlockRead].first)) {
uint32_t nextWord(0);
......@@ -217,19 +243,21 @@ public:
//fArrayWord[fArrayWrite ]=(d&0xffffffff);
//fArrayWord[fArrayWrite+1]=(d>>32);
//fArrayWrite+=2;
#else
if(!fEventBuffer[fEconRead][fBlockRead].unreadable()) {
uint32_t nextWord(0);
assert(fEventBuffer[fEconRead][fBlockRead].halfReadAndIncrementPtr(nextWord));
#endif
if(nextWord!=0) {
fArrayWord[fArrayWrite]=nextWord;
fArrayWrite++;
if(fPrintLevel>5) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() "
<< "Read buffer words = 0x" << std::hex
//<< fArrayWord[fArrayWrite-2] << " "
<< fArrayWord[fArrayWrite-1]
<< std::dec << std::endl;
<< nextWord << std::dec << std::endl;
}
fArrayWord[fArrayWrite]=nextWord;
fArrayWrite++;
if(fBlockCheck[fEconRead][fBlockRead].processBx(fArrayWord[fArrayWrite-1])) fBlockRead++;
if(fBlockRead==fSlinkArch->econArch(fEconRead).numberOfBlocks()) {
......@@ -241,6 +269,11 @@ public:
}
} else {
if(fPrintLevel>5) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() "
<< "Nothing in buffer" << std::endl;
}
done=true;
}
}
......@@ -478,12 +511,15 @@ private:
EconArch fEconArch;
bool fL1AcceptBoe;
bool fL1AcceptEoe;
//unsigned fNumberOfHgcrocs;
//double fHgcrocMean[18];
//unsigned fHgcrocToElink[18];
CircularBufferUR<1> fElink[7];
CircularBufferUR<16> fEventBuffer[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
//CircularBufferUR32<1> fElink[7];
CircularBufferUR32<16> fEventBuffer[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
//PartitionedBuffer<7,16> fPartitionedBuffer[5];
//unsigned fNumberOfChannels[18];
......@@ -495,6 +531,7 @@ private:
unsigned fArrayWrite;
uint32_t fArrayWord[4];
unsigned fNumberOfEventWords;
unsigned fTotalNumberOfEventWords;
BlockCheck fBlockCheck[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
std::pair<bool,uint32_t> fBlockPair[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
......
#ifndef CircularBufferUR_HH
#define CircularBufferUR_HH
// Write pointer points to next location to write to
// Read pointer points to next location to read from
#include "MultipleUltraRam.hh"
#include "CircularBuffer.hh"
template <unsigned NumberOfUltraRams>
class CircularBufferUR {
class CircularBufferUR : public CircularBuffer<uint64_t> {
public:
enum {
CircularBufferURLength=NumberOfUltraRams*UltraRam::UltraRamBufferLength
};
CircularBufferUR() {
reset();
}
bool writeAndIncrementPtr(uint64_t d) {
if(((fWritePtr+1)%CircularBufferURLength)==fReadPtr) return false;
fMultipleUltraRam.write(fWritePtr,d);
fWritePtr++;
if(fWritePtr>=CircularBufferURLength) fWritePtr-=CircularBufferURLength;
return true;
}
bool read(uint64_t& d) const {
if(fReadPtr==fWritePtr) return false;
d=fMultipleUltraRam.read(fReadPtr);
return true;
}
bool incrementReadPtr() {
if(fReadPtr==fWritePtr) return false;
fReadPtr++;
if(fReadPtr>=CircularBufferURLength) fReadPtr-=CircularBufferURLength;
return true;
}
bool readAndIncrementPtr(uint64_t& d) {
if(!read(d)) return false;
return incrementReadPtr();
CircularBufferUR() : CircularBuffer<uint64_t>(4096*NumberOfUltraRams) {
}
unsigned space() const {
if(fWritePtr<fReadPtr) return fReadPtr-fWritePtr-1;
return fReadPtr+CircularBufferURLength-fWritePtr-1;
}
unsigned used() const {
if(fReadPtr<=fWritePtr) return fWritePtr-fReadPtr;
return fWritePtr+CircularBufferURLength-fReadPtr;
}
bool empty() const {
return fWritePtr==fReadPtr;
}
void reset() {
fWritePtr=0;
fReadPtr=0;
}
private:
MultipleUltraRam<NumberOfUltraRams> fMultipleUltraRam;
unsigned fWritePtr;
unsigned fReadPtr;
};
#endif
#ifndef CircularBufferUR32_HH
#define CircularBufferUR32_HH
#include "CircularBufferUR.hh"
template <unsigned NumberOfUltraRams>
class CircularBufferUR32 : public CircularBufferUR<NumberOfUltraRams> {
public:
enum {
writeValue,
readValue
};
CircularBufferUR32() {
fIsCachedWord[0]=false;
fIsCachedWord[1]=false;
}
bool halfWriteAndIncrementPtr(const uint32_t &d) {
if(!fIsCachedWord[writeValue]) {
fIsCachedWord[writeValue]=true;
fCachedWord[writeValue]=d;
return true;
}
uint64_t value=d;
value=(value<<32)+fCachedWord[writeValue];
if(!this->writeAndIncrementPtr(value)) return false;
fIsCachedWord[writeValue]=false;
return true;
}
bool halfReadAndIncrementPtr(uint32_t &d) {
if(fIsCachedWord[readValue]) {
fIsCachedWord[readValue]=false;
d=fCachedWord[readValue];
return true;
}
uint64_t value;
if(!this->readAndIncrementPtr(value)) return false;
d=(value&0xffffffff);
fIsCachedWord[readValue]=true;
fCachedWord[readValue]=(value>>32);
return true;
}
bool isCachedWriteWord() const {
return fIsCachedWord[writeValue];
}
bool isCachedReadWord() const {
return fIsCachedWord[readValue];
}
bool unreadable() const {
return (this->empty() && !fIsCachedWord[readValue]);
}
private:
bool fIsCachedWord[2];
uint32_t fCachedWord[2];
};
#endif
......@@ -114,7 +114,9 @@ public:
<< " = " << std::setw(10) << std::setfill(' ')
<< fEventDump[i] << " = 0x"
<< std::hex << std::setw(8) << std::setfill('0')
<< fEventDump[i] << std::dec << std::endl;
<< fEventDump[i] << std::dec;
if(fEventDump[i]==0) std::cout << " <<<=======";
std::cout << std::endl;
}
std::cout << std::endl;
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment