我正在尝试编写一个程序,将给定电路的每个强连接组件放入一个不同的子模块中。
所以,我尝试在Yosys中添加一个SCC传递函数,将每个SCC添加到submod中。功能是:
void putSelectionIntoParition (RTLIL::Design *design,
std::vector<pair<std::string,RTLIL::Selection>>& SelectionVector)
{
int p_count = 0;
for (std::vector<pair<std::string,RTLIL::Selection>>::iterator it = SelectionVector.begin();
it != SelectionVector.end(); ++it)
{
design->selection_stack[0] = it->second;
design->selection_stack[0].optimize(design);
std::string command = "submod -name ";
command.append(it->first);
Pass::call_on_selection(design, it->second, command);
++p_count;
}
}
但是,我的代码无法正常运行。 我想问题是我使用的“选择”过程。我想知道yosys源中是否有任何实用程序/ API接受单元格的向量(以及名称子模块)并将它们放入子模块中。
答案 0 :(得分:1)
以下应该可以正常工作:
void putSelectionIntoParition(RTLIL::Design *design,
std::vector<pair<std::string, RTLIL::Selection>> &SelectionVector)
{
for (auto it : SelectionVector) {
std::string command = "submod -name " + it.first;
Pass::call_on_selection(design, it.second, command);
}
}
您绝对不需要(也不应该)修改selection_stack
。
我想知道yosys源中是否有任何实用程序/ API接受单元格的向量(以及名称子模块)并将它们放入子模块中。
您可以通过在单元格上设置submod="<name>"
属性来执行此操作。然后只需运行submod
命令。
您可能已经看到scc
文档提到了尚未实现的-set_attr
选项。我现在在提交ef603c6
中实现了此选项(提交914aa8a
包含scc
的错误修正。)
使用此功能,您现在可以使用以下yosys脚本完成所描述的内容。
read_verilog test.v
prep
scc -set_attr submod scc{}
submod
show test
我已使用后续test.v
文件对此进行了测试:
module test(input A, B, output X, Y);
assign X = (A & B) ^ X, Y = A | (B ^ Y);
endmodule
3. Executing SCC pass (detecting logic loops).
Found an SCC: $xor$test.v:2$2
Found an SCC: $or$test.v:2$4 $xor$test.v:2$3
Found 2 SCCs in module test.
Found 2 SCCs.