Commit e9862dab authored by Andrey Filippov's avatar Andrey Filippov

Converting event_logger to use serial timestamps and 4 sesnor channels

parent 6a297fff
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Author: andrey * Author: andrey
* Description: move data from xclk to mclk domain * Description: move data from xclk to mclk domain
* *
* Copyright (c) 2015 <set up in Preferences-Verilog/VHDL Editor-Templates> . * Copyright (c) 2015 Elphel, Inc.
* buf_xclk_mclk16_393.v is free software; you can redistribute it and/or modify * buf_xclk_mclk16_393.v is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
...@@ -21,63 +21,46 @@ ...@@ -21,63 +21,46 @@
`timescale 1ns/1ps `timescale 1ns/1ps
module buf_xclk_mclk16_393( module buf_xclk_mclk16_393(
xclk, // posedge input mclk, // system clock, posedge
mclk, // posedge input xclk, // half frequency (80 MHz nominal)
rst, // @posedge xclk input rst, // @posedge xclk reset module
din, input [15:0] din,
din_stb, input din_stb,
dout, output reg [15:0] dout,
dout_stb); output reg dout_stb);
input xclk; // half frequency (80 MHz nominal) reg [1:0] wa;
input mclk; // system clock - frequency (160 MHz nominal) reg [1:0] wa_mclk;
input rst; // reset module reg [1:0] wa_mclk_d;
input [15:0] din; reg rst_mclk;
input din_stb; reg [1:0] ra;
output [15:0] dout; reg [1:0] ra_next;
output dout_stb; reg inc_ra;
wire [15:0] pre_dout;
reg [1:0] wa; always @ (posedge xclk) begin
reg [1:0] wa_mclk; if (rst) wa[1:0] <= 2'h0;
reg [1:0] wa_mclk_d; else if (din_stb) wa[1:0] <={wa[0],~wa[1]};
reg rst_mclk; end
reg [1:0] ra;
reg [1:0] ra_next;
reg inc_ra;
wire [15:0] pre_dout;
reg [15:0] dout;
reg dout_stb;
always @ (posedge xclk) begin
if (rst) wa[1:0] <= 2'h0;
else if (din_stb) wa[1:0] <={wa[0],~wa[1]};
end
always @ (posedge mclk) begin
wa_mclk[1:0] <= wa[1:0];
wa_mclk_d[1:0] <= wa_mclk[1:0];
rst_mclk<= rst;
if (rst_mclk) ra[1:0] <= 2'h0;
else ra[1:0] <= inc_ra?{ra[0],~ra[1]}:{ra[1],ra[0]};
if (rst_mclk) ra_next[1:0] <= 2'h1;
else ra_next[1:0] <= inc_ra?{~ra[1],~ra[0]}:{ra[0],~ra[1]};
inc_ra <= !rst && (ra[1:0]!=wa_mclk_d[1:0]) && (!inc_ra || (ra_next[1:0]!=wa_mclk_d[1:0]));
dout_stb <= inc_ra;
if (inc_ra) dout[15:0] <= pre_dout[15:0];
end
myRAM_WxD_D #( .DATA_WIDTH(16),.DATA_DEPTH(2))
i_fifo_4x16 (.D(din[15:0]),
.WE(din_stb),
.clk(xclk),
.AW(wa[1:0]),
.AR(ra[1:0]),
.QW(),
.QR(pre_dout[15:0]));
endmodule
always @ (posedge mclk) begin
wa_mclk[1:0] <= wa[1:0];
wa_mclk_d[1:0] <= wa_mclk[1:0];
rst_mclk<= rst;
if (rst_mclk) ra[1:0] <= 2'h0;
else ra[1:0] <= inc_ra?{ra[0],~ra[1]}:{ra[1],ra[0]};
if (rst_mclk) ra_next[1:0] <= 2'h1;
else ra_next[1:0] <= inc_ra?{~ra[1],~ra[0]}:{ra[0],~ra[1]};
inc_ra <= !rst && (ra[1:0]!=wa_mclk_d[1:0]) && (!inc_ra || (ra_next[1:0]!=wa_mclk_d[1:0]));
dout_stb <= inc_ra;
if (inc_ra) dout[15:0] <= pre_dout[15:0];
end
reg [15:0] fifo_4x16_ram[0:3];
always @ (posedge xclk) if (din_stb) fifo_4x16_ram[wa[1:0]] <= din[15:0];
assign pre_dout[15:0] = fifo_4x16_ram[ra[1:0]];
endmodule endmodule
This diff is collapsed.
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Author: andrey * Author: andrey
* Description: * Description:
* *
* Copyright (c) 2015 <set up in Preferences-Verilog/VHDL Editor-Templates> . * Copyright (c) 2015 Elphel, Inc.
* imu_message393.v is free software; you can redistribute it and/or modify * imu_message393.v is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
...@@ -27,73 +27,58 @@ de-assert the trig input - message with the timestamp will be logged ...@@ -27,73 +27,58 @@ de-assert the trig input - message with the timestamp will be logged
fixed-length de-noise circuitry with latency 256*T(xclk) (~3usec) fixed-length de-noise circuitry with latency 256*T(xclk) (~3usec)
*/ */
module imu_message393 ( sclk, // system clock, negedge module imu_message393 (
xclk, // half frequency (80 MHz nominal) input mclk, // system clock, negedge TODO:COnvert to posedge!
we, // write enable for registers to log (@negedge sclk), with lower data half input xclk, // half frequency (80 MHz nominal)
wa, // write address for register (4 bits, @negedge sclk) input we, // write enable for registers to log (@negedge mclk), with lower data half
di, // 16-bit data in multiplexed input [3:0] wa, // write address for register (4 bits, @negedge mclk)
en, // enable module operation, if 0 - reset // input [15:0] di, // 16-bit data in multiplexed
trig, // leading edge - sample time, trailing set rdy input [31:0] din, // 32-bit data in, non-multiplexed
ts, // timestamop request input en, // enable module operation, if 0 - reset
rdy, // data ready input trig, // leading edge - sample time, trailing set rdy
rd_stb, // data read strobe (increment address) output ts, // timestamop request
rdata); // data out (16 bits) output rdy, // data ready
input rd_stb, // data read strobe (increment address)
output [15:0] rdata); // data out (16 bits)
input sclk; // system clock, negedge reg [ 4:0] raddr;
input xclk; // half frequency (80 MHz nominal) reg rdy_r=1'b0;
input we; // write enable for registers to log (@negedge sclk) reg [ 2:0] trig_d;
input [3:0] wa; // write address for register (4 bits, @negedge sclk) reg [ 7:0] denoise_count;
input [15:0] di; // 16-bit data in (32 multiplexed) reg [ 1:0] trig_denoise;
input en; // enable reg ts_r;
input trig; // leading edge - sample time, trailing set rdy
output ts; // timestamp request assign rdy = rdy_r;
output rdy; // encoded nmea data ready assign ts = ts_r;
input rd_stb; // encoded nmea data read strobe (increment address)
output [15:0] rdata; // encoded data (16 bits) always @ (posedge xclk) begin
if (!en) trig_d[2:0] <= 3'h0;
reg [ 4:0] raddr; else trig_d[2:0] <= {trig_d[1:0], trig};
reg rdy=1'b0;
reg we_d; if (!en) trig_denoise[0] <= 1'b0;
reg [ 4:1] waddr; else if (denoise_count[7:0]==8'h0) trig_denoise[0] <= trig_d[2];
reg [ 2:0] trig_d;
reg [ 7:0] denoise_count; if (trig_d[2]==trig_denoise[0]) denoise_count[7:0] <= 8'hff;
reg [ 1:0] trig_denoise; else denoise_count[7:0] <= denoise_count[7:0] - 1;
reg ts;
reg [15:0] di_d; trig_denoise[1] <= trig_denoise[0];
always @ (negedge sclk) begin ts_r <= !trig_denoise[1] && trig_denoise[0];
di_d[15:0] <= di[15:0];
waddr[4:1] <= wa[3:0]; if (!en || ts_r) raddr[4:0] <= 5'h0;
we_d <=we; else if (rd_stb) raddr[4:0] <= raddr[4:0] + 1;
end
always @ (posedge xclk) begin if (ts_r || (rd_stb && (raddr[4:0]==5'h1b)) || !en) rdy_r <= 1'b0;
if (!en) trig_d[2:0] <= 3'h0; else if (trig_denoise[1] && !trig_denoise[0]) rdy_r <= 1'b1;
else trig_d[2:0] <= {trig_d[1:0], trig}; end
if (!en) trig_denoise[0] <= 1'b0;
else if (denoise_count[7:0]==8'h0) trig_denoise[0] <= trig_d[2];
if (trig_d[2]==trig_denoise[0]) denoise_count[7:0] <= 8'hff;
else denoise_count[7:0] <= denoise_count[7:0] - 1;
trig_denoise[1] <= trig_denoise[0];
ts <= !trig_denoise[1] && trig_denoise[0];
if (!en || ts) raddr[4:0] <= 5'h0;
else if (rd_stb) raddr[4:0] <= raddr[4:0] + 1;
if (ts || (rd_stb && (raddr[4:0]==5'h1b)) || !en) rdy <= 1'b0;
else if (trig_denoise[1] && !trig_denoise[0]) rdy <= 1'b1;
end
myRAM_WxD_D #( .DATA_WIDTH(16),.DATA_DEPTH(5))
i_odbuf (.D(di_d[15:0]),
.WE(we | we_d),
.clk(~sclk),
.AW({waddr[4:1],we_d}),
.AR(raddr[4:0]),
.QW(),
.QR(rdata[15:0]));
endmodule
reg [31:0] odbuf0_ram[0:15];
wire [31:0] odbuf0_ram_out;
always @ (posedge mclk) if (we) begin
odbuf0_ram[wa[3:0]] <= din[31:0];
end
assign odbuf0_ram_out = odbuf0_ram[raddr[4:1]];
assign rdata[15:0] = raddr[0] ? odbuf0_ram_out[15:0] : odbuf0_ram_out[31:16];
endmodule endmodule
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Author: andrey * Author: andrey
* Description: Acquire timestmps for events * Description: Acquire timestmps for events
* *
* Copyright (c) 2015 <set up in Preferences-Verilog/VHDL Editor-Templates> . * Copyright (c) 2015 Elphel, Inc.
* imu_timestamps393.v is free software; you can redistribute it and/or modify * imu_timestamps393.v is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -30,7 +30,7 @@ module timestamp_fifo( ...@@ -30,7 +30,7 @@ module timestamp_fifo(
input pre_stb, // marks pre-first input byte (s0,s1,s2,s3,u0,u1,u2,u3) input pre_stb, // marks pre-first input byte (s0,s1,s2,s3,u0,u1,u2,u3)
input [7:0] din, // data in - valid for 8 cycles after pre_stb input [7:0] din, // data in - valid for 8 cycles after pre_stb
input aclk, // clock to synchronize advance puls input aclk, // clock to synchronize "advance" commands
input advance, // @aclk advance registers input advance, // @aclk advance registers
input rclk, // output clock input rclk, // output clock
...@@ -65,11 +65,11 @@ module timestamp_fifo( ...@@ -65,11 +65,11 @@ module timestamp_fifo(
always @(posedge rst or posedge rclk) begin always @(posedge rst or posedge rclk) begin
if (rst) snd <= 0; if (rst) snd <= 0;
else if (rstb) snd <= 1; else if (rstb) snd <= 1;
else if (&rpntr[2:0]) snd <= 0; else if (&rpntr[2:1]) snd <= 0; // at count 6
if (rst) rpntr[2:0] <= 0; if (rst) rpntr[2:0] <= 0;
else if (!snd) rpntr[2:0] <= 0; else if (!snd && !rstb) rpntr[2:0] <= 0;
else rpntr[2:0] <= rpntr[2:0] + 1; else rpntr[2:0] <= rpntr[2:0] + 1;
if (snd) dout <= fifo_ram[rpntr]; if (snd) dout <= fifo_ram[rpntr];
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment