This commit is contained in:
@@ -56,8 +56,4 @@ initial begin
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
endmodule
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/****
|
||||
* playback_controller_tb.sv - a testbench for the playback_controller.sv
|
||||
* module.
|
||||
*
|
||||
* @author: Dilanthi Prentice
|
||||
* @date: [unsure of due date]
|
||||
*
|
||||
* */
|
||||
`include "sdvd_defs.sv"
|
||||
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
|
||||
Reference in New Issue
Block a user