SDVD/design/nexys_a7_top.sv
Waylon Cude a50efdc6c6 Fixed up debouncer and added some assertions
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
2025-05-30 13:56:52 -07:00

73 lines
1.8 KiB
Systemverilog

`ifdef VERILATOR
`include "sdvd_defs.sv"
`endif
import sdvd_defs::SPEED;
module nexys_a7_top(
input logic CLK100MHZ, CPU_RESETN,
input logic BTNC, BTNR,
output logic CA,CB,CC,CD,CE,CF,CG,
output logic [7:0] AN
);
// Active high reset
wire reset;
assign reset = ~CPU_RESETN;
logic clk_1khz, clk_10hz;
logic seconds_pulse;
SPEED speed;
// Map C{A-G} to an array of 7-segment displays
wire [6:0] segments [7:0];
wire [2:0] segment_mux_select;
// These segments are currently unused
assign segments[7] = 0;
assign segments[6] = 0;
assign {CA,CB,CC,CD,CE,CF,CG} = ~segments[segment_mux_select];
logic [$clog2(60)-1:0] seconds;
logic [$clog2(60)-1:0] minutes;
logic [$clog2(60)-1:0] hours;
low_freq_clock_gen clockGen(CLK100MHZ, reset, speed, clk_1khz, clk_10hz, seconds_pulse);
// Count the number on seconds, hours, and minutes elapsed
// If the speed is faster this will pulse more often than once a second
// but will still theoretically be a second of video time
always_ff @(posedge seconds_pulse) begin
if (reset) begin
seconds <= 0;
minutes <= 0;
hours <= 0;
end
else if (seconds == 59) begin
seconds <= 0;
if (minutes == 59) begin
minutes <= 0;
hours <= hours + 1;
end
else
minutes <= minutes + 1;
end
else
seconds <= seconds + 1;
end
display_anode_driver anodeDriver(clk_1khz,reset,AN,segment_mux_select);
seconds_display secondsSegment (seconds, segments[1], segments[0]);
seconds_display minutesSegment (minutes, segments[3], segments[2]);
seconds_display hoursSegment (hours, segments[5], segments[4]);
// Run the playback speed state machine at a lower rate
// Gets rid of button bouncing
playback_controller playbackController (clk_10hz,reset,BTNC, BTNR, speed);
endmodule