add: zero-level test. TB complete
This commit is contained in:
@ -229,7 +229,8 @@ module generator_tb;
|
|||||||
input int pulse_p,
|
input int pulse_p,
|
||||||
input int pulse_n,
|
input int pulse_n,
|
||||||
input int pulse_h,
|
input int pulse_h,
|
||||||
input bit skip_reset
|
input bit skip_reset, // skip reset sequence on demand
|
||||||
|
input bit count_level // count ticks of amplitude == pulse_h or amplitude != pulse_h
|
||||||
);
|
);
|
||||||
int total_impulse_cycles = 0;
|
int total_impulse_cycles = 0;
|
||||||
|
|
||||||
@ -253,10 +254,17 @@ module generator_tb;
|
|||||||
begin : counter_proc
|
begin : counter_proc
|
||||||
forever begin
|
forever begin
|
||||||
@(posedge dac_wrt);
|
@(posedge dac_wrt);
|
||||||
|
if (count_level) begin
|
||||||
if (dac_out == pulse_h) begin
|
if (dac_out == pulse_h) begin
|
||||||
total_impulse_cycles++;
|
total_impulse_cycles++;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else begin
|
||||||
|
if (dac_out != current_zero_level) begin
|
||||||
|
total_impulse_cycles++;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
join_none
|
join_none
|
||||||
|
|
||||||
@ -271,12 +279,22 @@ module generator_tb;
|
|||||||
disable counter_proc;
|
disable counter_proc;
|
||||||
repeat(10) @(posedge clk);
|
repeat(10) @(posedge clk);
|
||||||
|
|
||||||
|
if (count_level) begin
|
||||||
if (total_impulse_cycles == pulse_w*pulse_n)
|
if (total_impulse_cycles == pulse_w*pulse_n)
|
||||||
$display("[TB] -run_test_case- Pulse generation CORRECT");
|
$display("[TB] -run_test_case- Pulse generation CORRECT");
|
||||||
else begin
|
else begin
|
||||||
$display("[ERROR] -run_test_case- Pulse generation INCORRECT. Total number of pulses: %d, must be: %d", total_impulse_cycles, pulse_w*pulse_n);
|
$display("[ERROR] -run_test_case- Pulse generation INCORRECT. Total number of pulses: %d, must be: %d", total_impulse_cycles, pulse_w*pulse_n);
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if (total_impulse_cycles == 0)
|
||||||
|
$display("[TB] -run_test_case- Pulse generation CORRECT");
|
||||||
|
else begin
|
||||||
|
$display("[ERROR] -run_test_case- Pulse generation INCORRECT. Total number of pulses: %d, must be: %d", total_impulse_cycles, 0);
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
end
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
// --- ОСНОВНОЙ ПРОЦЕСС ТЕСТИРОВАНИЯ ---
|
// --- ОСНОВНОЙ ПРОЦЕСС ТЕСТИРОВАНИЯ ---
|
||||||
@ -321,11 +339,23 @@ module generator_tb;
|
|||||||
.pulse_p(r_p),
|
.pulse_p(r_p),
|
||||||
.pulse_n(r_n),
|
.pulse_n(r_n),
|
||||||
.pulse_h(r_h),
|
.pulse_h(r_h),
|
||||||
.skip_reset(r_skip)
|
.skip_reset(r_skip),
|
||||||
|
.count_level(1)
|
||||||
);
|
);
|
||||||
end
|
end
|
||||||
$display("[TB] Test 2 complete");
|
$display("[TB] Test 2 complete");
|
||||||
|
|
||||||
|
$display("[TB] Test 3. Zero level of pulse height");
|
||||||
|
run_test_case(
|
||||||
|
.pulse_w(77),
|
||||||
|
.pulse_p(131),
|
||||||
|
.pulse_n(13),
|
||||||
|
.pulse_h(current_zero_level),
|
||||||
|
.skip_reset(0),
|
||||||
|
.count_level(0)
|
||||||
|
);
|
||||||
|
$display("[TB] Test 3 complete");
|
||||||
|
|
||||||
$display("[TB] All Tests complete!");
|
$display("[TB] All Tests complete!");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user