Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilLord666 committed Jul 22, 2023
1 parent fa7995d commit e95933a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 5 additions & 7 deletions quick_rs232.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@
// Flow controls
`define NO_FLOW_CONTROL 0
`define CTS_RTS_FLOW_CONTROL 1
// Baud Rate
// todo(UMV) add consts ...


// Baud = Bit/s, supported values: 2400, 4800, 9600, 19200, 38400, 57600, or 115200 (RS232 )
module quick_rs232 #(
parameter CLK_FREQ = 50000000, // clk input Frequency (Hz)
parameter CLK_TICKS_PER_RS232_BIT = 434, // ticks of clock per rs232 bit (i.e 434 is a value for 50MHz at clk && 115200 bit/s RS232 speed), = clk freq / rs232 speed
parameter DEFAULT_BYTE_LEN = 8, // RS232 byte length, available values are - 5, 6, 7, 8, 9
parameter DEFAULT_PARITY = `EVEN_PARITY, // Parity: No, Even, Odd, Mark or Space
parameter DEFAULT_STOP_BITS = `ONE_STOP_BIT, // Stop bits number: 0, 1.5 or 2
parameter DEFAULT_BAUD_RATE = 115200, // Baud = Bit/s, supported values: 2400, 4800, 9600, 19200, 38400, 57600, or 115200
parameter DEFAULT_STOP_BITS = `ONE_STOP_BIT, // Stop bits number: 0, 1.5 or 2
parameter DEFAULT_RECV_BUFFER_LEN = 16, // Input (Rx) buffer size
parameter DEFAULT_FLOW_CONTROL = `NO_FLOW_CONTROL // Flow control type: NO, HARDWARE
)
Expand Down Expand Up @@ -120,8 +118,8 @@ begin
rx_data_bit_counter <= 0;
rx_data_parity <= 1'b0;
rx_err <= 1'b0;
TICKS_PER_UART_BIT <= CLK_FREQ / DEFAULT_BAUD_RATE;
HALF_TICKS_PER_UART_BIT <= TICKS_PER_UART_BIT / 2;
TICKS_PER_UART_BIT <= CLK_TICKS_PER_RS232_BIT;
HALF_TICKS_PER_UART_BIT <= CLK_TICKS_PER_RS232_BIT / 2;
j <= 0;
end
else
Expand Down
6 changes: 3 additions & 3 deletions quick_rs232_tb.v
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ wire tx_busy;

reg [31:0] counter;

localparam reg[31:0] RS232_BIT_TICKS = 50000000 / 115200; // == 434
localparam reg[31:0] RS232_BIT_TICKS = 434; // 115200 bit/s at 50 MHz

quick_rs232 #(.CLK_FREQ(50000000), .DEFAULT_BYTE_LEN(8), .DEFAULT_PARITY(1), .DEFAULT_STOP_BITS(0),
.DEFAULT_BAUD_RATE(115200), .DEFAULT_RECV_BUFFER_LEN(16), .DEFAULT_FLOW_CONTROL(0))
quick_rs232 #(.CLK_TICKS_PER_RS232_BIT(RS232_BIT_TICKS), .DEFAULT_BYTE_LEN(8), .DEFAULT_PARITY(1), .DEFAULT_STOP_BITS(0),
.DEFAULT_RECV_BUFFER_LEN(16), .DEFAULT_FLOW_CONTROL(0))
serial_dev (.clk(clk), .rst(rst), .rx(rx), .tx(tx), .rts(rts), .cts(cts),
.rx_read(rx_read), .rx_err(rx_err), .rx_data(rx_data), .rx_byte_received(rx_byte_received),
.tx_transaction(tx_transaction), .tx_data(tx_data), .tx_data_ready(tx_data_ready),
Expand Down

0 comments on commit e95933a

Please sign in to comment.