blob: ea20a8a4b8dc3bbaeaa93af2ade0aa29efe3f4dc [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4//
5module tb;
6 // dep packages
7 import uvm_pkg::*;
8 import dv_utils_pkg::*;
9 import ${name}_env_pkg::*;
10 import ${name}_test_pkg::*;
11
12 // macro includes
13 `include "uvm_macros.svh"
14 `include "dv_macros.svh"
15
16 wire clk, rst_n;
Srikrishna Iyer639c43b2020-05-27 23:38:17 -070017 wire devmode;
lowRISC Contributors802543a2019-08-31 12:12:56 +010018% if is_cip:
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070019% if has_interrupts:
lowRISC Contributors802543a2019-08-31 12:12:56 +010020 wire [NUM_MAX_INTERRUPTS-1:0] interrupts;
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070021% endif
22% if has_alerts:
Cindy Chen9e019902019-12-04 17:49:45 -080023 // TODO: change alert_names
24 list_of_alerts = {"alert_names"};
lowRISC Contributors802543a2019-08-31 12:12:56 +010025% endif
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070026% endif
lowRISC Contributors802543a2019-08-31 12:12:56 +010027
28 // interfaces
29 clk_rst_if clk_rst_if(.clk(clk), .rst_n(rst_n));
30% if is_cip:
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070031% if has_interrupts:
lowRISC Contributors802543a2019-08-31 12:12:56 +010032 pins_if #(NUM_MAX_INTERRUPTS) intr_if(interrupts);
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070033% endif
34% if has_alerts:
Cindy Chen9e019902019-12-04 17:49:45 -080035 // TODO: declare alert interfaces according to the list_of_alerts
36 alert_if alert_names(.clk(clk), .rst_n(rst_n))
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070037% endif
Srikrishna Iyer639c43b2020-05-27 23:38:17 -070038 pins_if #(1) devmode_if(devmode);
lowRISC Contributors802543a2019-08-31 12:12:56 +010039 tl_if tl_if(.clk(clk), .rst_n(rst_n));
40% endif
41% for agent in env_agents:
42 ${agent}_if ${agent}_if();
43% endfor
44
45 // dut
46 ${name} dut (
47 .clk_i (clk ),
48% if is_cip:
49 .rst_ni (rst_n ),
50
51 .tl_i (tl_if.h2d ),
Cindy Chen9e019902019-12-04 17:49:45 -080052% if has_alerts:
53 .tl_o (tl_if.d2h ),
54 .alert_rx_i (alert_names.alert_rx ),
55 .alert_tx_o (alert_names.alert_tx )
56% else:
lowRISC Contributors802543a2019-08-31 12:12:56 +010057 .tl_o (tl_if.d2h )
Cindy Chen9e019902019-12-04 17:49:45 -080058% endif
lowRISC Contributors802543a2019-08-31 12:12:56 +010059% else:
60 .rst_ni (rst_n )
61
62% endif
63 // TODO: add remaining IOs and hook them
64 );
65
66 initial begin
67 // drive clk and rst_n from clk_if
68 clk_rst_if.set_active();
69 uvm_config_db#(virtual clk_rst_if)::set(null, "*.env", "clk_rst_vif", clk_rst_if);
70% if is_cip:
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070071% if has_interrupts:
lowRISC Contributors802543a2019-08-31 12:12:56 +010072 uvm_config_db#(intr_vif)::set(null, "*.env", "intr_vif", intr_if);
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070073% endif
74% if has_alerts:
Cindy Chen9e019902019-12-04 17:49:45 -080075 // TODO: set alert interfaces with the correct names
76 uvm_config_db#(virtual alert_if)::set(null, "*.env.m_alert_agent_alert_names",
77 "vif", alert_names);
Srikrishna Iyera8255fd2019-10-11 11:58:17 -070078% endif
lowRISC Contributors802543a2019-08-31 12:12:56 +010079 uvm_config_db#(devmode_vif)::set(null, "*.env", "devmode_vif", devmode_if);
lowRISC Contributors802543a2019-08-31 12:12:56 +010080 uvm_config_db#(virtual tl_if)::set(null, "*.env.m_tl_agent*", "vif", tl_if);
81% endif
82% for agent in env_agents:
83 uvm_config_db#(virtual ${agent}_if)::set(null, "*.env.m_${agent}_agent*", "vif", ${agent}_if);
84% endfor
85 $timeformat(-12, 0, " ps", 12);
86 run_test();
87 end
88
89endmodule