-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.v
More file actions
67 lines (60 loc) · 1.62 KB
/
Copy pathmain.v
File metadata and controls
67 lines (60 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 08/27/2025 09:12:29 PM
// Design Name:
// Module Name: main
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module main(
input SW0,
input SW1,
input SW3,
input SW4,
input BTNU,
input BTND,
input clk,
output LED0,
output LED1,
output LED2,
output LED3,
output LED15
);
// set up registers for blinking LED
reg [31:0] counter;
reg LED15_REG;
// set LEDs to turn on @ required conditions
assign LED0 = (SW0 && SW1) ? 1 : 0;
assign LED1 = (SW3 || SW4) ? 1 : 0;
assign LED2 = (BTNU ^ BTND) ? 1 : 0;
assign LED3 = ~(BTNU ^ BTND) ? 1 : 0;
assign LED15 = LED15_REG;
always @(posedge clk)
begin
// magic numbers represent middle & end of duty cycle
if(counter == 32'b00000101111101011110000011111111) // if counted 100,000,000 positive edges
begin
LED15_REG <= 0; // reset LED
counter <= 0; // reset counter
end
else if(counter == 32'b00000010111110101111000010000000) // if counted 50,000,000 positive edges
begin
LED15_REG <= 1; // set LED
counter <= counter + 1; // increment counter
end
else
counter <= counter + 1; // increment counter
end
endmodule