x393  1.0
FPGAcodeforElphelNC393camera
imu_message393.v
Go to the documentation of this file.
1 
44 `timescale 1ns/1ps
45 
47  input mclk, // system clock, negedge TODO:COnvert to posedge!
48  input xclk, // half frequency (80 MHz nominal)
49  input we, // write enable for registers to log (@negedge mclk), with lower data half
50  input [3:0] wa, // write address for register (4 bits, @negedge mclk)
51 // input [15:0] di, // 16-bit data in multiplexed
52  input [31:0] din, // 32-bit data in, non-multiplexed
53  input en, // enable module operation, if 0 - reset
54  input trig, // leading edge - sample time, trailing set rdy
55  output ts, // timestamop request
56  output rdy, // data ready
57  input rd_stb, // data read strobe (increment address)
58  output [15:0] rdata); // data out (16 bits)
59 
60  reg [ 4:0] raddr;
61  reg rdy_r=1'b0;
62  reg [ 2:0] trig_d;
63  reg [ 7:0] denoise_count;
64  reg [ 1:0] trig_denoise;
65  reg ts_r;
66 
67  assign rdy = rdy_r;
68  assign ts = ts_r;
69 
70  always @ (posedge xclk) begin
71  if (!en) trig_d[2:0] <= 3'h0;
72  else trig_d[2:0] <= {trig_d[1:0], trig};
73 
74  if (!en) trig_denoise[0] <= 1'b0;
75  else if (denoise_count[7:0]==8'h0) trig_denoise[0] <= trig_d[2];
76 
77  if (trig_d[2]==trig_denoise[0]) denoise_count[7:0] <= 8'hff;
78  else denoise_count[7:0] <= denoise_count[7:0] - 1;
79 
80  trig_denoise[1] <= trig_denoise[0];
81 
82  ts_r <= !trig_denoise[1] && trig_denoise[0];
83 
84  if (!en || ts_r) raddr[4:0] <= 5'h0;
85  else if (rd_stb) raddr[4:0] <= raddr[4:0] + 1;
86 
87  if (ts_r || (rd_stb && (raddr[4:0]==5'h1b)) || !en) rdy_r <= 1'b0;
88  else if (trig_denoise[1] && !trig_denoise[0]) rdy_r <= 1'b1;
89  end
90 
91  reg [31:0] odbuf0_ram[0:15];
92  wire [31:0] odbuf0_ram_out;
93  always @ (posedge mclk) if (we) begin
94  odbuf0_ram[wa[3:0]] <= din[31:0];
95  end
96  assign odbuf0_ram_out = odbuf0_ram[raddr[4:1]];
97  assign rdata[15:0] = raddr[0] ? odbuf0_ram_out[15:0] : odbuf0_ram_out[31:16];
98 
99 endmodule
100 
3610odbuf0_ram_outwire[31:0]
[0:15] 3609odbuf0_ramreg[31:0]
3607trig_denoisereg[1:0]
3603raddrreg[4:0]
[15:0] 3602rdata
3606denoise_countreg[7:0]
3605trig_dreg[2:0]