I moved around where packages are. I couldn't find any evidence of where other people put them, but for now they are in the `lib/` folder. Other infrastructure changes are that all the weird includes we need to make the linter happy are gated behind ifdefs, so they don't mess with vivado. I kinda can't believe concurrent assertions work because there's so little info about them, good to ssee they actually do something
109 lines
2.3 KiB
Systemverilog
109 lines
2.3 KiB
Systemverilog
/****
|
|
* playback_controller_tb.sv - a testbench for the playback_controller.sv
|
|
* module.
|
|
*
|
|
* @author: Dilanthi Prentice
|
|
* @date: [unsure of due date]
|
|
*
|
|
* */
|
|
`ifdef VERILATOR
|
|
`include "sdvd_defs.sv"
|
|
`endif
|
|
import sdvd_defs::SPEED;
|
|
|
|
module playback_controller_tb;
|
|
logic clk, reset;
|
|
logic play, ff;
|
|
SPEED speed;
|
|
int errors;
|
|
|
|
//instatiate the dut
|
|
playback_controller dut(clk, reset, play, ff, speed);
|
|
|
|
//clock generation
|
|
initial clk = 0;
|
|
always #5 clk = ~clk;
|
|
|
|
//play button press
|
|
task press_play();
|
|
play = 1;
|
|
@(posedge clk);
|
|
play = 0;
|
|
@(posedge clk);
|
|
endtask
|
|
|
|
//ff button press
|
|
task press_ff();
|
|
ff = 1;
|
|
@(posedge clk);
|
|
ff = 0;
|
|
@(posedge clk);
|
|
endtask
|
|
|
|
initial
|
|
begin
|
|
@(posedge clk);
|
|
play = 0;
|
|
ff = 0;
|
|
|
|
reset = 1;
|
|
@(posedge clk);
|
|
reset = 0;
|
|
|
|
@(posedge clk);
|
|
assert (speed === 0) else
|
|
begin
|
|
$error("Speed not zero after reset");
|
|
errors++;
|
|
end
|
|
@(posedge clk);
|
|
|
|
press_play();
|
|
assert (speed === 1) else
|
|
begin
|
|
$error("Play not working");
|
|
errors++;
|
|
end
|
|
|
|
press_play();
|
|
assert (speed === 0) else
|
|
begin
|
|
$error("Pause not working");
|
|
errors++;
|
|
end
|
|
|
|
press_ff();
|
|
assert (speed === 2) else
|
|
begin
|
|
$error("Not in FF2 after ff btn pressed once");
|
|
errors++;
|
|
end
|
|
|
|
press_ff();
|
|
assert (speed === 4) else
|
|
begin
|
|
$error("Not in FF4 after ff btn pressed twice");
|
|
errors++;
|
|
end
|
|
|
|
press_ff();
|
|
assert (speed === 8) else
|
|
begin
|
|
$error("Not in FF8 after ff btn pressed thrice");
|
|
errors++;
|
|
end
|
|
|
|
press_play();
|
|
assert (speed === 0) else
|
|
begin
|
|
$error("Unsuccessful return to pause after play btn pressed from a FF state");
|
|
errors++;
|
|
end
|
|
|
|
if (errors === 0)
|
|
$display("No errors detected in playback_controller");
|
|
|
|
$finish;
|
|
end
|
|
endmodule
|