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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [commands/] [CMD_BSF_BSR.txt] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
 
2
3
`define CMD_BSx     #AUTOGEN_NEXT_CMD_MOD2
4
`define CMD_BSF     #AUTOGEN_NEXT_CMD_LIKE_PREV
5
`define CMD_BSR     #AUTOGEN_NEXT_CMD
6
7
 
8
9
dec_ready_2byte_modregrm && decoder[7:0] == 8'hBC
10
`CMD_BSF
11
SET(consume_modregrm_one);
12
13
 
14
15
dec_ready_2byte_modregrm && decoder[7:0] == 8'hBD
16
`CMD_BSR
17
SET(consume_modregrm_one);
18
19
 
20
21
IF({ rd_cmd[6:1], 1'd0 } == `CMD_BSx);
22
 
23
    SET(rd_dst_is_reg);
24
 
25
    SET(rd_req_reg);
26
    SET(rd_req_eflags);
27
 
28
    // dst: reg, src: reg
29
    IF(rd_modregrm_mod == 2'b11);
30
        SET(rd_src_is_rm);
31
 
32
        IF(rd_mutex_busy_modregrm_rm); SET(rd_waiting); ENDIF();
33
    ENDIF();
34
 
35
    // dst: memory, src: reg
36
    IF(rd_modregrm_mod != 2'b11);
37
 
38
        SET(rd_src_is_memory);
39
 
40
        IF(rd_mutex_busy_memory); SET(rd_waiting);
41
        ELSE();
42
            SET(read_virtual);
43
 
44
            IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
45
        ENDIF();
46
    ENDIF();
47
ENDIF();
48
49
 
50
51
//----------------------- BSF, BSR
52
 
53
wire [4:0]  e_bit_scan_forward;
54
wire        e_bit_scan_zero;
55
wire [31:0] e_src_ze;
56
wire [4:0]  e_bit_scan_reverse;
57
 
58
assign e_bit_scan_forward =
59
    (src[0])?  5'd0 :
60
    (src[1])?  5'd1 :
61
    (src[2])?  5'd2 :
62
    (src[3])?  5'd3 :
63
    (src[4])?  5'd4 :
64
    (src[5])?  5'd5 :
65
    (src[6])?  5'd6 :
66
    (src[7])?  5'd7 :
67
    (src[8])?  5'd8 :
68
    (src[9])?  5'd9 :
69
    (src[10])? 5'd10 :
70
    (src[11])? 5'd11 :
71
    (src[12])? 5'd12 :
72
    (src[13])? 5'd13 :
73
    (src[14])? 5'd14 :
74
    (src[15])? 5'd15 :
75
    (src[16])? 5'd16 :
76
    (src[17])? 5'd17 :
77
    (src[18])? 5'd18 :
78
    (src[19])? 5'd19 :
79
    (src[20])? 5'd20 :
80
    (src[21])? 5'd21 :
81
    (src[22])? 5'd22 :
82
    (src[23])? 5'd23 :
83
    (src[24])? 5'd24 :
84
    (src[25])? 5'd25 :
85
    (src[26])? 5'd26 :
86
    (src[27])? 5'd27 :
87
    (src[28])? 5'd28 :
88
    (src[29])? 5'd29 :
89
    (src[30])? 5'd30 :
90
    (src[31])? 5'd31 :
91
               5'd0;
92
 
93
assign e_src_ze = (exe_operand_16bit)? { 16'd0, src[15:0] } : src;
94
 
95
assign e_bit_scan_reverse =
96
    (e_src_ze[31])? 5'd31 :
97
    (e_src_ze[30])? 5'd30 :
98
    (e_src_ze[29])? 5'd29 :
99
    (e_src_ze[28])? 5'd28 :
100
    (e_src_ze[27])? 5'd27 :
101
    (e_src_ze[26])? 5'd26 :
102
    (e_src_ze[25])? 5'd25 :
103
    (e_src_ze[24])? 5'd24 :
104
    (e_src_ze[23])? 5'd23 :
105
    (e_src_ze[22])? 5'd22 :
106
    (e_src_ze[21])? 5'd21 :
107
    (e_src_ze[20])? 5'd20 :
108
    (e_src_ze[19])? 5'd19 :
109
    (e_src_ze[18])? 5'd18 :
110
    (e_src_ze[17])? 5'd17 :
111
    (e_src_ze[16])? 5'd16 :
112
    (e_src_ze[15])? 5'd15 :
113
    (e_src_ze[14])? 5'd14 :
114
    (e_src_ze[13])? 5'd13 :
115
    (e_src_ze[12])? 5'd12 :
116
    (e_src_ze[11])? 5'd11 :
117
    (e_src_ze[10])? 5'd10 :
118
    (e_src_ze[9])?  5'd9 :
119
    (e_src_ze[8])?  5'd8 :
120
    (e_src_ze[7])?  5'd7 :
121
    (e_src_ze[6])?  5'd6 :
122
    (e_src_ze[5])?  5'd5 :
123
    (e_src_ze[4])?  5'd4 :
124
    (e_src_ze[3])?  5'd3 :
125
    (e_src_ze[2])?  5'd2 :
126
    (e_src_ze[1])?  5'd1 :
127
    (e_src_ze[0])?  5'd0 :
128
                    5'd0;
129
 
130
assign e_bit_scan_zero = (exe_operand_16bit)? src[15:0] == 16'd0 : src[31:0] == 32'd0;
131
132
 
133
134
IF({ exe_cmd[6:1], 1'd0 } == `CMD_BSx);
135
 
136
    SET(exe_result_signals, { 4'd0, e_bit_scan_zero });
137
 
138
    IF(exe_cmd == `CMD_BSF);
139
        SET(exe_result, { 27'd0, e_bit_scan_forward });
140
    ENDIF();
141
 
142
    IF(exe_cmd == `CMD_BSR);
143
        SET(exe_result, { 27'd0, e_bit_scan_reverse });
144
    ENDIF();
145
 
146
ENDIF();
147
148
 
149
150
IF({ wr_cmd[6:1], 1'd0 } == `CMD_BSx);
151
 
152
    IF(result_signals[0]);
153
        SAVE(zflag, `TRUE);
154
    ELSE();
155
        SET(write_regrm);
156
 
157
        SAVE(zflag, `FALSE);
158
        SAVE(sflag, sflag_result);
159
        SAVE(pflag, pflag_result);
160
 
161
        SAVE(aflag, aflag_arith);
162
        SAVE(cflag, cflag_arith);
163
        SAVE(oflag, oflag_arith);
164
    ENDIF();
165
ENDIF();
166

powered by: WebSVN 2.1.0

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