Chapter 9 – Env

We are getting close to have a working testbench, there are two classes missing: the env and the test.

The env is a very simple class that instantiates the agent and the scoreboard and connects them together.

The source is represented in Code 9.1.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class simpleadder_env extends uvm_env;
     `uvm_component_utils(simpleadder_env)
 
     simpleadder_agent sa_agent;
     simpleadder_scoreboard sa_sb;
 
     function new(string name, uvm_component parent);
          super.new(name, parent);
     endfunction: new
 
     function void build_phase(uvm_phase phase);
          super.build_phase(phase);
          sa_agent    = simpleadder_agent::type_id::create(...
          sa_sb        = simpleadder_scoreboard::type_id::create(...
     endfunction: build_phase
 
     function void connect_phase(uvm_phase phase);
          super.connect_phase(phase);
          sa_agent.agent_ap_before.connect(sa_sb.sb_export_before);
          sa_agent.agent_ap_after.connect(sa_sb.sb_export_after);
     endfunction: connect_phase
endclass: simpleadder_env

Code 9.1 – Code for the env

In Figure 9.1, it’s represented the current state of our testbench. There is only one component left now: the test class.

State of the testbench after the envCode 9.1 – State of the testbench after the env

The code for the env can be found here: