x393  1.0
FPGAcodeforElphelNC393camera
huffman_stuffer_meta.v
Go to the documentation of this file.
1 
46 `timescale 1ns/1ps
47 
49  input mclk, // system clock to write tables
50  input mrst,
51  input xclk, // pixel clock, sync to incoming data
52  input en_huffman, // @xclk
53  input en_stuffer, // @xclk
54  input abort_stuffer, // @ any
55 
56 // Interface to program Huffman tables
57  input tser_we, // enable write to a table
58  input tser_a_not_d, // address/not data distributed to submodules
59  input [ 7:0] tser_d, // byte-wide serialized tables address/data to submodules
60 
61 // Input data
62  input [15:0] di, // [15:0] specially RLL prepared 16-bit data (to FIFO) (sync to xclk)
63  input ds, // di valid strobe (sync to xclk)
64 
65 // time stamping - will copy time at the end of color_first (later than the first hact after vact in the current frame, but before the next one
66 // and before the data is needed for output
67  input ts_pre_stb, // @mclk - 1 cycle before receiving 8 bytes of timestamp data
68  input [7:0] ts_data, // timestamp data (s0,s1,s2,s3,us0,us1,us2,us3==0)
69  input color_first, // @fradv_clk only used for timestamp
70  // outputs @ negedge clk
71  output [31:0] data_out, // [31:0] output data
72  output data_out_valid,// output data valid
73  output done, // reset by !en, goes high after some delay after flushing
74  output running, // from registering timestamp until done
75  input clk_flush, // other clock to generate synchronized 1-cycle flush_clk output
76  output flush_clk // 1-cycle flush output @ clk_flush
77 
78 `ifdef DEBUG_RING
79  ,output test_lbw,
80  output gotLastBlock, // last block done - flush the rest bits
81 
82  output [3:0] dbg_etrax_dma
83  ,output dbg_ts_rstb
84  ,output [7:0] dbg_ts_dout
85 `endif
86 );
87  wire [26:0] huffman_do27;
88  wire [4:0] huffman_dl;
89  wire huffman_dv;
92 
93  wire [31:0] stuffer_do32;
94  wire [1:0] stuffer_bytes;
95  wire stuffer_dv;
97 
98  wire [31:0] escape_do32;
99  wire [1:0] escape_bytes;
100  wire escape_dv;
102  huffman_snglclk huffman_snglclk_i (
103  .xclk (xclk), // input
104  .rst (~en_huffman), // input
105  .mclk (mclk), // input
106  .tser_we (tser_we), // input
107  .tser_a_not_d (tser_a_not_d), // input
108  .tser_d (tser_d), // input[7:0]
109  .di (di), // input[15:0]
110  .ds (ds), // input
111  .do27 (huffman_do27), // output[26:0]
112  .dl (huffman_dl), // output[4:0]
113  .dv (huffman_dv), // output
114  .flush (huffman_flush), // output
115  .last_block (huffman_last_block), // output
116 `ifdef DEBUG_RING
117  .test_lbw (test_lbw),
118  .gotLastBlock (gotLastBlock), // last block done - flush the rest bits
119 `else
120  .test_lbw (),
121  .gotLastBlock (), // last block done - flush the rest bits
122 `endif
123  .clk_flush (clk_flush), // input
124  .flush_clk (flush_clk), // output
125  .fifo_or_full() // output
126  );
127 
129  .DIN_LEN(27)
130  ) bit_stuffer_27_32_i (
131  .xclk (xclk), // input
132  .rst (~en_huffman), // input
133  .din (huffman_do27), // input[26:0]
134  .dlen (huffman_dl), // input[4:0]
135  .ds (huffman_dv), // input
136  .flush_in (huffman_flush), // input
137  .d_out (stuffer_do32), // output[31:0]
138  .bytes_out (stuffer_bytes), // output[1:0] reg
139  .dv (stuffer_dv), // output reg
140  .flush_out (stuffer_flush_out) // output reg
141  );
142 
143 
144  bit_stuffer_escape bit_stuffer_escape_i (
145  .xclk (xclk), // input
146  .rst (~en_huffman), // input
147  .din (stuffer_do32), // input[31:0]
148  .bytes_in (stuffer_bytes), // input[1:0]
149  .in_stb (stuffer_dv), // input
150  .flush_in (stuffer_flush_out), // input
151  .d_out (escape_do32), // output[31:0] reg
152  .bytes_out (escape_bytes), // output[1:0] reg
153  .dv (escape_dv), // output reg
154  .flush_out (escape_flush_out) // output reg
155  );
156 
157  bit_stuffer_metadata bit_stuffer_metadata_i (
158  .mclk (mclk), // input
159  .mrst (mrst), // input
160  .xclk (xclk), // input
161  .xrst (~en_stuffer), // input
162  .last_block (huffman_last_block), // input
163  .ts_pre_stb (ts_pre_stb), // input
164  .ts_data (ts_data), // input[7:0]
165  .color_first (color_first), // input
166  .din (escape_do32), // input[31:0]
167  .bytes_in (escape_bytes), // input[1:0]
168  .in_stb (escape_dv), // input
169  .flush (escape_flush_out), // input
170  .abort (abort_stuffer), // input
171  .data_out (data_out), // output[31:0] reg
172  .data_out_valid (data_out_valid), // output reg
173  .done (done), // output reg
174  .running (running) // output reg
175 `ifdef DEBUG_RING
176  ,.dbg_etrax_dma (dbg_etrax_dma), // output[3:0] reg
177  .dbg_ts_rstb (dbg_ts_rstb), // output
178  .dbg_ts_dout (dbg_ts_dout) // output[7:0]
179 `endif
180  );
181 
182 endmodule
183 
184 
reg [1:0] 1274bytes_out
bit_stuffer_27_32_i bit_stuffer_27_32
huffman_snglclk_i huffman_snglclk
bit_stuffer_metadata_i bit_stuffer_metadata
[DIN_LEN-1:0] 1269din
bit_stuffer_escape_i bit_stuffer_escape