| // Copyright lowRISC contributors. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| // |
| module tb; |
| // dep packages |
| import uvm_pkg::*; |
| import dv_utils_pkg::*; |
| import pattgen_env_pkg::*; |
| import pattgen_test_pkg::*; |
| import pattgen_agent_pkg::*; |
| |
| // macro includes |
| `include "uvm_macros.svh" |
| `include "dv_macros.svh" |
| |
| wire clk, rst_n; |
| wire devmode; |
| |
| wire [NUM_PATTGEN_CHANNELS-1:0] pda_tx_o; |
| wire [NUM_PATTGEN_CHANNELS-1:0] pcl_tx_o; |
| wire intr_done_ch0; |
| wire intr_done_ch1; |
| wire [NUM_MAX_INTERRUPTS-1:0] interrupts; |
| |
| // interfaces |
| clk_rst_if clk_rst_if(.clk(clk), .rst_n(rst_n)); |
| pins_if #(NUM_MAX_INTERRUPTS) intr_if(interrupts); |
| pins_if #(1) devmode_if(devmode); |
| pattgen_if #(NUM_PATTGEN_CHANNELS) pattgen_if(); |
| tl_if tl_if(.clk(clk), .rst_n(rst_n)); |
| |
| `DV_ALERT_IF_CONNECT() |
| |
| // dut |
| pattgen dut ( |
| .clk_i (clk ), |
| .rst_ni (rst_n ), |
| |
| .tl_i (tl_if.h2d ), |
| .tl_o (tl_if.d2h ), |
| |
| .alert_rx_i (alert_rx ), |
| .alert_tx_o (alert_tx ), |
| |
| .cio_pda0_tx_o (pda_tx_o[0] ), |
| .cio_pcl0_tx_o (pcl_tx_o[0] ), |
| .cio_pda1_tx_o (pda_tx_o[1] ), |
| .cio_pcl1_tx_o (pcl_tx_o[1] ), |
| |
| // TODO: Connect and monitor these ports. |
| .cio_pda0_tx_en_o (), |
| .cio_pcl0_tx_en_o (), |
| .cio_pda1_tx_en_o (), |
| .cio_pcl1_tx_en_o (), |
| |
| .intr_done_ch0_o (intr_done_ch0 ), |
| .intr_done_ch1_o (intr_done_ch1 ) |
| ); |
| |
| assign pattgen_if.rst_ni = rst_n; |
| assign pattgen_if.clk_i = clk; |
| assign pattgen_if.pda_tx = pda_tx_o; |
| assign pattgen_if.pcl_tx = pcl_tx_o; |
| |
| assign interrupts[DoneCh0] = intr_done_ch0; |
| assign interrupts[DoneCh1] = intr_done_ch1; |
| |
| initial begin |
| // drive clk and rst_n from clk_if |
| clk_rst_if.set_active(); |
| uvm_config_db#(virtual clk_rst_if)::set(null, "*.env", "clk_rst_vif", clk_rst_if); |
| uvm_config_db#(intr_vif)::set(null, "*.env", "intr_vif", intr_if); |
| uvm_config_db#(devmode_vif)::set(null, "*.env", "devmode_vif", devmode_if); |
| uvm_config_db#(virtual tl_if)::set(null, "*.env.m_tl_agent*", "vif", tl_if); |
| uvm_config_db#(virtual pattgen_if)::set(null, "*.env.m_pattgen_agent*", "vif", pattgen_if); |
| $timeformat(-12, 0, " ps", 12); |
| run_test(); |
| end |
| |
| endmodule |