-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParamtericCounter.v
49 lines (40 loc) · 1.28 KB
/
ParamtericCounter.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
48
49
`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;
param_counter #2 u1 (SW[9], SW[8], SW[7], SW[6], LEDR[1:0]);
endmodule
module param_counter(clock, enable, updown, resetn, q);
parameter n = 3;
input clock, enable, updown, resetn;
output reg [n-1:0] q;
always@(posedge clock)
begin
if (resetn == 0)
q <= 0;
else if (enable == 1)
q <= q + (updown?1:-1);
end
endmodule