/
bPushedCounter.sv
52 lines (50 loc) · 1.21 KB
/
bPushedCounter.sv
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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 12/25/2019 12:08:49 AM
// Design Name:
// Module Name: bPushedCounter
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module bPushedCounter(input logic clk, clr, gameOver, bn, be, bs, bw,
output logic[3:0] o3,
output logic[3:0] o2,
output logic[3:0] o1,
output logic[3:0] o0);
int count = 0;
logic isPushed;
always_ff @ (posedge clk)
begin
if(gameOver)
count <= count;
if(clr)
begin
count <= 0;
end
if(bn | be | bs | bw && isPushed == 0 & ~gameOver)
begin
count <= count + 1;
isPushed <= 1;
end
o3 <= count / 1000;
o2 <= (count / 100) % 10;
o1 <= (count / 10) % 10;
o0 <= count % 10;
if(~bn & ~be & ~bs & ~bw & isPushed)
begin
isPushed <= 0;
end
end
endmodule