init
This commit is contained in:
47
code/vezba9/verif/Agent/calc_agent.sv
Normal file
47
code/vezba9/verif/Agent/calc_agent.sv
Normal file
@@ -0,0 +1,47 @@
|
||||
class calc_agent extends uvm_agent;
|
||||
|
||||
// components
|
||||
calc_driver drv;
|
||||
calc_sequencer seqr;
|
||||
calc_monitor mon;
|
||||
virtual interface calc_if vif;
|
||||
// configuration
|
||||
calc_config cfg;
|
||||
int value;
|
||||
`uvm_component_utils_begin (calc_agent)
|
||||
`uvm_field_object(cfg, UVM_DEFAULT)
|
||||
`uvm_component_utils_end
|
||||
|
||||
function new(string name = "calc_agent", uvm_component parent = null);
|
||||
super.new(name,parent);
|
||||
endfunction
|
||||
|
||||
function void build_phase(uvm_phase phase);
|
||||
super.build_phase(phase);
|
||||
/************Geting from configuration database*******************/
|
||||
if (!uvm_config_db#(virtual calc_if)::get(this, "", "calc_if", vif))
|
||||
`uvm_fatal("NOVIF",{"virtual interface must be set:",get_full_name(),".vif"})
|
||||
|
||||
if(!uvm_config_db#(calc_config)::get(this, "", "calc_config", cfg))
|
||||
`uvm_fatal("NOCONFIG",{"Config object must be set for: ",get_full_name(),".cfg"})
|
||||
/*****************************************************************/
|
||||
|
||||
/************Setting to configuration database********************/
|
||||
uvm_config_db#(virtual calc_if)::set(this, "*", "calc_if", vif);
|
||||
/*****************************************************************/
|
||||
|
||||
mon = calc_monitor::type_id::create("mon", this);
|
||||
if(cfg.is_active == UVM_ACTIVE) begin
|
||||
drv = calc_driver::type_id::create("drv", this);
|
||||
seqr = calc_sequencer::type_id::create("seqr", this);
|
||||
end
|
||||
endfunction : build_phase
|
||||
|
||||
function void connect_phase(uvm_phase phase);
|
||||
super.connect_phase(phase);
|
||||
if(cfg.is_active == UVM_ACTIVE) begin
|
||||
drv.seq_item_port.connect(seqr.seq_item_export);
|
||||
end
|
||||
endfunction : connect_phase
|
||||
|
||||
endclass : calc_agent
|
||||
25
code/vezba9/verif/Agent/calc_agent_pkg.sv
Normal file
25
code/vezba9/verif/Agent/calc_agent_pkg.sv
Normal file
@@ -0,0 +1,25 @@
|
||||
`ifndef CALC_AGENT_PKG
|
||||
`define CALC_AGENT_PKG
|
||||
|
||||
package calc_agent_pkg;
|
||||
|
||||
import uvm_pkg::*;
|
||||
`include "uvm_macros.svh"
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// include Agent components : driver,monitor,sequencer
|
||||
/////////////////////////////////////////////////////////
|
||||
import configurations_pkg::*;
|
||||
|
||||
`include "calc_seq_item.sv"
|
||||
`include "calc_sequencer.sv"
|
||||
`include "calc_driver.sv"
|
||||
`include "calc_monitor.sv"
|
||||
`include "calc_agent.sv"
|
||||
|
||||
endpackage
|
||||
|
||||
`endif
|
||||
|
||||
|
||||
|
||||
36
code/vezba9/verif/Agent/calc_driver.sv
Normal file
36
code/vezba9/verif/Agent/calc_driver.sv
Normal file
@@ -0,0 +1,36 @@
|
||||
`ifndef CALC_DRIVER_SV
|
||||
`define CALC_DRIVER_SV
|
||||
class calc_driver extends uvm_driver#(calc_seq_item);
|
||||
|
||||
`uvm_component_utils(calc_driver)
|
||||
|
||||
virtual interface calc_if vif;
|
||||
|
||||
function new(string name = "calc_driver", uvm_component parent = null);
|
||||
super.new(name,parent);
|
||||
if (!uvm_config_db#(virtual calc_if)::get(this, "", "calc_if", vif))
|
||||
`uvm_fatal("NOVIF",{"virtual interface must be set for: ",get_full_name(),".vif"})
|
||||
endfunction
|
||||
|
||||
function void connect_phase(uvm_phase phase);
|
||||
super.connect_phase(phase);
|
||||
|
||||
endfunction : connect_phase
|
||||
|
||||
|
||||
task main_phase(uvm_phase phase);
|
||||
forever begin
|
||||
seq_item_port.get_next_item(req);
|
||||
`uvm_info(get_type_name(),
|
||||
$sformatf("Driver sending...\n%s", req.sprint()),
|
||||
UVM_HIGH)
|
||||
// do actual driving here
|
||||
/* TODO */
|
||||
seq_item_port.item_done();
|
||||
end
|
||||
endtask : main_phase
|
||||
|
||||
endclass : calc_driver
|
||||
|
||||
`endif
|
||||
|
||||
45
code/vezba9/verif/Agent/calc_monitor.sv
Normal file
45
code/vezba9/verif/Agent/calc_monitor.sv
Normal file
@@ -0,0 +1,45 @@
|
||||
class calc_monitor extends uvm_monitor;
|
||||
|
||||
// control fileds
|
||||
bit checks_enable = 1;
|
||||
bit coverage_enable = 1;
|
||||
|
||||
uvm_analysis_port #(calc_seq_item) item_collected_port;
|
||||
|
||||
`uvm_component_utils_begin(calc_monitor)
|
||||
`uvm_field_int(checks_enable, UVM_DEFAULT)
|
||||
`uvm_field_int(coverage_enable, UVM_DEFAULT)
|
||||
`uvm_component_utils_end
|
||||
|
||||
// The virtual interface used to drive and view HDL signals.
|
||||
virtual interface calc_if vif;
|
||||
|
||||
// current transaction
|
||||
calc_seq_item curr_it;
|
||||
|
||||
// coverage can go here
|
||||
// ...
|
||||
|
||||
function new(string name = "calc_monitor", uvm_component parent = null);
|
||||
super.new(name,parent);
|
||||
item_collected_port = new("item_collected_port", this);
|
||||
if (!uvm_config_db#(virtual calc_if)::get(this, "", "calc_if", vif))
|
||||
`uvm_fatal("NOVIF",{"virtual interface must be set:",get_full_name(),".vif"})
|
||||
endfunction
|
||||
|
||||
function void connect_phase(uvm_phase phase);
|
||||
super.connect_phase(phase);
|
||||
|
||||
endfunction : connect_phase
|
||||
|
||||
task main_phase(uvm_phase phase);
|
||||
// forever begin
|
||||
// curr_it = calc_seq_item::type_id::create("curr_it", this);
|
||||
// ...
|
||||
// collect transactions
|
||||
// ...
|
||||
// item_collected_port.write(curr_it);
|
||||
// end
|
||||
endtask : main_phase
|
||||
|
||||
endclass : calc_monitor
|
||||
21
code/vezba9/verif/Agent/calc_seq_item.sv
Normal file
21
code/vezba9/verif/Agent/calc_seq_item.sv
Normal file
@@ -0,0 +1,21 @@
|
||||
`ifndef CALC_SEQ_ITEM_SV
|
||||
`define CALC_SEQ_ITEM_SV
|
||||
|
||||
parameter DATA_WIDTH = 32;
|
||||
parameter RESP_WIDTH = 2;
|
||||
parameter CMD_WIDTH = 4;
|
||||
|
||||
class calc_seq_item extends uvm_sequence_item;
|
||||
|
||||
|
||||
|
||||
`uvm_object_utils_begin(calc_seq_item)
|
||||
`uvm_object_utils_end
|
||||
|
||||
function new (string name = "calc_seq_item");
|
||||
super.new(name);
|
||||
endfunction // new
|
||||
|
||||
endclass : calc_seq_item
|
||||
|
||||
`endif
|
||||
15
code/vezba9/verif/Agent/calc_sequencer.sv
Normal file
15
code/vezba9/verif/Agent/calc_sequencer.sv
Normal file
@@ -0,0 +1,15 @@
|
||||
`ifndef CALC_SEQUENCER_SV
|
||||
`define CALC_SEQUENCER_SV
|
||||
|
||||
class calc_sequencer extends uvm_sequencer#(calc_seq_item);
|
||||
|
||||
`uvm_component_utils(calc_sequencer)
|
||||
|
||||
function new(string name = "calc_sequencer", uvm_component parent = null);
|
||||
super.new(name,parent);
|
||||
endfunction
|
||||
|
||||
endclass : calc_sequencer
|
||||
|
||||
`endif
|
||||
|
||||
Reference in New Issue
Block a user