CORE-798 Fix Make EL GIP Library FPGA Vendor Independent.
Make uart variable bit length
This commit is contained in:
parent
d94e6b415d
commit
b235c6041a
1 changed files with 12 additions and 11 deletions
|
|
@ -25,18 +25,20 @@
|
|||
`timescale 1ns/1ps
|
||||
module uart_1MBd_uart_txrd_4 #(
|
||||
parameter OVERSAMPLE_RATE = 5'd16,
|
||||
parameter ENABLE_CLOCK_DIVIDER = 6'd52
|
||||
parameter ENABLE_CLOCK_DIVIDER = 6'd52,
|
||||
parameter DW = 4'd8,
|
||||
parameter TW = 4'd10
|
||||
)
|
||||
(
|
||||
// Port Declarations
|
||||
input wire clk,
|
||||
output wire de_out,
|
||||
output wire [7:0] rx_data_out,
|
||||
output wire [DW-1:0] rx_data_out,
|
||||
output wire rx_dv_out,
|
||||
input wire rx_en_in,
|
||||
input wire rx_in,
|
||||
output wire rx_error_out,
|
||||
input wire [7:0] tx_data_in,
|
||||
input wire [DW-1:0] tx_data_in,
|
||||
input wire tx_dv_in,
|
||||
input wire tx_en_in,
|
||||
output wire tx_out,
|
||||
|
|
@ -46,7 +48,6 @@ module uart_1MBd_uart_txrd_4 #(
|
|||
|
||||
// Parameters
|
||||
// Internal Declarations
|
||||
localparam DATA_BITS = 4'd8;
|
||||
localparam EDGE_DETECT_POSITION = OVERSAMPLE_RATE/2;
|
||||
|
||||
// RX State machine constants
|
||||
|
|
@ -71,7 +72,7 @@ wire clk_en;
|
|||
wire rx_neg_edge;
|
||||
wire rx_bit_valid;
|
||||
reg [2:0] rx_state = RX_IDLE;
|
||||
reg [3:0] rx_bit_cnt = DATA_BITS - 4'd1;
|
||||
reg [3:0] rx_bit_cnt = DW - 4'd1;
|
||||
reg rx_receiving = 1'b0;
|
||||
reg rx_done = 1'b0;
|
||||
reg rx_error = 1'b0;
|
||||
|
|
@ -81,10 +82,10 @@ wire tx_new_word;
|
|||
wire tx_next_bit;
|
||||
wire tx_last_bit;
|
||||
wire tx_done;
|
||||
reg [3:0] tx_bit_cnt = DATA_BITS + 4'd2;
|
||||
reg [3:0] tx_bit_cnt = DW + 4'd2;
|
||||
reg tx_ignore_idle = 1'b0;
|
||||
|
||||
reg [9:0] tx_data = 10'h3ff; // Extra bits allow easy addition of start bit to data.
|
||||
reg [DW+1:0] tx_data = ~0; // Extra bits allow easy addition of start bit to data.
|
||||
reg tx_rdy = 1'b1;
|
||||
reg tx_busy = 1'b0;
|
||||
|
||||
|
|
@ -141,7 +142,7 @@ begin
|
|||
if (~tx_busy | tx_next_bit) tx_bit_tmr <= (OVERSAMPLE_RATE-5'd1);
|
||||
else if (clk_en) tx_bit_tmr <= tx_bit_tmr - 5'd1;
|
||||
|
||||
if (tx_new_word) tx_bit_cnt <= DATA_BITS + 4'd2;
|
||||
if (tx_new_word) tx_bit_cnt <= DW + 4'd2;
|
||||
else if (tx_next_bit) tx_bit_cnt <= tx_bit_cnt - 4'd1;
|
||||
|
||||
if (tx_new_word) tx_busy <= 1'b1; // This takes priority, to allow continuous transmission
|
||||
|
|
@ -153,8 +154,8 @@ begin
|
|||
else
|
||||
begin
|
||||
tx_bit_tmr <= (OVERSAMPLE_RATE-5'd1);
|
||||
tx_bit_cnt <= DATA_BITS + 4'd2;
|
||||
tx_data <= 10'h3ff;
|
||||
tx_bit_cnt <= DW + 4'd2;
|
||||
tx_data <= ~0;
|
||||
tx_busy <= 1'b0;
|
||||
tx_rdy <= 1'b1;
|
||||
end
|
||||
|
|
@ -207,7 +208,7 @@ begin
|
|||
case (rx_state)
|
||||
RX_GET_START : if (rx_neg_edge)
|
||||
begin
|
||||
rx_bit_cnt <= DATA_BITS- 4'd1; // Ensure correct number of bits are counted
|
||||
rx_bit_cnt <= DW- 4'd1; // Ensure correct number of bits are counted
|
||||
rx_receiving <= 1'b1;
|
||||
rx_state <= RX_GET_DATA; // State transition
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue