| // Copyright lowRISC contributors. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| // |
| // Testbench module for pinmux. |
| // Intended to be used with a formal tool. |
| |
| module pinmux_tb |
| import pinmux_pkg::*; |
| import pinmux_reg_pkg::*; |
| import prim_pad_wrapper_pkg::*; |
| import top_earlgrey_pkg::*; |
| #( |
| parameter logic [NumAlerts-1:0] AlertAsyncOn = {NumAlerts{1'b1}} |
| ) ( |
| input clk_i, |
| input rst_ni, |
| input rst_sys_ni, |
| input prim_mubi_pkg::mubi4_t scanmode_i, |
| input clk_aon_i, |
| input rst_aon_ni, |
| output logic pin_wkup_req_o, |
| output logic usb_wkup_req_o, |
| input sleep_en_i, |
| input strap_en_i, |
| input lc_ctrl_pkg::lc_tx_t lc_dft_en_i, |
| input lc_ctrl_pkg::lc_tx_t lc_hw_debug_en_i, |
| input lc_ctrl_pkg::lc_tx_t lc_check_byp_en_i, |
| input lc_ctrl_pkg::lc_tx_t lc_escalate_en_i, |
| output lc_ctrl_pkg::lc_tx_t pinmux_hw_debug_en_o, |
| output dft_strap_test_req_t dft_strap_test_o, |
| input dft_hold_tap_sel_i, |
| output jtag_pkg::jtag_req_t lc_jtag_o, |
| input jtag_pkg::jtag_rsp_t lc_jtag_i, |
| output jtag_pkg::jtag_req_t rv_jtag_o, |
| input jtag_pkg::jtag_rsp_t rv_jtag_i, |
| output jtag_pkg::jtag_req_t dft_jtag_o, |
| input jtag_pkg::jtag_rsp_t dft_jtag_i, |
| input usbdev_dppullup_en_i, |
| input usbdev_dnpullup_en_i, |
| output logic usb_dppullup_en_o, |
| output logic usb_dnpullup_en_o, |
| input usbdev_suspend_req_i, |
| input usbdev_wake_ack_i, |
| output logic usbdev_bus_reset_o, |
| output logic usbdev_sense_lost_o, |
| output logic usbdev_wake_detect_active_o, |
| input tlul_pkg::tl_h2d_t tl_i, |
| output tlul_pkg::tl_d2h_t tl_o, |
| input prim_alert_pkg::alert_rx_t[NumAlerts-1:0] alert_rx_i, |
| output prim_alert_pkg::alert_tx_t[NumAlerts-1:0] alert_tx_o, |
| input [NMioPeriphOut-1:0] periph_to_mio_i, |
| input [NMioPeriphOut-1:0] periph_to_mio_oe_i, |
| output logic[NMioPeriphIn-1:0] mio_to_periph_o, |
| input [NDioPads-1:0] periph_to_dio_i, |
| input [NDioPads-1:0] periph_to_dio_oe_i, |
| output logic[NDioPads-1:0] dio_to_periph_o, |
| output prim_pad_wrapper_pkg::pad_attr_t[NMioPads-1:0] mio_attr_o, |
| output logic[NMioPads-1:0] mio_out_o, |
| output logic[NMioPads-1:0] mio_oe_o, |
| input [NMioPads-1:0] mio_in_i, |
| output prim_pad_wrapper_pkg::pad_attr_t[NDioPads-1:0] dio_attr_o, |
| output logic[NDioPads-1:0] dio_out_o, |
| output logic[NDioPads-1:0] dio_oe_o, |
| input [NDioPads-1:0] dio_in_i |
| ); |
| |
| import top_earlgrey_pkg::*; |
| |
| // Copied from chip_earlgrey_asic.sv |
| // TODO: find a better way to automatically generate this FPV testbench via topgen/ipgen. |
| localparam int Tap0PadIdx = 30; |
| localparam int Tap1PadIdx = 27; |
| localparam int Dft0PadIdx = 25; |
| localparam int Dft1PadIdx = 26; |
| localparam int TckPadIdx = 38; |
| localparam int TmsPadIdx = 35; |
| localparam int TrstNPadIdx = 39; |
| localparam int TdiPadIdx = 37; |
| localparam int TdoPadIdx = 36; |
| |
| // DFT and Debug signal positions in the pinout. |
| localparam pinmux_pkg::target_cfg_t PinmuxTargetCfg = '{ |
| tck_idx: TckPadIdx, |
| tms_idx: TmsPadIdx, |
| trst_idx: TrstNPadIdx, |
| tdi_idx: TdiPadIdx, |
| tdo_idx: TdoPadIdx, |
| tap_strap0_idx: Tap0PadIdx, |
| tap_strap1_idx: Tap1PadIdx, |
| dft_strap0_idx: Dft0PadIdx, |
| dft_strap1_idx: Dft1PadIdx, |
| // TODO: check whether there is a better way to pass these USB-specific params |
| usb_dp_idx: DioUsbdevUsbDp, |
| usb_dn_idx: DioUsbdevUsbDn, |
| usb_sense_idx: MioInUsbdevSense, |
| // Pad types for attribute WARL behavior |
| dio_pad_type: { |
| BidirStd, // DIO spi_host0_csb |
| BidirStd, // DIO spi_host0_sck |
| InputStd, // DIO spi_device_csb |
| InputStd, // DIO spi_device_sck |
| BidirOd, // DIO sysrst_ctrl_aon_flash_wp_l |
| BidirOd, // DIO sysrst_ctrl_aon_ec_rst_l |
| BidirStd, // DIO spi_device_sd |
| BidirStd, // DIO spi_device_sd |
| BidirStd, // DIO spi_device_sd |
| BidirStd, // DIO spi_device_sd |
| BidirStd, // DIO spi_host0_sd |
| BidirStd, // DIO spi_host0_sd |
| BidirStd, // DIO spi_host0_sd |
| BidirStd, // DIO spi_host0_sd |
| BidirStd, // DIO usbdev_usb_dn |
| BidirStd // DIO usbdev_usb_dp |
| }, |
| mio_pad_type: { |
| BidirOd, // MIO Pad 46 |
| BidirOd, // MIO Pad 45 |
| BidirOd, // MIO Pad 44 |
| BidirOd, // MIO Pad 43 |
| BidirStd, // MIO Pad 42 |
| BidirStd, // MIO Pad 41 |
| BidirStd, // MIO Pad 40 |
| BidirStd, // MIO Pad 39 |
| BidirStd, // MIO Pad 38 |
| BidirStd, // MIO Pad 37 |
| BidirStd, // MIO Pad 36 |
| BidirStd, // MIO Pad 35 |
| BidirOd, // MIO Pad 34 |
| BidirOd, // MIO Pad 33 |
| BidirOd, // MIO Pad 32 |
| BidirStd, // MIO Pad 31 |
| BidirStd, // MIO Pad 30 |
| BidirStd, // MIO Pad 29 |
| BidirStd, // MIO Pad 28 |
| BidirStd, // MIO Pad 27 |
| BidirStd, // MIO Pad 26 |
| BidirStd, // MIO Pad 25 |
| BidirStd, // MIO Pad 24 |
| BidirStd, // MIO Pad 23 |
| BidirStd, // MIO Pad 22 |
| BidirOd, // MIO Pad 21 |
| BidirOd, // MIO Pad 20 |
| BidirOd, // MIO Pad 19 |
| BidirOd, // MIO Pad 18 |
| BidirStd, // MIO Pad 17 |
| BidirStd, // MIO Pad 16 |
| BidirStd, // MIO Pad 15 |
| BidirStd, // MIO Pad 14 |
| BidirStd, // MIO Pad 13 |
| BidirStd, // MIO Pad 12 |
| BidirStd, // MIO Pad 11 |
| BidirStd, // MIO Pad 10 |
| BidirStd, // MIO Pad 9 |
| BidirOd, // MIO Pad 8 |
| BidirOd, // MIO Pad 7 |
| BidirOd, // MIO Pad 6 |
| BidirStd, // MIO Pad 5 |
| BidirStd, // MIO Pad 4 |
| BidirStd, // MIO Pad 3 |
| BidirStd, // MIO Pad 2 |
| BidirStd, // MIO Pad 1 |
| BidirStd // MIO Pad 0 |
| } |
| }; |
| |
| pinmux #( |
| .TargetCfg(PinmuxTargetCfg), |
| .AlertAsyncOn(AlertAsyncOn) |
| ) dut_asic (.*); |
| |
| endmodule : pinmux_tb |