Line 62... |
Line 62... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.9 2001/10/20 09:58:40 gorban
|
|
// Small synopsis fixes
|
|
//
|
// Revision 1.8 2001/08/24 21:01:12 mohor
|
// Revision 1.8 2001/08/24 21:01:12 mohor
|
// Things connected to parity changed.
|
// Things connected to parity changed.
|
// Clock devider changed.
|
// Clock devider changed.
|
//
|
//
|
// Revision 1.7 2001/08/23 16:05:05 mohor
|
// Revision 1.7 2001/08/23 16:05:05 mohor
|
Line 98... |
Line 101... |
|
|
// synopsys translate_off
|
// synopsys translate_off
|
`include "timescale.v"
|
`include "timescale.v"
|
// synopsys translate_on
|
// synopsys translate_on
|
|
|
module uart_wb (clk,
|
module uart_wb (clk, wb_rst_i,
|
wb_rst_i,
|
|
wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o,
|
wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o,
|
|
wb_dat_i, wb_dat_o, wb_dat8_i, wb_dat8_o, wb_dat32_o, wb_sel_i,
|
we_o, re_o // Write and read enable output for the core
|
we_o, re_o // Write and read enable output for the core
|
|
|
);
|
);
|
|
|
input clk;
|
input clk;
|
|
|
// WISHBONE interface
|
// WISHBONE interface
|
input wb_rst_i;
|
input wb_rst_i;
|
input wb_we_i;
|
input wb_we_i;
|
input wb_stb_i;
|
input wb_stb_i;
|
input wb_cyc_i;
|
input wb_cyc_i;
|
|
input [3:0] wb_sel_i;
|
|
`ifdef DATA_BUS_WIDTH_8
|
|
input [7:0] wb_dat_i; //input WISHBONE bus
|
|
output [7:0] wb_dat_o;
|
|
reg [7:0] wb_dat_o;
|
|
wire [7:0] wb_dat_i;
|
|
`else // for 32 data bus mode
|
|
input [31:0] wb_dat_i; //input WISHBONE bus
|
|
output [31:0] wb_dat_o;
|
|
reg [31:0] wb_dat_o;
|
|
wire [31:0] wb_dat_i;
|
|
`endif
|
|
input [7:0] wb_dat8_o; // internal 8 bit output to be put into wb_dat_o
|
|
output [7:0] wb_dat8_i;
|
|
input [31:0] wb_dat32_o; // 32 bit data output (for debug interface)
|
output wb_ack_o;
|
output wb_ack_o;
|
output we_o;
|
output we_o;
|
output re_o;
|
output re_o;
|
|
|
wire we_o;
|
wire we_o;
|
reg wb_ack_o;
|
reg wb_ack_o;
|
|
reg [7:0] wb_dat8_i;
|
|
wire [7:0] wb_dat8_o;
|
|
|
always @(posedge clk or posedge wb_rst_i)
|
always @(posedge clk or posedge wb_rst_i)
|
begin
|
|
if (wb_rst_i)
|
if (wb_rst_i)
|
begin
|
|
wb_ack_o <= #1 1'b0;
|
wb_ack_o <= #1 1'b0;
|
end
|
|
else
|
else
|
begin
|
|
// wb_ack_o <= #1 wb_stb_i & wb_cyc_i; // 1 clock wait state on all transfers
|
|
wb_ack_o <= #1 wb_stb_i & wb_cyc_i & ~wb_ack_o; // 1 clock wait state on all transfers
|
wb_ack_o <= #1 wb_stb_i & wb_cyc_i & ~wb_ack_o; // 1 clock wait state on all transfers
|
end
|
|
end
|
|
|
|
assign we_o = wb_we_i & wb_cyc_i & wb_stb_i; //WE for registers
|
assign we_o = wb_we_i & wb_cyc_i & wb_stb_i; //WE for registers
|
assign re_o = ~wb_we_i & wb_cyc_i & wb_stb_i; //RE for registers
|
assign re_o = ~wb_we_i & wb_cyc_i & wb_stb_i; //RE for registers
|
|
|
|
`ifdef DATA_BUS_WIDTH_8 // 8-bit data bus
|
|
always @(posedge clk or posedge wb_rst_i)
|
|
if (wb_rst_i)
|
|
wb_dat_o <= #1 0;
|
|
else
|
|
wb_dat_o <= #1 wb_dat8_o;
|
|
|
|
always @(wb_dat_i)
|
|
wb_dat8_i = wb_dat_i;
|
|
|
|
`else // 32-bit bus
|
|
// put output to the correct byte in 32 bits using select line
|
|
always @(posedge clk or posedge wb_rst_i)
|
|
if (wb_rst_i)
|
|
wb_dat_o <= #1 0;
|
|
else if (re_o)
|
|
case (wb_sel_i)
|
|
4'b0001: wb_dat_o <= #1 {24'b0, wb_dat8_o};
|
|
4'b0010: wb_dat_o <= #1 {16'b0, wb_dat8_o, 8'b0};
|
|
4'b0100: wb_dat_o <= #1 {8'b0, wb_dat8_o, 16'b0};
|
|
4'b1000: wb_dat_o <= #1 {wb_dat8_o, 24'b0};
|
|
4'b1111: wb_dat_o <= #1 wb_dat32_o; // debug interface output
|
|
default: wb_dat_o <= #1 0;
|
|
// later add here selects for 16 and 32 bits
|
|
endcase // case(wb_sel_i)
|
|
|
|
// handle input (this will add a little timing overhead on input but it should asynchronous
|
|
// or another one clock delay will be introduced)
|
|
always @(wb_sel_i or wb_dat_i)
|
|
case (wb_sel_i)
|
|
4'b0001 : wb_dat8_i = wb_dat_i[7:0];
|
|
4'b0010 : wb_dat8_i = wb_dat_i[15:8];
|
|
4'b0100 : wb_dat8_i = wb_dat_i[23:16];
|
|
4'b1000 : wb_dat8_i = wb_dat_i[31:24];
|
|
default : wb_dat8_i = wb_dat_i[7:0];
|
|
endcase // case(wb_sel_i)
|
|
|
|
`endif // !`ifdef DATA_BUS_WIDTH_8
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|