Skip to content

Commit

Permalink
need to fix some minor issues with the sample buffer; there is potent…
Browse files Browse the repository at this point in the history
…ially a throughput problem
  • Loading branch information
reed-foster committed Oct 7, 2023
1 parent c4cf9eb commit 32048c9
Show file tree
Hide file tree
Showing 13 changed files with 423 additions and 90 deletions.
72 changes: 56 additions & 16 deletions axis_x2_test_behav.wcfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,55 @@
</db_ref>
</db_ref_list>
<zoom_setting>
<ZoomStartTime time="5,988.800 ns"></ZoomStartTime>
<ZoomEndTime time="6,063.701 ns"></ZoomEndTime>
<Cursor1Time time="5,995.000 ns"></Cursor1Time>
<ZoomStartTime time="15.635000 us"></ZoomStartTime>
<ZoomEndTime time="22.915001 us"></ZoomEndTime>
<Cursor1Time time="21.695000 us"></Cursor1Time>
</zoom_setting>
<column_width_setting>
<NameColumnWidth column_width="187"></NameColumnWidth>
<ValueColumnWidth column_width="70"></ValueColumnWidth>
<NameColumnWidth column_width="193"></NameColumnWidth>
<ValueColumnWidth column_width="93"></ValueColumnWidth>
</column_width_setting>
<WVObjectSize size="21" />
<WVObjectSize size="31" />
<wvobject type="array" fp_name="/axis_x2_test/error_count">
<obj_property name="ElementShortName">error_count[31:0]</obj_property>
<obj_property name="ObjectShortName">error_count[31:0]</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/axis_x2_test/reset">
<obj_property name="ElementShortName">reset</obj_property>
<obj_property name="ObjectShortName">reset</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/axis_x2_test/clk">
<obj_property name="ElementShortName">clk</obj_property>
<obj_property name="ObjectShortName">clk</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/data_out_test">
<obj_property name="ElementShortName">data_out_test[0:3][35:0]</obj_property>
<obj_property name="ObjectShortName">data_out_test[0:3][35:0]</obj_property>
</wvobject>
<wvobject type="other" fp_name="/axis_x2_test/d_in">
<obj_property name="ElementShortName">d_in</obj_property>
<obj_property name="ObjectShortName">d_in</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/CLK_RATE_HZ">
<obj_property name="ElementShortName">CLK_RATE_HZ[31:0]</obj_property>
<obj_property name="ObjectShortName">CLK_RATE_HZ[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/SAMPLE_WIDTH">
<obj_property name="ElementShortName">SAMPLE_WIDTH[31:0]</obj_property>
<obj_property name="ObjectShortName">SAMPLE_WIDTH[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/PARALLEL_SAMPLES">
<obj_property name="ElementShortName">PARALLEL_SAMPLES[31:0]</obj_property>
<obj_property name="ObjectShortName">PARALLEL_SAMPLES[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/SAMPLE_FRAC_BITS">
<obj_property name="ElementShortName">SAMPLE_FRAC_BITS[31:0]</obj_property>
<obj_property name="ObjectShortName">SAMPLE_FRAC_BITS[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/LATENCY">
<obj_property name="ElementShortName">LATENCY[31:0]</obj_property>
<obj_property name="ObjectShortName">LATENCY[31:0]</obj_property>
</wvobject>
<wvobject fp_name="divider10" type="divider">
<obj_property name="label">dut</obj_property>
<obj_property name="DisplayName">label</obj_property>
Expand All @@ -33,16 +73,16 @@
<obj_property name="ObjectShortName">reset</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/dut_i/data_in_reg">
<obj_property name="ElementShortName">data_in_reg[0:1][15:0]</obj_property>
<obj_property name="ObjectShortName">data_in_reg[0:1][15:0]</obj_property>
<obj_property name="ElementShortName">data_in_reg[0:1][17:0]</obj_property>
<obj_property name="ObjectShortName">data_in_reg[0:1][17:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/dut_i/product">
<obj_property name="ElementShortName">product[0:1][31:0]</obj_property>
<obj_property name="ObjectShortName">product[0:1][31:0]</obj_property>
<obj_property name="ElementShortName">product[0:1][35:0]</obj_property>
<obj_property name="ObjectShortName">product[0:1][35:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/dut_i/product_d">
<obj_property name="ElementShortName">product_d[0:1][15:0]</obj_property>
<obj_property name="ObjectShortName">product_d[0:1][15:0]</obj_property>
<obj_property name="ElementShortName">product_d[0:1][17:0]</obj_property>
<obj_property name="ObjectShortName">product_d[0:1][17:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/dut_i/valid_d">
<obj_property name="ElementShortName">valid_d[3:0]</obj_property>
Expand All @@ -61,8 +101,8 @@
<obj_property name="DisplayName">label</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/data_in_if/data">
<obj_property name="ElementShortName">data[31:0]</obj_property>
<obj_property name="ObjectShortName">data[31:0]</obj_property>
<obj_property name="ElementShortName">data[35:0]</obj_property>
<obj_property name="ObjectShortName">data[35:0]</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/axis_x2_test/data_in_if/ready">
<obj_property name="ElementShortName">ready</obj_property>
Expand All @@ -85,8 +125,8 @@
<obj_property name="DisplayName">label</obj_property>
</wvobject>
<wvobject type="array" fp_name="/axis_x2_test/data_out_if/data">
<obj_property name="ElementShortName">data[31:0]</obj_property>
<obj_property name="ObjectShortName">data[31:0]</obj_property>
<obj_property name="ElementShortName">data[35:0]</obj_property>
<obj_property name="ObjectShortName">data[35:0]</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/axis_x2_test/data_out_if/ready">
<obj_property name="ElementShortName">ready</obj_property>
Expand Down
176 changes: 176 additions & 0 deletions dac_prescaler_test_behav.wcfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<wave_config>
<wave_state>
</wave_state>
<db_ref_list>
<db_ref path="dac_prescaler_test_behav.wdb" id="1">
<top_modules>
<top_module name="dac_prescaler_test" />
<top_module name="glbl" />
</top_modules>
</db_ref>
</db_ref_list>
<zoom_setting>
<ZoomStartTime time="14,748.750 ns"></ZoomStartTime>
<ZoomEndTime time="15,104.251 ns"></ZoomEndTime>
<Cursor1Time time="15,045.000 ns"></Cursor1Time>
</zoom_setting>
<column_width_setting>
<NameColumnWidth column_width="210"></NameColumnWidth>
<ValueColumnWidth column_width="93"></ValueColumnWidth>
</column_width_setting>
<WVObjectSize size="38" />
<wvobject type="array" fp_name="/dac_prescaler_test/error_count">
<obj_property name="ElementShortName">error_count[31:0]</obj_property>
<obj_property name="ObjectShortName">error_count[31:0]</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/reset">
<obj_property name="ElementShortName">reset</obj_property>
<obj_property name="ObjectShortName">reset</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/clk">
<obj_property name="ElementShortName">clk</obj_property>
<obj_property name="ObjectShortName">clk</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/scale_factor">
<obj_property name="ElementShortName">scale_factor[17:0]</obj_property>
<obj_property name="ObjectShortName">scale_factor[17:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/scale_factor_d">
<obj_property name="ElementShortName">scale_factor_d[17:0]</obj_property>
<obj_property name="ObjectShortName">scale_factor_d[17:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/data_out_test">
<obj_property name="ElementShortName">data_out_test[0:3][255:0]</obj_property>
<obj_property name="ObjectShortName">data_out_test[0:3][255:0]</obj_property>
<obj_property name="isExpanded"></obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/CLK_RATE_HZ">
<obj_property name="ElementShortName">CLK_RATE_HZ[31:0]</obj_property>
<obj_property name="ObjectShortName">CLK_RATE_HZ[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/SAMPLE_WIDTH">
<obj_property name="ElementShortName">SAMPLE_WIDTH[31:0]</obj_property>
<obj_property name="ObjectShortName">SAMPLE_WIDTH[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/PARALLEL_SAMPLES">
<obj_property name="ElementShortName">PARALLEL_SAMPLES[31:0]</obj_property>
<obj_property name="ObjectShortName">PARALLEL_SAMPLES[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/SCALE_WIDTH">
<obj_property name="ElementShortName">SCALE_WIDTH[31:0]</obj_property>
<obj_property name="ObjectShortName">SCALE_WIDTH[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/SAMPLE_FRAC_BITS">
<obj_property name="ElementShortName">SAMPLE_FRAC_BITS[31:0]</obj_property>
<obj_property name="ObjectShortName">SAMPLE_FRAC_BITS[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/SCALE_FRAC_BITS">
<obj_property name="ElementShortName">SCALE_FRAC_BITS[31:0]</obj_property>
<obj_property name="ObjectShortName">SCALE_FRAC_BITS[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/LATENCY">
<obj_property name="ElementShortName">LATENCY[31:0]</obj_property>
<obj_property name="ObjectShortName">LATENCY[31:0]</obj_property>
</wvobject>
<wvobject fp_name="divider718" type="divider">
<obj_property name="label">data_in</obj_property>
<obj_property name="DisplayName">label</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/data_in_if/data">
<obj_property name="ElementShortName">data[255:0]</obj_property>
<obj_property name="ObjectShortName">data[255:0]</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/data_in_if/ready">
<obj_property name="ElementShortName">ready</obj_property>
<obj_property name="ObjectShortName">ready</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/data_in_if/valid">
<obj_property name="ElementShortName">valid</obj_property>
<obj_property name="ObjectShortName">valid</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/data_in_if/last">
<obj_property name="ElementShortName">last</obj_property>
<obj_property name="ObjectShortName">last</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/data_in_if/DWIDTH">
<obj_property name="ElementShortName">DWIDTH[31:0]</obj_property>
<obj_property name="ObjectShortName">DWIDTH[31:0]</obj_property>
</wvobject>
<wvobject fp_name="divider724" type="divider">
<obj_property name="label">data_out</obj_property>
<obj_property name="DisplayName">label</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/data_out_if/data">
<obj_property name="ElementShortName">data[255:0]</obj_property>
<obj_property name="ObjectShortName">data[255:0]</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/data_out_if/ready">
<obj_property name="ElementShortName">ready</obj_property>
<obj_property name="ObjectShortName">ready</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/data_out_if/valid">
<obj_property name="ElementShortName">valid</obj_property>
<obj_property name="ObjectShortName">valid</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/data_out_if/last">
<obj_property name="ElementShortName">last</obj_property>
<obj_property name="ObjectShortName">last</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/data_out_if/DWIDTH">
<obj_property name="ElementShortName">DWIDTH[31:0]</obj_property>
<obj_property name="ObjectShortName">DWIDTH[31:0]</obj_property>
</wvobject>
<wvobject fp_name="divider730" type="divider">
<obj_property name="label">dut</obj_property>
<obj_property name="DisplayName">label</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/dut_i/clk">
<obj_property name="ElementShortName">clk</obj_property>
<obj_property name="ObjectShortName">clk</obj_property>
</wvobject>
<wvobject type="logic" fp_name="/dac_prescaler_test/dut_i/reset">
<obj_property name="ElementShortName">reset</obj_property>
<obj_property name="ObjectShortName">reset</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/data_in_reg">
<obj_property name="ElementShortName">data_in_reg[0:15][15:0]</obj_property>
<obj_property name="ObjectShortName">data_in_reg[0:15][15:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/scale_factor_reg">
<obj_property name="ElementShortName">scale_factor_reg[17:0]</obj_property>
<obj_property name="ObjectShortName">scale_factor_reg[17:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/product">
<obj_property name="ElementShortName">product[0:15][33:0]</obj_property>
<obj_property name="ObjectShortName">product[0:15][33:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/product_d">
<obj_property name="ElementShortName">product_d[0:15][15:0]</obj_property>
<obj_property name="ObjectShortName">product_d[0:15][15:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/valid_d">
<obj_property name="ElementShortName">valid_d[3:0]</obj_property>
<obj_property name="ObjectShortName">valid_d[3:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/SAMPLE_WIDTH">
<obj_property name="ElementShortName">SAMPLE_WIDTH[31:0]</obj_property>
<obj_property name="ObjectShortName">SAMPLE_WIDTH[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/PARALLEL_SAMPLES">
<obj_property name="ElementShortName">PARALLEL_SAMPLES[31:0]</obj_property>
<obj_property name="ObjectShortName">PARALLEL_SAMPLES[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/SCALE_WIDTH">
<obj_property name="ElementShortName">SCALE_WIDTH[31:0]</obj_property>
<obj_property name="ObjectShortName">SCALE_WIDTH[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/SAMPLE_FRAC_BITS">
<obj_property name="ElementShortName">SAMPLE_FRAC_BITS[31:0]</obj_property>
<obj_property name="ObjectShortName">SAMPLE_FRAC_BITS[31:0]</obj_property>
</wvobject>
<wvobject type="array" fp_name="/dac_prescaler_test/dut_i/SCALE_FRAC_BITS">
<obj_property name="ElementShortName">SCALE_FRAC_BITS[31:0]</obj_property>
<obj_property name="ObjectShortName">SCALE_FRAC_BITS[31:0]</obj_property>
</wvobject>
</wave_config>
43 changes: 31 additions & 12 deletions dds_test.srcs/sim_1/new/axis_x2_test.sv
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ logic clk = 0;
localparam CLK_RATE_HZ = 100_000_000;
always #(0.5s/CLK_RATE_HZ) clk = ~clk;

localparam int SAMPLE_WIDTH = 16;
localparam int SAMPLE_WIDTH = 18;
localparam int PARALLEL_SAMPLES = 2;
localparam int SAMPLE_FRAC_BITS = 16;

Axis_If #(.DWIDTH(SAMPLE_WIDTH*PARALLEL_SAMPLES)) data_out_if();
Axis_If #(.DWIDTH(SAMPLE_WIDTH*PARALLEL_SAMPLES)) data_in_if();

localparam int LATENCY = 4;
logic [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] data_out_test [LATENCY];

assign data_out_if.ready = 1;

initial begin
reset <= 1'b1;
data_in_if.valid <= 1'b0;
data_out_if.ready <= 1'b1;
repeat (100) @(posedge clk);
reset <= 1'b0;
repeat (500) @(posedge clk);
Expand All @@ -30,25 +30,44 @@ initial begin
data_in_if.valid <= 1'b0;
repeat (10) @(posedge clk);
data_in_if.valid <= 1'b1;
repeat (10) @(posedge clk);
data_out_if.ready <= 1'b0;
repeat (10) @(posedge clk);
data_out_if.ready <= 1'b1;
repeat (20) @(posedge clk);
data_out_if.ready <= 1'b0;
repeat (10) @(posedge clk);
data_in_if.valid <= 1'b0;
repeat (5) @(posedge clk);
data_out_if.ready <= 1'b1;
repeat (5) @(posedge clk);
data_in_if.valid <= 1'b1;
repeat (1000) @(posedge clk);
$info("error_count = %d", error_count);
$finish;
end

typedef logic [SAMPLE_WIDTH-1:0] uint_t;
typedef logic signed [SAMPLE_WIDTH-1:0] int_t;

real d_in;

always @(posedge clk) begin
if (reset) begin
data_in_if.data <= '0;
end else if (data_in_if.ready && data_in_if.valid) begin
for (int i = 0; i < PARALLEL_SAMPLES; i++) begin
data_in_if.data[i*SAMPLE_WIDTH+:SAMPLE_WIDTH] <= $urandom_range({SAMPLE_WIDTH{1'b1}});
end
for (int j = 0; j < LATENCY-1; j++) begin
data_out_test[j] <= data_out_test[j+1];
end else begin
if (data_in_if.ready && data_in_if.valid) begin
for (int i = 0; i < PARALLEL_SAMPLES; i++) begin
data_in_if.data[i*SAMPLE_WIDTH+:SAMPLE_WIDTH] <= $urandom_range({SAMPLE_WIDTH{1'b1}});
end
end
for (int i = 0; i < PARALLEL_SAMPLES; i++) begin
data_out_test[LATENCY-1][i*SAMPLE_WIDTH+:SAMPLE_WIDTH] <= uint_t'(((real'(data_in_if.data[i*SAMPLE_WIDTH+:SAMPLE_WIDTH])/(2.0**15))**2) * 2.0**14);
if (data_out_if.ready) begin
for (int j = 0; j < LATENCY-1; j++) begin
data_out_test[j] <= data_out_test[j+1];
end
for (int i = 0; i < PARALLEL_SAMPLES; i++) begin
d_in = real'(int_t'(data_in_if.data[i*SAMPLE_WIDTH+:SAMPLE_WIDTH]));
data_out_test[LATENCY-1][i*SAMPLE_WIDTH+:SAMPLE_WIDTH] <= int_t'(((d_in/(2.0**SAMPLE_FRAC_BITS))**2) * 2.0**SAMPLE_FRAC_BITS);
end
end
end
end
Expand Down
Loading

0 comments on commit 32048c9

Please sign in to comment.