-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpress.sv
43 lines (36 loc) · 850 Bytes
/
press.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
module press (Clock, pressed, pull, stop);
input Clock, stop;
input pressed;
output reg pull;
reg ps;
reg ns;
always @(*)
ns = pressed;
always @(posedge Clock)
ps <= ns;
always @(*)
if (stop) pull = 1'b0;
else pull = (~ps & ns);
endmodule
module press_testbench();
reg CLOCK_50, pressed, pull;
wire out;
press dut (CLOCK_50, pressed, pull);
// Set up the clock.
parameter CLOCK_PERIOD = 100;
initial CLOCK_50 = 1;
always begin
#(CLOCK_PERIOD/2);
CLOCK_50 = ~CLOCK_50;
end
initial begin
pressed<= 1; @(posedge CLOCK_50);
pressed<= 0; @(posedge CLOCK_50);
pressed<= 0; @(posedge CLOCK_50);
@(posedge CLOCK_50);
@(posedge CLOCK_50);
pressed<= 1; @(posedge CLOCK_50);
@(posedge CLOCK_50);
$stop;
end
endmodule