-
Notifications
You must be signed in to change notification settings - Fork 0
/
View.v
132 lines (122 loc) · 4.8 KB
/
View.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
`timescale 1ns/1ps
module View(
cp,
click,
state,
data,
shinning,
inLeft, inMiddle, inRight,
initTime,
second,
showLeft, showRight,
w_inWaterLED,
w_WLED,
r_outWaterLED,
r_spinWaterLED,
r_inWaterLED,
r_RLED,
d_outwaterLED,
d_spinWaterLED,
beeLED,
setLED,
powerLED,
colorLED
);
input cp;
input click;
input [2:0] state;
input [9:0] data;
input [2:0] shinning;
input [5:0] inLeft;
input [5:0] inMiddle;
input [5:0] inRight;
input [2:0] initTime;
input second;
output [7:0] showLeft;
output [7:0] showRight;
output w_inWaterLED;
output w_WLED;
output r_outWaterLED;
output r_spinWaterLED;
output r_inWaterLED;
output r_RLED;
output d_outwaterLED;
output d_spinWaterLED;
output beeLED;
output setLED;
output powerLED;
output reg [2:0] colorLED = 0;
wire [5:0] left;
wire [5:0] middle;
wire [5:0] right;
localparam shutDownST = 0, beginST = 1, setST = 2, runST = 3;
localparam errorST = 4, pauseST = 5, finishST = 6, sleepST = 7;
localparam showEmpty = 55, showFull = 56, showPause = 57, showError = 58, showHE = 59, showLL = 60, showO = 61;
always @(posedge second) begin
if (state == runST) begin
colorLED <= colorLED + 1;
end
else if (state == errorST) begin
colorLED <= 3'b100;
end
else if (state == pauseST) begin
colorLED <= colorLED;
end
else begin
colorLED <= 0;
end
end
assign left = (state == shutDownST || state == sleepST) ? showEmpty :
(state == beginST && initTime < 4) ? showHE :
(state == beginST) ? showFull :
(state == finishST) ? showFull : inLeft;
assign right = (state == shutDownST || state == sleepST) ? showEmpty :
(state == beginST && initTime < 4) ? showO :
(state == beginST) ? showFull :
(state == finishST) ? showFull : inRight;
assign middle = (state == shutDownST || state == sleepST) ? showEmpty :
(state == beginST && initTime < 4) ? showLL :
(state == beginST) ? showFull :
(state == finishST) ? showFull :
(state == pauseST) ? showPause :
(state == errorST) ? showError : inMiddle;
assign w_inWaterLED = (state == shutDownST || state == sleepST) ? 0 :
(state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == runST) ? ((shinning == 0) ? second : data[7]) : data[7];
assign w_WLED = (state == shutDownST || state == sleepST) ? 0 :
(state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == runST) ? ((shinning == 1) ? second : data[6]): data[6];
assign r_outWaterLED = (state == shutDownST || state == sleepST) ? 0 :
(state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == runST) ? ((shinning == 2) ? second : data[5]) : data[5];
assign r_spinWaterLED = (state == shutDownST || state == sleepST) ? 0 :
(state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == runST) ? ((shinning == 3) ? second : data[4]) : data[4];
assign r_inWaterLED = (state == shutDownST || state == sleepST) ? 0 :
(state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == runST) ? ((shinning == 4) ? second : data[3]) : data[3];
assign r_RLED = (state == shutDownST || state == sleepST) ? 0 :
(state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == runST) ? ((shinning == 5) ? second : data[2]) : data[2];
assign d_outwaterLED = (state == shutDownST || state == sleepST) ? 0 :
(state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == runST) ? ((shinning == 6) ? second : data[1]) : data[1];
assign d_spinWaterLED = (state == shutDownST || state == sleepST) ? 0 :
(state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == runST) ? ((shinning == 7) ? second : data[0]) : data[0];
assign beeLED = (state == finishST) ? second :
(click) ? 1 : 0;
assign powerLED = data[8];
assign setLED = (state == beginST) ? 1 :
(state == finishST) ? 1 :
(state == shutDownST || state == sleepST) ? 0 : data[9];
ShowView l (cp, left, middle, right, showLeft, showRight);
endmodule // View