Line 42... |
Line 42... |
//
|
//
|
module uartdev(i_clk, i_rx_uart, o_tx_uart,
|
module uartdev(i_clk, i_rx_uart, o_tx_uart,
|
i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
|
i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
|
o_wb_ack, o_wb_stall, o_wb_data,
|
o_wb_ack, o_wb_stall, o_wb_data,
|
o_rx_int, o_tx_int);
|
o_rx_int, o_tx_int);
|
parameter DEFAULT_SETUP = { 2'b00, 1'b0, 1'b0, 2'b00, 24'd10417 };
|
parameter DEFAULT_SETUP = { 2'b00, 1'b0, 1'b0, 2'b00, 24'd8333 };
|
input i_clk, i_rx_uart;
|
input i_clk, i_rx_uart;
|
output wire o_tx_uart;
|
output wire o_tx_uart;
|
input i_wb_cyc, i_wb_stb, i_wb_we;
|
input i_wb_cyc, i_wb_stb, i_wb_we;
|
input [1:0] i_wb_addr;
|
input [1:0] i_wb_addr;
|
input [31:0] i_wb_data;
|
input [31:0] i_wb_data;
|
Line 63... |
Line 63... |
if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we)&&(~i_wb_addr[1]))
|
if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we)&&(~i_wb_addr[1]))
|
r_setup <= i_wb_data[29:0];
|
r_setup <= i_wb_data[29:0];
|
|
|
initial r_tx_stb = 1'b0;
|
initial r_tx_stb = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we)&&(i_wb_addr == 2'b10))
|
if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we)&&(i_wb_addr == 2'b11))
|
begin
|
begin
|
// Note: there's no check for overflow here.
|
// Note: there's no check for overflow here.
|
// You're on your own: verify that the device
|
// You're on your own: verify that the device
|
// isn't busy first.
|
// isn't busy first.
|
r_tx_data <= i_wb_data[7:0];
|
r_tx_data <= i_wb_data[7:0];
|
Line 98... |
Line 98... |
rx_rdy <= (rx_rdy | rx_stb);
|
rx_rdy <= (rx_rdy | rx_stb);
|
|
|
case(i_wb_addr)
|
case(i_wb_addr)
|
2'b00: o_wb_data <= { 2'b00, r_setup };
|
2'b00: o_wb_data <= { 2'b00, r_setup };
|
2'b01: o_wb_data <= { 2'b00, r_setup };
|
2'b01: o_wb_data <= { 2'b00, r_setup };
|
2'b10: o_wb_data <= { 31'h00,tx_busy };
|
2'b10: begin
|
2'b11: begin
|
|
if ((i_wb_cyc)&&(i_wb_stb)&&(~i_wb_we))
|
if ((i_wb_cyc)&&(i_wb_stb)&&(~i_wb_we))
|
rx_rdy <= rx_stb;
|
rx_rdy <= rx_stb;
|
o_wb_data <= { 20'h00, rx_break, rx_frame_err, rx_parity_err, ~rx_rdy, r_data };
|
o_wb_data <= { 20'h00, rx_break, rx_frame_err, rx_parity_err, ~rx_rdy, r_data };
|
end
|
end
|
|
2'b11: o_wb_data <= { 31'h00,tx_busy };
|
endcase
|
endcase
|
o_wb_ack <= (i_wb_cyc)&&(i_wb_stb); // Read or write, we ack
|
o_wb_ack <= (i_wb_cyc)&&(i_wb_stb); // Read or write, we ack
|
end
|
end
|
|
|
assign o_wb_stall = 1'b0;
|
assign o_wb_stall = 1'b0;
|