0% found this document useful (0 votes)
15 views4 pages

XXXX

This document describes an Ethernet agent class in SystemVerilog. The agent contains drivers, sequencers and monitors to drive and sample traffic to/from an Ethernet interface. It can be configured to work in different GMII modes and its monitors can be enabled/disabled. The agent provides methods to set the speed, enable monitors, send frames and set sideband signals.

Uploaded by

samanthasmr305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

XXXX

This document describes an Ethernet agent class in SystemVerilog. The agent contains drivers, sequencers and monitors to drive and sample traffic to/from an Ethernet interface. It can be configured to work in different GMII modes and its monitors can be enabled/disabled. The agent provides methods to set the speed, enable monitors, send frames and set sideband signals.

Uploaded by

samanthasmr305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

//---------------------------------------------------------------------------------

------------------------------------
/asdasd
//d
//------------sa
//-------------a
//---------------------------------------------------------------------------------
------------------------------------
class eth802_3_agent ed2_3_frame) ap_rx; // Transaction name matches dio agent name
uvm_analysis_dasdse m_gmii_monitor_tx; // ETH802_3 Agent Monitor (TX Port)
das; // Enable logging what monitors see on interface to PCAP file.

//----------------------------------------------------------------
// UVM registration macro
//----------------------------------------------------------------
`uvm_component_utils(eth802_3_agent)
dinput strisadeth_gmii_mode_e gmii_mode); // sets gmii speed mode for agent
extern virtual task enable_monitor(eth802_3_monitor_type_e mon_typ, bit enable);
// enable/disable monitor mid test
extern virtual function void enableMonitorRX(); // enables RX monitor
extern virtual function void disableMonitorRX(); // disables RX
monitor
extern virtual task set_ifg(int ifg, string msg_id = ""); // sets interframe
gap for agent
extern task send_frame(eth802_3_frame tr);
extern task set_sideband_signals(eth802_3_speed_e an_speed = SPEED_1GBIT, bit
an_link_ok = 1'b0, bit an_full_duplex = 1'b0, logic [3:0] carrier_data = 4'b0,
set_error = 0'b0); // Set sideband signals

endclass: eth802_3_agentas

//----------------------------------------------
dsa----------------------------------------------------------------
function eth802_3_adsadgent::new(input string name, uvm_component parent);
super.new(name, parent);
ap_rx = new("m_analysis_port_rx", this);
ap_tx = new("m_analysis_port_tx", this);
pcap_log_enable = 0;
endfunction: new

//---------------------------------------------------------------------------------
------------------------------------
function void eth802_3_asadgent::build_phase(uvm_phase phase);
super.build_phase(phase);

if(!uvm_config_db#(virtual eth802_3_ifc)::get(this, "", "vif", this.ifc))


`uvm_fatal("NOVIF",{"virtusadfg)::get(this, "", "eth802_3_agent_cfg",
m_eth_ag_cfg))
`uvm_fatal("NOCONFIG", $sformatf("Failed to find configuration object for
%s",get_full_name()));

`uvm_info(get_type_name(), $sformatf("Buildsadng %s using Mode = %s",


get_type_name(), m_eth_ag_cfg.eth_mode), UVM_MEDIUM);
sad
if (m_eth_ag_cfg.is_active) begin
m_gmii_driver = eth802_3_driver ::type_id::create("m_gmii_driver", this);
m_sequencer = eth802_3_sequencer::type_id::create("m_sequencer", this);

// monitor and coverage module that process RX transactions


if (m_eth_ag_cfg.eth_mode == STANDARD_GMII ) m_gmii_monitor_rx =
eth802_3_gmii_monitor ::type_id::create("m_gmii_monitor_rx", this);
else if (m_eth_ag_cfg.eth_mode == STANDARD_RGMII) m_gmii_monitor_rx =
eth802_3_rgmii_monitor ::type_id::create("m_rgmii_monitor_rx", this);
else if (m_eth_ag_cfg.eth_mode == TTTECH_IP) m_gmii_monitor_rx =
eth802_3_tttech_gmii_monitor::type_id::create("m_tttech_gmii_monitor_rx", this);
else `uvm_error(get_name(), "Unrecognized monitor ethernet mode")

if (m_eth_ag_cfg.has_coverage)
m_coverage_rx = eth802_3_coverage::type_id::create("m_coverage_rx", this);

// monitor settings
m_gmii_monitor_rx.monitor_type = RX_MONITOR;
m_gmii_monitor_rx.pcap_log_enable = pcap_log_enable;
end

// monitor and coverage module that process TX transactions


if (m_eth_ag_cfg.eth_mode == STANDARD_GMII) m_gmii_monitor_tx =
eth802_3_gmii_monitor ::type_id::create("m_gmii_monitor_tx", this);
else if (m_eth_ag_cfg.eth_mode == STANDARD_RGMII) m_gmii_monitor_tx =
eth802_3_rgmii_monitor ::type_id::create("m_rgmii_monitor_tx", this);
else if (m_eth_ag_cfg.eth_mode == TTTECH_IP) m_gmii_monitor_tx =
eth802_3_tttech_gmii_monitor::type_id::create("m_tttech_gmii_monitor_tx", this);
else `uvm_error(get_name(), "Unrecognized monitor ethernet mode")

if (m_eth_ag_cfg.has_coverage)
m_coverage_tx = eth802_3_coverage::type_id::create("m_coverage_tx", this);

m_gmii_monitor_tx.monitor_type = TX_MONITOR;
m_gmii_monitor_tx.pcap_log_enable = pcap_log_enable;
endfunction: build_phase

//---------------------------------------------------------------------------------
------------------------------------
function void eth802_3_agent::connect_phase(uvm_phase phase);
if (m_eth_ag_cfg.is_active) begin
// driver and sequencer
m_gmii_driver.ifc = this.ifc;
m_sequencer.m_cfg = m_eth_ag_cfg;
m_gmii_driver.m_cfg = m_eth_ag_cfg;
m_gmii_driver.seq_item_port.connect(m_sequencer.seq_item_export);

// monitor and coverage module that process RX transactions


m_gmii_monitor_rx.ifc = this.ifc;
m_gmii_monitor_rx.ap.connect(ap_rx);

if (m_eth_ag_cfg.has_coverage)
ap_rx.connect(m_coverage_rx.coverage_transaction_rx_imp);

m_gmii_monitor_rx.m_cfg = m_eth_ag_cfg;
end

// monitor and coverage module that process TX transactions


m_gmii_monitor_tx.ifc = this.ifc;
m_gmii_monitor_tx.ap.connect(ap_tx);

if (m_eth_ag_cfg.has_coverage)
ap_tx.connect(m_coverage_tx.coverage_transaction_tx_imp);
m_gmii_monitor_tx.m_cfg = m_eth_ag_cfg;
endfunction: connect_phase

//---------------------------------------------------------------------------------
------------------------------------
task eth802_3_agent::set_speed(eth802_3_speed_e speed);
string msg_id;
string speed_str = speed.name();
$sformat(msg_id, "%s::set_speed()", get_name());

m_gmii_monitor_tx.m_cfg.speed = speed;
m_gmii_monitor_rx.m_cfg.speed = speed;
m_gmii_driver.m_cfg.speed = speed;
m_gmii_driver.set_speed(speed);

uvm_report_info(msg_id, $sformatf("Speed was set to %s.", speed_str));


endtask: set_speed

//---------------------------------------------------------------------------------
------------------------------------
task eth802_3_agent::set_gmii_mode(eth_gmii_mode_e gmii_mode);
string msg_id;
string gmii_mode_str = gmii_mode.name();
$sformat(msg_id, "%s::set_speed()", get_name());

m_gmii_monitor_tx.m_cfg.gmii_mode = gmii_mode;
m_gmii_monitor_rx.m_cfg.gmii_mode = gmii_mode;
m_gmii_driver.m_cfg.gmii_mode = gmii_mode;
m_gmii_driver.set_gmii_mode(gmii_mode);

uvm_report_info(msg_id, $sformatf("GMII mode was set to %s.", gmii_mode_str));


endtask: set_gmii_mode

//---------------------------------------------------------------------------------
------------------------------------
task eth802_3_agent::enable_monitor(eth802_3_monitor_type_e mon_typ, bit enable);
string msg_id;
string enable_str = "ENABLED";
string mon_typ_str = "RX";

$sformat(msg_id, "%s::enable_monitor()", get_name());

if (!enable) begin
enable_str = "DISABLED";
end

if (mon_typ == RX_MONITOR) begin


ifc.EN_MON_RXCLK_EN = enable;
end else begin
ifc.EN_MON_TXCLK_EN = enable;
mon_typ_str = "TX";
end

uvm_report_info(msg_id, $sformatf("%s monitor is %s.", mon_typ_str,


enable_str));
endtask: enable_monitor

//---------------------------------------------------------------------------------
------------------------------------
function void eth802_3_agent::enableMonitorRX();
//m_gmii_monitor_tx.monitor_en = 1'b1;
m_gmii_monitor_rx.monitor_en = 1'b1;
endfunction : enableMonitorRX

//---------------------------------------------------------------------------------
------------------------------------
function void eth802_3_agent::disableMonitorRX();
//m_gmii_monitor_tx.monitor_en = 1'b0;
m_gmii_monitor_rx.monitor_en = 1'b0;
endfunction : disableMonitorRX

//---------------------------------------------------------------------------------
------------------------------------
task eth802_3_agent::set_ifg(int ifg, string msg_id = "");
m_gmii_driver.set_ifg(ifg);
`uvm_info(msg_id, $sformatf("%s : IFG was set to %d", get_name(), ifg),
UVM_LOW);
endtask: set_ifg

//---------------------------------------------------------------------------------
------------------------------------
task eth802_3_agent::send_frame(eth802_3_frame tr);
m_sequencer.inject_transaction(tr);
endtask: send_frame

//---------------------------------------------------------------------------------
------------------------------------
task eth802_3_agent::set_sideband_signals(eth802_3_speed_e an_speed = SPEED_1GBIT,
bit an_link_ok = 1'b0, bit an_full_duplex = 1'b0, logic [3:0] carrier_data = 4'b0,
set_error = 0'b0);
if(m_eth_ag_cfg.eth_mode == STANDARD_RGMII ) begin
set_speed(an_speed);
m_gmii_driver.set_sideband_signals_idle(an_speed, an_link_ok, an_full_duplex,
carrier_data, set_error);
end else begin
`uvm_fatal(get_type_name(), $sformatf("Sideband signals can only be set in
STANDARD_RGMII mode"));
end
endtask: set_sideband_signals

//---------------------------------------------------------------------------------
------------------------------------

You might also like