-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumDecoder.v
154 lines (150 loc) · 2.54 KB
/
NumDecoder.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
`timescale 1ns / 1ps
module NumDecoder(
input [7:0] num,
input clk,
output reg [3:0] val0,
output reg [3:0] val1,
output reg [3:0] val2,
output reg [3:0] val3
);
always @ (posedge clk)
begin
if (num >= 180)
begin
val3 <= 3;
if (num >= 230)
begin
val1 <= 5;
val0 <= num-230;
end
else if (num >= 220)
begin
val1 <= 4;
val0 <= num-220;
end
else if (num >= 210)
begin
val1 <= 3;
val0 <= num-210;
end
else if (num >= 200)
begin
val1 <= 2;
val0 <= num-200;
end
else if (num >= 190)
begin
val1 <= 1;
val0 <= num-190;
end
else
begin
val1 <= 0;
val0 <= num-180;
end
end
/////////////2min///////////////////////////////////
else if (num >= 120)
begin
val3 <= 2;
if (num >= 170)
begin
val1 <= 5;
val0 <= num-170;
end
else if (num >= 160)
begin
val1 <= 4;
val0 <= num-160;
end
else if (num >= 150)
begin
val1 <= 3;
val0 <= num-150;
end
else if (num >= 140)
begin
val1 <= 2;
val0 <= num-140;
end
else if (num >= 130)
begin
val1 <= 1;
val0 <= num-130;
end
else
begin
val1 <= 0;
val0 <= num-120;
end
end
else if (num >= 60)
begin
val3 <= 1;
if (num >= 110)
begin
val1 <= 5;
val0 <= num-110;
end
else if (num >= 100)
begin
val1 <= 4;
val0 <= num-100;
end
else if (num >= 90)
begin
val1 <= 3;
val0 <= num-90;
end
else if (num >= 80)
begin
val1 <= 2;
val0 <= num-80;
end
else if (num >= 70)
begin
val1 <= 1;
val0 <= num-70;
end
else
begin
val1 <= 0;
val0 <= num-60;
end
end
else
begin
val3 <= 0;
if (num >= 50)
begin
val1 <= 5;
val0 <= num-50;
end
else if (num >= 40)
begin
val1 <= 4;
val0 <= num-40;
end
else if (num >= 30)
begin
val1 <= 3;
val0 <= num-30;
end
else if (num >= 20)
begin
val1 <= 2;
val0 <= num-20;
end
else if (num >= 10)
begin
val1 <= 1;
val0 <= num-10;
end
else
begin
val1 <= 0;
val0 <= num;
end
end
end
endmodule