Skip to content

Commit

Permalink
remove extra copy of ELINKS.ALIGN
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeichlersmith committed Apr 11, 2022
1 parent 853e136 commit 6fb7bcf
Showing 1 changed file with 0 additions and 94 deletions.
94 changes: 0 additions & 94 deletions tool/pftool_elinks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,100 +167,6 @@ void elinks( const std::string& cmd, PolarfireTarget* pft )
n_good_idles[ilink], n_bad_idles[ilink], bg_idles);
}
}
if (cmd=="ALIGN") {
nevents=10;

int delay_step = BaseMenu::readline_int("Delay step: ",delay_step);

int nsamples=1;
{
bool multi;
int nextra;
pft->hcal.fc().getMultisampleSetup(multi,nextra);
if (multi) nsamples=nextra+1;
}

int bitslip_candidate[8] = {0,0,0,0,0,0,0,0};
int delay_candidate[8] = {0,0,0,0,0,0,0,0};
int record_bx[8] = {0,0,0,0,0,0,0,0};
int record_idle[8] = {0,0,0,0,0,0,0,0};

pft->prepareNewRun();

for(int bitslip = 0; bitslip <= 7; bitslip += 1){
std::cout << "Scanning bitslip: " << bitslip << std::endl;
for(int delay = 0; delay <= 128; delay += delay_step){
for(int jlink = 0; jlink < 8; jlink++){
elinks.setDelay(jlink,delay);
elinks.setBitslipAuto(jlink,false);
elinks.setBitslip(jlink,bitslip);
}
int n_good_bxheaders[8] = {0,0,0,0,0,0,0,0};
int n_bad_bxheaders[8] = {0,0,0,0,0,0,0,0};
int n_good_idles[8] = {0,0,0,0,0,0,0,0};
int n_bad_idles[8] = {0,0,0,0,0,0,0,0};
for (int ievt{0}; ievt < nevents; ievt++) {
pft->backend->fc_sendL1A();
std::vector<uint32_t> event_raw = pft->daqReadEvent();
pflib::decoding::SuperPacket event{&(event_raw[0]), int(event_raw.size())};
for (int s{0}; s < nsamples; s++) {
for(int jlink = 0; jlink < 8; jlink++){
auto packet = event.sample(s).roc(jlink);
if (packet.length() > 2) {
if (event.sample(s).roc(jlink).good_bxheader()) n_good_bxheaders[jlink]++;
else n_bad_bxheaders[jlink]++;
if (event.sample(s).roc(jlink).good_idle()) n_good_idles[jlink]++;
else n_bad_idles[jlink]++;
}
}
}
}
for(int i = 0; i < 8; i++){
if(n_good_idles[i] >= record_idle[i] && n_good_bxheaders[i] >= record_bx[i]){
record_bx[i] = n_good_bxheaders[i];
record_idle[i] = n_good_idles[i];
bitslip_candidate[i] = bitslip;
delay_candidate[i] = delay;
}
}

/*
for(int jlink = 0; jlink < 8; jlink++){
std::cout << n_good_bxheaders[jlink] << ":" << n_good_idles[jlink] << " ";
}
std::cout << std::endl;
*/
}
}
std::cout << "Candidates" << std::endl;
for(int i = 0; i < 8; i++){
std::cout << "Link " << i << std::endl;
std::cout << "Bitslip: " << bitslip_candidate[i] << " Delay: " << delay_candidate[i] << std::endl;

elinks.setDelay(i,delay_candidate[i]);
elinks.setBitslipAuto(i,false);
elinks.setBitslip(i,bitslip_candidate[i]);

float bg_bxheaders = 1.;
int bad_bxheaders = nsamples*nevents-record_bx[i];
if (record_bx[i]>0)
bg_bxheaders = float(bad_bxheaders)/
(record_bx[i]+bad_bxheaders);
std::cout << "Percentage of bad BX headers: " << bg_bxheaders*100. << std::endl;
if(bg_bxheaders > 0.1){
std::cout << "Consider a PLL hard_reset" << std::endl;
}
float bg_idles = 1.;
int bad_idles = nsamples*nevents-record_idle[i];
if (record_idle[i]>0)
bg_idles = float(bad_idles)/
(record_idle[i]+bad_idles);
std::cout << "Percentage of bad idles: " << bg_idles*100. << std::endl;
if(bg_idles > 0.1){
std::cout << "Consider a PLL hard_reset" << std::endl;
}
}
}
if (cmd=="BITSLIP") {
ilink=BaseMenu::readline_int("Which elink? ",ilink);
int bitslip=BaseMenu::readline_int("Bitslip value (-1 for auto): ",elinks.getBitslip(ilink));
Expand Down

0 comments on commit 6fb7bcf

Please sign in to comment.