OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [commands/] [CMD_Arith.txt] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
 
2
3
`define CMD_Arith   #AUTOGEN_NEXT_CMD_MOD8
4
`define CMD_ADD     #AUTOGEN_NEXT_CMD_LIKE_PREV
5
`define CMD_OR      #AUTOGEN_NEXT_CMD
6
`define CMD_ADC     #AUTOGEN_NEXT_CMD
7
`define CMD_SBB     #AUTOGEN_NEXT_CMD
8
`define CMD_AND     #AUTOGEN_NEXT_CMD
9
`define CMD_SUB     #AUTOGEN_NEXT_CMD
10
`define CMD_XOR     #AUTOGEN_NEXT_CMD
11
`define CMD_CMP     #AUTOGEN_NEXT_CMD
12
 
13
`define CMDEX_Arith_immediate       4'd0
14
`define CMDEX_Arith_modregrm        4'd1
15
`define CMDEX_Arith_modregrm_imm    4'd2
16
17
 
18
19
dec_ready_one_imm && decoder[7:6] == 2'b00 && decoder[2:1] == 2'b10
20
{`CMD_Arith | { 4'd0, decoder[5:3] } }
21
SET(dec_cmdex, `CMDEX_Arith_immediate);
22
IF(decoder[0] == 1'b0); SET(dec_is_8bit); ENDIF();
23
SET(consume_one_imm);
24
25
 
26
27
dec_ready_modregrm_one && decoder[7:6] == 2'b00 && decoder[2] == 1'b0
28
prefix_group_1_lock && (decoder[1] == 1'b1 || `DEC_MODREGRM_IS_MOD_11 || decoder[5:3] == 3'b111)
29
{`CMD_Arith | { 4'd0, decoder[5:3] } }
30
SET(dec_cmdex, `CMDEX_Arith_modregrm);
31
IF(decoder[0] == 1'b0); SET(dec_is_8bit); ENDIF();
32
SET(consume_modregrm_one);
33
34
 
35
36
dec_ready_modregrm_imm && { decoder[7:2], 2'b00 } == 8'h80
37
prefix_group_1_lock && (decoder[13:11] == 3'b111 || `DEC_MODREGRM_IS_MOD_11)
38
{`CMD_Arith | { 4'd0, decoder[13:11] } }
39
SET(dec_cmdex, `CMDEX_Arith_modregrm_imm);
40
IF(decoder[0] == 1'b0); SET(dec_is_8bit); ENDIF();
41
SET(consume_modregrm_imm);
42
43
 
44
45
wire rd_arith_modregrm_to_rm;
46
wire rd_arith_modregrm_to_reg;
47
 
48
assign rd_arith_modregrm_to_rm = ~(rd_decoder[1]);
49
assign rd_arith_modregrm_to_reg= rd_decoder[1];
50
51
 
52
53
IF({ rd_cmd[6:3], 3'd0 } == `CMD_Arith && rd_cmdex == `CMDEX_Arith_modregrm);
54
 
55
    SET(rd_src_is_reg,  rd_arith_modregrm_to_rm);
56
    SET(rd_dst_is_reg,  rd_arith_modregrm_to_reg);
57
 
58
    SET(rd_req_eflags);
59
 
60
    // dst: reg, src: reg
61
    IF(rd_modregrm_mod == 2'b11);
62
 
63
        // reg, reg
64
        SET(rd_dst_is_rm,   rd_arith_modregrm_to_rm);
65
        SET(rd_src_is_rm,   rd_arith_modregrm_to_reg);
66
 
67
        IF(rd_decoder[5:3] != 3'b111); // not CMP
68
            SET(rd_req_reg, rd_arith_modregrm_to_reg);
69
            SET(rd_req_rm,  rd_arith_modregrm_to_rm);
70
        ENDIF();
71
 
72
        IF(rd_mutex_busy_modregrm_reg || rd_mutex_busy_modregrm_rm); SET(rd_waiting); ENDIF();
73
    ENDIF();
74
 
75
    // dst: memory, src: reg;
76
    // dst: reg,    src: memory
77
    IF(rd_modregrm_mod != 2'b11);
78
 
79
        SET(rd_src_is_memory,   rd_arith_modregrm_to_reg);
80
        SET(rd_dst_is_memory,   rd_arith_modregrm_to_rm);
81
 
82
        IF(rd_decoder[5:3] != 3'b111 && rd_arith_modregrm_to_rm);   SET(rd_req_memory); ENDIF(); // not CMP and dst: memory
83
        IF(rd_decoder[5:3] != 3'b111 && rd_arith_modregrm_to_reg);  SET(rd_req_reg);    ENDIF(); // dst: reg
84
 
85
        IF(rd_mutex_busy_memory || rd_mutex_busy_modregrm_reg); SET(rd_waiting);
86
        ELSE();
87
 
88
            IF(rd_decoder[5:3] != 3'b111 && rd_arith_modregrm_to_rm);   SET(read_rmw_virtual); // not CMP and dst: memory
89
            ELSE();                                                     SET(read_virtual);     // CMP
90
            ENDIF();
91
 
92
            IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
93
        ENDIF();
94
    ENDIF();
95
ENDIF();
96
97
 
98
99
IF({ rd_cmd[6:3], 3'd0 } == `CMD_Arith && rd_cmdex == `CMDEX_Arith_modregrm_imm);
100
 
101
    SET(rd_req_eflags);
102
 
103
    // dst: reg, src: imm
104
    IF(rd_modregrm_mod == 2'b11);
105
 
106
        // reg, reg
107
        IF(rd_decoder[1:0] == 2'b11);   SET(rd_src_is_modregrm_imm_se);
108
        ELSE();                         SET(rd_src_is_modregrm_imm);
109
        ENDIF();
110
 
111
        SET(rd_dst_is_rm);
112
 
113
        IF(rd_decoder[13:11] != 3'b111); SET(rd_req_rm); ENDIF(); //CMP
114
 
115
        IF(rd_mutex_busy_modregrm_rm); SET(rd_waiting); ENDIF();
116
    ENDIF();
117
 
118
    // dst: memory, src: imm
119
    IF(rd_modregrm_mod != 2'b11);
120
 
121
        IF(rd_decoder[1:0] == 2'b11);    SET(rd_src_is_modregrm_imm_se);
122
        ELSE();                          SET(rd_src_is_modregrm_imm);
123
        ENDIF();
124
 
125
        SET(rd_dst_is_memory);
126
 
127
        IF(rd_decoder[13:11] != 3'b111); SET(rd_req_memory); ENDIF(); // not CMP
128
 
129
        IF(rd_mutex_busy_memory); SET(rd_waiting);
130
        ELSE();
131
 
132
            IF(rd_decoder[13:11] != 3'b111); SET(read_rmw_virtual); // not CMP
133
            ELSE();                          SET(read_virtual);     // CMP
134
            ENDIF();
135
 
136
            IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
137
        ENDIF();
138
    ENDIF();
139
ENDIF();
140
141
 
142
143
IF({ rd_cmd[6:3], 3'd0 } == `CMD_Arith && rd_cmdex == `CMDEX_Arith_immediate);
144
 
145
    SET(rd_src_is_imm);
146
    SET(rd_dst_is_eax);
147
 
148
    SET(rd_req_eflags);
149
    IF(rd_decoder[5:3] != 3'b111); SET(rd_req_eax); ENDIF(); //not CMP
150
 
151
    // dst: eAX, src: imm
152
    IF(rd_mutex_busy_eax); SET(rd_waiting); ENDIF();
153
ENDIF();
154
155
 
156
157
IF({ exe_cmd[6:3], 3'd0 } == `CMD_Arith);
158
 
159
    SET(exe_arith_index, {`TRUE, exe_cmd[2:0]});
160
 
161
    SET(exe_result, ({ 1'b0, exe_cmd[2:0] } == `ARITH_ADD)?   exe_arith_add[31:0] :
162
                    ({ 1'b0, exe_cmd[2:0] } == `ARITH_OR)?    exe_arith_or :
163
                    ({ 1'b0, exe_cmd[2:0] } == `ARITH_ADC)?   exe_arith_adc[31:0] :
164
                    ({ 1'b0, exe_cmd[2:0] } == `ARITH_SBB)?   exe_arith_sbb[31:0] :
165
                    ({ 1'b0, exe_cmd[2:0] } == `ARITH_AND)?   exe_arith_and :
166
                    ({ 1'b0, exe_cmd[2:0] } == `ARITH_XOR)?   exe_arith_xor :
167
                                                              exe_arith_sub[31:0]);
168
 
169
    IF(exe_cmd[2:1] == 2'b01 && exe_mutex_current[`MUTEX_EFLAGS_BIT]); SET(exe_waiting); ENDIF(); // ADC,SBB -- wait for mutex_eflags
170
ENDIF();
171
172
 
173
174
IF({ wr_cmd[6:3], 3'd0 } == `CMD_Arith);
175
 
176
    IF(wr_cmd[2:0] != 3'b111 && wr_dst_is_memory && ~(write_for_wr_ready)); SET(wr_waiting); ENDIF(); //not CMP
177
 
178
    IF(wr_cmd[2:0] != 3'b111); // writeback not for CMP
179
        SET(write_rmw_virtual,  wr_dst_is_memory);
180
        SET(write_regrm,        wr_dst_is_reg || wr_dst_is_rm);
181
        SET(write_eax,          wr_dst_is_eax);
182
    ENDIF();
183
 
184
    SAVE(zflag, zflag_result);
185
    SAVE(sflag, sflag_result);
186
    SAVE(pflag, pflag_result);
187
 
188
    SAVE(aflag, aflag_arith);
189
    SAVE(cflag, cflag_arith);
190
    SAVE(oflag, oflag_arith);
191
ENDIF();
192

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.