1 |
2 |
alfik |
|
2 |
|
|
|
3 |
|
|
`define CMD_BTx #AUTOGEN_NEXT_CMD_MOD4
|
4 |
|
|
`define CMD_BT #AUTOGEN_NEXT_CMD_LIKE_PREV
|
5 |
|
|
`define CMD_BTS #AUTOGEN_NEXT_CMD
|
6 |
|
|
`define CMD_BTR #AUTOGEN_NEXT_CMD
|
7 |
|
|
`define CMD_BTC #AUTOGEN_NEXT_CMD
|
8 |
|
|
|
9 |
|
|
`define CMDEX_BTx_modregrm_imm 4'd0
|
10 |
|
|
`define CMDEX_BTx_modregrm 4'd1
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
(dec_ready_2byte_modregrm && decoder[7:0] == 8'hA3) || (dec_ready_2byte_modregrm_imm && decoder[7:0] == 8'hBA && decoder[13:11] == 3'd4)
|
15 |
|
|
`CMD_BT
|
16 |
|
|
IF(decoder[0] == 1'b0); SET(dec_cmdex, `CMDEX_BTx_modregrm_imm); ELSE(); SET(dec_cmdex, `CMDEX_BTx_modregrm); ENDIF();
|
17 |
|
|
IF(decoder[0] == 1'b0); SET(consume_modregrm_imm); ELSE(); SET(consume_modregrm_one); ENDIF();
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
(dec_ready_2byte_modregrm && decoder[7:0] == 8'hB3) || (dec_ready_2byte_modregrm_imm && decoder[7:0] == 8'hBA && decoder[13:11] == 3'd6)
|
22 |
|
|
prefix_group_1_lock && `DEC_MODREGRM_IS_MOD_11
|
23 |
|
|
`CMD_BTR
|
24 |
|
|
IF(decoder[0] == 1'b0); SET(dec_cmdex, `CMDEX_BTx_modregrm_imm); ELSE(); SET(dec_cmdex, `CMDEX_BTx_modregrm); ENDIF();
|
25 |
|
|
IF(decoder[0] == 1'b0); SET(consume_modregrm_imm); ELSE(); SET(consume_modregrm_one); ENDIF();
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
(dec_ready_2byte_modregrm && decoder[7:0] == 8'hAB) || (dec_ready_2byte_modregrm_imm && decoder[7:0] == 8'hBA && decoder[13:11] == 3'd5)
|
30 |
|
|
prefix_group_1_lock && `DEC_MODREGRM_IS_MOD_11
|
31 |
|
|
`CMD_BTS
|
32 |
|
|
IF(decoder[0] == 1'b0); SET(dec_cmdex, `CMDEX_BTx_modregrm_imm); ELSE(); SET(dec_cmdex, `CMDEX_BTx_modregrm); ENDIF();
|
33 |
|
|
IF(decoder[0] == 1'b0); SET(consume_modregrm_imm); ELSE(); SET(consume_modregrm_one); ENDIF();
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
(dec_ready_2byte_modregrm && decoder[7:0] == 8'hBB) || (dec_ready_2byte_modregrm_imm && decoder[7:0] == 8'hBA && decoder[13:11] == 3'd7)
|
38 |
|
|
prefix_group_1_lock && `DEC_MODREGRM_IS_MOD_11
|
39 |
|
|
`CMD_BTC
|
40 |
|
|
IF(decoder[0] == 1'b0); SET(dec_cmdex, `CMDEX_BTx_modregrm_imm); ELSE(); SET(dec_cmdex, `CMDEX_BTx_modregrm); ENDIF();
|
41 |
|
|
IF(decoder[0] == 1'b0); SET(consume_modregrm_imm); ELSE(); SET(consume_modregrm_one); ENDIF();
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
IF({ rd_cmd[6:2], 2'd0 } == `CMD_BTx); // `CMDEX_BTx_modregrm || `CMDEX_BTx_modregrm_imm
|
46 |
|
|
|
47 |
|
|
SET(address_bits_transform, rd_cmdex == `CMDEX_BTx_modregrm);
|
48 |
|
|
|
49 |
|
|
SET(rd_src_is_reg, rd_cmdex == `CMDEX_BTx_modregrm);
|
50 |
|
|
SET(rd_src_is_modregrm_imm, rd_cmdex == `CMDEX_BTx_modregrm_imm);
|
51 |
|
|
|
52 |
|
|
SET(rd_req_eflags);
|
53 |
|
|
|
54 |
|
|
// dst: reg, src: reg
|
55 |
|
|
IF(rd_modregrm_mod == 2'b11);
|
56 |
|
|
|
57 |
|
|
SET(rd_dst_is_rm);
|
58 |
|
|
|
59 |
|
|
SET(rd_req_rm, rd_cmd[1:0] != 2'd0); // not BT
|
60 |
|
|
|
61 |
|
|
IF(rd_mutex_busy_modregrm_rm || (rd_cmdex == `CMDEX_BTx_modregrm && rd_mutex_busy_modregrm_reg)); SET(rd_waiting); ENDIF();
|
62 |
|
|
ENDIF();
|
63 |
|
|
|
64 |
|
|
// dst: memory, src: reg
|
65 |
|
|
IF(rd_modregrm_mod != 2'b11);
|
66 |
|
|
|
67 |
|
|
SET(rd_dst_is_memory);
|
68 |
|
|
|
69 |
|
|
SET(rd_req_memory, rd_cmd[1:0] != 2'd0); // not BT
|
70 |
|
|
|
71 |
|
|
IF(rd_mutex_busy_memory || (rd_cmdex == `CMDEX_BTx_modregrm && rd_mutex_busy_modregrm_reg)); SET(rd_waiting);
|
72 |
|
|
ELSE();
|
73 |
|
|
SET(read_rmw_virtual, rd_cmd[1:0] != 2'd0); // not BT
|
74 |
|
|
SET(read_virtual, rd_cmd[1:0] == 2'd0); // BT
|
75 |
|
|
|
76 |
|
|
IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
|
77 |
|
|
ENDIF();
|
78 |
|
|
ENDIF();
|
79 |
|
|
ENDIF();
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
//----------------------- BT, BTC, BTR, BTS
|
84 |
|
|
|
85 |
|
|
wire [4:0] e_bit_selector;
|
86 |
|
|
wire e_bit_selected;
|
87 |
|
|
wire e_bit_value;
|
88 |
|
|
wire [31:0] e_bit_result;
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
assign e_bit_selector = (exe_operand_16bit)? { 1'b0, src[3:0] } : src[4:0];
|
92 |
|
|
|
93 |
|
|
assign e_bit_selected =
|
94 |
|
|
(e_bit_selector == 5'd0)? dst[0] :
|
95 |
|
|
(e_bit_selector == 5'd1)? dst[1] :
|
96 |
|
|
(e_bit_selector == 5'd2)? dst[2] :
|
97 |
|
|
(e_bit_selector == 5'd3)? dst[3] :
|
98 |
|
|
(e_bit_selector == 5'd4)? dst[4] :
|
99 |
|
|
(e_bit_selector == 5'd5)? dst[5] :
|
100 |
|
|
(e_bit_selector == 5'd6)? dst[6] :
|
101 |
|
|
(e_bit_selector == 5'd7)? dst[7] :
|
102 |
|
|
(e_bit_selector == 5'd8)? dst[8] :
|
103 |
|
|
(e_bit_selector == 5'd9)? dst[9] :
|
104 |
|
|
(e_bit_selector == 5'd10)? dst[10] :
|
105 |
|
|
(e_bit_selector == 5'd11)? dst[11] :
|
106 |
|
|
(e_bit_selector == 5'd12)? dst[12] :
|
107 |
|
|
(e_bit_selector == 5'd13)? dst[13] :
|
108 |
|
|
(e_bit_selector == 5'd14)? dst[14] :
|
109 |
|
|
(e_bit_selector == 5'd15)? dst[15] :
|
110 |
|
|
(e_bit_selector == 5'd16)? dst[16] :
|
111 |
|
|
(e_bit_selector == 5'd17)? dst[17] :
|
112 |
|
|
(e_bit_selector == 5'd18)? dst[18] :
|
113 |
|
|
(e_bit_selector == 5'd19)? dst[19] :
|
114 |
|
|
(e_bit_selector == 5'd20)? dst[20] :
|
115 |
|
|
(e_bit_selector == 5'd21)? dst[21] :
|
116 |
|
|
(e_bit_selector == 5'd22)? dst[22] :
|
117 |
|
|
(e_bit_selector == 5'd23)? dst[23] :
|
118 |
|
|
(e_bit_selector == 5'd24)? dst[24] :
|
119 |
|
|
(e_bit_selector == 5'd25)? dst[25] :
|
120 |
|
|
(e_bit_selector == 5'd26)? dst[26] :
|
121 |
|
|
(e_bit_selector == 5'd27)? dst[27] :
|
122 |
|
|
(e_bit_selector == 5'd28)? dst[28] :
|
123 |
|
|
(e_bit_selector == 5'd29)? dst[29] :
|
124 |
|
|
(e_bit_selector == 5'd30)? dst[30] :
|
125 |
|
|
dst[31];
|
126 |
|
|
|
127 |
|
|
assign e_bit_value = (exe_cmd == `CMD_BTC)? ~e_bit_selected :
|
128 |
|
|
(exe_cmd == `CMD_BTR)? 1'b0 :
|
129 |
|
|
1'b1;
|
130 |
|
|
|
131 |
|
|
assign e_bit_result =
|
132 |
|
|
(e_bit_selector == 5'd0)? { dst[31:1], e_bit_value } :
|
133 |
|
|
(e_bit_selector == 5'd1)? { dst[31:2], e_bit_value, dst[0] } :
|
134 |
|
|
(e_bit_selector == 5'd2)? { dst[31:3], e_bit_value, dst[1:0] } :
|
135 |
|
|
(e_bit_selector == 5'd3)? { dst[31:4], e_bit_value, dst[2:0] } :
|
136 |
|
|
(e_bit_selector == 5'd4)? { dst[31:5], e_bit_value, dst[3:0] } :
|
137 |
|
|
(e_bit_selector == 5'd5)? { dst[31:6], e_bit_value, dst[4:0] } :
|
138 |
|
|
(e_bit_selector == 5'd6)? { dst[31:7], e_bit_value, dst[5:0] } :
|
139 |
|
|
(e_bit_selector == 5'd7)? { dst[31:8], e_bit_value, dst[6:0] } :
|
140 |
|
|
(e_bit_selector == 5'd8)? { dst[31:9], e_bit_value, dst[7:0] } :
|
141 |
|
|
(e_bit_selector == 5'd9)? { dst[31:10], e_bit_value, dst[8:0] } :
|
142 |
|
|
(e_bit_selector == 5'd10)? { dst[31:11], e_bit_value, dst[9:0] } :
|
143 |
|
|
(e_bit_selector == 5'd11)? { dst[31:12], e_bit_value, dst[10:0] } :
|
144 |
|
|
(e_bit_selector == 5'd12)? { dst[31:13], e_bit_value, dst[11:0] } :
|
145 |
|
|
(e_bit_selector == 5'd13)? { dst[31:14], e_bit_value, dst[12:0] } :
|
146 |
|
|
(e_bit_selector == 5'd14)? { dst[31:15], e_bit_value, dst[13:0] } :
|
147 |
|
|
(e_bit_selector == 5'd15)? { dst[31:16], e_bit_value, dst[14:0] } :
|
148 |
|
|
(e_bit_selector == 5'd16)? { dst[31:17], e_bit_value, dst[15:0] } :
|
149 |
|
|
(e_bit_selector == 5'd17)? { dst[31:18], e_bit_value, dst[16:0] } :
|
150 |
|
|
(e_bit_selector == 5'd18)? { dst[31:19], e_bit_value, dst[17:0] } :
|
151 |
|
|
(e_bit_selector == 5'd19)? { dst[31:20], e_bit_value, dst[18:0] } :
|
152 |
|
|
(e_bit_selector == 5'd20)? { dst[31:21], e_bit_value, dst[19:0] } :
|
153 |
|
|
(e_bit_selector == 5'd21)? { dst[31:22], e_bit_value, dst[20:0] } :
|
154 |
|
|
(e_bit_selector == 5'd22)? { dst[31:23], e_bit_value, dst[21:0] } :
|
155 |
|
|
(e_bit_selector == 5'd23)? { dst[31:24], e_bit_value, dst[22:0] } :
|
156 |
|
|
(e_bit_selector == 5'd24)? { dst[31:25], e_bit_value, dst[23:0] } :
|
157 |
|
|
(e_bit_selector == 5'd25)? { dst[31:26], e_bit_value, dst[24:0] } :
|
158 |
|
|
(e_bit_selector == 5'd26)? { dst[31:27], e_bit_value, dst[25:0] } :
|
159 |
|
|
(e_bit_selector == 5'd27)? { dst[31:28], e_bit_value, dst[26:0] } :
|
160 |
|
|
(e_bit_selector == 5'd28)? { dst[31:29], e_bit_value, dst[27:0] } :
|
161 |
|
|
(e_bit_selector == 5'd29)? { dst[31:30], e_bit_value, dst[28:0] } :
|
162 |
|
|
(e_bit_selector == 5'd30)? { dst[31], e_bit_value, dst[29:0] } :
|
163 |
|
|
{ e_bit_value, dst[30:0] };
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
IF({ exe_cmd[6:2], 2'd0 } == `CMD_BTx); // `CMDEX_MODREGRM || `CMDEX_MODREGRM_IMM
|
169 |
|
|
|
170 |
|
|
SET(exe_result, e_bit_result);
|
171 |
|
|
|
172 |
|
|
SET(exe_result_signals, { 4'd0, e_bit_selected });
|
173 |
|
|
|
174 |
|
|
ENDIF();
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
IF({ wr_cmd[6:2], 2'd0 } == `CMD_BTx); // `CMDEX_MODREGRM || `CMDEX_MODREGRM_IMM
|
179 |
|
|
|
180 |
|
|
IF(wr_cmd[1:0] != 2'd0); // not BT
|
181 |
|
|
IF(wr_dst_is_memory && ~(write_for_wr_ready)); SET(wr_waiting); ENDIF(); // not BT
|
182 |
|
|
|
183 |
|
|
SET(write_regrm, wr_dst_is_rm);
|
184 |
|
|
SET(write_rmw_virtual, wr_dst_is_memory);
|
185 |
|
|
ENDIF();
|
186 |
|
|
|
187 |
|
|
SAVE(cflag, result_signals[0]);
|
188 |
|
|
ENDIF();
|
189 |
|
|
|