| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- `timescale 1ns/1ps
- module host_port_selector_tb;
- reg clk = 0;
- reg rst_n = 0;
- reg rs_rx = 1;
- reg ttl_rx = 1;
- reg tx = 1;
- reg done = 0;
- wire selected_rx;
- wire rs_tx;
- wire ttl_tx;
- wire locked;
- wire select;
- wire rs_sync;
- wire ttl_sync;
- always #5 clk = ~clk;
- host_port_selector dut (
- .clk(clk), .rst_n(rst_n), .rs232_rx_async(rs_rx), .ttl_rx_async(ttl_rx),
- .shared_tx(tx), .transaction_done(done), .selected_rx(selected_rx),
- .rs232_tx(rs_tx), .ttl_tx(ttl_tx), .locked(locked), .port_sel(select),
- .rs232_rx_sync(rs_sync), .ttl_rx_sync(ttl_sync)
- );
- initial begin
- repeat (3) @(negedge clk);
- rst_n = 1;
- rs_rx = 0;
- repeat (4) @(negedge clk);
- if (!locked || select) $fatal;
- tx = 0;
- @(negedge clk);
- if (rs_tx !== 0 || ttl_tx !== 1) $fatal;
- rs_rx = 1;
- done = 1;
- repeat (4) @(negedge clk);
- done = 0;
- if (locked) $fatal;
- ttl_rx = 0;
- repeat (4) @(negedge clk);
- if (!locked || !select) $fatal;
- tx = 0;
- if (rs_tx !== 1 || ttl_tx !== 0) $fatal;
- $display("PASS: host_port_selector_tb");
- $finish;
- end
- endmodule
|