[27] | 1 | module Paella
|
---|
| 2 | (
|
---|
| 3 | input wire CLK_50MHz,
|
---|
| 4 | output wire LED,
|
---|
| 5 |
|
---|
| 6 | inout wire [3:0] TRG,
|
---|
[68] | 7 | inout wire I2C_SDA,
|
---|
[72] | 8 | inout wire I2C_SCL,
|
---|
[68] | 9 | inout wire [4:0] CON_A,
|
---|
[27] | 10 | inout wire [15:0] CON_B,
|
---|
[63] | 11 | input wire [12:0] CON_C,
|
---|
[27] | 12 | input wire [1:0] CON_BCLK,
|
---|
| 13 | input wire [1:0] CON_CCLK,
|
---|
| 14 |
|
---|
| 15 | input wire ADC_DCO,
|
---|
| 16 | input wire ADC_FCO,
|
---|
[41] | 17 | input wire [2:0] ADC_D,
|
---|
[27] | 18 |
|
---|
| 19 | output wire USB_SLRD,
|
---|
| 20 | output wire USB_SLWR,
|
---|
| 21 | input wire USB_IFCLK,
|
---|
| 22 | input wire USB_FLAGA, // EMPTY flag for EP6
|
---|
| 23 | input wire USB_FLAGB, // FULL flag for EP8
|
---|
| 24 | input wire USB_FLAGC,
|
---|
[30] | 25 | inout wire USB_PA0,
|
---|
| 26 | inout wire USB_PA1,
|
---|
| 27 | output wire USB_PA2,
|
---|
| 28 | inout wire USB_PA3,
|
---|
| 29 | output wire USB_PA4,
|
---|
| 30 | output wire USB_PA5,
|
---|
| 31 | output wire USB_PA6,
|
---|
| 32 | inout wire USB_PA7,
|
---|
[27] | 33 | inout wire [7:0] USB_PB,
|
---|
| 34 |
|
---|
| 35 | output wire RAM_CLK,
|
---|
| 36 | output wire RAM_CE1,
|
---|
| 37 | output wire RAM_WE,
|
---|
| 38 | output wire [19:0] RAM_ADDR,
|
---|
| 39 | inout wire RAM_DQAP,
|
---|
| 40 | inout wire [7:0] RAM_DQA,
|
---|
| 41 | inout wire RAM_DQBP,
|
---|
| 42 | inout wire [7:0] RAM_DQB
|
---|
| 43 | );
|
---|
| 44 |
|
---|
[72] | 45 | localparam N = 3;
|
---|
| 46 |
|
---|
[27] | 47 | // Turn output ports off
|
---|
[65] | 48 | /*
|
---|
[27] | 49 | assign RAM_CLK = 1'b0;
|
---|
| 50 | assign RAM_CE1 = 1'b0;
|
---|
| 51 | assign RAM_WE = 1'b0;
|
---|
| 52 | assign RAM_ADDR = 20'h00000;
|
---|
[65] | 53 | */
|
---|
| 54 | assign RAM_CLK = CLK_50MHz;
|
---|
| 55 | assign RAM_CE1 = 1'b0;
|
---|
[27] | 56 |
|
---|
| 57 | // Turn inout ports to tri-state
|
---|
| 58 | assign TRG = 4'bz;
|
---|
[68] | 59 | assign CON_A = 5'bz;
|
---|
[27] | 60 | assign CON_B = 16'bz;
|
---|
[30] | 61 | assign USB_PA0 = 1'bz;
|
---|
| 62 | assign USB_PA1 = 1'bz;
|
---|
| 63 | assign USB_PA3 = 1'bz;
|
---|
| 64 | assign USB_PA7 = 1'bz;
|
---|
[65] | 65 | // assign RAM_DQAP = 1'bz;
|
---|
| 66 | // assign RAM_DQA = 8'bz;
|
---|
| 67 | // assign RAM_DQBP = 1'bz;
|
---|
| 68 | // assign RAM_DQB = 8'bz;
|
---|
[27] | 69 |
|
---|
[30] | 70 | assign USB_PA2 = ~usb_rden;
|
---|
| 71 | assign USB_PA4 = usb_addr[0];
|
---|
| 72 | assign USB_PA5 = usb_addr[1];
|
---|
| 73 | assign USB_PA6 = ~usb_pktend;
|
---|
| 74 |
|
---|
[27] | 75 | wire usb_wrreq, usb_rdreq, usb_rden, usb_pktend;
|
---|
[59] | 76 | wire usb_aclr;
|
---|
| 77 | wire usb_tx_wrreq, usb_rx_rdreq;
|
---|
| 78 | wire usb_tx_full, usb_rx_empty;
|
---|
| 79 | wire [7:0] usb_tx_data, usb_rx_data;
|
---|
[27] | 80 | wire [1:0] usb_addr;
|
---|
| 81 |
|
---|
| 82 | assign USB_SLRD = ~usb_rdreq;
|
---|
| 83 | assign USB_SLWR = ~usb_wrreq;
|
---|
| 84 |
|
---|
[59] | 85 | usb_fifo usb_unit
|
---|
[27] | 86 | (
|
---|
| 87 | .usb_clk(USB_IFCLK),
|
---|
| 88 | .usb_data(USB_PB),
|
---|
| 89 | .usb_full(~USB_FLAGB),
|
---|
| 90 | .usb_empty(~USB_FLAGA),
|
---|
| 91 | .usb_wrreq(usb_wrreq),
|
---|
| 92 | .usb_rdreq(usb_rdreq),
|
---|
| 93 | .usb_rden(usb_rden),
|
---|
| 94 | .usb_pktend(usb_pktend),
|
---|
| 95 | .usb_addr(usb_addr),
|
---|
[34] | 96 |
|
---|
[27] | 97 | .clk(CLK_50MHz),
|
---|
[59] | 98 | .aclr(usb_aclr),
|
---|
[34] | 99 |
|
---|
[59] | 100 | .tx_full(usb_tx_full),
|
---|
| 101 | .tx_wrreq(usb_tx_wrreq),
|
---|
| 102 | .tx_data(usb_tx_data),
|
---|
[34] | 103 |
|
---|
[59] | 104 | .rx_empty(usb_rx_empty),
|
---|
| 105 | .rx_rdreq(usb_rx_rdreq),
|
---|
| 106 | .rx_q(usb_rx_data)
|
---|
[27] | 107 | );
|
---|
| 108 |
|
---|
[72] | 109 | reg bln_reset [N-1:0];
|
---|
| 110 | wire [11:0] baseline [N-1:0];
|
---|
| 111 | wire [11:0] bln_baseline [N-1:0];
|
---|
[44] | 112 |
|
---|
[72] | 113 | reg ana_reset [N-1:0];
|
---|
| 114 | wire ana_peak_ready [N-1:0];
|
---|
[44] | 115 |
|
---|
[72] | 116 | reg osc_reset [N-1:0];
|
---|
| 117 | reg [9:0] osc_addr [N-1:0];
|
---|
| 118 | wire [9:0] osc_start_addr [N-1:0];
|
---|
| 119 | wire [15:0] osc_q [N-1:0];
|
---|
| 120 | wire osc_trig [N-1:0];
|
---|
[27] | 121 |
|
---|
[72] | 122 | wire [3:0] osc_mux_sel [N-1:0];
|
---|
| 123 | wire [11:0] osc_mux_data [N-1:0];
|
---|
| 124 |
|
---|
| 125 | wire trg_reset [N-1:0];
|
---|
| 126 | wire [3:0] trg_mux_sel [N-1:0];
|
---|
| 127 | wire [11:0] trg_mux_data [N-1:0];
|
---|
| 128 | wire [11:0] trg_thrs [N-1:0];
|
---|
| 129 |
|
---|
| 130 | reg hst_reset [N-1:0];
|
---|
| 131 | reg [11:0] hst_addr [N-1:0];
|
---|
| 132 | wire hst_data_ready [N-1:0];
|
---|
| 133 | wire [11:0] hst_data [N-1:0];
|
---|
| 134 | wire [31:0] hst_q [N-1:0];
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | wire [3:0] hst_mux_sel [N-1:0];
|
---|
| 138 | wire [12:0] hst_mux_data [N-1:0];
|
---|
| 139 |
|
---|
| 140 | wire [3:0] bln_mux_sel [N-1:0];
|
---|
| 141 | wire [11:0] bln_mux_data [N-1:0];
|
---|
| 142 |
|
---|
[59] | 143 | wire mux_reset, mux_type;
|
---|
| 144 | wire [1:0] mux_chan, mux_byte;
|
---|
| 145 | wire [15:0] mux_addr;
|
---|
| 146 |
|
---|
[45] | 147 | reg [7:0] mux_q;
|
---|
[59] | 148 | reg [1:0] mux_max_byte;
|
---|
| 149 | reg [15:0] mux_min_addr, mux_max_addr;
|
---|
[44] | 150 |
|
---|
[72] | 151 | wire adc_clk [N-1:0];
|
---|
| 152 | wire [11:0] adc_data [N-1:0];
|
---|
[41] | 153 |
|
---|
[72] | 154 | wire data_ready [N-1:0];
|
---|
| 155 | wire [11:0] data [N-1:0];
|
---|
| 156 | wire [11:0] int_data [N-1:0];
|
---|
[45] | 157 |
|
---|
[72] | 158 | /*
|
---|
[63] | 159 | assign osc_thrs[0] = 16'd40;
|
---|
[68] | 160 | assign osc_thrs[1] = 16'd60;
|
---|
[63] | 161 | assign osc_thrs[2] = 16'd40;
|
---|
| 162 | assign osc_thrs[3] = 16'd1650;
|
---|
[72] | 163 | */
|
---|
| 164 | wire [31:0] uwt_d1 [N-1:0];
|
---|
| 165 | wire [31:0] uwt_a1 [N-1:0];
|
---|
| 166 | wire [31:0] uwt_peak1 [N-1:0];
|
---|
| 167 | wire [31:0] uwt_d2 [N-1:0];
|
---|
| 168 | wire [31:0] uwt_a2 [N-1:0];
|
---|
| 169 | wire [31:0] uwt_peak2 [N-1:0];
|
---|
| 170 | wire [31:0] uwt_d3 [N-1:0];
|
---|
| 171 | wire [31:0] uwt_a3 [N-1:0];
|
---|
| 172 | wire [31:0] uwt_peak3 [N-1:0];
|
---|
[63] | 173 |
|
---|
[72] | 174 | wire [1:0] uwt_flag1 [N-1:0];
|
---|
| 175 | wire [1:0] uwt_flag2 [N-1:0];
|
---|
| 176 | wire [1:0] uwt_flag3 [N-1:0];
|
---|
[63] | 177 |
|
---|
[45] | 178 | assign adc_clk[0] = ADC_FCO;
|
---|
| 179 | assign adc_clk[1] = ADC_FCO;
|
---|
[70] | 180 | // assign adc_clk[2] = ADC_FCO;
|
---|
[72] | 181 | /*
|
---|
[63] | 182 | assign adc_clk[3] = ADC_FCO;
|
---|
[72] | 183 | */
|
---|
[63] | 184 | /*
|
---|
| 185 | assign adc_clk[3] = CON_CCLK[0];
|
---|
| 186 | assign adc_data[3] = CON_C[11:0];
|
---|
| 187 | */
|
---|
[68] | 188 | /*
|
---|
[63] | 189 | adc_para adc_para_unit (
|
---|
| 190 | .lvds_dco(ADC_DCO),
|
---|
| 191 | .lvds_fco(ADC_FCO),
|
---|
| 192 | .para_data_ready(CON_CCLK[0]),
|
---|
| 193 | .para_data(CON_C[11:0]),
|
---|
| 194 | .adc_data(adc_data[3]));
|
---|
[68] | 195 | */
|
---|
[59] | 196 | /*
|
---|
[54] | 197 | wire adc_pll_clk;
|
---|
| 198 |
|
---|
| 199 | adc_pll adc_pll_unit(
|
---|
| 200 | .inclk0(ADC_FCO),
|
---|
| 201 | .c0(adc_pll_clk));
|
---|
| 202 | */
|
---|
[70] | 203 |
|
---|
[59] | 204 | wire tst_adc_clk;
|
---|
| 205 | wire [11:0] tst_adc_data;
|
---|
[48] | 206 |
|
---|
[59] | 207 | test test_unit(
|
---|
[63] | 208 | .clk(CLK_50MHz),
|
---|
[59] | 209 | .tst_clk(tst_adc_clk),
|
---|
| 210 | .tst_data(tst_adc_data));
|
---|
[48] | 211 |
|
---|
[70] | 212 | assign adc_clk[2] = tst_adc_clk;
|
---|
| 213 | assign adc_data[2] = tst_adc_data;
|
---|
| 214 |
|
---|
[41] | 215 | /*
|
---|
[38] | 216 | altserial_flash_loader #(
|
---|
| 217 | .enable_shared_access("OFF"),
|
---|
| 218 | .enhanced_mode(1),
|
---|
| 219 | .intended_device_family("Cyclone III")) sfl_unit (
|
---|
| 220 | .noe(1'b0),
|
---|
| 221 | .asmi_access_granted(),
|
---|
| 222 | .asmi_access_request(),
|
---|
| 223 | .data0out(),
|
---|
| 224 | .dclkin(),
|
---|
| 225 | .scein(),
|
---|
| 226 | .sdoin());
|
---|
[41] | 227 | */
|
---|
[72] | 228 |
|
---|
[63] | 229 | adc_lvds #(
|
---|
[72] | 230 | .size(2),
|
---|
[63] | 231 | .width(12)) adc_lvds_unit (
|
---|
[41] | 232 | .lvds_dco(ADC_DCO),
|
---|
[54] | 233 | // .lvds_dco(adc_pll_clk),
|
---|
[41] | 234 | .lvds_fco(ADC_FCO),
|
---|
[72] | 235 | .lvds_d(ADC_D[1:0]),
|
---|
| 236 | .adc_data({ adc_data[1],
|
---|
| 237 | adc_data[0] }));
|
---|
| 238 |
|
---|
| 239 |
|
---|
| 240 | reg [15:0] cfg_memory [31:0];
|
---|
| 241 | wire [15:0] cfg_src_data;
|
---|
| 242 | wire [15:0] cfg_src_addr, cfg_dst_data, cfg_dst_addr;
|
---|
| 243 |
|
---|
| 244 | wire cfg_polarity [N-1:0];
|
---|
| 245 | wire [11:0] cfg_baseline [N-1:0];
|
---|
| 246 | wire [11:0] cfg_hst_threshold [N-1:0];
|
---|
| 247 | wire [11:0] cfg_trg_threshold [N-1:0];
|
---|
| 248 |
|
---|
| 249 | wire cfg_reset;
|
---|
| 250 |
|
---|
| 251 | integer j;
|
---|
| 252 |
|
---|
| 253 | always @(posedge CLK_50MHz)
|
---|
| 254 | begin
|
---|
| 255 | if (cfg_reset)
|
---|
| 256 | begin
|
---|
| 257 | for(j = 0; j <= 31; j = j + 1)
|
---|
| 258 | begin
|
---|
| 259 | cfg_memory[j] <= 16'd0;
|
---|
| 260 | end
|
---|
| 261 | end
|
---|
| 262 | else
|
---|
| 263 | begin
|
---|
| 264 | cfg_memory[cfg_dst_addr[4:0]] <= cfg_dst_data;
|
---|
| 265 | end
|
---|
| 266 | end
|
---|
| 267 |
|
---|
[44] | 268 | genvar i;
|
---|
[72] | 269 |
|
---|
[44] | 270 | generate
|
---|
[72] | 271 | for (i = 0; i < N; i = i + 1)
|
---|
[44] | 272 | begin : MCA_CHAIN
|
---|
[72] | 273 |
|
---|
| 274 | assign cfg_polarity[i] = cfg_memory[10][4*i];
|
---|
| 275 | assign cfg_baseline[i] = cfg_memory[11+i][11:0];
|
---|
| 276 | assign cfg_hst_threshold[i] = cfg_memory[14+i][11:0];
|
---|
| 277 | assign cfg_trg_threshold[i] = cfg_memory[17+i][11:0];
|
---|
| 278 |
|
---|
| 279 | assign osc_mux_sel[i] = cfg_memory[20+i][3:0];
|
---|
| 280 | assign trg_mux_sel[i] = cfg_memory[20+i][7:4];
|
---|
| 281 |
|
---|
[75] | 282 | assign hst_mux_sel[i] = cfg_memory[23+i][3:0];
|
---|
| 283 | assign bln_mux_sel[i] = cfg_memory[23+i][7:4];
|
---|
| 284 |
|
---|
[44] | 285 | adc_fifo adc_fifo_unit (
|
---|
[45] | 286 | .adc_clk(adc_clk[i]),
|
---|
| 287 | .adc_data(adc_data[i]),
|
---|
[59] | 288 | .clk(CLK_50MHz),
|
---|
[72] | 289 | .data_ready(data_ready[i]),
|
---|
| 290 | .data(int_data[i]));
|
---|
| 291 |
|
---|
| 292 | assign data[i] = (cfg_polarity[i]) ? (int_data[i] ^ 12'hfff) : (int_data[i]);
|
---|
| 293 |
|
---|
| 294 | uwt_bior31 #(.L(1)) uwt_1_unit (
|
---|
| 295 | .clk(CLK_50MHz),
|
---|
| 296 | .data_ready(data_ready[i]),
|
---|
| 297 | .x({20'h00000, data[i]}),
|
---|
| 298 | .d(uwt_d1[i]),
|
---|
| 299 | .a(uwt_a1[i]),
|
---|
| 300 | .peak(uwt_peak1[i]),
|
---|
| 301 | .flag(uwt_flag1[i]));
|
---|
| 302 |
|
---|
| 303 | uwt_bior31 #(.L(2)) uwt_2_unit (
|
---|
| 304 | .clk(CLK_50MHz),
|
---|
| 305 | .data_ready(data_ready[i]),
|
---|
| 306 | .x(uwt_a1[i]),
|
---|
| 307 | .d(uwt_d2[i]),
|
---|
| 308 | .a(uwt_a2[i]),
|
---|
| 309 | .peak(uwt_peak2[i]),
|
---|
| 310 | .flag(uwt_flag2[i]));
|
---|
| 311 |
|
---|
| 312 | uwt_bior31 #(.L(3)) uwt_3_unit (
|
---|
| 313 | .clk(CLK_50MHz),
|
---|
| 314 | .data_ready(data_ready[i]),
|
---|
| 315 | .x(uwt_a2[i]),
|
---|
| 316 | .d(uwt_d3[i]),
|
---|
| 317 | .a(uwt_a3[i]),
|
---|
| 318 | .peak(uwt_peak3[i]),
|
---|
| 319 | .flag(uwt_flag3[i]));
|
---|
| 320 |
|
---|
| 321 | lpm_mux #(
|
---|
[75] | 322 | .lpm_size(5),
|
---|
[72] | 323 | .lpm_type("LPM_MUX"),
|
---|
| 324 | .lpm_width(12),
|
---|
[75] | 325 | .lpm_widths(3)) osc_mux_unit (
|
---|
| 326 | .sel(osc_mux_sel[i][2:0]),
|
---|
| 327 | .data({ bln_baseline[i],
|
---|
| 328 | uwt_a3[i][20:9],
|
---|
[72] | 329 | uwt_a2[i][17:6],
|
---|
| 330 | uwt_a1[i][14:3],
|
---|
| 331 | data[i] }),
|
---|
| 332 | .result(osc_mux_data[i]));
|
---|
| 333 |
|
---|
| 334 | lpm_mux #(
|
---|
[75] | 335 | .lpm_size(5),
|
---|
[72] | 336 | .lpm_type("LPM_MUX"),
|
---|
| 337 | .lpm_width(12),
|
---|
[75] | 338 | .lpm_widths(3)) trg_mux_unit (
|
---|
| 339 | .sel(trg_mux_sel[i][2:0]),
|
---|
| 340 | .data({ bln_baseline[i],
|
---|
| 341 | uwt_a3[i][20:9],
|
---|
[72] | 342 | uwt_a2[i][17:6],
|
---|
| 343 | uwt_a1[i][14:3],
|
---|
| 344 | data[i] }),
|
---|
| 345 | .result(trg_mux_data[i]));
|
---|
| 346 |
|
---|
| 347 | lpm_mux #(
|
---|
| 348 | .lpm_size(2),
|
---|
| 349 | .lpm_type("LPM_MUX"),
|
---|
| 350 | .lpm_width(13),
|
---|
| 351 | .lpm_widths(1)) hst_mux_unit (
|
---|
| 352 | .sel(hst_mux_sel[i][0]),
|
---|
[80] | 353 | .data({ {uwt_peak3[i][11:0], ana_peak_ready[i]},
|
---|
[72] | 354 | {data[i], data_ready[i]} }),
|
---|
| 355 | .result(hst_mux_data[i]));
|
---|
[27] | 356 |
|
---|
[72] | 357 | lpm_mux #(
|
---|
| 358 | .lpm_size(2),
|
---|
| 359 | .lpm_type("LPM_MUX"),
|
---|
| 360 | .lpm_width(12),
|
---|
| 361 | .lpm_widths(1)) bln_mux_unit (
|
---|
| 362 | .sel(bln_mux_sel[i][0]),
|
---|
| 363 | .data({bln_baseline[i], cfg_baseline[i]}),
|
---|
| 364 | .result(bln_mux_data[i]));
|
---|
| 365 |
|
---|
| 366 | baseline baseline_unit (
|
---|
| 367 | .clk(CLK_50MHz),
|
---|
| 368 | .reset(bln_reset[i]),
|
---|
| 369 | .data_ready(data_ready[i]),
|
---|
| 370 | .uwt_flag(uwt_flag3[i]),
|
---|
| 371 | .uwt_data(uwt_peak3[i]),
|
---|
| 372 | .baseline(bln_baseline[i]));
|
---|
| 373 |
|
---|
[44] | 374 | analyser analyser_unit (
|
---|
| 375 | .clk(CLK_50MHz),
|
---|
| 376 | .reset(ana_reset[i]),
|
---|
[72] | 377 | .data_ready(data_ready[i]),
|
---|
| 378 | .uwt_flag(uwt_flag3[i]),
|
---|
[80] | 379 | .peak_ready(ana_peak_ready[i]));
|
---|
[54] | 380 |
|
---|
[72] | 381 | assign hst_data[i] = (hst_mux_data[i][12:1] > bln_mux_data[i]) ? (hst_mux_data[i][12:1] - bln_mux_data[i]) : 12'd0;
|
---|
| 382 | assign hst_data_ready[i] = (hst_mux_data[i][0]) & (hst_data[i] >= cfg_hst_threshold[i]);
|
---|
| 383 |
|
---|
| 384 | histogram #(.W(32)) histogram_unit (
|
---|
[44] | 385 | .clk(CLK_50MHz),
|
---|
| 386 | .reset(hst_reset[i]),
|
---|
[72] | 387 | .data_ready(hst_data_ready[i]),
|
---|
| 388 | .data(hst_data[i]),
|
---|
[44] | 389 | .address(hst_addr[i]),
|
---|
| 390 | .q(hst_q[i]));
|
---|
[72] | 391 |
|
---|
| 392 | trigger trigger_unit (
|
---|
[44] | 393 | .clk(CLK_50MHz),
|
---|
[72] | 394 | .reset(trg_reset[i]),
|
---|
| 395 | .data_ready(data_ready[i]),
|
---|
| 396 | .data(trg_mux_data[i]),
|
---|
| 397 | .threshold(cfg_trg_threshold[i]),
|
---|
| 398 | .trigger(osc_trig[i]));
|
---|
| 399 |
|
---|
| 400 |
|
---|
[44] | 401 | oscilloscope oscilloscope_unit (
|
---|
| 402 | .clk(CLK_50MHz),
|
---|
| 403 | .reset(osc_reset[i]),
|
---|
[72] | 404 | .data_ready(data_ready[i]),
|
---|
| 405 | .data(osc_mux_data[i]),
|
---|
| 406 | .trigger(osc_trig[i]),
|
---|
[44] | 407 | .address(osc_addr[i]),
|
---|
| 408 | .start_address(osc_start_addr[i]),
|
---|
| 409 | .q(osc_q[i]));
|
---|
| 410 | end
|
---|
| 411 | endgenerate
|
---|
[27] | 412 |
|
---|
[44] | 413 | always @*
|
---|
[27] | 414 | begin
|
---|
[72] | 415 | for (j = 0; j < N; j = j + 1)
|
---|
[46] | 416 | begin
|
---|
| 417 | osc_reset[j] = 1'b0;
|
---|
| 418 | osc_addr[j] = 10'b0;
|
---|
| 419 | hst_reset[j] = 1'b0;
|
---|
| 420 | hst_addr[j] = 12'b0;
|
---|
| 421 | end
|
---|
| 422 |
|
---|
[72] | 423 | case(mux_type)
|
---|
| 424 | // case({mux_type, mux_chan})
|
---|
| 425 | 1'b0:
|
---|
| 426 | // 3'b000, 3'b001, 3'b010, 3'b011:
|
---|
[27] | 427 | begin
|
---|
[45] | 428 | osc_reset[mux_chan] = mux_reset;
|
---|
| 429 | osc_addr[mux_chan] = mux_addr[9:0];
|
---|
| 430 | mux_max_byte = 2'd1;
|
---|
| 431 | mux_min_addr = {6'd0, osc_start_addr[mux_chan]};
|
---|
[59] | 432 | mux_max_addr = 16'd1023;
|
---|
[27] | 433 | end
|
---|
[45] | 434 |
|
---|
[72] | 435 | 1'b1:
|
---|
| 436 | // 3'b100, 3'b101, 3'b110, 3'b011:
|
---|
[27] | 437 | begin
|
---|
[45] | 438 | hst_reset[mux_chan] = mux_reset;
|
---|
| 439 | hst_addr[mux_chan] = mux_addr[11:0];
|
---|
[70] | 440 | mux_max_byte = 2'd3;
|
---|
[45] | 441 | mux_min_addr = 16'd0;
|
---|
[70] | 442 | mux_max_addr = 16'd4095;
|
---|
[27] | 443 | end
|
---|
| 444 | endcase
|
---|
| 445 | end
|
---|
[45] | 446 |
|
---|
| 447 | always @*
|
---|
| 448 | begin
|
---|
[59] | 449 | case ({mux_type, mux_byte})
|
---|
| 450 | 3'b000: mux_q = osc_q[mux_chan][7:0];
|
---|
| 451 | 3'b001: mux_q = osc_q[mux_chan][15:8];
|
---|
[35] | 452 |
|
---|
[59] | 453 | 3'b100: mux_q = hst_q[mux_chan][7:0];
|
---|
| 454 | 3'b101: mux_q = hst_q[mux_chan][15:8];
|
---|
| 455 | 3'b110: mux_q = hst_q[mux_chan][23:16];
|
---|
[68] | 456 | 3'b111: mux_q = hst_q[mux_chan][31:24];
|
---|
[45] | 457 |
|
---|
| 458 | default: mux_q = 8'd0;
|
---|
| 459 | endcase
|
---|
| 460 | end
|
---|
[68] | 461 |
|
---|
| 462 | wire i2c_aclr;
|
---|
| 463 | wire i2c_wrreq;
|
---|
| 464 | wire i2c_full;
|
---|
| 465 | wire [15:0] i2c_data;
|
---|
| 466 |
|
---|
| 467 | i2c_fifo i2c_unit(
|
---|
| 468 | .clk(CLK_50MHz),
|
---|
| 469 | .aclr(i2c_aclr),
|
---|
| 470 | .wrreq(i2c_wrreq),
|
---|
| 471 | .data(i2c_data),
|
---|
| 472 | .full(i2c_full),
|
---|
[70] | 473 | /*
|
---|
| 474 | normal connection
|
---|
[68] | 475 | .i2c_sda(I2C_SDA),
|
---|
[70] | 476 | .i2c_scl(I2C_SCL),
|
---|
[68] | 477 |
|
---|
[70] | 478 | following is a cross wire connection for EPT
|
---|
| 479 | */
|
---|
| 480 | .i2c_sda(I2C_SCL),
|
---|
| 481 | .i2c_scl(I2C_SDA));
|
---|
| 482 |
|
---|
[59] | 483 | control control_unit (
|
---|
| 484 | .clk(CLK_50MHz),
|
---|
[72] | 485 | .cfg_reset(cfg_reset),
|
---|
| 486 | .cfg_src_data(cfg_memory[cfg_src_addr[4:0]]),
|
---|
| 487 | .cfg_src_addr(cfg_src_addr),
|
---|
| 488 | .cfg_dst_data(cfg_dst_data),
|
---|
| 489 | .cfg_dst_addr(cfg_dst_addr),
|
---|
[59] | 490 | .rx_empty(usb_rx_empty),
|
---|
| 491 | .tx_full(usb_tx_full),
|
---|
| 492 | .rx_data(usb_rx_data),
|
---|
| 493 | .mux_max_byte(mux_max_byte),
|
---|
| 494 | .mux_min_addr(mux_min_addr),
|
---|
| 495 | .mux_max_addr(mux_max_addr),
|
---|
| 496 | .mux_q(mux_q),
|
---|
| 497 | .mux_reset(mux_reset),
|
---|
| 498 | .mux_type(mux_type),
|
---|
| 499 | .mux_chan(mux_chan),
|
---|
| 500 | .mux_byte(mux_byte),
|
---|
| 501 | .mux_addr(mux_addr),
|
---|
| 502 | .rx_rdreq(usb_rx_rdreq),
|
---|
| 503 | .tx_wrreq(usb_tx_wrreq),
|
---|
| 504 | .tx_data(usb_tx_data),
|
---|
[65] | 505 | .ram_we(RAM_WE),
|
---|
| 506 | .ram_addr(RAM_ADDR),
|
---|
| 507 | .ram_data({RAM_DQA, RAM_DQAP, RAM_DQB, RAM_DQBP}),
|
---|
[68] | 508 | .i2c_wrreq(i2c_wrreq),
|
---|
| 509 | .i2c_data(i2c_data),
|
---|
| 510 | .i2c_full(i2c_full),
|
---|
[59] | 511 | .led(LED));
|
---|
[45] | 512 |
|
---|
[54] | 513 | endmodule
|
---|