0

我正在尝试编写一个程序,将给定电路的每个强连接组件放入一个不同的子模块中。

因此,我尝试在 Yosys 中向 SCC 传递添加一个函数,以将每个 SCC 添加到子模块中。功能是:

  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 接受单元向量(以及名称子模块)并将它们放入子模块中。

4

1 回答 1

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.
于 2016-11-05T23:17:40.653 回答