Skip to content

Commit a0e2e50

Browse files
committed
add a wishbone configuration interface
1 parent 38f8368 commit a0e2e50

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

rtl/verilog/i2s_wb_if.v

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2014, Stefan Kristiansson <[email protected]>
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and non-source forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in non-source form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS WORK IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23+
* WORK, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
module i2s_wb_if #(
27+
parameter WB_AW = 32,
28+
parameter WB_DW = 32
29+
)(
30+
input rst,
31+
input wb_clk,
32+
33+
input [WB_AW-1:0] wb_adr_i,
34+
input [WB_DW-1:0] wb_dat_i,
35+
input [WB_DW/8-1:0] wb_sel_i,
36+
input wb_we_i ,
37+
input wb_cyc_i,
38+
input wb_stb_i,
39+
input [2:0] wb_cti_i,
40+
input [1:0] wb_bte_i,
41+
output [WB_DW-1:0] wb_dat_o,
42+
output reg wb_ack_o,
43+
output wb_err_o,
44+
output wb_rty_o,
45+
46+
output reg [WB_DW-1:0] prescaler
47+
);
48+
49+
assign wb_err_o = 0;
50+
assign wb_rty_o = 0;
51+
assign wb_dat_o = wb_adr_i[5:2] == 0 ? prescaler : 0;
52+
53+
always @(posedge wb_clk) begin
54+
if (wb_ack_o & wb_we_i) begin
55+
case (wb_adr_i[5:2])
56+
0: prescaler <= wb_dat_i;
57+
endcase
58+
end
59+
60+
if (rst)
61+
prescaler <= 0;
62+
end
63+
64+
always @(posedge wb_clk)
65+
if (rst)
66+
wb_ack_o <= 0;
67+
else
68+
wb_ack_o <= wb_cyc_i & wb_stb_i & !wb_ack_o;
69+
70+
endmodule

0 commit comments

Comments
 (0)