|
| 1 | +// Copyright 2025 ETH Zurich and University of Bologna. |
| 2 | +// Solderpad Hardware License, Version 0.51, see LICENSE for details. |
| 3 | +// SPDX-License-Identifier: SHL-0.51 |
| 4 | +// |
| 5 | +// Authors: |
| 6 | +// - Thomas Benz <tbenz@iis.ee.ethz.ch> |
| 7 | + |
| 8 | +`timescale 1ns/1ns |
| 9 | +module fbtb_croc_soc(); |
| 10 | + |
| 11 | + localparam time Period = 100ns; |
| 12 | + localparam time PeriodHalf = Period / 2; |
| 13 | + localparam time TAppl = 20ns; |
| 14 | + localparam time TTest = 80ns; |
| 15 | + |
| 16 | + int fd = 0; |
| 17 | + int sim_time = 0; |
| 18 | + int ret = 0; |
| 19 | + string line; |
| 20 | + logic clk_sample = 0; |
| 21 | + |
| 22 | + // chip signals from file |
| 23 | + logic clk_i; |
| 24 | + logic rst_ni; |
| 25 | + logic ref_clk_i; |
| 26 | + logic testmode_i; |
| 27 | + logic fetch_en_i; |
| 28 | + logic status_o, status_to; |
| 29 | + logic jtag_tck_i; |
| 30 | + logic jtag_tdi_i; |
| 31 | + logic jtag_tdo_o, jtag_tdo_to; |
| 32 | + logic jtag_tms_i; |
| 33 | + logic jtag_trst_ni; |
| 34 | + logic uart_rx_i; |
| 35 | + logic uart_tx_o, uart_tx_to; |
| 36 | + logic [15:0] gpio_i; |
| 37 | + logic [15:0] gpio_o, gpio_to; |
| 38 | + logic [15:0] gpio_out_en_o, gpio_out_en_to; |
| 39 | + |
| 40 | + initial begin |
| 41 | + forever begin |
| 42 | + clk_sample = !clk_sample; |
| 43 | + #PeriodHalf; |
| 44 | + end |
| 45 | + end |
| 46 | + |
| 47 | + initial begin |
| 48 | + fd = $fopen("../vsim/stimuli.txt", "r"); |
| 49 | + while (!$feof(fd)) begin |
| 50 | + // fetch line |
| 51 | + ret = $fgets(line, fd); |
| 52 | + // parse line, apply data to chip |
| 53 | + #TAppl; |
| 54 | + ret = $fscanf(fd, "%010d.%01b%01b%01b%01b%01b%01b%01b%01b%01b%01b%16b.%01b%01b%01b%16b%16b", |
| 55 | + sim_time, |
| 56 | + clk_i, |
| 57 | + rst_ni, |
| 58 | + ref_clk_i, |
| 59 | + testmode_i, |
| 60 | + fetch_en_i, |
| 61 | + jtag_tck_i, |
| 62 | + jtag_tdi_i, |
| 63 | + jtag_tms_i, |
| 64 | + jtag_trst_ni, |
| 65 | + uart_rx_i, |
| 66 | + gpio_i, |
| 67 | + status_to, |
| 68 | + jtag_tdo_to, |
| 69 | + uart_tx_to, |
| 70 | + gpio_to, |
| 71 | + gpio_out_en_to |
| 72 | + ); |
| 73 | + // test outputs |
| 74 | + #(TTest - TAppl); |
| 75 | + if (status_o !== status_to )$warning("Output mismatch status_o (%01b instead of %01b) at: %010d", status_o, status_to, sim_time); |
| 76 | + if (jtag_tdo_o !== jtag_tdo_to )$warning("Output mismatch jtag_tdo_o (%01b instead of %01b) at: %010d", jtag_tdo_o, jtag_tdo_to, sim_time); |
| 77 | + if (uart_tx_o !== uart_tx_to )$warning("Output mismatch uart_tx_o (%01b instead of %01b) at: %010d", uart_tx_o, uart_tx_to, sim_time); |
| 78 | + if (gpio_o !== gpio_to )$warning("Output mismatch gpio_o (%01b instead of %01b) at: %010d", gpio_o, gpio_to, sim_time); |
| 79 | + if (gpio_out_en_o !== gpio_out_en_to)$warning("Output mismatch gpio_out_en_o (%01b instead of %01b) at: %010d", gpio_out_en_o, gpio_out_en_to, sim_time); |
| 80 | + // next sample |
| 81 | + @(posedge clk_sample); |
| 82 | + end |
| 83 | + $finish; |
| 84 | + $fclose(fd); |
| 85 | + end |
| 86 | +endmodule |
0 commit comments