0
我目前正試圖在UVM中隨機化約束32位地址。 有沒有辦法讓我限制地址的特定位?特定位的UVM約束
rand bit [31:0] addr;
// last two bits should always be zero
req.randomize() with { addr[1:0] == 2'b00; };
我目前正試圖在UVM中隨機化約束32位地址。 有沒有辦法讓我限制地址的特定位?特定位的UVM約束
rand bit [31:0] addr;
// last two bits should always be zero
req.randomize() with { addr[1:0] == 2'b00; };
是的,有辦法限制地址的特定位。
一種方法是像您那樣使用randomize with
。
另一種方法是在class
內部創建一個constraint
塊。例如:
class foo;
rand bit [31:0] addr;
constraint c1 { addr[1:0] == 2'b00; }
endclass
module tb;
foo req = new();
initial begin
repeat (5) begin
req.randomize();
$display(req.addr, " ", req.addr[1:0]);
end
end
endmodule
/*
Output:
3053944240 0
2417184000 0
629780252 0
469272576 0
1715295476 0
*/
該代碼看起來不錯。你有什麼問題? – toolic
該代碼應該工作。你也可以使用下面的'req.randomize(); loc_addr = {req.addr [31:2],2'b00}'這是粗糙的方式,但總是會起作用。 – vjain419