From fb4471615554adec27ccf3a67e754005f98a9d0c Mon Sep 17 00:00:00 2001 From: Gona Deepika <113277941+Gonadeepika@users.noreply.github.com> Date: Mon, 13 May 2024 12:12:00 +0530 Subject: [PATCH] Add files via upload --- dst_agent.sv | 55 +++++++++++++++++++ dst_agt_config.sv | 24 ++++++++ dst_agt_top.sv | 43 +++++++++++++++ dst_driver.sv | 98 +++++++++++++++++++++++++++++++++ dst_monitor.sv | 98 +++++++++++++++++++++++++++++++++ dst_seqs.sv | 48 ++++++++++++++++ dst_sequencer.sv | 14 +++++ dst_xtn.sv | 33 +++++++++++ src_agent.sv | 55 +++++++++++++++++++ src_agt_config.sv | 22 ++++++++ src_agt_top.sv | 45 +++++++++++++++ src_drivr.sv | 110 +++++++++++++++++++++++++++++++++++++ src_monitor.sv | 106 +++++++++++++++++++++++++++++++++++ src_seqs.sv | 137 ++++++++++++++++++++++++++++++++++++++++++++++ src_sequencer.sv | 15 +++++ src_xtn.sv | 48 ++++++++++++++++ 16 files changed, 951 insertions(+) create mode 100644 dst_agent.sv create mode 100644 dst_agt_config.sv create mode 100644 dst_agt_top.sv create mode 100644 dst_driver.sv create mode 100644 dst_monitor.sv create mode 100644 dst_seqs.sv create mode 100644 dst_sequencer.sv create mode 100644 dst_xtn.sv create mode 100644 src_agent.sv create mode 100644 src_agt_config.sv create mode 100644 src_agt_top.sv create mode 100644 src_drivr.sv create mode 100644 src_monitor.sv create mode 100644 src_seqs.sv create mode 100644 src_sequencer.sv create mode 100644 src_xtn.sv diff --git a/dst_agent.sv b/dst_agent.sv new file mode 100644 index 0000000..4b054f8 --- /dev/null +++ b/dst_agent.sv @@ -0,0 +1,55 @@ +class router_rd_agent extends uvm_agent; + + // Factory Registration + `uvm_component_utils(router_rd_agent) + + // Declare handle for configuration object + router_rd_agt_config m_cfg; + + // Declare handles of router_wr_monitor,router_wr_sequencer and router_wr_driver with Handle names as monh, seqrh, drvh respectively + router_rd_monitor monh; + router_rd_sequencer seqrh; + router_rd_driver drvh; + + extern function new(string name = "router_rd_agent", uvm_component parent = null); + extern function void build_phase(uvm_phase phase); + extern function void connect_phase(uvm_phase phase); + +endclass + + + +//----------------- constructor new method -------------------// +function router_rd_agent::new(string name = "router_rd_agent",uvm_component parent = null); + super.new(name,parent); +endfunction + + + +//----------------- build method ------------------// + +function void router_rd_agent::build_phase(uvm_phase phase); + + super.build_phase(phase); + // get the config object using uvm_config_db + if(!uvm_config_db #(router_rd_agt_config)::get(this,"","router_rd_agt_config",m_cfg)) + `uvm_fatal("CONFIG","cannot get() m_cfg from uvm_config_db. Have you set() it?") + monh=router_rd_monitor::type_id::create("monh",this); + if(m_cfg.is_active==UVM_ACTIVE) + begin + drvh=router_rd_driver::type_id::create("drvh",this); + seqrh=router_rd_sequencer::type_id::create("seqrh",this); + end +endfunction + + + +//----------------- connect method -------------------// + +function void router_rd_agent::connect_phase(uvm_phase phase); + if(m_cfg.is_active==UVM_ACTIVE) + begin + drvh.seq_item_port.connect(seqrh.seq_item_export); + end +endfunction + diff --git a/dst_agt_config.sv b/dst_agt_config.sv new file mode 100644 index 0000000..04ff6b0 --- /dev/null +++ b/dst_agt_config.sv @@ -0,0 +1,24 @@ +class router_rd_agt_config extends uvm_object; + + `uvm_object_utils(router_rd_agt_config) + + virtual router_if vif; + + static int drv_data_count = 0; + static int mon_data_count = 0; + + uvm_active_passive_enum is_active = UVM_ACTIVE; + + extern function new(string name = "router_rd_agt_config"); + +endclass + + + +//----------------- constructor new method -------------------// + +function router_rd_agt_config::new(string name = "router_rd_agt_config"); + super.new(name); +endfunction + + diff --git a/dst_agt_top.sv b/dst_agt_top.sv new file mode 100644 index 0000000..3dd89af --- /dev/null +++ b/dst_agt_top.sv @@ -0,0 +1,43 @@ +class router_rd_agt_top extends uvm_env; + + `uvm_component_utils(router_rd_agt_top) + + router_rd_agent agnth[]; + + router_env_config m_cfg; + + extern function new (string name="router_rd_agt_top",uvm_component parent); + extern function void build_phase(uvm_phase phase); + +endclass + + + +//----------------- constructor new method -------------------// + +function router_rd_agt_top ::new(string name="router_rd_agt_top",uvm_component parent); + super.new(name,parent); +endfunction + + + +//----------------- build method -------------------// + +function void router_rd_agt_top::build_phase(uvm_phase phase); + super.build_phase(phase); + if(!uvm_config_db #(router_env_config)::get(this,"","router_env_config",m_cfg)) + `uvm_fatal("CONFIG","cannot get() m_cfg from uvm_config_db. Have you set() it?") + + agnth = new[m_cfg.no_of_read_agent]; + + foreach(agnth[i]) + begin + // set router_wr_agent_config into the database using the + // router_env_config's router_wr_agent_config object + agnth[i]=router_rd_agent::type_id::create($sformatf("agnth[%0d]",i) ,this); + + uvm_config_db #(router_rd_agt_config)::set(this,$sformatf("agnth[%0d]*",i), "router_rd_agt_config", m_cfg.rd_agt_cfg[i]); + + end +endfunction + diff --git a/dst_driver.sv b/dst_driver.sv new file mode 100644 index 0000000..ec5cf49 --- /dev/null +++ b/dst_driver.sv @@ -0,0 +1,98 @@ +class router_rd_driver extends uvm_driver #(read_xtn); + + `uvm_component_utils(router_rd_driver) + + virtual router_if.RDR_MP vif; + router_rd_agt_config m_cfg; + + extern function new(string name ="router_rd_driver",uvm_component parent); + extern function void build_phase(uvm_phase phase); + extern function void connect_phase(uvm_phase phase); + extern task run_phase(uvm_phase phase); + extern task send_to_dut(read_xtn xtn); + extern function void report_phase(uvm_phase phase); + +endclass + + + +//----------------- constructor new method -------------------// +function router_rd_driver::new(string name ="router_rd_driver",uvm_component parent); + super.new(name,parent); +endfunction + + + +//----------------- build() phase method -------------------// +function void router_rd_driver::build_phase(uvm_phase phase); + + super.build_phase(phase); + // get the config object using uvm_config_db + if(!uvm_config_db #(router_rd_agt_config)::get(this,"","router_rd_agt_config",m_cfg)) + `uvm_fatal("CONFIG","cannot get() m_cfg from uvm_config_db. Have you set() it?") + +endfunction + + + +//----------------- connect() phase method -------------------// + // in connect phase assign the configuration object's virtual interface + // to the driver's virtual interface instance(handle --> "vif") +function void router_rd_driver::connect_phase(uvm_phase phase); + vif = m_cfg.vif; +endfunction + + + +//----------------- run() phase method -------------------// + // In forever loop + // Get the sequence item using seq_item_port + // Call send_to_dut task + // Get the next sequence item using seq_item_port + +task router_rd_driver::run_phase(uvm_phase phase); + + forever + begin + seq_item_port.get_next_item(req); + send_to_dut(req); + seq_item_port.item_done; + end +endtask + + + +//----------------- task send_to_dut() method -------------------// +task router_rd_driver::send_to_dut(read_xtn xtn); + + begin + `uvm_info("ROUTER_RD_DRIVER",$sformatf("printing from driver \n %s",xtn.sprint()),UVM_LOW) + @(vif.rdr_cb); + // wait(vif.rdr_cb.v_out) + while(!vif.rdr_cb.v_out) + @(vif.rdr_cb); + repeat(xtn.no_of_cycles) + @(vif.rdr_cb); + vif.rdr_cb.read_enb <= 1; +// wait(!vif.rdr_cb.v_out) + while(vif.rdr_cb.v_out) + @(vif.rdr_cb); + vif.rdr_cb.read_enb <= 0; + //@(vif.rdr_cb); + m_cfg.drv_data_count++; + //repeat(2) + @(vif.rdr_cb); + end + +endtask + + + + +//------------------------------- UVM report_phase-----------------// + +function void router_rd_driver::report_phase(uvm_phase phase); + `uvm_info(get_type_name(), $sformatf("Report: ROUTER read driver sent %0d transactions", m_cfg.drv_data_count), UVM_LOW) +endfunction + + diff --git a/dst_monitor.sv b/dst_monitor.sv new file mode 100644 index 0000000..1b2fbb3 --- /dev/null +++ b/dst_monitor.sv @@ -0,0 +1,98 @@ +class router_rd_monitor extends uvm_monitor; + + `uvm_component_utils(router_rd_monitor) + + virtual router_if.RMON_MP vif; + router_rd_agt_config m_cfg; + + uvm_analysis_port#(read_xtn) monitor_port; + + extern function new(string name ="router_rd_monitor",uvm_component parent); + extern function void build_phase(uvm_phase phase); + extern function void connect_phase(uvm_phase phase); + extern task run_phase(uvm_phase phase); + extern task collect_data(); + extern function void report_phase(uvm_phase phase); + +endclass + + + +//----------------- constructor new method -------------------// +function router_rd_monitor::new(string name ="router_rd_monitor",uvm_component parent); + super.new(name,parent); + monitor_port = new("monitor_port",this); +endfunction + + + +//----------------- build() phase method -------------------// +function void router_rd_monitor::build_phase(uvm_phase phase); + + super.build_phase(phase); + // get the config object using uvm_config_db + if(!uvm_config_db #(router_rd_agt_config)::get(this,"","router_rd_agt_config",m_cfg)) + `uvm_fatal("CONFIG","cannot get() m_cfg from uvm_config_db. Have you set() it?") + +endfunction + + + +//----------------- connect() phase method -------------------// +// to the driver's virtual interface instance(handle --> "vif" +function void router_rd_monitor::connect_phase(uvm_phase phase); + super.connect_phase(phase); + vif = m_cfg.vif; +endfunction + + + +//----------------- run_phase()method -------------------// + // In forever loop + // Call task collect_data +task router_rd_monitor::run_phase(uvm_phase phase); + forever + // Call collect data task + collect_data(); +endtask + + + +//--------------Collect Reference Data from DUV IF-----------------// +task router_rd_monitor::collect_data(); + + read_xtn mon_data; + mon_data=read_xtn::type_id::create("mon_data"); + @(vif.rmon_cb); + + while(!vif.rmon_cb.read_enb) + @(vif.rmon_cb); + @(vif.rmon_cb); + + mon_data.header = vif.rmon_cb.data_out; + mon_data.payload_data=new[mon_data.header[7:2]]; + @(vif.rmon_cb); + foreach(mon_data.payload_data[i]) + begin + //while(!vif.rmon_cb.read_enb) + mon_data.payload_data[i]=vif.rmon_cb.data_out; + @(vif.rmon_cb); + end + mon_data.parity=vif.rmon_cb.data_out; + @(vif.rmon_cb); + m_cfg.mon_data_count++; + + `uvm_info("ROUTER_RD_MONITOR",$sformatf("printing from monitor \n %s",mon_data.sprint()),UVM_LOW) + + monitor_port.write(mon_data); +endtask + + + +//-------------------- UVM report_phase---------------------------------- +function void router_rd_monitor::report_phase(uvm_phase phase); + `uvm_info(get_type_name(), $sformatf("Report: ROUTER Read Monitor Collected %0d Transactions", m_cfg.mon_data_count), UVM_LOW) +endfunction + + + diff --git a/dst_seqs.sv b/dst_seqs.sv new file mode 100644 index 0000000..44fffe6 --- /dev/null +++ b/dst_seqs.sv @@ -0,0 +1,48 @@ +class router_rd_seq extends uvm_sequence #(read_xtn); + + // Factory registration using `uvm_object_utils + `uvm_object_utils(router_rd_seq) + + // Standard UVM Methods: + extern function new(string name ="router_rd_seq"); +endclass + + + +//----------------- constructor new method -------------------// +function router_rd_seq::new(string name ="router_rd_seq"); + super.new(name); +endfunction + + + +//-------------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class router_rxtns1 extends router_rd_seq; + + // Factory registration using `uvm_object_utils + `uvm_object_utils(router_rxtns1) + + extern function new(string name ="router_rxtns1"); + extern task body(); + +endclass + + + +//----------------- constructor new method -------------------// +function router_rxtns1::new(string name ="router_rxtns1"); + super.new(name); +endfunction + + +//-----------------------------------task body---------------------------------------- +task router_rxtns1::body(); + + req=read_xtn::type_id::create("req"); + start_item(req); + assert(req.randomize() with {no_of_cycles inside {[1:28]};} ); + `uvm_info("ROUTER_RD_SEQUENCE",$sformatf("printing from sequence \n %s", req.sprint()),UVM_HIGH) + finish_item(req); +endtask + diff --git a/dst_sequencer.sv b/dst_sequencer.sv new file mode 100644 index 0000000..54817ff --- /dev/null +++ b/dst_sequencer.sv @@ -0,0 +1,14 @@ +class router_rd_sequencer extends uvm_sequencer #(read_xtn); + + // Factory registration using `uvm_component_utils + `uvm_component_utils(router_rd_sequencer) + + // Standard UVM Methods: + extern function new(string name = "router_rd_sequencer",uvm_component parent); +endclass + + +//----------------- constructor new method -------------------// +function router_rd_sequencer::new(string name="router_rd_sequencer",uvm_component parent); + super.new(name,parent); +endfunction diff --git a/dst_xtn.sv b/dst_xtn.sv new file mode 100644 index 0000000..cd07d53 --- /dev/null +++ b/dst_xtn.sv @@ -0,0 +1,33 @@ +class read_xtn extends uvm_sequence_item; + + `uvm_object_utils(read_xtn) + + bit [7:0] header; + bit [7:0] payload_data[]; + bit [7:0] parity; + rand bit [5:0] no_of_cycles; + + extern function new(string name = "read_xtn"); + extern function void do_print(uvm_printer printer); + +endclass + + + +function read_xtn::new(string name = "read_xtn"); + super.new(name); +endfunction : new + + + +function void read_xtn::do_print(uvm_printer printer); + super.do_print(printer); + + printer.print_field( "header", this.header, 8, UVM_HEX ); + foreach(payload_data[i]) + printer.print_field($sformatf("payload_data[%0d]",i), this.payload_data[i], 8, UVM_HEX); + printer.print_field( "parity", this.parity, 8, UVM_HEX); + printer.print_field( "no_of_cycles", this.no_of_cycles, 6, UVM_HEX); + +endfunction + diff --git a/src_agent.sv b/src_agent.sv new file mode 100644 index 0000000..f1bfa7f --- /dev/null +++ b/src_agent.sv @@ -0,0 +1,55 @@ +class router_wr_agent extends uvm_agent; + + // Factory Registration + `uvm_component_utils(router_wr_agent) + + // Declare handle for configuration object + router_wr_agt_config m_cfg; + + // Declare handles of router_wr_monitor,router_wr_sequencer and router_wr_driver with Handle names as monh, seqrh, drvh respectively + router_wr_monitor monh; + router_wr_sequencer seqrh; + router_wr_driver drvh; + + extern function new(string name = "router_wr_agent", uvm_component parent = null); + extern function void build_phase(uvm_phase phase); + extern function void connect_phase(uvm_phase phase); + +endclass + + +//----------------- constructor new method -------------------// + +function router_wr_agent::new(string name = "router_wr_agent",uvm_component parent = null); + super.new(name,parent); +endfunction + + + +//----------------- build method ------------------// + +function void router_wr_agent::build_phase(uvm_phase phase); + + super.build_phase(phase); + // get the config object using uvm_config_db + if(!uvm_config_db #(router_wr_agt_config)::get(this,"","router_wr_agt_config",m_cfg)) + `uvm_fatal("CONFIG","cannot get() m_cfg from uvm_config_db. Have you set() it?") + monh=router_wr_monitor::type_id::create("monh",this); + if(m_cfg.is_active==UVM_ACTIVE) + begin + drvh=router_wr_driver::type_id::create("drvh",this); + seqrh=router_wr_sequencer::type_id::create("seqrh",this); + end + +endfunction + + + +//----------------- connect method -------------------// + +function void router_wr_agent::connect_phase(uvm_phase phase); + if(m_cfg.is_active==UVM_ACTIVE) + begin + drvh.seq_item_port.connect(seqrh.seq_item_export); + end +endfunction diff --git a/src_agt_config.sv b/src_agt_config.sv new file mode 100644 index 0000000..47d9825 --- /dev/null +++ b/src_agt_config.sv @@ -0,0 +1,22 @@ +class router_wr_agt_config extends uvm_object; + + `uvm_object_utils(router_wr_agt_config) + + virtual router_if vif; + static int drv_data_count = 0; + static int mon_data_count = 0; + + uvm_active_passive_enum is_active = UVM_ACTIVE; + + extern function new(string name = "router_wr_agt_config"); + +endclass + + + +//----------------- constructor new method -------------------// + +function router_wr_agt_config::new(string name = "router_wr_agt_config"); + super.new(name); +endfunction + diff --git a/src_agt_top.sv b/src_agt_top.sv new file mode 100644 index 0000000..59853b0 --- /dev/null +++ b/src_agt_top.sv @@ -0,0 +1,45 @@ +class router_wr_agt_top extends uvm_env; + + `uvm_component_utils(router_wr_agt_top) + + router_wr_agent agnth[]; + + router_env_config m_cfg; + + extern function new (string name="router_wr_agt_top",uvm_component parent); + extern function void build_phase(uvm_phase phase); + +endclass + + + +//----------------- constructor new method -------------------// + +function router_wr_agt_top::new(string name="router_wr_agt_top",uvm_component parent); + super.new(name,parent); +endfunction + + + +//----------------- build method -------------------// + +function void router_wr_agt_top::build_phase(uvm_phase phase); + super.build_phase(phase); + if(!uvm_config_db #(router_env_config)::get(this,"","router_env_config",m_cfg)) + `uvm_fatal("CONFIG","cannot get() m_cfg from uvm_config_db. Have you set() it?") + + agnth = new[m_cfg.no_of_write_agent]; + + foreach(agnth[i]) + begin + // set router_wr_agent_config into the database using the + // router_env_config's router_wr_agent_config object + agnth[i]=router_wr_agent::type_id::create($sformatf("agnth[%0d]",i) ,this); + + uvm_config_db #(router_wr_agt_config)::set(this,$sformatf("agnth[%0d]*",i), "router_wr_agt_config", m_cfg.wr_agt_cfg[i]); + + end +endfunction + + + diff --git a/src_drivr.sv b/src_drivr.sv new file mode 100644 index 0000000..4746f60 --- /dev/null +++ b/src_drivr.sv @@ -0,0 +1,110 @@ +class router_wr_driver extends uvm_driver #(write_xtn); + + `uvm_component_utils(router_wr_driver) + + virtual router_if.WDR_MP vif; + router_wr_agt_config m_cfg; + + extern function new(string name ="router_wr_driver",uvm_component parent); + extern function void build_phase(uvm_phase phase); + extern function void connect_phase(uvm_phase phase); + extern task run_phase(uvm_phase phase); + extern task send_to_dut(write_xtn xtn); + extern function void report_phase(uvm_phase phase); + +endclass + + + +//----------------- constructor new method -------------------// +function router_wr_driver::new(string name ="router_wr_driver",uvm_component parent); + super.new(name,parent); +endfunction + + + +//----------------- build() phase method -------------------// +function void router_wr_driver::build_phase(uvm_phase phase); + super.build_phase(phase); + // get the config object using uvm_config_db + if(!uvm_config_db #(router_wr_agt_config)::get(this,"","router_wr_agt_config",m_cfg)) + `uvm_fatal("CONFIG","cannot get() m_cfg from uvm_config_db. Have you set() it?") +endfunction + + + +//----------------- connect() phase method -------------------// + // in connect phase assign the configuration object's virtual interface + // to the driver's virtual interface instance(handle --> "vif") +function void router_wr_driver::connect_phase(uvm_phase phase); + vif = m_cfg.vif; +endfunction + + + + +//----------------- run() phase method -------------------// + // In forever loop + // Get the sequence item using seq_item_port + // Call send_to_dut task + // Get the next sequence item using seq_item_port + + task router_wr_driver::run_phase(uvm_phase phase); + + @(vif.wdr_cb); + vif.wdr_cb.rst<=0; + @(vif.wdr_cb); + vif.wdr_cb.rst<=1; + + forever + begin + seq_item_port.get_next_item(req); + send_to_dut(req); + seq_item_port.item_done(); + end + endtask +//----------------- task send_to_dut() method -------------------// +task router_wr_driver::send_to_dut(write_xtn xtn); + `uvm_info("ROUTER_WR_DRIVER",$sformatf("printing from driver \n %s", xtn.sprint()),UVM_LOW) + // Add the write logic + @(vif.wdr_cb); + while(vif.wdr_cb.busy) + @(vif.wdr_cb); + + vif.wdr_cb.pkt_valid <= 1; + vif.wdr_cb.data_in<= xtn.header; + @(vif.wdr_cb); + + foreach(xtn.payload_data[i]) + begin + //if(vif.wdr_cb.busy) + //begin + while(vif.wdr_cb.busy) + @(vif.wdr_cb); + //end + //$display($time,"INSIDE LOOOOOOOOOOP i = %d",i0; + vif.wdr_cb.data_in<= xtn.payload_data[i]; + @(vif.wdr_cb); + end + + while(vif.wdr_cb.busy) + @(vif.wdr_cb); + vif.wdr_cb.pkt_valid <= 0; + vif.wdr_cb.data_in <= xtn.parity; + // @(vif.wdr_cb); + repeat(2) + @(vif.wdr_cb); + + xtn.err= vif.wdr_cb.error; + m_cfg.drv_data_count++; + @(vif.wdr_cb); + +endtask + + + + +//------------------------- UVM report_phase +function void router_wr_driver::report_phase(uvm_phase phase); + `uvm_info(get_type_name(), $sformatf("Report: ROUTER write driver sent %0d transactions", m_cfg.drv_data_count),UVM_LOW) +endfunction diff --git a/src_monitor.sv b/src_monitor.sv new file mode 100644 index 0000000..b25be1c --- /dev/null +++ b/src_monitor.sv @@ -0,0 +1,106 @@ +class router_wr_monitor extends uvm_monitor; + + `uvm_component_utils(router_wr_monitor) + + virtual router_if.WMON_MP vif; + router_wr_agt_config m_cfg; + + uvm_analysis_port#(write_xtn) monitor_port; + + extern function new(string name ="router_wr_monitor",uvm_component parent); + extern function void build_phase(uvm_phase phase); + extern function void connect_phase(uvm_phase phase); + extern task run_phase(uvm_phase phase); + extern task collect_data(); + extern function void report_phase(uvm_phase phase); + +endclass + + + +//----------------- constructor new method -------------------// +function router_wr_monitor::new(string name ="router_wr_monitor",uvm_component parent); + super.new(name,parent); + monitor_port = new("monitor_port",this); +endfunction + + + +//----------------- build() phase method -------------------// +function void router_wr_monitor::build_phase(uvm_phase phase); + super.build_phase(phase); + // get the config object using uvm_config_db + if(!uvm_config_db #(router_wr_agt_config)::get(this,"","router_wr_agt_config",m_cfg)) + `uvm_fatal("CONFIG","cannot get() m_cfg from uvm_config_db. Have you set() it?") +endfunction + + + +//----------------- connect() phase method -------------------// + // in connect phase assign the configuration object's virtual interface + // to the driver's virtual interface instance(handle --> "vif") +function void router_wr_monitor::connect_phase(uvm_phase phase); + vif = m_cfg.vif; +endfunction + + + +//----------------- run() phase method -------------------// + // In forever loop + // Call task collect_data +task router_wr_monitor::run_phase(uvm_phase phase); + forever + // Call collect data task + collect_data(); +endtask + + + +//-------------------collect task--------------------------------// +// Collect Reference Data from DUV IF + +task router_wr_monitor::collect_data(); + + write_xtn mon_data; + begin + mon_data = write_xtn::type_id::create("mon_data"); + + @(vif.wmon_cb); + while(!vif.wmon_cb.pkt_valid) + @(vif.wmon_cb); + while(vif.wmon_cb.busy) + @(vif.wmon_cb); + mon_data.header = vif.wmon_cb.data_in; + mon_data.payload_data = new[mon_data.header[7:2]]; + @(vif.wmon_cb) + foreach(mon_data.payload_data[i]) + begin + while(vif.wmon_cb.busy) + @(vif.wmon_cb); + mon_data.payload_data[i]=vif.wmon_cb.data_in; + @(vif.wmon_cb); + end + +// wait(!vif.wmon_cb.pkt_valid && !vif.wmon_cb.busy) + while(vif.wmon_cb.busy) + @(vif.wmon_cb); + + mon_data.parity = vif.wmon_cb.data_in; + repeat(2) @(vif.wmon_cb); + mon_data.err=vif.wmon_cb.error; + m_cfg.mon_data_count++; + + `uvm_info("ROUTER_WR_MONITOR",$sformatf("printing from monitor \n %s",mon_data.sprint()),UVM_LOW) + monitor_port.write(mon_data); + end + +endtask + + + +//------------------------ UVM report_phase------------------------------// +function void router_wr_monitor::report_phase(uvm_phase phase); + `uvm_info(get_type_name(), $sformatf("Report: ROUTER Write Monitor Collected %0d Transactions", m_cfg.mon_data_count), UVM_LOW) +endfunction + + diff --git a/src_seqs.sv b/src_seqs.sv new file mode 100644 index 0000000..9a7051f --- /dev/null +++ b/src_seqs.sv @@ -0,0 +1,137 @@ +class router_wr_seq extends uvm_sequence #(write_xtn); + + // Factory registration using `uvm_object_utils + `uvm_object_utils(router_wr_seq) + + // Standard UVM Methods: + extern function new(string name ="router_wr_seq"); +endclass + + + +//----------------- constructor new method -------------------// +function router_wr_seq::new(string name ="router_wr_seq"); + super.new(name); +endfunction + + + + +//-------------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class router_wxtns_small_pkt extends router_wr_seq; + + // Factory registration using `uvm_object_utils + `uvm_object_utils(router_wxtns_small_pkt) + + bit [1:0]addr; + + // Standard UVM Methods: + extern function new(string name ="router_wxtns_small_pkt"); + extern task body(); +endclass + + + +//----------------- constructor new method -------------------// +function router_wxtns_small_pkt::new(string name = "router_wxtns_small_pkt"); + super.new(name); +endfunction + + + +//----------------- task body method -------------------// + // Generate 10 sequence items with address always equal to 55 + // Hint use create req, start item, assert for randomization with in line + // constraint (with) finish item inside repeat's begin end block + +task router_wxtns_small_pkt::body(); + if(!uvm_config_db #(bit[1:0])::get(null,get_full_name(),"bit[1:0]",addr)) + `uvm_fatal(get_type_name(),"cannot get() addr from uvm_config_db. Have you set() it?") + + req=write_xtn::type_id::create("req"); + start_item(req); + assert(req.randomize() with {header[7:2] inside {[1:15]} && header[1:0] == addr;}); + `uvm_info("ROUTER_WR_SEQUENCE",$sformatf("printing from sequence \n %s", req.sprint()),UVM_HIGH) + finish_item(req); +endtask + + + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class router_wxtns_medium_pkt extends router_wr_seq; + + // Factory registration using `uvm_object_utils + `uvm_object_utils(router_wxtns_medium_pkt) + + bit [1:0]addr; + + // Standard UVM Methods: + extern function new(string name ="router_wxtns_medium_pkt"); + extern task body(); +endclass + + +//----------------- constructor new method -------------------// +function router_wxtns_medium_pkt::new(string name = "router_wxtns_medium_pkt"); + super.new(name); +endfunction + + +//----------------- task body method -------------------// + // Generate 10 sequence items with address always equal to 55 + // Hint use create req, start item, assert for randomization with in line + // constraint (with) finish item inside repeat's begin end block + +task router_wxtns_medium_pkt::body(); + if(!uvm_config_db #(bit[1:0])::get(null,get_full_name(),"bit[1:0]",addr)) + `uvm_fatal(get_type_name(),"cannot get() addr from uvm_config_db. Have you set() it?") + + req=write_xtn::type_id::create("req"); + start_item(req); + assert(req.randomize() with {header[7:2] inside {[16:30]} && header[1:0] == addr;}); + `uvm_info("ROUTER_WR_SEQUENCE",$sformatf("printing from sequence \n %s", req.sprint()),UVM_HIGH) + finish_item(req); +endtask + + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class router_wxtns_large_pkt extends router_wr_seq; + + + // Factory registration using `uvm_object_utils + `uvm_object_utils(router_wxtns_large_pkt) + + bit [1:0]addr; + + // Standard UVM Methods: + extern function new(string name ="router_wxtns_large_pkt"); + extern task body(); +endclass + + +//----------------- constructor new method -------------------// +function router_wxtns_large_pkt::new(string name = "router_wxtns_large_pkt"); + super.new(name); +endfunction + + +//----------------- task body method -------------------// + // Generate 10 sequence items with address always equal to 55 + // Hint use create req, start item, assert for randomization with in line + // constraint (with) finish item inside repeat's begin end block + +task router_wxtns_large_pkt::body(); + if(!uvm_config_db #(bit[1:0])::get(null,get_full_name(),"bit[1:0]",addr)) + `uvm_fatal(get_type_name(),"cannot get() addr from uvm_config_db. Have you set() it?") + + req=write_xtn::type_id::create("req"); + start_item(req); + assert(req.randomize() with {header[7:2] inside {[31:63]} && header[1:0] == addr;}); + `uvm_info("ROUTER_WR_SEQUENCE",$sformatf("printing from sequence \n %s", req.sprint()),UVM_HIGH) + finish_item(req); +endtask diff --git a/src_sequencer.sv b/src_sequencer.sv new file mode 100644 index 0000000..1b29e31 --- /dev/null +++ b/src_sequencer.sv @@ -0,0 +1,15 @@ +class router_wr_sequencer extends uvm_sequencer #(write_xtn); + + // Factory registration using `uvm_component_utils + `uvm_component_utils(router_wr_sequencer) + + // Standard UVM Methods: + extern function new(string name = "router_wr_sequencer",uvm_component parent); +endclass + + +//----------------- constructor new method -------------------// +function router_wr_sequencer::new(string name="router_wr_sequencer",uvm_component parent); + super.new(name,parent); +endfunction + diff --git a/src_xtn.sv b/src_xtn.sv new file mode 100644 index 0000000..5a7857d --- /dev/null +++ b/src_xtn.sv @@ -0,0 +1,48 @@ +class write_xtn extends uvm_sequence_item; + + `uvm_object_utils(write_xtn) + + rand bit[7:0] header;//[1:0] address + rand bit[7:0] payload_data[];//header will decide the payload length from [7:2] + + bit[7:0]parity;//xor operation of header with payloads + bit err; + + constraint c1{header[1:0]!=3;}//no address for 11 + constraint c2{payload_data.size == header[7:2];}//payload size decided by header [7:2] + constraint c3{payload_data.size!=0;}//payload size should not be zero + + extern function new(string name = "write_xtn"); + extern function void post_randomize(); + extern function void do_print(uvm_printer printer); + +endclass + + + +function write_xtn::new(string name = "write_xtn"); + super.new(name); +endfunction : new + + + +function void write_xtn::post_randomize();//after randomization, to calculate the parity + parity = 0 ^ header; + foreach(payload_data[i]) + parity = parity ^ payload_data[i]; +endfunction + + + +function void write_xtn::do_print (uvm_printer printer); + super.do_print(printer); + + // srting name bitstream value size radix for printing + printer.print_field( "header", this.header, 8, UVM_HEX ); + + foreach(payload_data[i]) + printer.print_field($sformatf("payload_data[%0d]",i), this.payload_data[i], 8, UVM_HEX ); + printer.print_field( "parity", this.parity, 8, UVM_HEX ); + +endfunction:do_print +