forked from tanchou/Verilog
Add UART communication modules and testbenches
- Implemented rx_fifo module for receiving data with FIFO management. - Created tb_top_uart_rx_tx testbench for testing UART transmission and reception. - Developed tb_uart_rx testbench for validating UART receiver functionality. - Added tb_uart_tx testbench for testing UART transmitter behavior. - Designed top_led_uart module to interface UART with LED outputs. - Integrated top_uart_ultrasonic module for ultrasonic sensor data transmission via UART. - Implemented tx_fifo module for transmitting data with FIFO management. - Developed uart_rx module for receiving serial data with state machine control. - Created uart_top module to connect RX and TX functionalities with FIFO buffers. - Implemented uart_tx module for transmitting serial data with state machine control.
This commit is contained in:
49
Semaine_3/UARTV2/tb_uart_tx.v
Normal file
49
Semaine_3/UARTV2/tb_uart_tx.v
Normal file
@@ -0,0 +1,49 @@
|
||||
`timescale 1ns/1ps
|
||||
|
||||
module tb_uart_tx;
|
||||
|
||||
reg clk = 0;
|
||||
reg start = 0;
|
||||
reg [7:0] data = 8'h00;
|
||||
wire tx;
|
||||
wire busy;
|
||||
|
||||
always #18.5 clk = ~clk;
|
||||
|
||||
uart_tx #(
|
||||
.CLK_FREQ(27_000_000),
|
||||
.BAUD_RATE(115_200)
|
||||
)tx_instance (
|
||||
.clk(clk),
|
||||
.start(start),
|
||||
.data(data),
|
||||
.tx(tx),
|
||||
.busy(busy)
|
||||
);
|
||||
|
||||
initial begin
|
||||
$dumpfile("uart_tx.vcd");
|
||||
$dumpvars(0, tb_uart_tx);
|
||||
|
||||
#100;
|
||||
|
||||
data <= 8'hA5; // 10100101 0xA5
|
||||
start <= 1;
|
||||
#37 start <= 0;
|
||||
|
||||
// Attendre
|
||||
wait (busy == 0);
|
||||
|
||||
#1000;
|
||||
|
||||
data <= 8'h3C; // 00111100 0x3C
|
||||
start <= 1;
|
||||
#37 start <= 0;
|
||||
|
||||
wait (busy == 0);
|
||||
|
||||
#1000;
|
||||
$stop;
|
||||
end
|
||||
|
||||
endmodule
|
Reference in New Issue
Block a user