Attention

This documentation is a work in progress. Expect to see errors and unfinished things.

mon_2chan Source File

 1`timescale 1ns / 1ns
 2// 2 x 3-in-1 functionality
 3// 1. Mix an ADC output with LO sin (or) cos (see mixer.v)
 4// 2. Double CIC integrate the output signal from step-1. (via double_inte.v)
 5// 3. Take a sample from step-2 when the `input samp` is high AND
 6//    put the sampled data out on the stream when g_in is high (via serialize.v)
 7// TODO: Find a better name
 8module mon_2chan #(
 9     parameter dwi=16,  // data width
10     parameter rwi=28,  // result width
11     // Difference between above two widths should be N*log2 of the maximum number
12     // of samples per CIC sample, where N=2 is the order of the CIC filter.
13     parameter davr=3,  // how many guard bits to keep in output of multiplier
14     parameter dwlo=18  // Local Oscillator data width
15) (
16     input clk,  // timespec 8.4 ns
17     input signed [dwi-1:0] adcf,  // Full scale (?) ADC data, possibly muxed
18     input signed [dwlo-1:0] mcos,
19     input signed [dwlo-1:0] msin,
20     input samp, // mixer + double_integrated output capture trigger
21     input signed [rwi-1:0] s_in,  // Stream IN
22     output signed [rwi-1:0] s_out, // Stream OUT
23     input g_in,
24     output g_out,
25     input reset
26);
27
28// TODO: All we need is a delayed reset(?) why bother with a shift register?
29reg [1:0] reset_r=0;
30always @(posedge clk) begin
31     reset_r <= {reset_r[0], reset};
32end
33
34wire signed [rwi-1:0] s_reg1, s_reg2;
35wire g_reg1, g_reg2;
36
37wire signed [dwi+davr-1:0] m1out;
38wire signed [rwi-1:0] i1out;
39mixer       #(.dwi(dwi),.davr(davr),.dwlo(dwlo)) m1(.clk(clk), .adcf(adcf), .mult(mcos), .mixout(m1out));
40double_inte #(.dwi(dwi+davr),.dwo(rwi))          i1(.clk(clk), .in(m1out), .out(i1out),.reset(reset_r[1]));
41serialize   #(.dwi(rwi))                         s1(.clk(clk), .samp(samp), .data_in(i1out),
42     .stream_in(s_reg2), .stream_out(s_reg1), .gate_in(g_reg2), .gate_out(g_reg1));
43
44wire signed [dwi+davr-1:0] m2out;
45wire signed [rwi-1:0] i2out;
46mixer       #(.dwi(dwi),.davr(davr),.dwlo(dwlo)) m2(.clk(clk), .adcf(adcf), .mult(msin), .mixout(m2out));
47double_inte #(.dwi(dwi+davr),.dwo(rwi))          i2(.clk(clk), .in(m2out), .out(i2out),.reset(reset_r[1]));
48serialize   #(.dwi(rwi))                         s2(.clk(clk), .samp(samp), .data_in(i2out),
49     .stream_in(s_in), .stream_out(s_reg2), .gate_in(g_in), .gate_out(g_reg2));
50
51assign s_out = s_reg1;
52assign g_out = g_reg1;
53
54endmodule