-
Notifications
You must be signed in to change notification settings - Fork 0
/
Counter.v
executable file
·43 lines (37 loc) · 1.07 KB
/
Counter.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 22:55:16 04/13/2016
// Design Name:
// Module Name: Counter
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module Counter(count_out, count_in, count_up, max_count);
// This module counts up or down by 1 depending on the state of the input count_dir
// Count speed is handled outside of this module, since all it does it determine how
// frequently this module is used
input[11:0] count_in;
input[11:0] max_count;
//0 will count down, 1 will count up
input count_up;
output reg[11:0] count_out;
always @ (*)
begin
if (count_in == max_count && count_up == 1'b1)
assign count_out = 6'b000000;
else
assign count_out = count_in + count_up + count_up - 1'b1;
end
endmodule