2016-11-05 47 views
0

我正在嘗試編寫一個過程,將給定電路中的每個強連接組件放入不同的子模塊中。如何將單元格列表放入yosys中的子模塊

所以,我試圖添加一個函數到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接受單元格的矢量(以及名稱子模塊)並將它們放入子模塊中。

回答

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 

我已經與folling test.v文件測試此:

module test(input A, B, output X, Y); 
assign X = (A & B)^X, Y = A | (B^Y); 
endmodule 

enter image description here

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. 
+0

我想我發現了一個錯誤在那裏。我在我的主要帖子中解釋了它。請讓我知道你是否想要更多的解釋或例子。 – Mehrdad

+0

@Mehrdad在其默認模式下,'scc'不考慮FF單元或分層單元,因此就'scc'而言,'up_counter'不包含循環。使用'-all_cell_types'來覆蓋(參見'help scc')。如果您希望找到使用'scc'跨越多個層次單元的邏輯循環,則可以展平您的設計(例如,使用'prep -flatten')。 – CliffordVienna

+0

我用-all_cell_types做到了。它沒有工作。 – Mehrdad

相關問題