lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | // Copyright lowRISC contributors. |
| 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | // |
| 5 | module 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 Iyer | 639c43b | 2020-05-27 23:38:17 -0700 | [diff] [blame] | 17 | wire devmode; |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 18 | % if is_cip: |
Srikrishna Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 19 | % if has_interrupts: |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 20 | wire [NUM_MAX_INTERRUPTS-1:0] interrupts; |
Srikrishna Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 21 | % endif |
| 22 | % if has_alerts: |
Cindy Chen | 9e01990 | 2019-12-04 17:49:45 -0800 | [diff] [blame] | 23 | // TODO: change alert_names |
| 24 | list_of_alerts = {"alert_names"}; |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 25 | % endif |
Srikrishna Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 26 | % endif |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 27 | |
| 28 | // interfaces |
| 29 | clk_rst_if clk_rst_if(.clk(clk), .rst_n(rst_n)); |
| 30 | % if is_cip: |
Srikrishna Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 31 | % if has_interrupts: |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 32 | pins_if #(NUM_MAX_INTERRUPTS) intr_if(interrupts); |
Srikrishna Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 33 | % endif |
| 34 | % if has_alerts: |
Cindy Chen | 9e01990 | 2019-12-04 17:49:45 -0800 | [diff] [blame] | 35 | // TODO: declare alert interfaces according to the list_of_alerts |
| 36 | alert_if alert_names(.clk(clk), .rst_n(rst_n)) |
Srikrishna Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 37 | % endif |
Srikrishna Iyer | 639c43b | 2020-05-27 23:38:17 -0700 | [diff] [blame] | 38 | pins_if #(1) devmode_if(devmode); |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 39 | 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 Chen | 9e01990 | 2019-12-04 17:49:45 -0800 | [diff] [blame] | 52 | % 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 Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 57 | .tl_o (tl_if.d2h ) |
Cindy Chen | 9e01990 | 2019-12-04 17:49:45 -0800 | [diff] [blame] | 58 | % endif |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 59 | % 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 Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 71 | % if has_interrupts: |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 72 | uvm_config_db#(intr_vif)::set(null, "*.env", "intr_vif", intr_if); |
Srikrishna Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 73 | % endif |
| 74 | % if has_alerts: |
Cindy Chen | 9e01990 | 2019-12-04 17:49:45 -0800 | [diff] [blame] | 75 | // 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 Iyer | a8255fd | 2019-10-11 11:58:17 -0700 | [diff] [blame] | 78 | % endif |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 79 | uvm_config_db#(devmode_vif)::set(null, "*.env", "devmode_vif", devmode_if); |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 80 | 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 | |
| 89 | endmodule |