-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.v
138 lines (131 loc) · 2.74 KB
/
controller.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
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
`timescale 1ns / 1ns
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 00:04:27 01/13/2022
// Design Name:
// Module Name: controller
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module controller(
input [2:0] system_token,
input request,
input [7:0] TimeData,
input reset,
input clock,
input confirm,
input [2:0] user_token ,
output [7:0] data_Q,
output [7:0] data_P //,
// output reg P , output reg Q
);
reg Q ;
reg P ;
reg [2:0] state ;
parameter[2:0] A=3'b000 , B = 3'b001 , C = 3'b010 , D = 3'b011 , E = 3'b100 ;
//assign state = A ;
//begin : loop
//register QQ ( TimeData , clock , reset , Q , data_Q );
//register PP ( TimeData , clock , reset , P , data_P );
always @ (posedge clock or negedge reset )
begin
/*
if (~reset || ~request)
begin
state = A;
P = 1'b0;
Q = 1'b0 ;
end*/
if(~reset)
begin
state = A;
P=0;
Q=0;
end
else if(~request)
begin
state = A;
P=0;
Q=0;
end
else
begin
case(state)
A: if(request)
begin
state = B ;
P = 1'b0;
Q = 1'b0 ;
end
B:
begin
if(confirm)
begin
if( user_token == system_token )
begin
state = C ;
P = 1'b0;
Q = 1'b0 ;
end
else
begin
state = E ;
P = 1'b0;
Q = 1'b0 ;
end
end
end
C:
if(confirm)
begin
state = D ;
P = 1'b0;
Q = 1'b0 ;
end
D:
begin
if(TimeData[3:0] == 4'b1111 )
begin
P = 1'b1;
Q = 1'b0 ;
/* generate
register QQ ( TimeData , clock , reset , Q , data_Q );
register PP ( TimeData , clock , reset , P , data_P );
endgenerate*/
// break ;
//$finish ;
//disable loop ;
end
else
begin
P = 1'b0;
Q = 1'b1 ;
/*generate
register QQ ( TimeData , clock , reset , Q , data_Q );
register PP ( TimeData , clock , reset , P , data_P );
endgenerate*/
//break ;
//$finish;
// disable loop ;
end
end
default : state = A ;
endcase
end
end
///register PP ( TimeData , clock , reset , P , data_P );
//end
register QQ ( TimeData , clock , reset , Q , data_Q );
register PP ( TimeData , clock , reset , P , data_P );
endmodule