Hi Sir/Mam,
How i can hold my pwrite signal as 1 for first 16 randomization’s?? after 16 randomizes it should be held 0… below is my piece of code… please let me know what changes i have to make in my transaction class such that it should hold my values as said above ?
////////////////////////////////////////////////////////////////////
class apb_seq_item extends uvm_sequence_item;
rand bit [7:0]paddr;
rand bit [31:0]pwdata;
rand bit pwrite;
bit [31:0] prdata;
// bit [7:0]cnt;
constraint paddr_c {paddr[7:0] >= 8'd0; paddr[7:0] < 8'd6;}
constraint pwdata_c {pwdata[31:0] >= 32'd0; pwdata[31:0] < 32'd6;}
`uvm_object_utils_begin(apb_seq_item)
`uvm_field_int(paddr,UVM_DEFAULT)
`uvm_field_int(pwdata,UVM_DEFAULT)
`uvm_field_int(pwrite,UVM_DEFAULT)
`uvm_field_int(prdata,UVM_DEFAULT)
`uvm_object_utils_end
function new(string name= "apb_seq_item");
super.new(name);
endfunction
virtual function string convert2str();
return $sformatf("paddr:%d,pwdata:%d,pwrite:%b,prdata:%d",paddr,pwdata,pwrite,prdata);
endfunction
endclass
/////////////////////sequence///////////////////////////////
class apb_sequence extends uvm_sequence#(apb_seq_item);
`uvm_object_utils(apb_sequence)
function new(string name= "apb_sequence");
super.new(name);
endfunction
virtual task body();
apb_seq_item trans;
for(int i=0; i<31; i++) begin
trans=apb_seq_item::type_id::create("trans");
// start_item(trans);
`uvm_info("[Sequence]","Starting sequence",UVM_MEDIUM)
assert(trans.randomize());
`uvm_info("[Sequence]",$sformatf("Generated New Items are %s",trans.convert2str()),UVM_MEDIUM)
// finish_item(trans);
end
endtask
endclass
//////////////////////////sequencer//////////////////////////////////
class apb_sequencer extends uvm_sequencer#(apb_seq_item);
`uvm_component_utils(apb_sequencer)
//constructor
function new(string name, uvm_component parent);
super.new(name,parent);
endfunction
endclass
////////////////////////////env/////////////////////////////////////
class apb_env extends uvm_env;
`uvm_component_utils(apb_env)
function new(string name = "apb_env", uvm_component parent=null);
super.new(name, parent);
endfunction
apb_sequencer s0;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
s0 = apb_sequencer::type_id::create("s0", this);
endfunction
endclass
//////////////////////////test///////////////////////////////////////
class test extends uvm_test;
`uvm_component_utils(test)
function new(string name = "test", uvm_component parent=null);
super.new(name, parent);
endfunction
apb_env env;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
env = apb_env::type_id::create("env", this);
endfunction
virtual task run_phase(uvm_phase phase);
apb_sequence seq = apb_sequence::type_id::create("seq");
phase.raise_objection(this);
`uvm_info("[Test]","Test started",UVM_MEDIUM)
seq.start(env.s0);
// #50;
phase.drop_objection(this);
endtask
endclass
///////////////////////top/////////////////////////////////
module top;
initial begin
run_test("test");
end
endmodule