diff --git a/SDVD.xpr b/SDVD.xpr index b9cde0e..ec14c89 100644 --- a/SDVD.xpr +++ b/SDVD.xpr @@ -1,314 +1,340 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Vivado Synthesis Defaults - - - - - - - - - - - - Default settings for Implementation. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - default_dashboard - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Vivado Synthesis Defaults + + + + + + + + + + + Default settings for Implementation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + default_dashboard + + + diff --git a/design/playback_controller.sv b/design/playback_controller.sv index 05a49fe..b187d28 100644 --- a/design/playback_controller.sv +++ b/design/playback_controller.sv @@ -14,10 +14,79 @@ module playback_controller( output SPEED speed ); +typedef enum logic [2:0] { + PAUSE, PLAY, FF2, FF4, FF8 +} state_t; + +state_t current, next; + wire play_pulse,ff_pulse; // NOTE: These might need to be hooked to an even lower clock? Not sure debouncer playDebouncer (clk,reset,play,play_pulse); debouncer ffDebouncer (clk,reset,ff,ff_pulse); +//next state logic +always_comb +begin + unique case (current) + PAUSE: + begin + if (play_pulse) next = PLAY; + else if (ff_pulse) next = FF2; + else next = PAUSE; + end + PLAY: + begin + if (play_pulse) next = PAUSE; + else if (ff_pulse) next = FF2; + else next = PLAY; + end + FF2: + begin + if (play_pulse) next = PAUSE; + else if (ff_pulse) next = FF4; + else next = FF2; + end + FF4: + begin + if (play_pulse) next = PAUSE; + else if (ff_pulse) next = FF8; + else next = FF4; + end + FF8: + begin + if (play_pulse) next = PAUSE; + else if (ff_pulse) next = FF8; + else next = FF8; + end + default: + next = PAUSE; + endcase +end + +//output logic +always_comb +begin + unique case (current) + PAUSE: speed = 0; + PLAY: speed = 1; + FF2: speed = 2; + FF4: speed = 4; + FF8: speed = 8; + default:speed = 0; + endcase +end + +//sequential logic +always_ff @(posedge clk) +begin + if (reset) + current <= PAUSE; + else + current <= next; +end endmodule + + + diff --git a/verification/debouncer_tb.sv b/verification/debouncer_tb.sv index a541ac4..24ea02e 100644 --- a/verification/debouncer_tb.sv +++ b/verification/debouncer_tb.sv @@ -56,8 +56,4 @@ initial begin $finish; end - - - - endmodule diff --git a/verification/playback_controller_tb.sv b/verification/playback_controller_tb.sv new file mode 100644 index 0000000..a6e58b4 --- /dev/null +++ b/verification/playback_controller_tb.sv @@ -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