// Interface Declaration
interface adpcm_int;
logic clk;
logic frame;
logic [3:0] data;
endinterface: adpcm_int
// Transaction item class adpcm_txn
class adpcm_txn extends uvm_sequence_item;
`uvm_object_util(adpcm_txn)
rand logic[3:0] data;
rand int delay;
function new (string name);
super.new(name);
endfunction: new
constraint del_bet_pac {delay inside {[1:20]};}
endclass: adpcm_txn
// Driver class adpcm_drv
class adpcm_drv extends uvm_driver #(adpcm_txn);
`uvm_component_utils (adpcm_drv)
adpcm_txn req;
virtual adpcm_int adpcm_if;
function new(string name, uvm_components parent)
super.new(name, parent);
endfunction: new
task run_phase (uvm_phase phase);
// Default conditions
adpcm_if.frame <= 0;
adpcm_if.data <= 0;
forever begin
seq_item_port.get_next_item(req);
repeat(req.delay) begin
@(posedge adpcm_if.clk);
end
adpcm_if.frame <= 1;
for (int i = 0; i < 8; i++) begin
@(posedge adpcm_if.clk);
adpcm_if.data <= req.data[3:0];
req.data = req.data >> 4;
end
adpcm_if.frame <= 0;
seq_item_port.item_done();
end
endtask: run_phase
endclass: adpcm_drv
// Sequence Class adpcm_seq
class adpcm_seq extends uvm_sequence #(adpcm_txn);
`uvm_component_utils (adpcm_seq)
adpcm_txn req;
rand int no_of_reps = 10;
function new (string name);
super.new(name);
endfunction: new
task body;
req = adpcm_txn::type_id::create("req", this);
for (int i = 0; i < no_of_reps; i++) begin
start_item(req);
if (!req.randomize()) begin
`uvm_error("BODY", "req randomization failed")
end
finish_item(req);
`uvm_info("ADPCM_SEQ BODY",
$sformatf("Transmitted frame %0d", i), UVM_LOW)
end
endtask: body
endclass: adpcm_seq
Sunday, October 30, 2016
UVM PCM Driver Example.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment