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

Subversion Repositories ao486

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
 
2
3
`define CMD_AAA     #AUTOGEN_NEXT_CMD
4
`define CMD_AAS     #AUTOGEN_NEXT_CMD
5
`define CMD_DAA     #AUTOGEN_NEXT_CMD
6
`define CMD_DAS     #AUTOGEN_NEXT_CMD
7
8
 
9
10
dec_ready_one && decoder[7:0] == 8'h37
11
`CMD_AAA
12
SET(dec_is_8bit);
13
SET(consume_one);
14
15
 
16
17
dec_ready_one && decoder[7:0] == 8'h3F
18
`CMD_AAS
19
SET(dec_is_8bit);
20
SET(consume_one);
21
22
 
23
24
dec_ready_one && decoder[7:0] == 8'h27
25
`CMD_DAA
26
SET(dec_is_8bit);
27
SET(consume_one);
28
29
 
30
31
dec_ready_one && decoder[7:0] == 8'h2F
32
`CMD_DAS
33
SET(dec_is_8bit);
34
SET(consume_one);
35
36
 
37
38
IF(rd_cmd == `CMD_AAA || rd_cmd == `CMD_AAS || rd_cmd == `CMD_DAA || rd_cmd == `CMD_DAS);
39
 
40
    SET(rd_dst_is_eax);
41
 
42
    SET(rd_req_eflags);
43
    SET(rd_req_eax);
44
 
45
    IF(rd_mutex_busy_eax); SET(rd_waiting); ENDIF();
46
ENDIF();
47
48
 
49
50
wire e_bcd_condition_cf;
51
 
52
wire exe_bcd_condition_af;
53
wire exe_bcd_condition_cf;
54
 
55
wire [15:0] e_aaa_sum_ax;
56
wire [15:0] e_aaa_result;
57
 
58
wire [15:0] e_aas_sub_ax;
59
wire [15:0] e_aas_result;
60
 
61
wire [7:0]  e_daa_sum_low;
62
wire [7:0]  e_daa_step1;
63
wire [7:0]  e_daa_sum_high;
64
wire [7:0]  e_daa_result;
65
 
66
wire [7:0]  e_das_sub_low;
67
wire [7:0]  e_das_step1;
68
wire [7:0]  e_das_sub_high;
69
wire [7:0]  e_das_result;
70
 
71
//---------
72
 
73
assign e_bcd_condition_cf = (dst[7:0] > 8'h99 || cflag);
74
 
75
assign exe_bcd_condition_af = dst[3:0] > 4'd9 || aflag;
76
assign exe_bcd_condition_cf = e_bcd_condition_cf || (exe_bcd_condition_af && (cflag || (exe_cmd == `CMD_DAA)? dst[7:0] > 8'hF9 : dst[7:0] < 8'h06));
77
 
78
// AAA
79
assign e_aaa_sum_ax = dst[15:0] + 16'h0106;
80
assign e_aaa_result = (exe_bcd_condition_af)? { e_aaa_sum_ax[15:8], 4'b0, e_aaa_sum_ax[3:0] } : { dst[15:8], 4'd0, dst[3:0] };
81
 
82
// AAS
83
assign e_aas_sub_ax = dst[15:0] - 16'h0106;
84
assign e_aas_result = (exe_bcd_condition_af)? { e_aas_sub_ax[15:8], 4'b0, e_aas_sub_ax[3:0] } : { dst[15:8], 4'b0, dst[3:0] };
85
 
86
// DAA
87
assign e_daa_sum_low  = dst[7:0] + 8'h06;
88
assign e_daa_step1    = (exe_bcd_condition_af)? e_daa_sum_low : dst[7:0];
89
assign e_daa_sum_high = e_daa_step1 + 8'h60;
90
assign e_daa_result   = (e_bcd_condition_cf)? e_daa_sum_high : e_daa_step1;
91
 
92
// DAS
93
assign e_das_sub_low  = dst[7:0] - 8'h06;
94
assign e_das_step1    = (exe_bcd_condition_af)? e_das_sub_low : dst[7:0];
95
assign e_das_sub_high = e_das_step1 - 8'h60;
96
assign e_das_result   = (e_bcd_condition_cf)? e_das_sub_high : e_das_step1;
97
98
 
99
100
IF(exe_cmd == `CMD_AAA || exe_cmd == `CMD_AAS || exe_cmd == `CMD_DAA || exe_cmd == `CMD_DAS);
101
 
102
    SET(exe_result, (exe_cmd == `CMD_AAA)?  { 16'd0, e_aaa_result } :
103
                    (exe_cmd == `CMD_AAS)?  { 16'd0, e_aas_result } :
104
                    (exe_cmd == `CMD_DAA)?  { 16'd0, dst[15:8], e_daa_result } :
105
                                            { 16'd0, dst[15:8], e_das_result });
106
 
107
    SET(exe_result_signals, { 3'b0, exe_bcd_condition_af, exe_bcd_condition_cf });
108
 
109
    IF(exe_mutex_current[`MUTEX_EFLAGS_BIT]); SET(exe_waiting); ENDIF();
110
ENDIF();
111
112
 
113
114
IF(wr_cmd == `CMD_AAA || wr_cmd == `CMD_AAS);
115
    SAVE(eax, { eax[31:16], result[15:0] });
116
 
117
    SAVE(zflag, zflag_result);
118
    SAVE(sflag, sflag_result);
119
    SAVE(pflag, pflag_result);
120
 
121
    SAVE(aflag, result_signals[1]);
122
    SAVE(cflag, result_signals[1]);
123
    SAVE(oflag, oflag_arith);
124
ENDIF();
125
126
 
127
128
IF(wr_cmd == `CMD_DAA || wr_cmd == `CMD_DAS);
129
    SAVE(eax, { eax[31:16], result[15:0] });
130
 
131
    SAVE(zflag, zflag_result);
132
    SAVE(sflag, sflag_result);
133
    SAVE(pflag, pflag_result);
134
 
135
    SAVE(aflag, result_signals[1]);
136
    SAVE(cflag, result_signals[0]);
137
    SAVE(oflag, oflag_arith);
138
ENDIF();
139
140
 

powered by: WebSVN 2.1.0

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