-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSequence_Checker
138 lines (134 loc) · 2.82 KB
/
Sequence_Checker
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//-------------------------------------------------------------------------------
// University: Oregon Institute of Technology – CSET Department
// Class: CST 231
// Author: Luis Solis
// Lab: Lab4
// Project: digital door lock system
// File Name: Sequence_Checker.v
// List of other files used: Key_Pad_Scanner.v, Clock_Divider.v,
// reset_15.v, Sequence_Builder.v, my7Seg.v
//-------------------------------------------------------------------------------
// Description of the Code (1 - 5 lines)
// Lab Description: Will use our sequence and check to see if it a vaild or
// invaild
//-----------------------------------------------------------------------------
// Date: 01/04/2022
// Version: 1.0
// Revision: 02/4-22/2022
//
//-----------------------------------------------------------------------------
module Sequence_Checker(
input clk,
input reset,
input [3:0] seq1,
input [3:0] seq2,
input [3:0] seq3,
input [3:0] seq4,
input Check_seq,
output reg LEDE,
output reg LEDU,
output reg reset_out
);
reg [1:0] state1;
reg [7:0] count;
parameter [1:0] Init = 2'b00,
Check = 2'b01,
Error = 2'b10,
Unlock = 2'b11;
initial
begin
LEDE <= 1'b0;
LEDU <= 1'b0;
state1 <= Init;
count <= 8'b0;
end
// Always block to handle the case portion
always @(posedge clk or posedge reset)
begin
if(reset)
begin
state1 <= Init;
reset_out <=0;
count <= 0;
end
else
begin
case(state1)
Init:
begin
if(Check_seq)
state1 <= Check;
else
state1 <= state1;
end
Check:
case ({seq1,seq2,seq3,seq4})
16'h1234 : state1 <= Unlock;
16'hABCD : state1 <= Unlock;
16'h1122 : state1 <= Unlock;
16'h1010 : state1 <= Unlock;
16'h123A : state1 <= Unlock;
16'h2580 : state1 <= Unlock;
default : state1 <= Error;
endcase
Error:
begin
if(count < 50)
begin
count <= count + 1;
state1 <= state1;
end
else
begin
state1 <= Init;
reset_out <= 1;
end
end
Unlock:
begin
if(count < 50)
begin
count <= count + 1;
state1 <= state1;
end
else
begin
state1 <= Init;
reset_out <= 1;
end
end
endcase
end
end
// Always block to handle the state portion
always @(state1)
begin
case(state1)
Init:
begin
LEDE <= 1'b0;
LEDU <= 1'b0;
end
Check:
begin
LEDE <= 1'b0;
LEDU <= 1'b0;
end
Error:
begin
LEDE <= 1'b1;
LEDU <= 1'b0;
end
Unlock:
begin
LEDE <= 1'b0;
LEDU <= 1'b1;
end
default:
begin
LEDE <= 1'b0;
LEDU <= 1'b0;
end
endcase
end
endmodule