EDA Playground lets you type in and run HDL code (using a selection of free and commercial simulators and synthesizers).
It's great for learning HDLs, it's great for testing out unfamiliar things and it's great for sharing code.
You can start typing straight away. But to run your code, you'll need to sign or log in. Logging in with a Google account gives you access to all non-commercial simulators and some commercial simulators:
To run commercial simulators, you need to register and log in with a username and password. Registration is free, and only pre-approved email's will have access to the commercial simulators.
204
// Code your testbench here
// or browse Examples
`include "uvm_macros.svh"
import uvm_pkg::*;
typedef enum {GOOD, BAD_ERR1, BAD_ERR2} pkt_type;
pkt_type pkt;
`include "callbacks.sv"
`include "driver.sv"
`include "env.sv"
`include "tests.sv"
module tb_top;
initial begin
run_test();
end
endmodule
class driver extends uvm_component;
`uvm_component_utils(driver)
`uvm_register_cb(driver,driver_cb) // callback registration
function new(string name = "driver", uvm_component parent = null);
super.new(name,parent);
endfunction
task run_phase(uvm_phase phase);
super.run_phase(phase);
drive();
`uvm_do_callbacks(driver,driver_cb,modify_pkt()); // callback hook
`uvm_info(get_full_name(),$sformatf("Driven pkt is %s", pkt.name()),UVM_LOW);
endtask
task drive();
`uvm_info(get_full_name(),"Inside drive method",UVM_LOW);
std::randomize(pkt) with {pkt == GOOD;};
endtask
endclass
xxxxxxxxxx
class env extends uvm_env;
driver drv;
`uvm_component_utils(env)
function new(string name = "env", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
drv = driver::type_id::create("drv", this);
endfunction
endclass
xxxxxxxxxx
class base_test extends uvm_test;
`uvm_component_utils(base_test)
env env_o;
function new(string name = "base_test", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
env_o = env::type_id::create("env_o", this);
endfunction
endclass
class err_test extends base_test;
derived_cb drvd_cb;
`uvm_component_utils(err_test)
function new(string name = "err_test", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
drvd_cb = derived_cb::type_id::create("drvd_cb", this);
uvm_callbacks#(driver, driver_cb)::add(env_o.drv, drvd_cb);
endfunction
endclass
xxxxxxxxxx
class driver_cb extends uvm_callback;
`uvm_object_utils(driver_cb)
function new(string name = "driver_cb");
super.new(name);
endfunction
virtual task modify_pkt();
endtask
endclass
class derived_cb extends driver_cb;
`uvm_object_utils(derived_cb)
function new(string name = "derived_cb");
super.new(name);
endfunction
task modify_pkt; // callback method implementation
`uvm_info(get_full_name(),"Inside modify_pkt method: Injecting error pkt",UVM_LOW);
std::randomize(pkt) with {pkt inside {BAD_ERR1, BAD_ERR2};};
endtask
endclass
xxxxxxxxxx
Your account is not validated. If you wish to use commercial simulators, you need a validated account.
If you have already registered (or have recently changed your email address), but have not clicked on the link in the email we sent you, please do so. If you cannot find the email, please check your spam/junk folder. Or click here to resend the email.
If you have not already registered for a full account, you can do so by clicking below. You will then need to provide us with some identification information. You may wish to save your code first.
Creating, deleting, and renaming files is not supported during Collaboration. To encourage development of these features for Collaboration, tweet to @EDAPlayground
This playground may have been modified. Please save or copy before starting collaboration.
Your exercise has been submitted.