FPGA_module/uart/uart_tb.v

84 lines
1.5 KiB
Coq
Raw Normal View History

2024-08-04 06:24:44 +00:00
`timescale 1ns/1ps
module clk_tb;
reg clk, rst_n;
initial begin
clk = 0;
end
always #1 clk = ~clk;
initial begin
rst_n = 1;
#1 rst_n = 0;
#1 rst_n = 1;
end
// module uart_top(
// input wire clk,
// input wire rst_n,
// output wire clk_uart_tx,
// output wire tx_pin,
// output wire tx_busy,
// input wire rx_pin,
// output wire[7:0] rx_data;
// output wire rx_rdy;
// );
wire clk_uart_tx;
wire tx_pin;
wire tx_busy;
reg rx_pin;
wire[7:0] rx_data;
wire rx_rdy;
uart_top uart_top_inst(
.clk(clk),
.rst_n(rst_n),
.clk_uart_tx(clk_uart_tx),
.tx_pin(tx_pin),
.tx_busy(tx_busy),
.rx_pin(rx_pin),
.rx_data(rx_data),
.rx_rdy(rx_rdy)
);
reg [7:0] tx_data;
initial begin
rx_pin = 1;
#10;
tx_data = 8'h55;
rx_pin = 1'b0;#200;
rx_pin = tx_data[0] ;#200;
rx_pin = tx_data[1] ;#200;
rx_pin = tx_data[2] ;#200;
rx_pin = tx_data[3] ;#200;
rx_pin = tx_data[4] ;#200;
rx_pin = tx_data[5] ;#200;
rx_pin = tx_data[6] ;#200;
rx_pin = tx_data[7] ;#200;
rx_pin = 1'b1 ;#200;
// #200;
tx_data = 8'hAA;
rx_pin = 1'b0 ;#200;
rx_pin = tx_data[0] ;#200;
rx_pin = tx_data[1] ;#200;
rx_pin = tx_data[2] ;#200;
rx_pin = tx_data[3] ;#200;
rx_pin = tx_data[4] ;#200;
rx_pin = tx_data[5] ;#200;
rx_pin = tx_data[6] ;#200;
rx_pin = tx_data[7] ;#200;
rx_pin = 1'b1 ;#200;
#200;
end
initial begin
$dumpfile("uart_tb.vcd");
$dumpvars(0, clk_tb);
#100000 $finish;
end
endmodule