-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathT-FlipFlop.v
47 lines (39 loc) · 1.18 KB
/
T-FlipFlop.v
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
`timescale 1ns / 1ps
`default_nettype none
// DE1_SoC board needs the below main module
module main (
input wire CLOCK_50, //On Board 50 MHz
input wire [9:0] SW, // On board Switches
input wire [3:0] KEY, // On board push buttons
output wire [6:0] HEX0, // HEX displays
output wire [6:0] HEX1,
output wire [6:0] HEX2,
output wire [6:0] HEX3,
output wire [6:0] HEX4,
output wire [6:0] HEX5,
output wire [9:0] LEDR, // LEDs
output wire [7:0] x, // VGA pixel coordinates
output wire [6:0] y,
output wire [2:0] colour, // VGA pixel colour (0-7)
output wire plot, // Pixel drawn when this is pulsed
output wire vga_resetn // VGA resets to black when this is pulsed (NOT CURRENTLY AVAILABLE)
);
top v1(SW, LEDR);
endmodule
// Top Module
module top(SW, LEDR);
input [9:0] SW;
output [9:0] LEDR;
t_flipflop u1 (SW[0], SW[1], SW[9], LEDR[0]);
endmodule
module t_flipflop(t, resetn, clock, q);
input clock, t, resetn;
output reg q;
always@(posedge clock)
begin
if (!resetn)
q <= 0;
else if (t == 1)
q <= ~q;
end
endmodule