【问题标题】:How to put a list of cells into a submodule in yosys如何将单元列表放入yosys中的子模块
【发布时间】:2016-11-09 00:11:17
【问题描述】:

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

所以,我尝试在 Yosys 中向 SCC pass 添加一个函数,以将每个 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 接受单元向量(以及名称子模块)并将它们放入子模块中。

【问题讨论】:

    标签: yosys


    【解决方案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="&lt;name&gt;" 属性来做到这一点。然后只需运行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.
    

    【讨论】:

    • 我想我在那里发现了一个错误。我在我的主要帖子中解释了它。如果您需要更多解释或示例,请告诉我。
    • @Mehrdad 在其默认模式下,scc 不考虑 FF 单元或分层单元,因此就 scc 而言,您的 up_counter 不包含循环。使用-all_cell_types 覆盖(请参阅help scc)。如果您想使用 scc 找到跨越多个分层单元的逻辑循环,请展平您的设计(例如使用 prep -flatten)。
    • @Mehrdad 我确实尝试过,它在这里工作得很好。请编辑您的问题并说明您到底在做什么、预期的结果是什么以及您得到的结果与此有何不同。
    • 我已经更新了我的帖子并添加了我正在采取的步骤的更多详细信息。 (这是由最新的 yosys 完成的)。非常感谢您的帮助。
    • 我的错。对不起!下次我会遵守stackoverflow的规则。我会把它作为一个新问题发布。并将这个收回到原来的那个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-29
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 2013-07-26
    • 1970-01-01
    相关资源
    最近更新 更多