-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working on new design for timetagging buffer
- Loading branch information
1 parent
cce5391
commit 3920cba
Showing
11 changed files
with
408 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// width converter | ||
module axis_width_converter #( | ||
parameter int DWIDTH_IN = 16, | ||
parameter int DWIDTH_OUT = 128 | ||
) ( | ||
input wire clk, reset, | ||
Axis_If.Slave_Full data_in, | ||
Axis_If.Master_Full data_out | ||
); | ||
|
||
generate | ||
if (DWIDTH_IN > DWIDTH_OUT) begin | ||
// downsizer | ||
end else begin | ||
// upsizer | ||
end | ||
endgenerate | ||
|
||
endmodule |
52 changes: 52 additions & 0 deletions
52
dds_test.srcs/sources_1/new/banked_sample_buffer_wrapper.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module banked_sample_buffer_wrapper #( | ||
parameter N_CHANNELS = 2, | ||
parameter BUFFER_DEPTH = 8192, | ||
parameter PARALLEL_SAMPLES = 16, | ||
parameter SAMPLE_WIDTH = 16 | ||
) ( | ||
input wire clk, reset_n, | ||
|
||
input [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] s00_axis_tdata, | ||
input s00_axis_tvalid, | ||
output s00_axis_tready, | ||
|
||
input [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] s01_axis_tdata, | ||
input s01_axis_tvalid, | ||
output s01_axis_tready, | ||
|
||
output [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] m_axis_tdata, | ||
output m_axis_tvalid, | ||
input m_axis_tready, | ||
|
||
input [$clog2($clog2(N_CHANNELS)+1)+2-1:0] cfg_axis_tdata, | ||
input cfg_axis_tvalid, | ||
output cfg_axis_tready, | ||
|
||
output capture_started | ||
); | ||
|
||
banked_sample_buffer_sv #( | ||
.N_CHANNELS(N_CHANNELS), | ||
.BUFFER_DEPTH(BUFFER_DEPTH), | ||
.PARALLEL_SAMPLES(PARALLEL_SAMPLES), | ||
.SAMPLE_WIDTH(SAMPLE_WIDTH) | ||
) buffer_i ( | ||
.clk(clk), | ||
.reset(~reset_n), | ||
.s00_axis_tdata(s00_axis_tdata), | ||
.s00_axis_tvalid(s00_axis_tvalid), | ||
.s00_axis_tready(s00_axis_tready), | ||
.s01_axis_tdata(s01_axis_tdata), | ||
.s01_axis_tvalid(s01_axis_tvalid), | ||
.s01_axis_tready(s01_axis_tready), | ||
.m_axis_tdata(m_axis_tdata), | ||
.m_axis_tvalid(m_axis_tvalid), | ||
.m_axis_tlast(m_axis_tlast), | ||
.m_axis_tready(m_axis_tready), | ||
.cfg_axis_tdata(cfg_axis_tdata), | ||
.cfg_axis_tvalid(cfg_axis_tvalid), | ||
.cfg_axis_tready(cfg_axis_tready), | ||
.capture_started(capture_started) | ||
); | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
dds_test.srcs/sources_1/new/sample_discriminator_wrapper.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
module sample_discriminator_wrapper #( | ||
parameter SAMPLE_WIDTH = 16, | ||
parameter PARALLEL_SAMPLES = 1, | ||
parameter SAMPLE_INDEX_WIDTH = 14, | ||
parameter CLOCK_WIDTH = 50 | ||
) ( | ||
input wire clk, reset_n, | ||
|
||
input [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] s00_axis_tdata, | ||
input s00_axis_tvalid, | ||
output s00_axis_tready, | ||
|
||
input [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] s01_axis_tdata, | ||
input s01_axis_tvalid, | ||
output s01_axis_tready, | ||
|
||
output [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] m00_data_axis_tdata, | ||
output m00_data_axis_tvalid, | ||
input m00_data_axis_tready, | ||
|
||
output [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] m01_data_axis_tdata, | ||
output m01_data_axis_tvalid, | ||
input m01_data_axis_tready, | ||
|
||
output [SAMPLE_INDEX_WIDTH+CLOCK_WIDTH-1:0] m00_tstamp_axis_tdata, | ||
output m00_tstamp_axis_tvalid, | ||
input m00_tstamp_axis_tready, | ||
|
||
output [SAMPLE_INDEX_WIDTH+CLOCK_WIDTH-1:0] m01_tstamp_axis_tdata, | ||
output m01_tstamp_axis_tvalid, | ||
input m01_tstamp_axis_tready, | ||
|
||
input [2*2*SAMPLE_WIDTH-1:0] cfg_axis_tdata, | ||
input cfg_axis_tvalid, | ||
output cfg_axis_tready, | ||
|
||
input sample_index_reset | ||
); | ||
|
||
sample_discriminator_sv #( | ||
.SAMPLE_WIDTH(SAMPLE_WIDTH), | ||
.PARALLEL_SAMPLES(PARALLEL_SAMPLES), | ||
.SAMPLE_INDEX_WIDTH(SAMPLE_INDEX_WIDTH), | ||
.CLOCK_WIDTH(CLOCK_WIDTH) | ||
) ( | ||
.clk(clk), | ||
.reset(~reset_n), | ||
|
||
.s00_axis_tdata(s00_axis_tdata), | ||
.s00_axis_tvalid(s00_axis_tvalid), | ||
.s00_axis_tready(s00_axis_tready), | ||
|
||
.s01_axis_tdata(s01_axis_tdata), | ||
.s01_axis_tvalid(s01_axis_tvalid), | ||
.s01_axis_tready(s01_axis_tready), | ||
|
||
.m00_data_axis_tdata(m00_data_axis_tdata), | ||
.m00_data_axis_tvalid(m00_data_axis_tvalid), | ||
.m00_data_axis_tready(m00_data_axis_tready), | ||
|
||
.m01_data_axis_tdata(m01_data_axis_tdata), | ||
.m01_data_axis_tvalid(m01_data_axis_tvalid), | ||
.m01_data_axis_tready(m01_data_axis_tready), | ||
|
||
.m00_tstamp_axis_tdata(m00_tstamp_axis_tdata), | ||
.m00_tstamp_axis_tvalid(m00_tstamp_axis_tvalid), | ||
.m00_tstamp_axis_tready(m00_tstamp_axis_tready), | ||
|
||
.m01_tstamp_axis_tdata(m01_tstamp_axis_tdata), | ||
.m01_tstamp_axis_tvalid(m01_tstamp_axis_tvalid), | ||
.m01_tstamp_axis_tready(m01_tstamp_axis_tready), | ||
|
||
.cfg_axis_tdata(cfg_axis_tdata), | ||
.cfg_axis_tvalid(cfg_axis_tvalid), | ||
.cfg_axis_tready(cfg_axis_tready), | ||
|
||
.sample_index_reset(sample_index_reset) | ||
); | ||
|
||
endmodule |
103 changes: 103 additions & 0 deletions
103
dds_test.srcs/sources_1/new/timetagging_discriminating_buffer.sv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// timetagging_discriminating_buffer - Reed Foster | ||
// performs threshold-based sample discrimination | ||
module timetagging_discriminating_buffer #( | ||
parameter int N_CHANNELS = 2, | ||
parameter int TSTAMP_BUFFER_DEPTH = 1024, | ||
parameter int DATA_BUFFER_DEPTH = 32768, | ||
parameter int AXI_MM_WIDTH = 128, | ||
parameter int PARALLEL_SAMPLES = 1, | ||
parameter int SAMPLE_WIDTH = 16, | ||
parameter int APPROX_CLOCK_WIDTH = 48 | ||
) ( | ||
input wire clk, reset, | ||
Axis_Parallel_If.Slave_Simple data_in, // all channels in parallel | ||
Axis_If.Master_Full data_out, | ||
Axis_If.Slave_Simple disc_cfg_in, // {threshold_high, threshold_low} for each channel | ||
Axis_If.Slave_Simple buffer_cfg_in // {banking_mode, start, stop} | ||
); | ||
|
||
localparam int SAMPLE_INDEX_WIDTH = $clog2(DATA_BUFFER_DEPTH*N_CHANNELS); | ||
localparam int TIMESTAMP_WIDTH = SAMPLE_WIDTH * ((SAMPLE_INDEX_WIDTH + APPROX_CLOCK_WIDTH + (SAMPLE_WIDTH - 1)) / SAMPLE_WIDTH); | ||
|
||
// when either buffer fills up, it triggers a stop on the other with the stop_aux input | ||
logic [1:0] buffer_full; | ||
|
||
// axi-stream interfaces | ||
Axis_Parallel_If #(.DWIDTH(TIMESTAMP_WIDTH), .PARALLEL_CHANNELS(N_CHANNELS)) disc_tstamps(); | ||
Axis_Parallel_If #(.DWIDTH(SAMPLE_WIDTH*PARALLEL_SAMPLES), .PARALLEL_CHANNELS(N_CHANNELS)) disc_data(); | ||
Axis_If #(.DWIDTH($clog2($clog2(N_CHANNELS)+1)+2)) buf_tstamp_cfg (); | ||
Axis_If #(.DWIDTH($clog2($clog2(N_CHANNELS)+1)+2)) buf_data_cfg (); | ||
Axis_If #(.DWIDTH(TIMESTAMP_WIDTH)) buf_tstamp_out (); | ||
Axis_If #(.DWIDTH(SAMPLE_WIDTH*PARALLEL_SAMPLES)) buf_data_out (); | ||
|
||
// share buffer_cfg_in between both buffers so their configuration is synchronized | ||
assign buf_tstamp_cfg.data = buffer_cfg_in.data; | ||
assign buf_tstamp_cfg.valid = buffer_cfg_in.valid; | ||
assign buf_data_cfg.data = buffer_cfg_in.data; | ||
assign buf_data_cfg.valid = buffer_cfg_in.valid; | ||
assign buffer_cfg_in.ready = 1'b1; // doesn't matter what we do here, since both modules hold ready = 1'b1 | ||
|
||
// whenever a buffer capture is triggered through the buffer_cfg_in interface, | ||
// reset the sample_index counter in the sample discriminator | ||
logic start; | ||
always_ff @(posedge clk) begin | ||
if (reset) begin | ||
start <= '0; | ||
end else begin | ||
if (buffer_cfg_in.ok) begin | ||
start <= buffer_cfg_in.data[1]; | ||
end | ||
end | ||
end | ||
|
||
// merge both buffer outputs into a word that is AXI_MM_WIDTH bits | ||
|
||
sample_discriminator #( | ||
.SAMPLE_WIDTH(SAMPLE_WIDTH), | ||
.PARALLEL_SAMPLES(PARALLEL_SAMPLES), | ||
.N_CHANNELS(N_CHANNELS), | ||
.SAMPLE_INDEX_WIDTH($clog2(DATA_BUFFER_DEPTH*N_CHANNELS)), | ||
.CLOCK_WIDTH(TIMESTAMP_WIDTH - SAMPLE_INDEX_WIDTH) | ||
) disc_i ( | ||
.clk, | ||
.reset, | ||
.data_in, | ||
.data_out(disc_data), | ||
.timestamps_out(disc_tstamps), | ||
.config_in(disc_cfg_in), | ||
.sample_index_reset(start) | ||
); | ||
|
||
banked_sample_buffer #( | ||
.SAMPLE_WIDTH(SAMPLE_WIDTH), | ||
.BUFFER_DEPTH(DATA_BUFFER_DEPTH), | ||
.PARALLEL_SAMPLES(PARALLEL_SAMPLES), | ||
.N_CHANNELS(N_CHANNELS) | ||
) data_buffer_i ( | ||
.clk, | ||
.reset, | ||
.data_in(disc_data), | ||
.data_out(buf_data_out), | ||
.config_in(buf_data_cfg), | ||
.stop_aux(buffer_full[0]), | ||
.capture_started(), | ||
.buffer_full(buffer_full[1]) | ||
); | ||
|
||
banked_sample_buffer #( | ||
.SAMPLE_WIDTH(TIMESTAMP_WIDTH), | ||
.BUFFER_DEPTH(TSTAMP_BUFFER_DEPTH), | ||
.PARALLEL_SAMPLES(1), | ||
.N_CHANNELS(N_CHANNELS) | ||
) data_buffer_i ( | ||
.clk, | ||
.reset, | ||
.data_in(disc_tstamps), | ||
.data_out(buf_tstamp_out), | ||
.config_in(buf_tstamp_cfg), | ||
.stop_aux(buffer_full[1]), | ||
.capture_started(), | ||
.buffer_full(buffer_full[0]) | ||
); | ||
|
||
endmodule |
Oops, something went wrong.