src/CodeGen_CoreHLS.cpp
// Heuristic method to hit the critical path: Add a register in front of
// every operation that has a critical path that is "large", meaning at
// least 1/3 of the critical path in this case
Heuristic method to hit the critical path: Add a register in front of
every operation that has a critical path that is "large", meaning at
least 1/3 of the critical path in this case
Heuristic method to hit the critical path : Add a register in front of every operation that has a critical path that is " large " meaning at least 1 / 3 of the critical path in this case
void insertCriticalPathTargetRegisters(HardwareInfo& hwInfo, HWFunction& f) {
  if (!hwInfo.hasCriticalPathTarget) {
    return;
  }
  int cp = hwInfo.criticalPathTarget;
  set<HWInstr*> delayInsertionSites;
  for (auto instr : f.structuredOrder()) {
    if (hwInfo.criticalPath(instr->name) > (cp / 3)) {
      delayInsertionSites.insert(instr);
    }
  }
  std::map<HWInstr*, HWInstr*> delayRegister;
  for (auto s : delayInsertionSites) {
    auto delay = f.newI();
    delay->name = "delay";
    delay->latency = 1;
    delay->surroundingLoops = s->surroundingLoops;
    delay->resType = f.mod->getContext()->Bit()->Arr(16);
    delayRegister[s] = delay;
  }
  for (auto s : delayRegister) {
    f.insertAfter(s.first, s.second);
    f.replaceAllUsesWith(s.first, s.second);
  }
  for (auto s : delayRegister) {
    s.second->operands.push_back(s.first);
  }
  if (delayRegister.size() > 0) {
    cout << "Function after delay register insertion..." << endl;
    cout << f << endl;
  }
}
void insertCriticalPathTargetRegisters ( HardwareInfo & hwInfo , HWFunction & f ) { if ( ! hwInfo . hasCriticalPathTarget ) { return ; } int cp = hwInfo . criticalPathTarget ; set < HWInstr * > delayInsertionSites ; for ( auto instr : f . structuredOrder ( ) ) { if ( hwInfo . criticalPath ( instr -> name ) > ( cp / 3 ) ) { delayInsertionSites . insert ( instr ) ; } } std :: map < HWInstr * , HWInstr * > delayRegister ; for ( auto s : delayInsertionSites ) { auto delay = f . newI ( ) ; delay -> name = " " ; delay -> latency = 1 ; delay -> surroundingLoops = s -> surroundingLoops ; delay -> resType = f . mod -> getContext ( ) -> Bit ( ) -> Arr ( 16 ) ; delayRegister [ s ] = delay ; } for ( auto s : delayRegister ) { f . insertAfter ( s . first , s . second ) ; f . replaceAllUsesWith ( s . first , s . second ) ; } for ( auto s : delayRegister ) { s . second -> operands . push_back ( s . first ) ; } if ( delayRegister . size ( ) > 0 ) { cout << " " << endl ; cout << f << endl ; } }
Heuristic method to hit the critical path: Add a register in front of
every operation that has a critical path that is "large", meaning at
least 1/3 of the critical path in this case
Heuristic method to hit the critical path : Add a register in front of every operation that has a critical path that is " large " meaning at least 1 / 3 of the critical path in this case
// Now: For each delay register: insert it after its replacement // then: replace all uses of target with delay register // then: connect each delay