-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA3Q1_seq1010.v
90 lines (67 loc) · 1.64 KB
/
A3Q1_seq1010.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module seq1010(clk,reset,in,out);
input wire clk ,reset,in;
output reg out;
reg[1:0] curr,next;
parameter S0 = 2'b00,
S1 = 2'b01,
S2 = 2'b10,
S3 = 2'b11;
always @(curr or in )
begin
case(curr)
S0: if (in == 1'b1)
begin
next = S1;
out=1'b0;
end
else
begin
next = curr;
out=1'b0;
end
S1: if (in == 1'b0)
begin
next = S2;
out=1'b0;
end
else
begin
next = curr;
out=1'b0;
end
S2: if (in == 1'b1)
begin
next = S3;
out=1'b0;
end
else
begin
next = S0;
out=1'b0;
end
S3: if (in == 1'b0)
begin
next = S2;
out=1'b1;
end
else
begin
next = S1;
out=1'b0;
end
default:
next = S0;
endcase
end
always @(negedge clk)
begin
$write("%b",out);
end
always @(posedge clk or negedge reset)
begin
if(reset)
curr <= S0;
else
curr <= next;
end
endmodule