Professional Documents
Culture Documents
Mux Uvm
Mux Uvm
interface intif();
logic i0;
logic i1;
logic s;
logic y;
endinterface
/////DUT/////
assign inf.y=((inf.s==0)?inf.i0:inf.i1);
endmodule
////SEQUENCE ITEM
`ifndef _seqit_
`define _seqit_
`uvm_object_utils(mux_seq_item)
rand bit s;
bit y;
super.new(name);
endfunction
endclass
`endif
////SEQUENCE
`ifndef _seq_
`define _seq_
`uvm_object_utils(mux_seq)
mux_seq_item pkt;
super.new(name);
endfunction
task body();
repeat(10)
begin
assert(pkt.randomize());
//pkt.print();//stimulus randomizing
`uvm_info("seq","seq TRANSACTIONS",UVM_NONE);
$display("pkt=%d",pkt);
end
endtask
endclass
`endif
//////SEQUENCER/////
`ifndef _seqr_
`define _seqr_
super.new(name,parent);
endfunction
`endif
/////DRIVER
`ifndef _drv_
`define _drv_
`uvm_component_utils(mux_driver)
mux_seq_item pkt;
super.new(name,parent);
endfunction
super.build_phase(phase);
endfunction
forever
begin
pkt = mux_seq_item::type_id::create("seq");
seq_item_port.get_next_item(pkt);
inf.a=pkt.a;
inf.b=pkt.b;
inf.s=pkt.s;
#5;
//$display("drv::pkt=%d",pkt);
seq_item_port.item_done();
end
endtask
endclass
`endif
////MONITOR 1
`ifndef _mon1_
`define _mon1_
`uvm_component_utils(mux_mon1)
mux_seq_item pkt;
uvm_analysis_port #(mux_seq_item)item_collected_port;
super.new(name,parent);
item_collected_port=new("item_collected_port",this);
endfunction
super.build_phase(phase);
endfunction
pkt=mux_seq_item::type_id::create("pkt");
forever
begin
#2;
pkt.i0=inf.i0;
pkt.i1=inf.i1;
pkt.s=inf.s;
`uvm_info("MON1","MON1 TRANSACTIONS",UVM_NONE);
item_collected_port.write(pkt);
end
endtask
endclass
`endif
///MONITOR 2
`ifndef _mon2_
`define _mon2_
`uvm_component_utils(mux_mon2)
mux_seq_item pkt1;
uvm_analysis_port #(mux_seq_item)item_collected_port1;
super.new(name,parent);
item_collected_port1=new("item_collected_port1",this);
endfunction
super.build_phase(phase);
endfunction
pkt1=mux_seq_item::type_id::create("pkt1");
forever
begin
#2;
pkt1.y=inf.y;
//$display($time,"mon2::::::::pkt1=%d",pkt1);
//`uvm_info("MON2","MON2 TRANSACTIONS",UVM_NONE);
item_collected_port1.write(pkt1);
end
endtask
endclass
`endif
////AGENT1
`ifndef _ag1_
`define _ag1_
`uvm_component_utils(mux_agent1)
mux_seqr seqr;
mux_driver drv;
mux_mon1 mon1;
super.new(name,parent);
endfunction
super.build_phase(phase);
seqr=mux_seqr::type_id::create("seqr",this);
drv=mux_driver::type_id::create("drv",this);
mon1=mux_mon1::type_id::create("mon1",this);
endfunction
super.connect_phase(phase);
drv.seq_item_port.connect(seqr.seq_item_export);
endfunction
endclass
`endif
//////AGENT2//////
`ifndef _ag2_
`define _ag2_
`uvm_component_utils(mux_agent2)
mux_mon2 mon2;
super.new(name,parent);
endfunction
super.build_phase(phase);
mon2=mux_mon2::type_id::create("mon2",this);
endfunction
endclass
`endif
////SCOREBOARD
`ifndef _sb_
`define _sb_
`uvm_component_utils(mux_sb);
mux_seq_item pkt,pkt1;
uvm_tlm_analysis_fifo #(mux_seq_item)ip_fifo;
uvm_tlm_analysis_fifo #(mux_seq_item)op_fifo;
super.new(name,parent);
ip_fifo=new("ip_fifo",this);
op_fifo=new("op_fifo",this);
endfunction
super.build_phase(phase);
pkt=mux_seq_item::type_id::create("pkt",this);
pkt1=mux_seq_item::type_id::create("pkt1",this);
endfunction
forever
begin
fork
ip_fifo.get(pkt);
op_fifo.get(pkt1);
join
if(pkt1.y==((pkt.s==0)?pkt.i0:pkt.i1))
begin
end
else
begin
end
end
endtask
endclass
`endif
////////ENVIRONMENT/////
`ifndef _env_
`define _env_
`uvm_component_utils(mux_env)
mux_agent1 agent1;
mux_agent2 agent2;
mux_sb sb;
super.new(name,parent);
endfunction
super.build_phase(phase);
agent1=mux_agent1::type_id::create("agent1",this);
agent2=mux_agent2::type_id::create("agent2",this);
sb=mux_sb::type_id::create("sb",this);
endfunction
super.connect_phase(phase);
agent1.mon1.item_collected_port.connect(sb.ip_fifo.analysis_export);
agent2.mon2.item_collected_port1.connect(sb.op_fifo.analysis_export);
endfunction
endclass
`endif
////TEST///
`ifndef _test_
`define _test_
`uvm_component_utils(mux_test)
mux_env env;
super.new(name,parent);
endfunction
super.build_phase(phase);
env=mux_env::type_id::create("env",this);
endfunction
mux_seq seq;
seq=mux_seq::type_id::create("seq",this);
phase.raise_objection(this);
seq.start(env.agent1.seqr);
#1000;
phase.drop_objection(this);
endtask
endclass
`endif
//////////TOP////////////
import uvm_pkg::*;
`include "uvm_macros.svh"
`include "MUX_interface.sv"
//`include "DESIGN.sv"
`include "MUX_dut.sv"
`include "MUX_sequence_item.sv"
`include "mux_sequence.sv"
`include "MUX_sequencer.sv"
`include "MUX_driver.sv"
`include "MUX_monitor1.sv"
`include "MUX_monitor2.sv"
`include "MUX_agent1.sv"
`include "MUX_agent2.sv"
`include "MUX_sb.sv"
`include "MUX_envmt.sv"
`include "MUX_test.sv"
module mux_top();
intif inf();
mux_dut dut(inf);
initial
begin
run_test();
end
endmodule