source: trunk/MultiChannelUSB/histogram.v@ 144

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

remove idle state

File size: 4.1 KB
RevLine 
[27]1module histogram
2 (
[90]3 input wire clock, frame, reset,
4
5 input wire hst_good,
6 input wire [11:0] hst_data,
7
8 input wire bus_ssel, bus_wren,
9 input wire [12:0] bus_addr,
10 input wire [15:0] bus_mosi,
11
12 output wire [15:0] bus_miso,
13 output wire bus_busy
[27]14 );
15
16 // signal declaration
[90]17 reg [3:0] int_case_reg, int_case_next;
18 reg int_wren_reg, int_wren_next;
19 reg [11:0] int_addr_reg, int_addr_next;
20 reg [31:0] int_data_reg, int_data_next;
[27]21
[90]22 reg [12:0] bus_addr_reg, bus_addr_next;
23 reg [15:0] bus_miso_reg, bus_miso_next;
[27]24
[90]25 reg bus_wren_reg, bus_wren_next;
26 reg [15:0] bus_mosi_reg, bus_mosi_next;
27
28 wire [31:0] q_a_wire;
29 wire [15:0] q_b_wire;
30
[47]31 altsyncram #(
32 .address_reg_b("CLOCK0"),
33 .clock_enable_input_a("BYPASS"),
34 .clock_enable_input_b("BYPASS"),
35 .clock_enable_output_a("BYPASS"),
36 .clock_enable_output_b("BYPASS"),
37 .indata_reg_b("CLOCK0"),
38 .intended_device_family("Cyclone III"),
39 .lpm_type("altsyncram"),
40 .numwords_a(4096),
[90]41 .numwords_b(8192),
[47]42 .operation_mode("BIDIR_DUAL_PORT"),
43 .outdata_aclr_a("NONE"),
44 .outdata_aclr_b("NONE"),
[84]45 .outdata_reg_a("CLOCK0"),
46 .outdata_reg_b("CLOCK0"),
[47]47 .power_up_uninitialized("FALSE"),
48 .read_during_write_mode_mixed_ports("OLD_DATA"),
[90]49 .read_during_write_mode_port_a("NEW_DATA_NO_NBE_READ"),
50 .read_during_write_mode_port_b("NEW_DATA_NO_NBE_READ"),
[47]51 .widthad_a(12),
[90]52 .widthad_b(13),
53 .width_a(32),
54 .width_b(16),
[47]55 .width_byteena_a(1),
56 .width_byteena_b(1),
[51]57 .wrcontrol_wraddress_reg_b("CLOCK0")) hst_ram_unit(
[90]58 .wren_a(int_wren_reg),
59 .clock0(clock),
60 .wren_b(bus_wren_reg),
61 .address_a(int_addr_reg),
62 .address_b(bus_addr_reg),
63 .data_a(int_data_reg),
64 .data_b(bus_mosi_reg),
[51]65 .q_a(q_a_wire),
66 .q_b(q_b_wire),
67 .aclr0(1'b0),
68 .aclr1(1'b0),
69 .addressstall_a(1'b0),
70 .addressstall_b(1'b0),
71 .byteena_a(1'b1),
72 .byteena_b(1'b1),
73 .clock1(1'b1),
74 .clocken0(1'b1),
75 .clocken1(1'b1),
76 .clocken2(1'b1),
77 .clocken3(1'b1),
78 .eccstatus(),
79 .rden_a(1'b1),
80 .rden_b(1'b1));
[27]81
82 // body
[90]83 always @(posedge clock)
[27]84 begin
85 if (reset)
86 begin
[90]87 int_wren_reg <= 1'b1;
88 int_addr_reg <= 12'd0;
89 int_data_reg <= 32'd0;
[95]90 int_case_reg <= 4'b0;
[90]91 bus_addr_reg <= 13'd0;
92 bus_miso_reg <= 16'd0;
93 bus_wren_reg <= 1'b0;
94 bus_mosi_reg <= 16'd0;
[27]95 end
96 else
97 begin
[90]98 int_wren_reg <= int_wren_next;
99 int_addr_reg <= int_addr_next;
100 int_data_reg <= int_data_next;
101 int_case_reg <= int_case_next;
102 bus_addr_reg <= bus_addr_next;
103 bus_miso_reg <= bus_miso_next;
104 bus_wren_reg <= bus_wren_next;
105 bus_mosi_reg <= bus_mosi_next;
106 end
107 end
108
109 always @*
110 begin
111 bus_addr_next = bus_addr_reg;
112 bus_miso_next = bus_miso_reg;
113
114 bus_wren_next = 1'b0;
115 bus_mosi_next = bus_mosi_reg;
116
117 if (bus_ssel)
118 begin
119 bus_miso_next = q_b_wire;
120 bus_addr_next = bus_addr;
121 bus_wren_next = bus_wren;
122 if (bus_wren)
123 begin
124 bus_mosi_next = bus_mosi;
125 end
[27]126 end
127 end
128
129 always @*
130 begin
[90]131 int_wren_next = int_wren_reg;
132 int_addr_next = int_addr_reg;
133 int_data_next = int_data_reg;
134 int_case_next = int_case_reg;
135
136 case (int_case_reg)
[95]137
[51]138 0:
[27]139 begin
140 // write zeros
[95]141 int_addr_next = int_addr_reg + 12'd1;
[90]142 if (&int_addr_reg)
[27]143 begin
[90]144 int_wren_next = 1'b0;
[95]145 int_case_next = 4'd1;
[27]146 end
[51]147 end
148
[95]149 1:
[27]150 begin
[90]151 int_wren_next = 1'b0;
[95]152/*
[90]153 if (&int_data_reg)
[27]154 begin
[90]155 int_case_next = 4'd0;
[27]156 end
[90]157 else if (frame & hst_good)
[95]158*/
159 if (frame & hst_good)
[90]160 begin
161 int_addr_next = hst_data;
[95]162 int_case_next = 4'd2;
[90]163 end
[27]164 end
165
[95]166 2:
167 begin
168 int_case_next = 4'd3;
169 end
170
[51]171 3:
[27]172 begin
[90]173 int_case_next = 4'd4;
[27]174 end
175
[84]176 4:
177 begin
[95]178 int_case_next = 4'd1;
179 if (~&q_a_wire)
180 begin
181 int_wren_next = 1'b1;
182 int_data_next = q_a_wire + 32'd1;
183 end
[88]184 end
185
[27]186 default:
187 begin
[90]188 int_wren_next = 1'b0;
189 int_addr_next = 12'd0;
190 int_data_next = 32'd0;
191 int_case_next = 4'd0;
[27]192 end
193 endcase
194 end
195
196 // output logic
[90]197 assign bus_miso = bus_miso_reg;
198 assign bus_busy = 1'b0;
[27]199endmodule
Note: See TracBrowser for help on using the repository browser.