-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.v
187 lines (163 loc) · 3.67 KB
/
project.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
module project (
input [3:0] dat_a_in,
input [3:0] dat_b_in,
input [1:0] function_in,
output [6:0] led1,
output [6:0]led2,
output [6:0]led3
);
reg stat[0:2][0:6];
integer out=0;
integer t;
integer i=0;
integer out2;
always@(dat_a_in or dat_b_in)
begin
i=0;
case (function_in)
2'b00: out = dat_a_in + dat_b_in;
2'b01: out = dat_a_in - dat_b_in;
2'b10: out = dat_a_in * dat_b_in;
2'b11: out = dat_a_in / dat_b_in;
endcase
while( i<3)
begin
t = out % 10;
out = out / 10;
case(t)
0:begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b0;
stat[i][4] = 1'b0;
stat[i][5] = 1'b0;
stat[i][6] = 1'b1;
end
1:
begin
stat[i][0] = 1'b1;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b1;
stat[i][4] = 1'b1;
stat[i][5] = 1'b1;
stat[i][6] = 1'b1;
end
2:
begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b0;
stat[i][2] = 1'b1;
stat[i][3] = 1'b0;
stat[i][4] = 1'b0;
stat[i][5] = 1'b1;
stat[i][6] = 1'b0;
end
3:
begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b0;
stat[i][4] = 1'b1;
stat[i][5] = 1'b1;
stat[i][6] = 1'b0;
end
4:
begin
stat[i][0] = 1'b1;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b1;
stat[i][4] = 1'b1;
stat[i][5] = 1'b0;
stat[i][6] = 1'b0;
end
5:begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b1;
stat[i][2] = 1'b0;
stat[i][3] = 1'b0;
stat[i][4] = 1'b1;
stat[i][5] = 1'b0;
stat[i][6] = 1'b0;
end
6:
begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b0;
stat[i][4] = 1'b0;
stat[i][5] = 1'b1;
stat[i][6] = 1'b0;
end
7:begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b1;
stat[i][4] = 1'b1;
stat[i][5] = 1'b1;
stat[i][6] = 1'b1;
end
8:
begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b0;
stat[i][4] = 1'b0;
stat[i][5] = 1'b0;
stat[i][6] = 1'b0;
end
9:
begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b0;
stat[i][4] = 1'b1;
stat[i][5] = 1'b0;
stat[i][6] = 1'b0;
end
default:
begin
stat[i][0] = 1'b0;
stat[i][1] = 1'b0;
stat[i][2] = 1'b0;
stat[i][3] = 1'b0;
stat[i][4] = 1'b0;
stat[i][5] = 1'b0;
stat[i][6] = 1'b1;
end
endcase
i = i + 1;
end
end
assign led1[0]= stat[0][0];
assign led1[1]= stat[0][1];
assign led1[2]= stat[0][2];
assign led1[3]= stat[0][3];
assign led1[4]= stat[0][4];
assign led1[5]= stat[0][5];
assign led1[6]= stat[0][6];
assign led2[0]=stat[1][0];
assign led2[1]=stat[1][1];
assign led2[2]=stat[1][2];
assign led2[3]=stat[1][3];
assign led2[4]=stat[1][4];
assign led2[5]=stat[1][5];
assign led2[6]=stat[1][6];
assign led3[0]=stat[2][0];
assign led3[1]=stat[2][1];
assign led3[2]=stat[2][2];
assign led3[3]=stat[2][3];
assign led3[4]=stat[2][4];
assign led3[5]=stat[2][5];
assign led3[6]=stat[2][6];
// pin planner for led[0][0:6] for 1st block
// ...................[1][0:6] .... 2nd block
// ...................[2][0:6] .... 3rd block
endmodule