3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-24 06:43:41 +00:00

Loop info

This commit is contained in:
Alain Dargelas 2024-11-21 11:24:00 -08:00
parent 179bd25235
commit dc9d61ed61

View file

@ -34,25 +34,25 @@ class DecorateLoopsVisitor : public VeriVisitor
~DecorateLoopsVisitor() {}; ~DecorateLoopsVisitor() {};
virtual void VERI_VISIT(VeriLoop, node) virtual void VERI_VISIT(VeriLoop, node)
{ {
//std::cout << "Loop in: " << (VeriLoop *)&node << " id: " << outerLoopId << std::endl; // std::cout << "Loop in: " << (VeriLoop *)&node << " id: " << outerLoopId << std::endl;
if (loopStack.empty()) { if (loopStack.empty()) {
// We increase the loop count when we enter a new set of imbricated loops, // We increase the loop count when we enter a new set of imbricated loops,
// That way we have a loop index for the outermost loop as we want to identify and group // That way we have a loop index for the outermost loop as we want to identify and group
// logic generated by imbricated loops // logic generated by imbricated loops
outerLoopId++; outerLoopId++;
} }
loopStack.push((VeriLoop *)&node); loopStack.push((VeriLoop *)&node);
} }
void PreAction(VeriTreeNode &/*node*/) void PreAction(VeriTreeNode & /*node*/)
{ {
//VeriNode *vnode = dynamic_cast<VeriNode *>(&node); // VeriNode *vnode = dynamic_cast<VeriNode *>(&node);
//std::cout << "Node pre: " << vnode << std::endl; // std::cout << "Node pre: " << vnode << std::endl;
} }
virtual void PostAction(VeriTreeNode &node) virtual void PostAction(VeriTreeNode &node)
{ {
//std::cout << "Node post: " << (VeriTreeNode *)&node << std::endl; // std::cout << "Node post: " << (VeriTreeNode *)&node << std::endl;
if (loopStack.size()) { if (loopStack.size()) {
if (loopStack.top() == (VeriLoop *)&node) { if (loopStack.top() == (VeriLoop *)&node) {
loopStack.pop(); loopStack.pop();
@ -60,11 +60,11 @@ class DecorateLoopsVisitor : public VeriVisitor
return; return;
} }
Verific::linefile_type linefile = (Verific::linefile_type)node.Linefile(); Verific::linefile_type linefile = (Verific::linefile_type)node.Linefile();
// Unfortunately there is no good way to systematically copy certain AST attributes to the Netlist attributes like: // Unfortunately there is no good way to systematically copy certain AST attributes to the Netlist attributes like:
//VeriNode *vnode = dynamic_cast<VeriNode *>(&node); // VeriNode *vnode = dynamic_cast<VeriNode *>(&node);
//vnode->AddAttribute(" in_loop", new VeriIntVal(outerLoopId)); // vnode->AddAttribute(" in_loop", new VeriIntVal(outerLoopId));
// Instead using linefile struct to pass that information: // Instead using linefile struct to pass that information:
if (linefile) if (linefile)
linefile->SetInLoop(outerLoopId); linefile->SetInLoop(outerLoopId);
} }
} }