Attention

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

serializer_multichannel Source File

 1`timescale 1ns / 1ns
 2
 3/** SERIALIZER_MULTICHANNEL **
 4    Conveyor belt generator which takes a generic number of input vectors (flattened)
 5    and samples them into a shift-based conveyor belt.
 6
 7               sample_in
 8                   +
 9                   |
10         +---------v-------------+
11         |               +-----+ |
12d_in[0]+----------------->  S  +---> stream_out
13         |               +--^--+ |
14         |        +-----+   |    |
15d_in[1]+---------->  S  +---+    |
16         |        +--^--+        |
17         | +-----+   |           |
18d_in[N]+--->  S  +---+           |
19         | +-----+               |
20         +-----------------------+
21*/
22
23`ifdef SIMULATE
24`define FILL_BIT 1'bx
25`else
26`define FILL_BIT 1'b0
27`endif
28
29module serializer_multichannel #(
30   parameter n_chan = 8, // Number of channels to serialize
31   parameter dw = 16,
32   parameter l_to_r=1  // l_to_r=1: Channel shifting starts with CH0 (default)
33                       // l_to_r=0: Channel shifting starts with last CH
34) (
35   input                 clk,
36   input                 sample_in, // Sampling signal which determines when to push inputs to belt
37   input [n_chan*dw-1:0] data_in,   // Flattened array of unprocessed data streams
38   output                gate_out,
39   output [dw-1:0]       stream_out // Serialized stream of channels. Default order is CH0 first (l_to_r=1)
40);
41   wire [dw-1:0] shift_chain[n_chan:0]; // +1 for feed-out
42   wire          shift_gate[n_chan:0]; // +1 for feed-out
43   wire [dw-1:0] sr_in[n_chan-1:0];
44
45
46   assign shift_chain[0] = {dw{`FILL_BIT}}; // initialize shift-chain
47   assign shift_gate[0]  = 1'b0;
48
49   genvar ch_id;
50   generate for (ch_id=0; ch_id < n_chan; ch_id=ch_id+1) begin : g_serializer
51      if (l_to_r == 0) begin : g_l_to_r  // CH0 first
52         assign sr_in[ch_id] = data_in[(n_chan-ch_id)*dw-1: (n_chan-ch_id-1)*dw];
53      end else begin : g_r_to_l
54         assign sr_in[ch_id] = data_in[(ch_id+1)*dw-1: ch_id*dw];
55      end
56
57      serialize #(
58         .dwi(dw))
59      i_serialize_ch
60      (
61         .clk        (clk),
62         .samp       (sample_in),
63         .data_in    (sr_in[ch_id]),
64         .stream_in  (shift_chain[n_chan - ch_id - 1]),
65         .stream_out (shift_chain[n_chan - ch_id]),
66         .gate_in    (shift_gate[n_chan - ch_id -1]),
67         .gate_out   (shift_gate[n_chan - ch_id]),
68         .strobe_out () // Open - unused
69      );
70   end endgenerate
71
72   assign gate_out   = shift_gate[n_chan];
73   assign stream_out = shift_chain[n_chan];
74
75endmodule