184 lines
7.1 KiB
Systemverilog
184 lines
7.1 KiB
Systemverilog
// Generated by CIRCT firtool-1.151.0
|
|
module TLFpgaUART(
|
|
input clock,
|
|
reset,
|
|
output auto_in_a_ready,
|
|
input auto_in_a_valid,
|
|
input [2:0] auto_in_a_bits_opcode,
|
|
input [1:0] auto_in_a_bits_size,
|
|
input [5:0] auto_in_a_bits_source,
|
|
input [28:0] auto_in_a_bits_address,
|
|
input [7:0] auto_in_a_bits_mask,
|
|
input [63:0] auto_in_a_bits_data,
|
|
input auto_in_d_ready,
|
|
output auto_in_d_valid,
|
|
output [2:0] auto_in_d_bits_opcode,
|
|
output [1:0] auto_in_d_bits_size,
|
|
output [5:0] auto_in_d_bits_source,
|
|
output [63:0] auto_in_d_bits_data,
|
|
output auto_txd_out,
|
|
input auto_rxd_in
|
|
);
|
|
|
|
wire _out_back_front_q_io_deq_valid;
|
|
wire _out_back_front_q_io_deq_bits_read;
|
|
wire [8:0] _out_back_front_q_io_deq_bits_index;
|
|
wire [63:0] _out_back_front_q_io_deq_bits_data;
|
|
wire [7:0] _out_back_front_q_io_deq_bits_mask;
|
|
reg [31:0] clockFrequency;
|
|
reg [31:0] baudRate;
|
|
reg [31:0] divisor;
|
|
reg [9:0] txReg;
|
|
reg txBusy;
|
|
reg [31:0] txDiv;
|
|
reg [3:0] txCount;
|
|
reg rxSync_REG;
|
|
reg rxSync;
|
|
reg rxPrev;
|
|
reg rxBusy;
|
|
reg [31:0] rxDiv;
|
|
reg [3:0] rxCount;
|
|
reg [7:0] rxShift;
|
|
reg [7:0] rxData;
|
|
reg rxValid;
|
|
wire _out_out_bits_data_T_1 =
|
|
_out_back_front_q_io_deq_bits_index[8:2] == 7'h0;
|
|
wire [3:0] _out_backSel_T = 4'h1 << _out_back_front_q_io_deq_bits_index[1:0];
|
|
wire _out_wofireMux_T = _out_back_front_q_io_deq_valid & auto_in_d_ready;
|
|
wire _out_wofireMux_T_2 =
|
|
_out_wofireMux_T & ~_out_back_front_q_io_deq_bits_read;
|
|
wire out_woready_5 =
|
|
_out_wofireMux_T_2 & _out_backSel_T[2] & _out_out_bits_data_T_1;
|
|
wire [3:0][63:0] _GEN =
|
|
{{{32'h0, divisor}},
|
|
{{baudRate, clockFrequency}},
|
|
{{31'h0, rxValid, 31'h0, ~txBusy}},
|
|
{{24'h0, rxData, 32'h0}}};
|
|
always @(posedge clock) begin
|
|
if (reset) begin
|
|
clockFrequency <= 32'h5F5E100;
|
|
baudRate <= 32'h1C200;
|
|
divisor <= 32'h364;
|
|
txReg <= 10'h1;
|
|
txBusy <= 1'h0;
|
|
txDiv <= 32'h0;
|
|
txCount <= 4'h0;
|
|
rxSync_REG <= 1'h1;
|
|
rxSync <= 1'h1;
|
|
rxPrev <= 1'h1;
|
|
rxBusy <= 1'h0;
|
|
rxDiv <= 32'h0;
|
|
rxCount <= 4'h0;
|
|
rxShift <= 8'h0;
|
|
rxData <= 8'h0;
|
|
rxValid <= 1'h0;
|
|
end
|
|
else begin
|
|
automatic logic _rxStartDelay_T;
|
|
automatic logic [31:0] divisorMinusOne;
|
|
automatic logic _GEN_0;
|
|
automatic logic _GEN_1;
|
|
automatic logic _GEN_2 = ~rxBusy & rxPrev & ~rxSync;
|
|
automatic logic _GEN_3;
|
|
automatic logic _GEN_4;
|
|
automatic logic _GEN_5;
|
|
automatic logic _out_T_10 =
|
|
_out_wofireMux_T_2 & _out_backSel_T[0] & _out_out_bits_data_T_1
|
|
& _out_back_front_q_io_deq_bits_mask[0] & ~txBusy;
|
|
automatic logic [31:0] _out_womask_T_6 =
|
|
{{8{_out_back_front_q_io_deq_bits_mask[3]}},
|
|
{8{_out_back_front_q_io_deq_bits_mask[2]}},
|
|
{8{_out_back_front_q_io_deq_bits_mask[1]}},
|
|
{8{_out_back_front_q_io_deq_bits_mask[0]}}};
|
|
_rxStartDelay_T = divisor < 32'h2;
|
|
divisorMinusOne = _rxStartDelay_T ? 32'h1 : divisor - 32'h1;
|
|
_GEN_0 = txDiv == divisorMinusOne;
|
|
_GEN_1 = txCount == 4'h0;
|
|
_GEN_3 = rxDiv == 32'h0;
|
|
_GEN_4 = rxBusy & _GEN_3 & ~(rxCount[3]);
|
|
_GEN_5 = rxBusy & _GEN_3;
|
|
if (out_woready_5 & (&_out_womask_T_6))
|
|
clockFrequency <= _out_back_front_q_io_deq_bits_data[31:0];
|
|
if (out_woready_5
|
|
& (&{{8{_out_back_front_q_io_deq_bits_mask[7]}},
|
|
{8{_out_back_front_q_io_deq_bits_mask[6]}},
|
|
{8{_out_back_front_q_io_deq_bits_mask[5]}},
|
|
{8{_out_back_front_q_io_deq_bits_mask[4]}}}))
|
|
baudRate <= _out_back_front_q_io_deq_bits_data[63:32];
|
|
if (_out_wofireMux_T_2 & _out_backSel_T[3] & _out_out_bits_data_T_1
|
|
& (&_out_womask_T_6))
|
|
divisor <= _out_back_front_q_io_deq_bits_data[31:0];
|
|
if (_out_T_10) begin
|
|
txReg <= {1'h1, _out_back_front_q_io_deq_bits_data[7:0], 1'h0};
|
|
txDiv <= 32'h0;
|
|
txCount <= 4'h9;
|
|
end
|
|
else begin
|
|
automatic logic _GEN_6;
|
|
_GEN_6 = txBusy & _GEN_0;
|
|
if (_GEN_6)
|
|
txReg <= _GEN_1 ? 10'h3FF : {1'h1, txReg[9:1]};
|
|
if (txBusy)
|
|
txDiv <= _GEN_0 ? 32'h0 : txDiv + 32'h1;
|
|
if (~_GEN_6 | _GEN_1) begin
|
|
end
|
|
else
|
|
txCount <= txCount - 4'h1;
|
|
end
|
|
txBusy <= _out_T_10 | ~(txBusy & _GEN_0 & _GEN_1) & txBusy;
|
|
rxSync_REG <= auto_rxd_in;
|
|
rxSync <= rxSync_REG;
|
|
rxPrev <= rxSync;
|
|
rxBusy <= _GEN_2 | (~_GEN_5 | ~(rxCount[3])) & rxBusy;
|
|
if (_GEN_2) begin
|
|
rxDiv <= _rxStartDelay_T ? 32'h1 : divisor + {1'h0, divisor[31:1]} - 32'h1;
|
|
rxCount <= 4'h0;
|
|
end
|
|
else begin
|
|
if (rxBusy)
|
|
rxDiv <= _GEN_3 ? divisorMinusOne : rxDiv - 32'h1;
|
|
if (_GEN_4)
|
|
rxCount <= rxCount + 4'h1;
|
|
end
|
|
if (_GEN_2 | ~_GEN_4) begin
|
|
end
|
|
else
|
|
rxShift <= {rxSync, rxShift[7:1]};
|
|
if (_GEN_2 | ~(_GEN_5 & rxCount[3] & rxSync)) begin
|
|
end
|
|
else
|
|
rxData <= rxShift;
|
|
rxValid <=
|
|
~(_out_wofireMux_T & _out_back_front_q_io_deq_bits_read & _out_backSel_T[0]
|
|
& _out_out_bits_data_T_1 & _out_back_front_q_io_deq_bits_mask[4])
|
|
& (~_GEN_2 & _GEN_5 & rxCount[3] & rxSync | rxValid);
|
|
end
|
|
end // always @(posedge)
|
|
Queue1_RegMapperInput_i9_m8 out_back_front_q (
|
|
.clock (clock),
|
|
.reset (reset),
|
|
.io_enq_ready (auto_in_a_ready),
|
|
.io_enq_valid (auto_in_a_valid),
|
|
.io_enq_bits_read (auto_in_a_bits_opcode == 3'h4),
|
|
.io_enq_bits_index (auto_in_a_bits_address[11:3]),
|
|
.io_enq_bits_data (auto_in_a_bits_data),
|
|
.io_enq_bits_mask (auto_in_a_bits_mask),
|
|
.io_enq_bits_extra_tlrr_extra_source (auto_in_a_bits_source),
|
|
.io_enq_bits_extra_tlrr_extra_size (auto_in_a_bits_size),
|
|
.io_deq_ready (auto_in_d_ready),
|
|
.io_deq_valid (_out_back_front_q_io_deq_valid),
|
|
.io_deq_bits_read (_out_back_front_q_io_deq_bits_read),
|
|
.io_deq_bits_index (_out_back_front_q_io_deq_bits_index),
|
|
.io_deq_bits_data (_out_back_front_q_io_deq_bits_data),
|
|
.io_deq_bits_mask (_out_back_front_q_io_deq_bits_mask),
|
|
.io_deq_bits_extra_tlrr_extra_source (auto_in_d_bits_source),
|
|
.io_deq_bits_extra_tlrr_extra_size (auto_in_d_bits_size)
|
|
);
|
|
assign auto_in_d_valid = _out_back_front_q_io_deq_valid;
|
|
assign auto_in_d_bits_opcode = {2'h0, _out_back_front_q_io_deq_bits_read};
|
|
assign auto_in_d_bits_data =
|
|
_out_out_bits_data_T_1 ? _GEN[_out_back_front_q_io_deq_bits_index[1:0]] : 64'h0;
|
|
assign auto_txd_out = txReg[0];
|
|
endmodule
|
|
|