aputcha Posted November 15, 2011 Report Share Posted November 15, 2011 class txn; rand int size; rand int length; rand bit [31:0] addr; end class class my_seq extends base_seq rand bit [31:0] total_bytes; <----------------- this is a local variable virtual task body() for (int i=1; i< sequence_length; i++) begin `uvm_do_with(req, { size inside {0, 1, 2}; length inside {[0:15]}; total_bytes == ((1<<size) * (length+1)); <----------------- gives constraint inconsistancy failure }) end // for loop endtask: body endclass: my_seq Quote Link to comment Share on other sites More sharing options...
rafael.shirakawa Posted November 15, 2011 Report Share Posted November 15, 2011 (edited) Here is my suggestion: class txn; rand int size; rand int length; rand bit [31:0] addr; end class class my_seq extends base_seq rand bit [31:0] total_bytes; virtual task body() for (int i=1; i< sequence_length; i++) begin `uvm_create(req) void'(req.randomize() with { size inside {0, 1, 2}; length inside {[0:15]}; `uvm_send (req) void'(this.randomize() with { (total_bytes == ((1<<req.size) * (req.length+1));} end // for loop endtask: body endclass: my_seq Edited November 26, 2011 by rafael.shirakawa Quote Link to comment Share on other sites More sharing options...
dudi Posted November 16, 2011 Report Share Posted November 16, 2011 You can also use std:randomize to randomize primitive types Quote Link to comment Share on other sites More sharing options...
aputcha Posted November 16, 2011 Author Report Share Posted November 16, 2011 Thanks will it a try.. Quote Link to comment Share on other sites More sharing options...
Mickey Posted November 21, 2011 Report Share Posted November 21, 2011 I think, you can use req.size and req.length. class txn; rand int size; rand int length; rand bit [31:0] addr; end class class my_seq extends base_seq rand bit [31:0] total_bytes; virtual task body() for (int i=1; i< sequence_length; i++) begin `uvm_do_with(req, {req.size inside {0, 1, 2}; req.length inside {[0:15]}; total_bytes == ((1<<req.size) * (req.length+1)); }) end // for loop endtask: body endclass: my_seq Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.