-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConditionalCheck.v
80 lines (61 loc) · 1.7 KB
/
ConditionalCheck.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
`include "Defines.v"
module ConditionalCheck (
input [`COND_LEN - 1:0] cond,
input [3:0] statusRegister,
output wire condState
);
wire z, c, n, v;
// TODO: order of status registers must be checked.
assign {z, c, n, v} = statusRegister;
reg tempCondition;
assign condState = tempCondition;
always @(*) begin
case(cond)
`COND_EQ : begin
tempCondition <= z;
end
`COND_NE : begin
tempCondition <= ~z;
end
`COND_CS_HS : begin
tempCondition <= c;
end
`COND_CC_LO : begin
tempCondition <= ~c;
end
`COND_MI : begin
tempCondition <= n;
end
`COND_PL : begin
tempCondition <= ~n;
end
`COND_VS : begin
tempCondition <= v;
end
`COND_VC : begin
tempCondition <= ~v;
end
`COND_HI : begin
tempCondition <= c & ~z;
end
`COND_LS : begin
tempCondition <= ~c & z;
end
`COND_GE : begin
tempCondition <= (n & v) | (~n & ~v);
end
`COND_LT : begin
tempCondition <= (n & ~v) | (~n & v);
end
`COND_GT : begin
tempCondition <= ~z & ((n & v) | (~n & ~v));
end
`COND_LE : begin
tempCondition <= z & ((n & ~v) | (~n & v));
end
`COND_AL : begin
tempCondition <= 1'b1;
end
endcase
end
endmodule