comparison fpga/sniffer-pps/uart_tx.v @ 28:0f74428c177c

fpga/sniffer-pps: first version
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 29 Aug 2023 20:05:23 +0000
parents fpga/sniffer-basic/uart_tx.v@7db5fd6646df
children
comparison
equal deleted inserted replaced
27:990ecafdddb4 28:0f74428c177c
1 /*
2 * This Verilog module captures the UART output logic.
3 */
4
5 module uart_tx (IntClk, Tx_trigger, Tx_data, UART_out);
6
7 input IntClk;
8 input Tx_trigger;
9 input [15:0] Tx_data;
10 output UART_out;
11 reg UART_out;
12
13 reg tx_active;
14 reg [1:0] clk_div;
15 reg [4:0] bit_count;
16 reg [17:0] shift_reg;
17
18 initial begin
19 tx_active = 1'b0;
20 UART_out = 1'b1;
21 end
22
23 always @(posedge IntClk)
24 if (!tx_active && Tx_trigger)
25 begin
26 tx_active <= 1'b1;
27 UART_out <= 1'b0;
28 clk_div <= 2'd0;
29 shift_reg <= {Tx_data[15:8],2'b01,Tx_data[7:0]};
30 bit_count <= 5'd0;
31 end
32 else if (tx_active)
33 begin
34 clk_div <= clk_div + 2'd1;
35 if (clk_div == 2'd3)
36 begin
37 UART_out <= shift_reg[0];
38 shift_reg <= {1,shift_reg[17:1]};
39 bit_count <= bit_count + 5'd1;
40 if (bit_count == 5'd19)
41 tx_active <= 1'b0;
42 end
43 end
44
45 endmodule