root / usrp2 / control_lib / wb_readback_mux_16LE.v @ c7adcbe4
History | View | Annotate | Download (2.37 KB)
| 1 |
// |
|---|---|
| 2 |
// Copyright 2011 Ettus Research LLC |
| 3 |
// |
| 4 |
// This program is free software: you can redistribute it and/or modify |
| 5 |
// it under the terms of the GNU General Public License as published by |
| 6 |
// the Free Software Foundation, either version 3 of the License, or |
| 7 |
// (at your option) any later version. |
| 8 |
// |
| 9 |
// This program is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
// |
| 14 |
// You should have received a copy of the GNU General Public License |
| 15 |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
// |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
// Note -- clocks must be synchronous (derived from the same source) |
| 21 |
// Assumes alt_clk is running at a multiple of wb_clk |
| 22 |
|
| 23 |
// Note -- assumes that the lower-16 bits will be requested first, |
| 24 |
// and that the upper-16 bit request will come immediately after. |
| 25 |
|
| 26 |
module wb_readback_mux_16LE |
| 27 |
(input wb_clk_i, |
| 28 |
input wb_rst_i, |
| 29 |
input wb_stb_i, |
| 30 |
input [15:0] wb_adr_i, |
| 31 |
output [15:0] wb_dat_o, |
| 32 |
output reg wb_ack_o, |
| 33 |
|
| 34 |
input [31:0] word00, |
| 35 |
input [31:0] word01, |
| 36 |
input [31:0] word02, |
| 37 |
input [31:0] word03, |
| 38 |
input [31:0] word04, |
| 39 |
input [31:0] word05, |
| 40 |
input [31:0] word06, |
| 41 |
input [31:0] word07, |
| 42 |
input [31:0] word08, |
| 43 |
input [31:0] word09, |
| 44 |
input [31:0] word10, |
| 45 |
input [31:0] word11, |
| 46 |
input [31:0] word12, |
| 47 |
input [31:0] word13, |
| 48 |
input [31:0] word14, |
| 49 |
input [31:0] word15 |
| 50 |
); |
| 51 |
|
| 52 |
wire ack_next = wb_stb_i & ~wb_ack_o; |
| 53 |
|
| 54 |
always @(posedge wb_clk_i) |
| 55 |
if(wb_rst_i) |
| 56 |
wb_ack_o <= 0; |
| 57 |
else |
| 58 |
wb_ack_o <= ack_next; |
| 59 |
|
| 60 |
reg [31:0] data; |
| 61 |
assign wb_dat_o = data[15:0]; |
| 62 |
|
| 63 |
always @(posedge wb_clk_i) |
| 64 |
if (wb_adr_i[1] & ack_next) begin //upper half |
| 65 |
data[15:0] <= data[31:16]; |
| 66 |
end |
| 67 |
else if (~wb_adr_i[1] & ack_next) begin //lower half |
| 68 |
case(wb_adr_i[5:2]) |
| 69 |
0 : data <= word00; |
| 70 |
1 : data <= word01; |
| 71 |
2 : data <= word02; |
| 72 |
3 : data <= word03; |
| 73 |
4 : data <= word04; |
| 74 |
5 : data <= word05; |
| 75 |
6 : data <= word06; |
| 76 |
7 : data <= word07; |
| 77 |
8 : data <= word08; |
| 78 |
9 : data <= word09; |
| 79 |
10: data <= word10; |
| 80 |
11: data <= word11; |
| 81 |
12: data <= word12; |
| 82 |
13: data <= word13; |
| 83 |
14: data <= word14; |
| 84 |
15: data <= word15; |
| 85 |
endcase // case(wb_adr_i[5:2]) |
| 86 |
end |
| 87 |
|
| 88 |
endmodule // wb_readback_mux |
| 89 |
|
| 90 |
|