2015-12-09 39 views
1

在UVM測試中,我聲明並啓動序列,但具有相同參數的單獨序列的輸出在某種程度上是「相關的」(請參見底部的示例),所以當我只進行交叉覆蓋時,覆蓋率12.5%,這是什麼原因造成的?我怎樣才能使兩個序列的輸出獨立和隨機?生成相關數字的UVM序列

//declare 
ve_master_sequence#(8,`num_inputs) x_agent_sequence_inst; 
ve_master_sequence#(8,`num_inputs) y_agent_sequence_inst; 
//build_phase 
x_agent_sequence_inst = ve_master_sequence#(8,`num_inputs)::type_id::create("x_seq"); 
y_agent_sequence_inst = ve_master_sequence#(8,`num_inputs)::type_id::create("y_seq"); 
//run_phase 
x_agent_sequence_inst.start(multadd_env_inst.ve_x_agent_inst.sequencer); 
y_agent_sequence_inst.start(multadd_env_inst.ve_y_agent_inst.sequencer); 

該環境包含4個主代理,兩個32位,兩個8位。同樣的參數順序上的所有代理

// within the sequence 
virtual task body(); 
    `uvm_info("ve_master_sequence", $sformatf("begin body()"), UVM_MEDIUM); 
    for(int i=0; i<length; i++) begin 
    req = ve_seq_item#(data_width)::type_id::create("req"); 
    start_item(req); 

    while(!req.randomize() with { 
    data <= (2**data_width)-1; 
    delay dist { [0:1] := 2, [2:6] := 1}; 
    }); 

    finish_item(req); 
    get_response(req); 
    end 
    #1000; 
endtask 

運行我更換了req.randomize()與urandom_range $,這工作,但它意味着失去的SystemVerilog的所有約束的隨機能力。

當我運行代碼,並做交叉覆蓋有是大小相同的音序器的輸出之間的關係,

when y = 0 is always x = 79 or 80 
when y = 1 is always x = 80 or 81 
when y = 2 is always x = 81 or 82 
.... 
when y = 51 is always x = 130 or 131 
when y = 52 is always x = 131 or 132 

等。

+0

問題是什麼?請澄清。 – Hida

+2

ve_seq_item類中是否有任何約束? 嘗試用'if(reg.randomize()...)else'uvm_error(...)''切換出'while(!req.randomize()...',這會報告任何錯誤,而不是在if循環中卡住 – Hida

+0

「if」更改沒有報告任何錯誤,但也許這是一個線索,如果我更改序列的變量名稱,序列輸出的數字之間的關係發生變化,感謝評論 – StanOverflow

回答

1

顯然UVM使用其父隨機數字發生器和序列name爲序列創建一個新的RNG。這是給予好的random stability

嘗試更改序列的名稱以使它們更獨特。我假設更長的獨特字符串給予更高程度的隨機化。

0

序列類內部是這個循環創建序列項目。解釋是(如上所述)UVM使用類層次來創建隨機種子,這給出了很好的隨機穩定性

for(int i=0; i<1000; i++) begin 
    //this caused the error 
    req = ve_seq_item#(data_width)::type_id::create("req"); 

    //this fixed it 
    req = ve_seq_item#(data_width)::type_id::create($sformatf("req_%1d", i)); 
    //randomizing the sequence item with the loop variable