-
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.
found an obscure bug in the sample discriminator and redesigned its f…
…unctionality a bit. also improved code hygiene with some refactors of the testing code, putting reused parameterizable functions in a class and package
- Loading branch information
1 parent
eb045b0
commit 17cc159
Showing
5 changed files
with
268 additions
and
188 deletions.
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
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,43 @@ | ||
package sim_util_pkg; | ||
|
||
class sample_discriminator_util #( | ||
parameter int SAMPLE_WIDTH = 16, | ||
parameter int PARALLEL_SAMPLES = 2 | ||
); | ||
|
||
typedef logic signed [SAMPLE_WIDTH-1:0] signed_sample_t; | ||
|
||
// helper function to check if any of the parallel samples are above the high threshold | ||
// needed to replicate the behavior of the sample discriminator which starts saving | ||
// samples as soon as a sample arrives which is above the high threshold | ||
function logic any_above_high ( | ||
input logic [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] samples_in, | ||
input logic [SAMPLE_WIDTH-1:0] threshold_high | ||
); | ||
for (int j = 0; j < PARALLEL_SAMPLES; j++) begin | ||
if (signed_sample_t'(samples_in[j*SAMPLE_WIDTH+:SAMPLE_WIDTH]) > signed_sample_t'(threshold_high)) begin | ||
return 1'b1; | ||
end | ||
end | ||
return 1'b0; | ||
endfunction | ||
|
||
// helper function to check if all parallel samples are below the low threshold | ||
// needed to replicate the behavior of the sample discriminator which stops saving | ||
// samples once all the samples it receives in a single clock cycle are below | ||
// the low threshold | ||
function logic all_below_low ( | ||
input logic [SAMPLE_WIDTH*PARALLEL_SAMPLES-1:0] samples_in, | ||
input logic [SAMPLE_WIDTH-1:0] threshold_low | ||
); | ||
for (int j = 0; j < PARALLEL_SAMPLES; j++) begin | ||
if (signed_sample_t'(samples_in[j*SAMPLE_WIDTH+:SAMPLE_WIDTH]) > signed_sample_t'(threshold_low)) begin | ||
return 1'b0; | ||
end | ||
end | ||
return 1'b1; | ||
endfunction | ||
|
||
endclass | ||
|
||
endpackage |
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
Oops, something went wrong.