source: trunk/MultiChannelUSB/configuration.v@ 90

Last change on this file since 90 was 90, checked in by demin, 15 years ago

full rewrite

File size: 1.7 KB
RevLine 
[90]1module configuration
2 (
3 input wire clock, reset,
4
5 input wire bus_ssel, bus_wren,
6 input wire [3:0] bus_addr,
7 input wire [15:0] bus_mosi,
8
9 output wire [15:0] bus_miso,
10 output wire bus_busy,
11
12 output wire [255:0] cfg_bits
13 );
14
15 wire [15:0] int_ssel_wire;
16 wire [15:0] int_miso_wire;
17 reg [15:0] int_miso_reg [3:0];
18
19 wire [15:0] int_q_wire [15:0];
20 wire [255:0] int_bits_wire;
21
22 integer i;
23 genvar j;
24
25 generate
26 for (j = 0; j < 16; j = j + 1)
27 begin : BUS_OUTPUT
28 assign int_bits_wire[j*16+15:j*16] = int_q_wire[j];
29 lpm_ff #(
30 .lpm_fftype("DFF"),
31 .lpm_type("LPM_FF"),
32 .lpm_width(16)) cfg_reg_unit (
33 .enable(int_ssel_wire[j] & bus_ssel & bus_wren),
34 .sclr(reset),
35 .clock(clock),
36 .data(bus_mosi),
37 .q(int_q_wire[j]),
38 .aclr(),
39 .aload(),
40 .aset(),
41 .sload(),
42 .sset());
43 end
44 endgenerate
45
46 lpm_mux #(
47 .lpm_size(16),
48 .lpm_type("LPM_MUX"),
49 .lpm_width(16),
50 .lpm_widths(4)) bus_miso_mux_unit (
51 .sel(bus_addr),
52 .data(int_bits_wire),
53 .result(int_miso_wire));
54
55
56 lpm_decode #(
57 .lpm_decodes(16),
58 .lpm_type("LPM_DECODE"),
59 .lpm_width(4)) lpm_decode_unit (
60 .data(bus_addr),
61 .eq(int_ssel_wire),
62 .aclr(),
63 .clken(),
64 .clock(),
65 .enable());
66
67 always @(posedge clock)
68 begin
69 if (reset)
70 begin
71 for(i = 0; i <= 3; i = i + 1)
72 begin
73 int_miso_reg[i] <= 16'd0;
74 end
75 end
76 else
77 begin
78 for(i = 0; i < 3; i = i + 1)
79 begin
80 int_miso_reg[i+1] <= int_miso_reg[i];
81 end
82 int_miso_reg[0] <= int_miso_wire;
83 end
84 end
85
86 // output logic
87 assign bus_miso = int_miso_reg[3];
88 assign bus_busy = 1'b0;
89 assign cfg_bits = int_bits_wire;
90
91endmodule
Note: See TracBrowser for help on using the repository browser.