Attention
This documentation is a work in progress. Expect to see errors and unfinished things.
mon_chans Source File
1`timescale 1ns / 1ns
2
3module mon_chans #(
4 parameter NCHAN=1,
5 parameter DWI=16, // data width
6 parameter RWI=28, // result width
7 // Difference between above two widths should be N*log2 of the maximum number
8 // of samples per CIC sample, where N=2 is the order of the CIC filter.
9 parameter DWLO=18, // Local Oscillator data width
10 parameter DAVR=3
11) (
12 input clk, // timespec 8.4 ns
13 input signed [NCHAN*DWI-1:0] adc, // possibly muxed
14 input signed [NCHAN*DWLO-1:0] mlo,
15 input samp,
16 input signed [RWI-1:0] s_in,
17 output signed [RWI-1:0] s_out,
18 input g_in,
19 output g_out,
20 input reset
21);
22
23reg [1:0] reset_r=0;
24always @(posedge clk) reset_r <= {reset_r[0],reset};
25
26wire signed [(NCHAN+1)*RWI-1:0] s_reg;//, s_reg2;
27assign s_reg[(NCHAN+1)*RWI-1:NCHAN*RWI]=s_in;
28wire [NCHAN:0] g_reg;//, g_reg2;
29assign g_reg[NCHAN]=g_in;
30wire signed [NCHAN*(DWI+DAVR)-1:0] mout;
31wire signed [NCHAN*RWI-1:0] iout;
32
33genvar ix;
34generate for (ix=0;ix<NCHAN;ix=ix+1) begin : G_MIX_INTEG_SERIAL
35 mixer #(
36 .dwi(DWI),.davr(DAVR),.dwlo(DWLO))
37 mixer(.clk(clk), .adcf(adc[DWI*(ix+1)-1:DWI*ix]), .mult(mlo[DWLO*(ix+1)-1:DWLO*ix]),
38 .mixout(mout[(DWI+DAVR)*(ix+1)-1:(DWI+DAVR)*ix]));
39
40 double_inte #(
41 .dwi(DWI+DAVR),.dwo(RWI))
42 double_inte(.clk(clk), .in(mout[(DWI+DAVR)*(ix+1)-1:(DWI+DAVR)*ix]),
43 .out(iout[RWI*(ix+1)-1:RWI*ix]), .reset(reset_r[1]));
44
45 serialize #(
46 .dwi(RWI))
47 serialize(.clk(clk), .samp(samp), .data_in(iout[RWI*(ix+1)-1:RWI*ix]),
48 .stream_in(s_reg[RWI*(ix+2)-1:RWI*(ix+1)]),
49 .stream_out(s_reg[RWI*(ix+1)-1:RWI*ix]),
50 .gate_in(g_reg[ix+1]), .gate_out(g_reg[ix]));
51end
52endgenerate
53
54assign s_out = s_reg[RWI*(0+1)-1:RWI*0];
55assign g_out = g_reg[0];
56
57endmodule