OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [control/] [exec_matrix.vh] - Blame information for rev 7

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

Line No. Rev Author Line
1 6 gdevic
// Automatically generated by genmatrix.py
2
// 8-bit Load Group
3
if (pla[17] && !pla[50]) begin
4
    if (M1 && T1) begin
5
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo={!rsel3,rsel3}; /* Write 8-bit GP register */
6
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
7
                    ctl_sw_2d=1;
8
                    ctl_sw_1d=1;
9
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
10
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
11
    if (M2 && T1) begin  fMRead=1;
12
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
13
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
14
    if (M2 && T2) begin  fMRead=1;
15
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
16
                    ctl_inc_cy=pc_inc; /* Increment */
17
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
18
    if (M2 && T3) begin  fMRead=1; nextM=1; setM1=1; end
19
end
20
 
21
if (pla[61] && !pla[58] && !pla[59]) begin
22
    if (M1 && T1) begin
23
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo={!rsel3,rsel3}; /* Write 8-bit GP register */
24
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
25
                    ctl_sw_2u=1;
26
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
27
                    ctl_alu_op1_oe=1; /* OP1 latch */ end
28
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
29
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
30
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
31
                    ctl_sw_2d=1;
32
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
33
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
34
end
35
 
36
if (use_ixiy && pla[58]) begin
37
    if (M1 && T1) begin
38
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo={!rsel3,rsel3}; /* Write 8-bit GP register */
39
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
40
                    ctl_sw_2d=1;
41
                    ctl_sw_1d=1;
42
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
43
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
44
    if (M2 && T1) begin  fMRead=1;
45
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
46
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
47
    if (M2 && T2) begin  fMRead=1;
48
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
49
                    ctl_inc_cy=pc_inc; /* Increment */
50
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
51
    if (M2 && T3) begin  fMRead=1; nextM=1; end
52
    if (M3 && T1) begin  ixy_d=1; /* Compute WZ=IX+d */ end
53
    if (M3 && T2) begin  ixy_d=1; /* Compute WZ=IX+d */ end
54
    if (M3 && T3) begin  ixy_d=1; /* Compute WZ=IX+d */ end
55
    if (M3 && T4) begin  ixy_d=1; /* Compute WZ=IX+d */ end
56
    if (M3 && T5) begin  nextM=1; ctl_mRead=1; ixy_d=1; /* Compute WZ=IX+d */ end
57
end
58
 
59
if (~use_ixiy && pla[58]) begin
60
    if (M1 && T1) begin
61
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo={!rsel3,rsel3}; /* Write 8-bit GP register */
62
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
63
                    ctl_sw_2d=1;
64
                    ctl_sw_1d=1;
65
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
66
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
67
    if (M2 && T1) begin  fMRead=1;
68
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
69
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
70
    if (M2 && T2) begin  fMRead=1; end
71
    if (M2 && T3) begin  fMRead=1; nextM=1; setM1=1; end
72
    if (M4 && T1) begin  fMRead=1;
73
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
74
    if (M4 && T2) begin  fMRead=1; end
75
    if (M4 && T3) begin  fMRead=1; nextM=1; setM1=1; end
76
end
77
 
78
if (use_ixiy && pla[59]) begin
79
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
80
    if (M2 && T1) begin  fMRead=1;
81
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
82
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
83
    if (M2 && T2) begin  fMRead=1;
84
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
85
                    ctl_inc_cy=pc_inc; /* Increment */
86
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
87
    if (M2 && T3) begin  fMRead=1; nextM=1; end
88
    if (M3 && T1) begin  ixy_d=1; /* Compute WZ=IX+d */ end
89
    if (M3 && T2) begin  ixy_d=1; /* Compute WZ=IX+d */ end
90
    if (M3 && T3) begin  ixy_d=1; /* Compute WZ=IX+d */ end
91
    if (M3 && T4) begin  ixy_d=1; /* Compute WZ=IX+d */ end
92
    if (M3 && T5) begin  nextM=1; ctl_mWrite=1; ixy_d=1; /* Compute WZ=IX+d */ end
93
end
94
 
95
if (~use_ixiy && pla[59]) begin
96
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mWrite=1;
97
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
98
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
99
                    ctl_sw_2u=1;
100
                    ctl_sw_1u=1;
101
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
102
    if (M2 && T1) begin  fMWrite=1;
103
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
104
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
105
    if (M2 && T2) begin  fMWrite=1; end
106
    if (M2 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
107
    if (M4 && T1) begin  fMWrite=1;
108
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
109
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
110
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
111
                    ctl_sw_2u=1;
112
                    ctl_sw_1u=1;
113
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
114
    if (M4 && T2) begin  fMWrite=1; end
115
    if (M4 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
116
end
117
 
118
if (pla[40]) begin
119
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
120
    if (M2 && T1) begin  fMRead=1;
121
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
122
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
123
    if (M2 && T2) begin  fMRead=1;
124
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
125
                    ctl_inc_cy=pc_inc; /* Increment */
126
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
127
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1; end
128
    if (M3 && T1) begin  fMRead=1;
129
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
130
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ ixy_d=1; /* Compute WZ=IX+d */ end
131
    if (M3 && T2) begin  fMRead=1;
132
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
133
                    ctl_inc_cy=pc_inc; /* Increment */
134
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ ixy_d=1; /* Compute WZ=IX+d */ end
135
    if (M3 && T3) begin  fMRead=1; ixy_d=1; /* Compute WZ=IX+d */ end
136
    if (M3 && T4) begin  ixy_d=1; /* Compute WZ=IX+d */ end
137
    if (M3 && T5) begin  nextM=1; ctl_mWrite=1; ixy_d=1; /* Compute WZ=IX+d */ end
138
end
139
 
140
if (pla[50] && !pla[40]) begin
141
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
142
    if (M2 && T1) begin  fMRead=1;
143
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
144
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
145
    if (M2 && T2) begin  fMRead=1;
146
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
147
                    ctl_inc_cy=pc_inc; /* Increment */
148
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
149
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1; end
150
    if (M3 && T1) begin  fMWrite=1;
151
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
152
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
153
    if (M3 && T2) begin  fMWrite=1; end
154
    if (M3 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
155
    if (M4 && T1) begin  fMWrite=1;
156
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
157
    if (M4 && T2) begin  fMWrite=1; end
158
    if (M4 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
159
end
160
 
161
if (pla[8] && pla[13]) begin
162
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mWrite=1;
163
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
164
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
165
                    ctl_sw_2u=1;
166
                    ctl_sw_1u=1;
167
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
168
    if (M2 && T1) begin  fMWrite=1;
169
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit general purpose register, enable SW4 downstream */
170
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
171
    if (M2 && T2) begin  fMWrite=1;
172
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
173
                    ctl_inc_cy=pc_inc; /* Increment */
174
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
175
    if (M2 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
176
end
177
 
178
if (pla[8] && !pla[13]) begin
179
    if (M1 && T1) begin
180
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
181
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
182
                    ctl_sw_2d=1;
183
                    ctl_sw_1d=1;
184
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
185
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
186
    if (M2 && T1) begin  fMRead=1;
187
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit general purpose register, enable SW4 downstream */
188
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
189
    if (M2 && T2) begin  fMRead=1;
190
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
191
                    ctl_inc_cy=pc_inc; /* Increment */
192
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
193
    if (M2 && T3) begin  fMRead=1; nextM=1; setM1=1; end
194
end
195
 
196
if (pla[38] && pla[13]) begin
197
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
198
    if (M2 && T1) begin  fMRead=1;
199
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
200
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
201
    if (M2 && T2) begin  fMRead=1;
202
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
203
                    ctl_inc_cy=pc_inc; /* Increment */
204
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
205
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
206
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
207
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
208
                    ctl_sw_2d=1;
209
                    ctl_sw_1d=1;
210
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
211
    if (M3 && T1) begin  fMRead=1;
212
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
213
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
214
    if (M3 && T2) begin  fMRead=1;
215
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
216
                    ctl_inc_cy=pc_inc; /* Increment */
217
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
218
    if (M3 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
219
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
220
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
221
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
222
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
223
                    ctl_sw_2d=1;
224
                    ctl_sw_1d=1;
225
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
226
    if (M4 && T1) begin  fMWrite=1;
227
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
228
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
229
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
230
                    ctl_sw_2u=1;
231
                    ctl_sw_1u=1;
232
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
233
    if (M4 && T2) begin  fMWrite=1;
234
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
235
                    ctl_inc_cy=pc_inc; /* Increment */
236
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
237
    if (M4 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
238
end
239
 
240
if (pla[38] && !pla[13]) begin
241
    if (M1 && T1) begin
242
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
243
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
244
                    ctl_sw_2d=1;
245
                    ctl_sw_1d=1;
246
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
247
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
248
    if (M2 && T1) begin  fMRead=1;
249
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
250
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
251
    if (M2 && T2) begin  fMRead=1;
252
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
253
                    ctl_inc_cy=pc_inc; /* Increment */
254
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
255
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
256
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
257
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
258
                    ctl_sw_2d=1;
259
                    ctl_sw_1d=1;
260
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
261
    if (M3 && T1) begin  fMRead=1;
262
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
263
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
264
    if (M3 && T2) begin  fMRead=1;
265
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
266
                    ctl_inc_cy=pc_inc; /* Increment */
267
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
268
    if (M3 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
269
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
270
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
271
                    ctl_sw_2d=1;
272
                    ctl_sw_1d=1;
273
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
274
    if (M4 && T1) begin  fMRead=1;
275
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
276
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
277
    if (M4 && T2) begin  fMRead=1;
278
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
279
                    ctl_inc_cy=pc_inc; /* Increment */
280
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
281
    if (M4 && T3) begin  fMRead=1; nextM=1; setM1=1; end
282
end
283
 
284
if (pla[83]) begin
285
    if (M1 && T1) begin
286
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
287
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
288
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
289
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
290
                    ctl_alu_res_oe=1; /* Result latch */
291
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
292
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
293
                    ctl_flags_sz_we=1;
294
                    ctl_flags_xy_we=1;
295
                    ctl_flags_hf_we=1;
296
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_IFF2;
297
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
298
    if (M1 && T2) begin
299
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
300
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
301
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
302
    if (M1 && T3) begin
303
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
304
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
305
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
306
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
307
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
308
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
309
                    ctl_flags_sz_we=1;
310
                    ctl_flags_xy_we=1;
311
                    ctl_flags_hf_we=1;
312
                    ctl_flags_pf_we=1;
313
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
314
                    ctl_flags_cf_we=1; end
315
    if (M1 && T4) begin  validPLA=1;
316
                    ctl_reg_sel_ir=1; ctl_reg_sys_hilo={!op3,op3}; ctl_sw_4u=1; /* Read either I or R based on op3 (0 or 1) */
317
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
318
                    ctl_sw_2d=1;
319
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
320
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
321
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
322
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
323
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
324
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
325
                    ctl_flags_sz_we=1;
326
                    ctl_flags_xy_we=1;
327
                    ctl_flags_hf_we=1;
328
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
329
    if (M1 && T5) begin  nextM=1; setM1=1; end
330
end
331
 
332
if (pla[57]) begin
333
    if (M1 && T3) begin
334
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
335
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
336
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
337
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
338
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
339
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
340
                    ctl_flags_sz_we=1;
341
                    ctl_flags_xy_we=1;
342
                    ctl_flags_hf_we=1;
343
                    ctl_flags_pf_we=1;
344
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
345
                    ctl_flags_cf_we=1; end
346
    if (M1 && T4) begin  validPLA=1;
347
                    ctl_reg_sys_we=1; ctl_reg_sel_ir=1; ctl_reg_sys_hilo={!op3,op3}; ctl_sw_4d=1; /* Write either I or R based on op3 (0 or 1) */
348
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
349
                    ctl_sw_2u=1;
350
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
351
                    ctl_alu_op1_oe=1; /* OP1 latch */ end
352
    if (M1 && T5) begin  nextM=1; setM1=1; end
353
end
354
 
355
// 16-bit Load Group
356
if (pla[7]) begin
357
    if (M1 && T1) begin
358
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Write 8-bit GP register high byte */
359
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
360
                    ctl_sw_2d=1;
361
                    ctl_sw_1d=1;
362
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
363
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
364
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
365
    if (M2 && T1) begin  fMRead=1;
366
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
367
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
368
    if (M2 && T2) begin  fMRead=1;
369
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
370
                    ctl_inc_cy=pc_inc; /* Increment */
371
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
372
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1; end
373
    if (M3 && T1) begin  fMRead=1;
374
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
375
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
376
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Write 8-bit GP register low byte */
377
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
378
                    ctl_sw_2d=1;
379
                    ctl_sw_1d=1;
380
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
381
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
382
    if (M3 && T2) begin  fMRead=1;
383
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
384
                    ctl_inc_cy=pc_inc; /* Increment */
385
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
386
    if (M3 && T3) begin  fMRead=1; nextM=1; setM1=1; end
387
end
388
 
389
if (pla[30] && pla[13]) begin
390
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
391
    if (M2 && T1) begin  fMRead=1;
392
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
393
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
394
    if (M2 && T2) begin  fMRead=1;
395
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
396
                    ctl_inc_cy=pc_inc; /* Increment */
397
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
398
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
399
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
400
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
401
                    ctl_sw_2d=1;
402
                    ctl_sw_1d=1;
403
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
404
    if (M3 && T1) begin  fMRead=1;
405
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
406
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
407
    if (M3 && T2) begin  fMRead=1;
408
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
409
                    ctl_inc_cy=pc_inc; /* Increment */
410
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
411
    if (M3 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
412
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
413
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
414
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
415
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
416
                    ctl_sw_2d=1;
417
                    ctl_sw_1d=1;
418
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
419
    if (M4 && T1) begin  fMWrite=1;
420
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
421
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Read 8-bit GP register low byte */
422
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
423
                    ctl_sw_2u=1;
424
                    ctl_sw_1u=1;
425
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
426
    if (M4 && T2) begin  fMWrite=1;
427
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
428
                    ctl_inc_cy=pc_inc; /* Increment */
429
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
430
    if (M4 && T3) begin  fMWrite=1; nextM=1; ctl_mWrite=1;
431
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
432
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
433
    if (M5 && T1) begin  fMWrite=1;
434
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
435
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Read 8-bit GP register high byte */
436
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
437
                    ctl_sw_2u=1;
438
                    ctl_sw_1u=1;
439
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
440
    if (M5 && T2) begin  fMWrite=1;
441
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
442
                    ctl_inc_cy=pc_inc; /* Increment */
443
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
444
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
445
end
446
 
447
if (pla[30] && !pla[13]) begin
448
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
449
    if (M2 && T1) begin  fMRead=1;
450
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
451
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
452
    if (M2 && T2) begin  fMRead=1;
453
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
454
                    ctl_inc_cy=pc_inc; /* Increment */
455
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
456
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
457
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
458
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
459
                    ctl_sw_2d=1;
460
                    ctl_sw_1d=1;
461
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
462
    if (M3 && T1) begin  fMRead=1;
463
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
464
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
465
    if (M3 && T2) begin  fMRead=1;
466
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
467
                    ctl_inc_cy=pc_inc; /* Increment */
468
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
469
    if (M3 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
470
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
471
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
472
                    ctl_sw_2d=1;
473
                    ctl_sw_1d=1;
474
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
475
    if (M4 && T1) begin  fMRead=1;
476
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
477
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
478
    if (M4 && T2) begin  fMRead=1;
479
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
480
                    ctl_inc_cy=pc_inc; /* Increment */
481
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
482
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
483
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Write 8-bit GP register low byte */
484
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
485
                    ctl_sw_2d=1;
486
                    ctl_sw_1d=1;
487
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
488
    if (M5 && T1) begin  fMRead=1;
489
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
490
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
491
    if (M5 && T2) begin  fMRead=1;
492
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
493
                    ctl_inc_cy=pc_inc; /* Increment */
494
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
495
    if (M5 && T3) begin  fMRead=1; nextM=1; setM1=1;
496
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Write 8-bit GP register high byte */
497
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
498
                    ctl_sw_2d=1;
499
                    ctl_sw_1d=1;
500
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
501
end
502
 
503
if (pla[31] && pla[33]) begin
504
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
505
    if (M2 && T1) begin  fMRead=1;
506
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
507
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
508
    if (M2 && T2) begin  fMRead=1;
509
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
510
                    ctl_inc_cy=pc_inc; /* Increment */
511
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
512
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
513
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
514
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
515
                    ctl_sw_2d=1;
516
                    ctl_sw_1d=1;
517
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
518
    if (M3 && T1) begin  fMRead=1;
519
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
520
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
521
    if (M3 && T2) begin  fMRead=1;
522
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
523
                    ctl_inc_cy=pc_inc; /* Increment */
524
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
525
    if (M3 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
526
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
527
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
528
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
529
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
530
                    ctl_sw_2d=1;
531
                    ctl_sw_1d=1;
532
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
533
    if (M4 && T1) begin  fMWrite=1;
534
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
535
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Read 8-bit GP register low byte */
536
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
537
                    ctl_sw_2u=1;
538
                    ctl_sw_1u=1;
539
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
540
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
541
    if (M4 && T2) begin  fMWrite=1;
542
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
543
                    ctl_inc_cy=pc_inc; /* Increment */
544
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
545
    if (M4 && T3) begin  fMWrite=1; nextM=1; ctl_mWrite=1;
546
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
547
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
548
    if (M5 && T1) begin  fMWrite=1;
549
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
550
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Read 8-bit GP register high byte */
551
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
552
                    ctl_sw_2u=1;
553
                    ctl_sw_1u=1;
554
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
555
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
556
    if (M5 && T2) begin  fMWrite=1;
557
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
558
                    ctl_inc_cy=pc_inc; /* Increment */
559
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
560
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
561
end
562
 
563
if (pla[31] && !pla[33]) begin
564
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
565
    if (M2 && T1) begin  fMRead=1;
566
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
567
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
568
    if (M2 && T2) begin  fMRead=1;
569
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
570
                    ctl_inc_cy=pc_inc; /* Increment */
571
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
572
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
573
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
574
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
575
                    ctl_sw_2d=1;
576
                    ctl_sw_1d=1;
577
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
578
    if (M3 && T1) begin  fMRead=1;
579
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
580
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
581
    if (M3 && T2) begin  fMRead=1;
582
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
583
                    ctl_inc_cy=pc_inc; /* Increment */
584
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
585
    if (M3 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
586
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
587
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
588
                    ctl_sw_2d=1;
589
                    ctl_sw_1d=1;
590
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
591
    if (M4 && T1) begin  fMRead=1;
592
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
593
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
594
    if (M4 && T2) begin  fMRead=1;
595
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
596
                    ctl_inc_cy=pc_inc; /* Increment */
597
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
598
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
599
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Write 8-bit GP register low byte */
600
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
601
                    ctl_sw_2d=1;
602
                    ctl_sw_1d=1;
603
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
604
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
605
    if (M5 && T1) begin  fMRead=1;
606
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
607
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
608
    if (M5 && T2) begin  fMRead=1;
609
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
610
                    ctl_inc_cy=pc_inc; /* Increment */
611
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
612
    if (M5 && T3) begin  fMRead=1; nextM=1; setM1=1;
613
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Write 8-bit GP register high byte */
614
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
615
                    ctl_sw_2d=1;
616
                    ctl_sw_1d=1;
617
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
618
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
619
end
620
 
621
if (pla[5]) begin
622
    if (M1 && T4) begin  validPLA=1;
623
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
624
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
625
    if (M1 && T5) begin
626
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
627
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
628
    if (M1 && T6) begin  nextM=1; setM1=1; end
629
end
630
 
631
if (pla[23] && pla[16]) begin
632
    if (M1 && T4) begin  validPLA=1; end
633
    if (M1 && T5) begin  nextM=1; ctl_mWrite=1;
634
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
635
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
636
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
637
    if (M2 && T1) begin  fMWrite=1;
638
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
639
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
640
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Read 8-bit GP register high byte */
641
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
642
                    ctl_sw_2u=1;
643
                    ctl_sw_1u=1;
644
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
645
    if (M2 && T2) begin  fMWrite=1;
646
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
647
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
648
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
649
    if (M2 && T3) begin  fMWrite=1; nextM=1; ctl_mWrite=1;
650
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
651
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
652
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
653
    if (M3 && T1) begin  fMWrite=1;
654
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
655
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
656
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Read 8-bit GP register low byte */
657
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
658
                    ctl_sw_2u=1;
659
                    ctl_sw_1u=1;
660
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
661
    if (M3 && T2) begin  fMWrite=1;
662
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
663
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
664
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
665
    if (M3 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
666
end
667
 
668
if (pla[23] && !pla[16]) begin
669
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
670
    if (M2 && T1) begin  fMRead=1;
671
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
672
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
673
    if (M2 && T2) begin  fMRead=1;
674
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
675
                    ctl_inc_cy=pc_inc; /* Increment */
676
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
677
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
678
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Write 8-bit GP register low byte */
679
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
680
                    ctl_sw_2d=1;
681
                    ctl_sw_1d=1;
682
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
683
    if (M3 && T1) begin  fMRead=1;
684
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
685
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
686
    if (M3 && T2) begin  fMRead=1;
687
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
688
                    ctl_inc_cy=pc_inc; /* Increment */
689
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
690
    if (M3 && T3) begin  fMRead=1; nextM=1; setM1=1;
691
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Write 8-bit GP register high byte */
692
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
693
                    ctl_sw_2d=1;
694
                    ctl_sw_1d=1;
695
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
696
end
697
 
698
// Exchange, Block Transfer and Search Groups
699
if (pla[2]) begin
700
    if (M1 && T2) begin
701
                    ctl_reg_ex_de_hl=1; /* EX DE,HL */ end
702
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1; end
703
end
704
 
705
if (pla[39]) begin
706
    if (M1 && T2) begin
707
                    ctl_reg_ex_af=1; /* EX AF,AF' */ end
708
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1; end
709
end
710
 
711
if (pla[1]) begin
712
    if (M1 && T2) begin
713
                    ctl_reg_exx=1; /* EXX */ end
714
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1; end
715
end
716
 
717
if (pla[10]) begin
718
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
719
    if (M2 && T1) begin  fMRead=1;
720
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
721
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
722
    if (M2 && T2) begin  fMRead=1;
723
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
724
                    ctl_inc_cy=pc_inc; /* Increment */
725
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
726
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
727
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
728
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
729
                    ctl_sw_2d=1;
730
                    ctl_sw_1d=1;
731
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
732
    if (M3 && T1) begin  fMRead=1;
733
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
734
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
735
    if (M3 && T2) begin  fMRead=1;
736
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
737
                    ctl_inc_cy=pc_inc; /* Increment */
738
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
739
    if (M3 && T3) begin  fMRead=1;
740
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
741
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
742
                    ctl_sw_2d=1;
743
                    ctl_sw_1d=1;
744
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
745
    if (M3 && T4) begin  nextM=1; ctl_mWrite=1;
746
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
747
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
748
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
749
    if (M4 && T1) begin  fMWrite=1;
750
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
751
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
752
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Read 8-bit GP register high byte */
753
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
754
                    ctl_sw_2u=1;
755
                    ctl_sw_1u=1;
756
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
757
    if (M4 && T2) begin  fMWrite=1;
758
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
759
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
760
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
761
    if (M4 && T3) begin  fMWrite=1; nextM=1; ctl_mWrite=1;
762
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
763
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
764
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
765
    if (M5 && T1) begin  fMWrite=1;
766
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
767
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
768
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Read 8-bit GP register low byte */
769
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
770
                    ctl_sw_2u=1;
771
                    ctl_sw_1u=1;
772
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
773
    if (M5 && T2) begin  fMWrite=1;
774
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
775
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
776
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
777
    if (M5 && T3) begin  fMWrite=1;
778
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
779
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
780
    if (M5 && T4) begin
781
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit HL, enable SW4 upstream */
782
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
783
    if (M5 && T5) begin  nextM=1; setM1=1; end
784
end
785
 
786
if (pla[0]) begin
787
    begin  nonRep=1; /* Non-repeating block instruction */ end
788
end
789
 
790
if (pla[12]) begin
791
    if (M1 && T1) begin
792
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
793
                    ctl_alu_res_oe=1; /* Result latch */
794
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
795
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
796
                    ctl_flags_xy_we=1;
797
                    ctl_flags_hf_we=1;
798
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_REP;
799
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
800
                    ctl_flags_use_cf2=1; end
801
    if (M1 && T2) begin
802
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
803
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
804
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
805
    if (M1 && T3) begin
806
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
807
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
808
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
809
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
810
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
811
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
812
                    ctl_flags_sz_we=1;
813
                    ctl_flags_xy_we=1;
814
                    ctl_flags_hf_we=1;
815
                    ctl_flags_pf_we=1;
816
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
817
                    ctl_flags_cf_we=1; end
818
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
819
    if (M2 && T1) begin  fMRead=1;
820
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
821
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
822
    if (M2 && T2) begin  fMRead=1;
823
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit HL, enable SW4 upstream */
824
                    ctl_inc_cy=pc_inc; ctl_inc_dec=op3; /* Decrement if op3 is set; increment otherwise */
825
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
826
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
827
                    ctl_sw_2d=1;
828
                    ctl_sw_1d=1;
829
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
830
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
831
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
832
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
833
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
834
 
835
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
836
    if (ctl_alu_op_low) begin
837
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
838
    end else begin
839
        ctl_alu_core_hf=1;
840
    end
841
                    ctl_flags_hf_we=1;
842
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=0; end
843
    if (M3 && T1) begin  fMWrite=1;
844
                    ctl_reg_gp_sel=`GP_REG_DE; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit DE, enable SW4 downstream */
845
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
846
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
847
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
848
                    ctl_alu_res_oe=1; /* Result latch */
849
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
850
 
851
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
852
    if (ctl_alu_op_low) begin
853
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
854
    end else begin
855
        ctl_alu_core_hf=1;
856
    end
857
                    ctl_flags_use_cf2=1; end
858
    if (M3 && T2) begin  fMWrite=1;
859
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_DE; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit BC, enable SW4 upstream */
860
                    ctl_inc_cy=pc_inc; ctl_inc_dec=op3; /* Decrement if op3 is set; increment otherwise */
861
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
862
    if (M3 && T3) begin  fMWrite=1;
863
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit BC, enable SW4 downstream */
864
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
865
    if (M3 && T4) begin
866
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit BC, enable SW4 upstream */
867
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
868
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
869
                    ctl_repeat_we=1; /* Update repeating flag latch with BC=1 status */ end
870
    if (M3 && T5) begin  nextM=1; setM1=nonRep | !repeat_en; end
871
    if (M4 && T1) begin
872
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
873
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
874
    if (M4 && T2) begin
875
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
876
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
877
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
878
    if (M4 && T3) begin
879
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
880
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
881
    if (M4 && T4) begin
882
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
883
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
884
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
885
    if (M4 && T5) begin  nextM=1; setM1=1; end
886
end
887
 
888
if (pla[11]) begin
889
    if (M1 && T1) begin
890
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
891
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
892
                    ctl_alu_res_oe=1; /* Result latch */
893
                    ctl_alu_op1_sel_zero=1; /* Zero */
894
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
895
 
896
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
897
    if (ctl_alu_op_low) begin
898
                                                              ctl_flags_cf_set=1;
899
    end else begin
900
        ctl_alu_core_hf=1;
901
    end
902
                    ctl_flags_xy_we=1;
903
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_REP;
904
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
905
                    ctl_flags_use_cf2=1; end
906
    if (M1 && T2) begin
907
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
908
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
909
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
910
                    ctl_flags_hf_cpl=flags_nf; end
911
    if (M1 && T3) begin
912
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
913
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
914
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
915
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
916
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
917
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
918
                    ctl_flags_sz_we=1;
919
                    ctl_flags_xy_we=1;
920
                    ctl_flags_hf_we=1;
921
                    ctl_flags_pf_we=1;
922
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
923
                    ctl_flags_cf_we=1; end
924
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
925
    if (M2 && T1) begin  fMRead=1;
926
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
927
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
928
    if (M2 && T2) begin  fMRead=1;
929
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit HL, enable SW4 upstream */
930
                    ctl_inc_cy=pc_inc; ctl_inc_dec=op3; /* Decrement if op3 is set; increment otherwise */
931
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
932
    if (M2 && T3) begin  fMRead=1; nextM=1;
933
                    ctl_sw_2d=1;
934
                    ctl_sw_1d=1;
935
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
936
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
937
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
938
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
939
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
940
 
941
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
942
    if (ctl_alu_op_low) begin
943
                                                              ctl_flags_cf_set=1;
944
    end else begin
945
        ctl_alu_core_hf=1;
946
    end
947
                    ctl_flags_hf_we=1;
948
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=0; end
949
    if (M3 && T1) begin
950
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
951
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
952
                    ctl_alu_res_oe=1; /* Result latch */
953
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
954
 
955
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
956
    if (ctl_alu_op_low) begin
957
                                                              ctl_flags_cf_set=1;
958
    end else begin
959
        ctl_alu_core_hf=1;
960
    end
961
                    ctl_flags_sz_we=1;
962
                    ctl_flags_use_cf2=1; end
963
    if (M3 && T3) begin
964
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit BC, enable SW4 downstream */
965
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
966
    if (M3 && T4) begin
967
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit BC, enable SW4 upstream */
968
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
969
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
970
                    ctl_repeat_we=1; /* Update repeating flag latch with BC=1 status */ end
971
    if (M3 && T5) begin  nextM=1; setM1=nonRep | !repeat_en | flags_zf; end
972
    if (M4 && T1) begin
973
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
974
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
975
    if (M4 && T2) begin
976
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
977
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
978
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
979
    if (M4 && T3) begin
980
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
981
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
982
    if (M4 && T4) begin
983
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
984
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
985
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
986
    if (M4 && T5) begin  nextM=1; setM1=1; end
987
end
988
 
989
// 8-bit Arithmetic and Logic Group
990
if (pla[65] && !pla[52]) begin
991
    if (M1 && T1) begin  /* Which register to be written is decided elsewhere */
992
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
993
                    ctl_sw_2u=1;
994
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
995
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
996
                    ctl_alu_res_oe=1; /* Result latch */
997
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
998
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
999
                    ctl_flags_sz_we=1;
1000
                    ctl_flags_cf_we=1; end
1001
    if (M1 && T2) begin
1002
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1003
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1004
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1005
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1006
                    ctl_flags_hf_cpl=flags_nf; ctl_flags_cf_cpl=flags_nf; end
1007
    if (M1 && T3) begin
1008
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1009
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1010
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1011
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1012
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1013
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1014
                    ctl_flags_sz_we=1;
1015
                    ctl_flags_xy_we=1;
1016
                    ctl_flags_hf_we=1;
1017
                    ctl_flags_pf_we=1;
1018
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1019
                    ctl_flags_cf_we=1; end
1020
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
1021
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
1022
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1023
                    ctl_sw_2d=1;
1024
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1025
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1026
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1027
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1028
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1029
                    ctl_flags_sz_we=1;
1030
                    ctl_flags_xy_we=1;
1031
                    ctl_flags_hf_we=1; end
1032
end
1033
 
1034
if (pla[64]) begin
1035
    if (M1 && T1) begin  /* Which register to be written is decided elsewhere */
1036
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1037
                    ctl_sw_2u=1;
1038
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1039
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1040
                    ctl_alu_res_oe=1; /* Result latch */
1041
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1042
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1043
                    ctl_flags_sz_we=1;
1044
                    ctl_flags_cf_we=1; end
1045
    if (M1 && T2) begin
1046
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1047
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1048
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1049
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1050
                    ctl_flags_hf_cpl=flags_nf; ctl_flags_cf_cpl=flags_nf; end
1051
    if (M1 && T3) begin
1052
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1053
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1054
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1055
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1056
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1057
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1058
                    ctl_flags_sz_we=1;
1059
                    ctl_flags_xy_we=1;
1060
                    ctl_flags_hf_we=1;
1061
                    ctl_flags_pf_we=1;
1062
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1063
                    ctl_flags_cf_we=1; end
1064
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1;
1065
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
1066
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1067
                    ctl_sw_2d=1;
1068
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1069
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1070
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1071
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1072
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1073
                    ctl_flags_sz_we=1;
1074
                    ctl_flags_xy_we=1;
1075
                    ctl_flags_hf_we=1; end
1076
    if (M2 && T1) begin  fMRead=1;
1077
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
1078
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
1079
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */ end
1080
    if (M2 && T2) begin  fMRead=1;
1081
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
1082
                    ctl_inc_cy=pc_inc; /* Increment */
1083
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1084
    if (M2 && T3) begin  fMRead=1; nextM=1; setM1=1;
1085
                    ctl_sw_2d=1;
1086
                    ctl_sw_1d=1;
1087
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
1088
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1089
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1090
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1091
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1092
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1093
                    ctl_flags_sz_we=1;
1094
                    ctl_flags_xy_we=1;
1095
                    ctl_flags_hf_we=1; end
1096
end
1097
 
1098
if (use_ixiy && pla[52]) begin
1099
    if (M1 && T3) begin
1100
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1101
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1102
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1103
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1104
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1105
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1106
                    ctl_flags_sz_we=1;
1107
                    ctl_flags_xy_we=1;
1108
                    ctl_flags_hf_we=1;
1109
                    ctl_flags_pf_we=1;
1110
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1111
                    ctl_flags_cf_we=1; end
1112
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
1113
    if (M2 && T1) begin  fMRead=1;
1114
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
1115
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
1116
    if (M2 && T2) begin  fMRead=1;
1117
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
1118
                    ctl_inc_cy=pc_inc; /* Increment */
1119
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1120
    if (M2 && T3) begin  fMRead=1; nextM=1; end
1121
    if (M3 && T1) begin  ixy_d=1; /* Compute WZ=IX+d */ end
1122
    if (M3 && T2) begin  ixy_d=1; /* Compute WZ=IX+d */ end
1123
    if (M3 && T3) begin  ixy_d=1; /* Compute WZ=IX+d */ end
1124
    if (M3 && T4) begin  ixy_d=1; /* Compute WZ=IX+d */ end
1125
    if (M3 && T5) begin  nextM=1; ctl_mRead=1; ixy_d=1; /* Compute WZ=IX+d */ end
1126
end
1127
 
1128
if (!use_ixiy && pla[52]) begin
1129
    if (M1 && T1) begin  /* Which register to be written is decided elsewhere */
1130
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1131
                    ctl_sw_2u=1;
1132
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1133
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1134
                    ctl_alu_res_oe=1; /* Result latch */
1135
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1136
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1137
                    ctl_flags_sz_we=1;
1138
                    ctl_flags_cf_we=1; end
1139
    if (M1 && T2) begin
1140
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1141
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1142
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1143
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1144
                    ctl_flags_hf_cpl=flags_nf; ctl_flags_cf_cpl=flags_nf; end
1145
    if (M1 && T3) begin
1146
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1147
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1148
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1149
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1150
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1151
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1152
                    ctl_flags_sz_we=1;
1153
                    ctl_flags_xy_we=1;
1154
                    ctl_flags_hf_we=1;
1155
                    ctl_flags_pf_we=1;
1156
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1157
                    ctl_flags_cf_we=1; end
1158
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
1159
    if (M2 && T1) begin  fMRead=1;
1160
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
1161
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
1162
    if (M2 && T2) begin  fMRead=1;
1163
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
1164
                    ctl_inc_cy=pc_inc; /* Increment */
1165
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1166
    if (M2 && T3) begin  fMRead=1; nextM=1; setM1=1;
1167
                    ctl_sw_2d=1;
1168
                    ctl_sw_1d=1;
1169
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
1170
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1171
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1172
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1173
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1174
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1175
                    ctl_flags_sz_we=1;
1176
                    ctl_flags_xy_we=1;
1177
                    ctl_flags_hf_we=1; end
1178
    if (M4 && T1) begin  fMRead=1;
1179
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1180
    if (M4 && T2) begin  fMRead=1;
1181
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1182
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1183
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1184
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1185
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1186
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1187
                    ctl_flags_sz_we=1;
1188
                    ctl_flags_xy_we=1;
1189
                    ctl_flags_hf_we=1;
1190
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1191
                    ctl_flags_cf_we=1; end
1192
    if (M4 && T3) begin  fMRead=1; nextM=1; setM1=1;
1193
                    ctl_sw_2d=1;
1194
                    ctl_sw_1d=1;
1195
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
1196
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1197
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1198
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1199
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1200
                    ctl_state_alu=1; /* Assert the ALU PLA modifier to determine operation */
1201
                    ctl_flags_sz_we=1;
1202
                    ctl_flags_xy_we=1;
1203
                    ctl_flags_hf_we=1; end
1204
end
1205
 
1206
if (pla[66] && !pla[53]) begin
1207
    if (M1 && T1) begin
1208
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo={!rsel3,rsel3}; /* Write 8-bit GP register */
1209
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1210
                    ctl_sw_2u=1;
1211
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1212
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1213
                    ctl_alu_res_oe=1; /* Result latch */
1214
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1215
 
1216
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1217
    if (!ctl_alu_op_low) begin
1218
        ctl_alu_core_hf=1;
1219
    end
1220
                    ctl_flags_sz_we=1;
1221
                    ctl_flags_xy_we=1;
1222
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V;
1223
                    ctl_flags_use_cf2=1; end
1224
    if (M1 && T2) begin
1225
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1226
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1227
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1228
                    ctl_flags_hf_cpl=flags_nf; end
1229
    if (M1 && T3) begin
1230
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1231
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1232
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1233
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1234
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1235
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1236
                    ctl_flags_sz_we=1;
1237
                    ctl_flags_xy_we=1;
1238
                    ctl_flags_hf_we=1;
1239
                    ctl_flags_pf_we=1;
1240
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1241
                    ctl_flags_cf_we=1; end
1242
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
1243
    if (op4 & op5 & !op3) ctl_bus_zero_oe=1;                /* Trying to read flags? Put 0 on the bus instead. */
1244
    else begin ctl_reg_gp_sel=op54; ctl_reg_gp_hilo={!rsel3,rsel3}; end /* Read 8-bit GP register */
1245
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1246
                    ctl_sw_2d=1;
1247
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1248
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1249
                    ctl_alu_op2_sel_zero=1; /* Zero */
1250
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1251
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1252
 
1253
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1254
    if (!ctl_alu_op_low) begin
1255
        ctl_alu_core_hf=1;
1256
    end
1257
                    ctl_flags_sz_we=1;
1258
                    ctl_flags_xy_we=1;
1259
                    ctl_flags_hf_we=1;
1260
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
1261
                    ctl_flags_cf_set=1; /* Set CF going into the ALU core */
1262
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=0; end
1263
end
1264
 
1265
if (pla[75]) begin
1266
    if (M1 && T1) begin
1267
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
1268
                    ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; /* Clear CF going into the ALU core */
1269
                    ctl_alu_sel_op2_neg=1; end
1270
    if (M1 && T4) begin
1271
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
1272
                    ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; /* Clear CF going into the ALU core */
1273
                    ctl_alu_sel_op2_neg=1; end
1274
end
1275
 
1276
if ((M2 || M4) && pla[75]) begin
1277
    begin
1278
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
1279
                    ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; /* Clear CF going into the ALU core */
1280
                    ctl_alu_sel_op2_neg=1; end
1281
end
1282
 
1283
if (use_ixiy && pla[53]) begin
1284
    if (M1 && T3) begin
1285
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1286
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1287
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1288
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1289
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1290
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1291
                    ctl_flags_sz_we=1;
1292
                    ctl_flags_xy_we=1;
1293
                    ctl_flags_hf_we=1;
1294
                    ctl_flags_pf_we=1;
1295
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1296
                    ctl_flags_cf_we=1; end
1297
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
1298
    if (M2 && T1) begin  fMRead=1;
1299
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
1300
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
1301
    if (M2 && T2) begin  fMRead=1;
1302
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
1303
                    ctl_inc_cy=pc_inc; /* Increment */
1304
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1305
    if (M2 && T3) begin  fMRead=1; nextM=1; end
1306
    if (M3 && T1) begin  ixy_d=1; /* Compute WZ=IX+d */ end
1307
    if (M3 && T2) begin  ixy_d=1; /* Compute WZ=IX+d */ end
1308
    if (M3 && T3) begin  ixy_d=1; /* Compute WZ=IX+d */ end
1309
    if (M3 && T4) begin  ixy_d=1; /* Compute WZ=IX+d */ end
1310
    if (M3 && T5) begin  nextM=1; ctl_mRead=1; ixy_d=1; /* Compute WZ=IX+d */ end
1311
end
1312
 
1313
if (!use_ixiy && pla[53]) begin
1314
    if (M1 && T2) begin
1315
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1316
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1317
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1318
                    ctl_flags_hf_cpl=flags_nf; end
1319
    if (M1 && T3) begin
1320
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1321
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1322
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1323
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1324
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1325
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1326
                    ctl_flags_sz_we=1;
1327
                    ctl_flags_xy_we=1;
1328
                    ctl_flags_hf_we=1;
1329
                    ctl_flags_pf_we=1;
1330
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1331
                    ctl_flags_cf_we=1; end
1332
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
1333
    if (M2 && T1) begin  fMRead=1;
1334
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
1335
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
1336
    if (M2 && T2) begin  fMRead=1; end
1337
    if (M2 && T3) begin  fMRead=1;
1338
                    ctl_sw_2d=1;
1339
                    ctl_sw_1d=1;
1340
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
1341
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1342
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1343
                    ctl_alu_op2_sel_zero=1; /* Zero */
1344
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1345
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1346
 
1347
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1348
    if (!ctl_alu_op_low) begin
1349
        ctl_alu_core_hf=1;
1350
    end
1351
                    ctl_flags_hf_we=1;
1352
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
1353
                    ctl_flags_cf_set=1; /* Set CF going into the ALU core */
1354
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=0; end
1355
    if (M2 && T4) begin  nextM=1; ctl_mWrite=1;
1356
                    ctl_sw_2u=1;
1357
                    ctl_sw_1u=1;
1358
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
1359
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1360
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1361
                    ctl_alu_res_oe=1; /* Result latch */
1362
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1363
 
1364
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1365
    if (!ctl_alu_op_low) begin
1366
        ctl_alu_core_hf=1;
1367
    end
1368
                    ctl_flags_sz_we=1;
1369
                    ctl_flags_xy_we=1;
1370
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V;
1371
                    ctl_flags_use_cf2=1; end
1372
    if (M3 && T1) begin  fMWrite=1;
1373
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1374
    if (M3 && T2) begin  fMWrite=1; end
1375
    if (M3 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
1376
    if (M4 && T1) begin  fMRead=1;
1377
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1378
    if (M4 && T2) begin  fMRead=1; end
1379
    if (M4 && T3) begin  fMRead=1;
1380
                    ctl_sw_2d=1;
1381
                    ctl_sw_1d=1;
1382
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
1383
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1384
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1385
                    ctl_alu_op2_sel_zero=1; /* Zero */
1386
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1387
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1388
 
1389
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1390
    if (!ctl_alu_op_low) begin
1391
        ctl_alu_core_hf=1;
1392
    end
1393
                    ctl_flags_hf_we=1;
1394
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
1395
                    ctl_flags_cf_set=1; /* Set CF going into the ALU core */
1396
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=0; end
1397
    if (M4 && T4) begin  nextM=1; ctl_mWrite=1;
1398
                    ctl_sw_2u=1;
1399
                    ctl_sw_1u=1;
1400
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
1401
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1402
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1403
                    ctl_alu_res_oe=1; /* Result latch */
1404
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1405
 
1406
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1407
    if (!ctl_alu_op_low) begin
1408
        ctl_alu_core_hf=1;
1409
    end
1410
                    ctl_flags_sz_we=1;
1411
                    ctl_flags_xy_we=1;
1412
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V;
1413
                    ctl_flags_use_cf2=1; end
1414
    if (M5 && T1) begin  fMWrite=1;
1415
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1416
    if (M5 && T2) begin  fMWrite=1; end
1417
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
1418
end
1419
 
1420
// 16-bit Arithmetic Group
1421
if (pla[69]) begin
1422
    if (M1 && T2) begin
1423
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1424
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1425
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
1426
    if (M1 && T3) begin
1427
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1428
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1429
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1430
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1431
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1432
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1433
                    ctl_flags_sz_we=1;
1434
                    ctl_flags_xy_we=1;
1435
                    ctl_flags_hf_we=1;
1436
                    ctl_flags_pf_we=1;
1437
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
1438
                    ctl_flags_cf_we=1; end
1439
    if (M1 && T4) begin  validPLA=1; nextM=1;
1440
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b01;
1441
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1442
                    ctl_sw_2d=1;
1443
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1444
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
1445
    if (M2 && T1) begin
1446
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Read 8-bit GP register low byte */
1447
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1448
                    ctl_sw_2d=1;
1449
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1450
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1451
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1452
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1453
 
1454
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1455
    if (ctl_alu_op_low) begin
1456
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
1457
    end else begin
1458
        ctl_alu_core_hf=1;
1459
    end
1460
                    ctl_flags_hf_we=1;
1461
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
1462
    if (M2 && T2) begin
1463
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
1464
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
1465
                    ctl_sw_2u=1;
1466
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1467
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1468
                    ctl_alu_res_oe=1; /* Result latch */
1469
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1470
 
1471
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1472
    if (!ctl_alu_op_low) begin
1473
        ctl_alu_core_hf=1;
1474
    end
1475
                    ctl_flags_xy_we=1;
1476
                    ctl_flags_cf_we=1; end
1477
    if (M2 && T3) begin
1478
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b10;
1479
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1480
                    ctl_sw_2d=1;
1481
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1482
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
1483
    if (M2 && T4) begin  nextM=1;
1484
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Read 8-bit GP register high byte */
1485
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1486
                    ctl_sw_2d=1;
1487
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1488
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1489
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1490
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1491
 
1492
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1493
    if (!ctl_alu_op_low) begin
1494
        ctl_alu_core_hf=1;
1495
    end
1496
                    ctl_flags_hf_we=1;
1497
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
1498
    if (M3 && T1) begin
1499
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
1500
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
1501
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
1502
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
1503
                    ctl_sw_2u=1;
1504
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1505
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1506
                    ctl_alu_res_oe=1; /* Result latch */
1507
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1508
 
1509
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1510
    if (!ctl_alu_op_low) begin
1511
        ctl_alu_core_hf=1;
1512
    end
1513
                    ctl_flags_xy_we=1;
1514
                    ctl_flags_cf_we=1; end
1515
    if (M3 && T2) begin
1516
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit HL, enable SW4 upstream */
1517
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1518
    if (M3 && T3) begin  nextM=1; setM1=1; end
1519
end
1520
 
1521
if (op3 && pla[68]) begin
1522
    if (M1 && T2) begin
1523
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1524
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1525
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
1526
    if (M1 && T3) begin
1527
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1528
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1529
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1530
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1531
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1532
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1533
                    ctl_flags_sz_we=1;
1534
                    ctl_flags_xy_we=1;
1535
                    ctl_flags_hf_we=1;
1536
                    ctl_flags_pf_we=1;
1537
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
1538
                    ctl_flags_cf_we=1; end
1539
    if (M1 && T4) begin  validPLA=1; nextM=1;
1540
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b01;
1541
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1542
                    ctl_sw_2d=1;
1543
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1544
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
1545
    if (M2 && T1) begin
1546
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Read 8-bit GP register low byte */
1547
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1548
                    ctl_sw_2d=1;
1549
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1550
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1551
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1552
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1553
 
1554
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1555
    if (!ctl_alu_op_low) begin
1556
        ctl_alu_core_hf=1;
1557
    end
1558
                    ctl_flags_hf_we=1;
1559
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
1560
    if (M2 && T2) begin
1561
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
1562
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
1563
                    ctl_sw_2u=1;
1564
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1565
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1566
                    ctl_alu_res_oe=1; /* Result latch */
1567
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1568
 
1569
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1570
    if (!ctl_alu_op_low) begin
1571
        ctl_alu_core_hf=1;
1572
    end
1573
                    ctl_flags_sz_we=1;
1574
                    ctl_flags_xy_we=1;
1575
                    ctl_flags_cf_we=1; end
1576
    if (M2 && T3) begin
1577
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b10;
1578
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1579
                    ctl_sw_2d=1;
1580
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1581
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
1582
    if (M2 && T4) begin  nextM=1;
1583
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Read 8-bit GP register high byte */
1584
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1585
                    ctl_sw_2d=1;
1586
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1587
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1588
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1589
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1590
 
1591
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1592
    if (!ctl_alu_op_low) begin
1593
        ctl_alu_core_hf=1;
1594
    end
1595
                    ctl_flags_hf_we=1;
1596
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
1597
    if (M3 && T1) begin
1598
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
1599
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
1600
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
1601
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
1602
                    ctl_sw_2u=1;
1603
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1604
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1605
                    ctl_alu_res_oe=1; /* Result latch */
1606
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1607
 
1608
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1609
    if (!ctl_alu_op_low) begin
1610
        ctl_alu_core_hf=1;
1611
    end
1612
                    ctl_flags_sz_we=1;
1613
                    ctl_flags_xy_we=1;
1614
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V;
1615
                    ctl_flags_cf_we=1;
1616
                    ctl_alu_zero_16bit=1; /* 16-bit arithmetic operation uses ZF calculated over 2 bytes */ end
1617
    if (M3 && T2) begin
1618
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit HL, enable SW4 upstream */
1619
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1620
    if (M3 && T3) begin  nextM=1; setM1=1; end
1621
end
1622
 
1623
if (!op3 && pla[68]) begin
1624
    if (M1 && T2) begin
1625
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1626
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1627
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1628
                    ctl_flags_hf_cpl=flags_nf; ctl_flags_cf_cpl=flags_nf; end
1629
    if (M1 && T3) begin
1630
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1631
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1632
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1633
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1634
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1635
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1636
                    ctl_flags_sz_we=1;
1637
                    ctl_flags_xy_we=1;
1638
                    ctl_flags_hf_we=1;
1639
                    ctl_flags_pf_we=1;
1640
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
1641
                    ctl_flags_cf_we=1; end
1642
    if (M1 && T4) begin  validPLA=1; nextM=1;
1643
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b01;
1644
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1645
                    ctl_sw_2d=1;
1646
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1647
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
1648
    if (M2 && T1) begin
1649
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b01; /* Read 8-bit GP register low byte */
1650
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1651
                    ctl_sw_2d=1;
1652
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1653
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1654
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1655
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1656
 
1657
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
1658
    if (ctl_alu_op_low) begin
1659
                                                                                  ctl_flags_cf_cpl=1;
1660
    end else begin
1661
        ctl_alu_core_hf=1;
1662
    end
1663
                    ctl_flags_hf_we=1;
1664
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
1665
    if (M2 && T2) begin
1666
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
1667
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
1668
                    ctl_sw_2u=1;
1669
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1670
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1671
                    ctl_alu_res_oe=1; /* Result latch */
1672
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1673
 
1674
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
1675
    if (ctl_alu_op_low) begin
1676
                                                                                  ctl_flags_cf_cpl=1;
1677
    end else begin
1678
        ctl_alu_core_hf=1;
1679
    end
1680
                    ctl_flags_sz_we=1;
1681
                    ctl_flags_xy_we=1;
1682
                    ctl_flags_cf_we=1; end
1683
    if (M2 && T3) begin
1684
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b10;
1685
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1686
                    ctl_sw_2d=1;
1687
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1688
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
1689
    if (M2 && T4) begin  nextM=1;
1690
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b10; /* Read 8-bit GP register high byte */
1691
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1692
                    ctl_sw_2d=1;
1693
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1694
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1695
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1696
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1697
 
1698
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
1699
    if (!ctl_alu_op_low) begin
1700
        ctl_alu_core_hf=1;
1701
    end
1702
                    ctl_flags_hf_we=1;
1703
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
1704
    if (M3 && T1) begin
1705
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
1706
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
1707
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
1708
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
1709
                    ctl_sw_2u=1;
1710
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1711
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1712
                    ctl_alu_res_oe=1; /* Result latch */
1713
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1714
 
1715
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
1716
    if (ctl_alu_op_low) begin
1717
                                                                                  ctl_flags_cf_cpl=1;
1718
    end else begin
1719
        ctl_alu_core_hf=1;
1720
    end
1721
                    ctl_flags_sz_we=1;
1722
                    ctl_flags_xy_we=1;
1723
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V;
1724
                    ctl_flags_cf_we=1;
1725
                    ctl_alu_zero_16bit=1; /* 16-bit arithmetic operation uses ZF calculated over 2 bytes */ end
1726
    if (M3 && T2) begin
1727
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit HL, enable SW4 upstream */
1728
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
1729
    if (M3 && T3) begin  nextM=1; setM1=1; end
1730
end
1731
 
1732
if (pla[9]) begin
1733
    if (M1 && T4) begin  validPLA=1;
1734
                    ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit general purpose register, enable SW4 downstream */
1735
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
1736
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
1737
    if (M1 && T5) begin
1738
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit general purpose register, enable SW4 upstream */
1739
                    ctl_inc_cy=pc_inc; ctl_inc_dec=op3; /* Decrement if op3 is set; increment otherwise */
1740
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
1741
                    ctl_reg_use_sp=1; /* For 16-bit loads: use SP instead of AF */ end
1742
    if (M1 && T6) begin  nextM=1; setM1=1; end
1743
end
1744
 
1745
// General Purpose Arithmetic and CPU Control Groups
1746
if (pla[77]) begin
1747
    if (M1 && T1) begin
1748
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
1749
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1750
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1751
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1752
                    ctl_alu_res_oe=1; /* Result latch */
1753
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1754
 
1755
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1756
    if (!ctl_alu_op_low) begin
1757
        ctl_alu_core_hf=1;
1758
    end
1759
                    ctl_flags_sz_we=1;
1760
                    ctl_flags_xy_we=1;
1761
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
1762
                    ctl_flags_cf_we=1;
1763
                    ctl_alu_sel_op2_neg=flags_nf; ctl_flags_cf_cpl=!flags_nf; end
1764
    if (M1 && T2) begin
1765
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1766
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1767
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1768
                    ctl_flags_use_cf2=1;
1769
                    ctl_flags_hf_cpl=flags_nf; end
1770
    if (M1 && T3) begin
1771
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1772
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1773
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1774
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1775
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1776
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1777
                    ctl_flags_sz_we=1;
1778
                    ctl_flags_xy_we=1;
1779
                    ctl_flags_hf2_we=1; /* Write HF2 flag (DAA only) */
1780
                    ctl_flags_pf_we=1;
1781
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1782
                    ctl_flags_cf_we=1; end
1783
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
1784
                    ctl_sw_2d=1;
1785
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1786
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1787
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1788
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1789
 
1790
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
1791
    if (!ctl_alu_op_low) begin
1792
        ctl_alu_core_hf=1;
1793
    end
1794
                    ctl_flags_sz_we=1;
1795
                    ctl_flags_xy_we=1;
1796
                    ctl_flags_hf_we=1;
1797
                    ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; /* Clear CF going into the ALU core */
1798
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=2;
1799
                    ctl_daa_oe=1; /* Write DAA correction factor to the bus */
1800
                    ctl_alu_sel_op2_neg=flags_nf; ctl_flags_cf_cpl=!flags_nf; end
1801
end
1802
 
1803
if (pla[81]) begin
1804
    if (M1 && T1) begin
1805
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
1806
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1807
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1808
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1809
                    ctl_alu_res_oe=1; /* Result latch */
1810
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1811
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
1812
                    ctl_flags_xy_we=1;
1813
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
1814
                    ctl_alu_sel_op2_neg=1; end
1815
    if (M1 && T2) begin
1816
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1817
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1818
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1819
                    ctl_flags_hf_cpl=flags_nf; end
1820
    if (M1 && T3) begin
1821
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1822
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1823
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1824
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1825
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1826
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1827
                    ctl_flags_sz_we=1;
1828
                    ctl_flags_xy_we=1;
1829
                    ctl_flags_hf_we=1;
1830
                    ctl_flags_pf_we=1;
1831
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1832
                    ctl_flags_cf_we=1; end
1833
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
1834
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1835
                    ctl_alu_op1_sel_zero=1; /* Zero */
1836
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1837
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
1838
                    ctl_flags_xy_we=1;
1839
                    ctl_flags_hf_we=1;
1840
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
1841
                    ctl_alu_sel_op2_neg=1; end
1842
end
1843
 
1844
if (pla[82]) begin
1845
    if (M1 && T1) begin
1846
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
1847
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1848
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1849
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1850
                    ctl_alu_res_oe=1; /* Result latch */
1851
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1852
 
1853
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
1854
    if (ctl_alu_op_low) begin
1855
                                                              ctl_flags_cf_set=1;
1856
    end else begin
1857
        ctl_alu_core_hf=1;
1858
    end
1859
                    ctl_flags_sz_we=1;
1860
                    ctl_flags_xy_we=1;
1861
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V;
1862
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
1863
                    ctl_flags_cf_we=1; end
1864
    if (M1 && T2) begin
1865
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1866
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1867
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1868
                    ctl_flags_hf_cpl=flags_nf; ctl_flags_cf_cpl=flags_nf; end
1869
    if (M1 && T3) begin
1870
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1871
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1872
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1873
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1874
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1875
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1876
                    ctl_flags_sz_we=1;
1877
                    ctl_flags_xy_we=1;
1878
                    ctl_flags_hf_we=1;
1879
                    ctl_flags_pf_we=1;
1880
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1881
                    ctl_flags_cf_we=1; end
1882
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
1883
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1884
                    ctl_alu_op1_sel_zero=1; /* Zero */
1885
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1886
 
1887
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
1888
    if (ctl_alu_op_low) begin
1889
                                                              ctl_flags_cf_set=1;
1890
    end else begin
1891
        ctl_alu_core_hf=1;
1892
    end
1893
                    ctl_flags_sz_we=1;
1894
                    ctl_flags_xy_we=1;
1895
                    ctl_flags_hf_we=1;
1896
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1;
1897
                    ctl_flags_cf_we=1; end
1898
end
1899
 
1900
if (pla[89]) begin
1901
    if (M1 && T1) begin
1902
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1903
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1904
                    ctl_alu_res_oe=1; /* Result latch */
1905
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1906
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
1907
                    ctl_flags_xy_we=1;
1908
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
1909
    if (M1 && T2) begin
1910
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1911
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1912
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1913
                    ctl_flags_cf_we=1; ctl_flags_cf_cpl=1; /* CCF */
1914
                    ctl_flags_hf_cpl=!flags_cf; /* Used for CCF */ end
1915
    if (M1 && T3) begin
1916
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1917
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1918
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1919
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1920
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1921
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1922
                    ctl_flags_sz_we=1;
1923
                    ctl_flags_xy_we=1;
1924
                    ctl_flags_hf_we=1;
1925
                    ctl_flags_pf_we=1;
1926
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1927
                    ctl_flags_cf_we=1; end
1928
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
1929
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1930
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1931
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
1932
                    ctl_flags_xy_we=1;
1933
                    ctl_flags_hf_we=1;
1934
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
1935
end
1936
 
1937
if (pla[92]) begin
1938
    if (M1 && T1) begin
1939
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1940
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
1941
                    ctl_alu_res_oe=1; /* Result latch */
1942
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
1943
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
1944
                    ctl_flags_xy_we=1;
1945
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
1946
    if (M1 && T2) begin
1947
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
1948
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1949
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
1950
                    ctl_flags_cf_set=1; /* Set CF going into the ALU core */ end
1951
    if (M1 && T3) begin
1952
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
1953
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
1954
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
1955
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
1956
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
1957
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
1958
                    ctl_flags_sz_we=1;
1959
                    ctl_flags_xy_we=1;
1960
                    ctl_flags_hf_we=1;
1961
                    ctl_flags_pf_we=1;
1962
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
1963
                    ctl_flags_cf_we=1; end
1964
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
1965
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
1966
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
1967
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
1968
                    ctl_flags_xy_we=1;
1969
                    ctl_flags_hf_we=1;
1970
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
1971
end
1972
 
1973
if (pla[95]) begin
1974
    if (M1 && T3) begin
1975
                    ctl_state_halt_set=1; /* Enter HALT state */ end
1976
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1; end
1977
end
1978
 
1979
if (pla[97]) begin
1980
    if (M1 && T3) begin
1981
                    ctl_iffx_bit=op3; ctl_iffx_we=1; /* DI/EI */ end
1982
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
1983
                    ctl_no_ints=1; /* Disable interrupt generation for this opcode (DI/EI/CB/ED/DD/FD) */ end
1984
end
1985
 
1986
if (pla[96]) begin
1987
    if (M1 && T3) begin
1988
                    ctl_sw_1d=1;
1989
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
1990
                    ctl_im_we=1; /* IM n ('n' is read by opcode[4:3]) */ end
1991
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1; end
1992
end
1993
 
1994
// Rotate and Shift Group
1995
if (pla[25]) begin
1996
    if (M1 && T1) begin
1997
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
1998
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
1999
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2000
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2001
                    ctl_alu_res_oe=1; /* Result latch */
2002
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2003
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2004
                    ctl_flags_xy_we=1;
2005
                    ctl_flags_hf_we=1;
2006
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2007
                    ctl_flags_cf_we=1; end
2008
    if (M1 && T2) begin
2009
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2010
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2011
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
2012
                    ctl_flags_use_cf2=1; end
2013
    if (M1 && T3) begin
2014
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2015
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2016
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2017
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2018
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2019
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2020
                    ctl_flags_sz_we=1;
2021
                    ctl_flags_xy_we=1;
2022
                    ctl_flags_hf_we=1;
2023
                    ctl_flags_pf_we=1;
2024
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2025
                    ctl_flags_cf_we=1; end
2026
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
2027
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
2028
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2029
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2030
                    ctl_alu_shift_oe=1; ctl_shift_en=1; /* Shifter unit AND shift enable! */
2031
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2032
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2033
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2034
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2035
                    ctl_flags_xy_we=1;
2036
                    ctl_flags_hf_we=1;
2037
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2038
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=1; end
2039
end
2040
 
2041
if (~use_ixiy && pla[70] && !pla[55]) begin
2042
    if (M1 && T1) begin
2043
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0}; /* Write 8-bit GP register selected by op[2:0] */
2044
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2045
                    ctl_sw_2u=1;
2046
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2047
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2048
                    ctl_alu_res_oe=1; /* Result latch */
2049
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2050
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2051
                    ctl_flags_sz_we=1;
2052
                    ctl_flags_xy_we=1;
2053
                    ctl_flags_hf_we=1;
2054
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2055
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2056
                    ctl_flags_cf_we=1; end
2057
    if (M1 && T2) begin
2058
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2059
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2060
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
2061
                    ctl_flags_use_cf2=1; end
2062
    if (M1 && T3) begin
2063
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2064
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2065
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2066
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2067
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2068
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2069
                    ctl_flags_sz_we=1;
2070
                    ctl_flags_xy_we=1;
2071
                    ctl_flags_hf_we=1;
2072
                    ctl_flags_pf_we=1;
2073
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2074
                    ctl_flags_cf_we=1; end
2075
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
2076
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
2077
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2078
                    ctl_sw_2d=1;
2079
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2080
                    ctl_alu_shift_oe=1; ctl_shift_en=1; /* Shifter unit AND shift enable! */
2081
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2082
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2083
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2084
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2085
                    ctl_flags_sz_we=1;
2086
                    ctl_flags_xy_we=1;
2087
                    ctl_flags_hf_we=1;
2088
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2089
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=1; end
2090
    if (M4 && T1) begin  fMRead=1;
2091
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
2092
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
2093
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2094
                    ctl_ir_we=1; end
2095
    if (M4 && T2) begin  fMRead=1; end
2096
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
2097
                    ctl_sw_2d=1;
2098
                    ctl_sw_1d=1;
2099
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2100
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2101
                    ctl_alu_shift_oe=1; ctl_shift_en=1; /* Shifter unit AND shift enable! */
2102
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2103
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2104
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2105
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2106
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2107
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=1; end
2108
    if (M5 && T1) begin  fMWrite=1;
2109
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2110
                    ctl_sw_2u=1;
2111
                    ctl_sw_1u=1;
2112
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2113
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2114
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2115
                    ctl_alu_res_oe=1; /* Result latch */
2116
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2117
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2118
                    ctl_flags_sz_we=1;
2119
                    ctl_flags_xy_we=1;
2120
                    ctl_flags_hf_we=1;
2121
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2122
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2123
                    ctl_flags_cf_we=1; end
2124
    if (M5 && T2) begin  fMWrite=1; end
2125
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2126
end
2127
 
2128
if (~use_ixiy && pla[70] && pla[55]) begin
2129
    if (M1 && T2) begin
2130
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2131
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2132
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */
2133
                    ctl_flags_use_cf2=1; end
2134
    if (M1 && T3) begin
2135
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2136
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2137
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2138
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2139
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2140
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2141
                    ctl_flags_sz_we=1;
2142
                    ctl_flags_xy_we=1;
2143
                    ctl_flags_hf_we=1;
2144
                    ctl_flags_pf_we=1;
2145
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2146
                    ctl_flags_cf_we=1; end
2147
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
2148
    if (M2 && T1) begin  fMRead=1;
2149
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
2150
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2151
    if (M2 && T2) begin  fMRead=1; end
2152
    if (M2 && T3) begin  fMRead=1; end
2153
    if (M2 && T4) begin  nextM=1; ctl_mWrite=1;
2154
                    ctl_sw_2d=1;
2155
                    ctl_sw_1d=1;
2156
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2157
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2158
                    ctl_alu_shift_oe=1; ctl_shift_en=1; /* Shifter unit AND shift enable! */
2159
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2160
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2161
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2162
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2163
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2164
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=1; end
2165
    if (M3 && T1) begin  fMWrite=1;
2166
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2167
                    ctl_sw_2u=1;
2168
                    ctl_sw_1u=1;
2169
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2170
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2171
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2172
                    ctl_alu_res_oe=1; /* Result latch */
2173
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2174
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2175
                    ctl_flags_sz_we=1;
2176
                    ctl_flags_xy_we=1;
2177
                    ctl_flags_hf_we=1;
2178
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2179
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2180
                    ctl_flags_cf_we=1; end
2181
    if (M3 && T2) begin  fMWrite=1; end
2182
    if (M3 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2183
    if (M4 && T1) begin  fMRead=1;
2184
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
2185
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
2186
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2187
                    ctl_ir_we=1; end
2188
    if (M4 && T2) begin  fMRead=1; end
2189
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
2190
                    ctl_sw_2d=1;
2191
                    ctl_sw_1d=1;
2192
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2193
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2194
                    ctl_alu_shift_oe=1; ctl_shift_en=1; /* Shifter unit AND shift enable! */
2195
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2196
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2197
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2198
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2199
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2200
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=1; end
2201
    if (M5 && T1) begin  fMWrite=1;
2202
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2203
                    ctl_sw_2u=1;
2204
                    ctl_sw_1u=1;
2205
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2206
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2207
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2208
                    ctl_alu_res_oe=1; /* Result latch */
2209
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2210
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2211
                    ctl_flags_sz_we=1;
2212
                    ctl_flags_xy_we=1;
2213
                    ctl_flags_hf_we=1;
2214
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2215
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1;
2216
                    ctl_flags_cf_we=1; end
2217
    if (M5 && T2) begin  fMWrite=1; end
2218
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2219
end
2220
 
2221
if (pla[15] && op3) begin
2222
    if (M1 && T1) begin
2223
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
2224
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2225
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2226
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2227
                    ctl_alu_res_oe=1; /* Result latch */
2228
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2229
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2230
                    ctl_flags_sz_we=1;
2231
                    ctl_flags_xy_we=1;
2232
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2233
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2234
    if (M1 && T2) begin
2235
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2236
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2237
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
2238
    if (M1 && T3) begin
2239
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2240
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2241
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2242
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2243
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2244
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2245
                    ctl_flags_sz_we=1;
2246
                    ctl_flags_xy_we=1;
2247
                    ctl_flags_hf_we=1;
2248
                    ctl_flags_pf_we=1;
2249
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2250
                    ctl_flags_cf_we=1; end
2251
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
2252
    if (M2 && T1) begin  fMRead=1;
2253
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
2254
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2255
    if (M2 && T2) begin  fMRead=1;
2256
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
2257
                    ctl_inc_cy=pc_inc; /* Increment */
2258
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
2259
    if (M2 && T3) begin  fMRead=1; nextM=1; end
2260
    if (M3 && T1) begin
2261
                    ctl_sw_2d=1;
2262
                    ctl_sw_1d=1;
2263
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2264
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2265
                    ctl_alu_op2_sel_lq=1; /* Cross-bus wire (see schematic) */
2266
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */ end
2267
    if (M3 && T4) begin  nextM=1; ctl_mWrite=1;
2268
                    ctl_sw_2d=1;
2269
                    ctl_sw_1d=1;
2270
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2271
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2272
                    ctl_alu_op1_sel_low=1; /* Write low nibble with a high nibble */
2273
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */ end
2274
    if (M4 && T1) begin  fMWrite=1;
2275
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2276
                    ctl_sw_2u=1;
2277
                    ctl_sw_1u=1;
2278
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2279
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2280
                    ctl_alu_op2_oe=1; /* OP2 latch */ end
2281
    if (M4 && T2) begin  fMWrite=1;
2282
                    ctl_alu_op1_oe=1; /* OP1 latch */
2283
                    ctl_alu_op2_sel_bus=1; /* Internal bus */ end
2284
    if (M4 && T3) begin  fMWrite=1; nextM=1; setM1=1;
2285
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2286
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2287
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2288
                    ctl_flags_sz_we=1;
2289
                    ctl_flags_xy_we=1;
2290
                    ctl_flags_hf_we=1;
2291
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2292
end
2293
 
2294
if (pla[15] && !op3) begin
2295
    if (M1 && T1) begin
2296
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
2297
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2298
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2299
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2300
                    ctl_alu_res_oe=1; /* Result latch */
2301
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2302
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2303
                    ctl_flags_sz_we=1;
2304
                    ctl_flags_xy_we=1;
2305
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2306
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2307
    if (M1 && T2) begin
2308
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2309
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2310
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
2311
    if (M1 && T3) begin
2312
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2313
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2314
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2315
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2316
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2317
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2318
                    ctl_flags_sz_we=1;
2319
                    ctl_flags_xy_we=1;
2320
                    ctl_flags_hf_we=1;
2321
                    ctl_flags_pf_we=1;
2322
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2323
                    ctl_flags_cf_we=1; end
2324
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
2325
    if (M2 && T1) begin  fMRead=1;
2326
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
2327
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2328
    if (M2 && T2) begin  fMRead=1;
2329
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit WZ, enable SW4 upstream */
2330
                    ctl_inc_cy=pc_inc; /* Increment */
2331
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
2332
    if (M2 && T3) begin  fMRead=1; nextM=1; end
2333
    if (M3 && T1) begin
2334
                    ctl_sw_2d=1;
2335
                    ctl_sw_1d=1;
2336
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2337
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2338
                    ctl_alu_op2_sel_lq=1; /* Cross-bus wire (see schematic) */
2339
                    ctl_alu_op1_sel_low=1; /* Write low nibble with a high nibble */
2340
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */ end
2341
    if (M3 && T2) begin
2342
                    ctl_sw_2u=1;
2343
                    ctl_sw_1u=1;
2344
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2345
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2346
                    ctl_alu_op2_oe=1; /* OP2 latch */ end
2347
    if (M3 && T3) begin
2348
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
2349
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2350
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2351
                    ctl_alu_op2_sel_lq=1; /* Cross-bus wire (see schematic) */
2352
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */ end
2353
    if (M3 && T4) begin  nextM=1; ctl_mWrite=1;
2354
                    ctl_sw_2d=1;
2355
                    ctl_sw_1d=1;
2356
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2357
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2358
                    ctl_alu_op1_sel_low=1; /* Write low nibble with a high nibble */
2359
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */ end
2360
    if (M4 && T1) begin  fMWrite=1;
2361
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2362
                    ctl_sw_2u=1;
2363
                    ctl_sw_1u=1;
2364
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2365
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2366
                    ctl_alu_op2_oe=1; /* OP2 latch */ end
2367
    if (M4 && T2) begin  fMWrite=1;
2368
                    ctl_alu_op1_oe=1; /* OP1 latch */
2369
                    ctl_alu_op2_sel_bus=1; /* Internal bus */ end
2370
    if (M4 && T3) begin  fMWrite=1; nextM=1; setM1=1;
2371
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2372
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2373
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2374
                    ctl_flags_sz_we=1;
2375
                    ctl_flags_xy_we=1;
2376
                    ctl_flags_hf_we=1;
2377
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2378
end
2379
 
2380
// Bit Manipulation Group
2381
if (~use_ixiy && pla[72] && !pla[55]) begin
2382
    if (M1 && T1) begin
2383
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2384
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2385
                    ctl_alu_res_oe=1; /* Result latch */
2386
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2387
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1;
2388
                    ctl_flags_sz_we=1;
2389
                    ctl_flags_hf_we=1;
2390
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2391
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2392
    if (M1 && T2) begin
2393
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2394
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2395
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
2396
    if (M1 && T3) begin
2397
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2398
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2399
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2400
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2401
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2402
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2403
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2404
                    ctl_flags_sz_we=1;
2405
                    ctl_flags_xy_we=1;
2406
                    ctl_flags_hf_we=1;
2407
                    ctl_flags_pf_we=1;
2408
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2409
                    ctl_flags_cf_we=1; end
2410
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
2411
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
2412
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2413
                    ctl_sw_2d=1;
2414
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2415
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2416
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2417
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2418
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1;
2419
                    ctl_flags_sz_we=1;
2420
                    ctl_flags_xy_we=1;
2421
                    ctl_flags_hf_we=1;
2422
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2423
    if (M4 && T1) begin  fMRead=1;
2424
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2425
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2426
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2427
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2428
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2429
                    ctl_ir_we=1; end
2430
    if (M4 && T2) begin  fMRead=1; end
2431
    if (M4 && T3) begin  fMRead=1; end
2432
    if (M4 && T4) begin  nextM=1; setM1=1;
2433
                    ctl_sw_2d=1;
2434
                    ctl_sw_1d=1;
2435
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2436
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2437
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2438
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2439
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2440
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1;
2441
                    ctl_flags_sz_we=1;
2442
                    ctl_flags_hf_we=1;
2443
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2444
end
2445
 
2446
if (~use_ixiy && pla[72] && pla[55]) begin
2447
    if (M1 && T1) begin
2448
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2449
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2450
                    ctl_alu_res_oe=1; /* Result latch */
2451
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2452
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1;
2453
                    ctl_flags_sz_we=1;
2454
                    ctl_flags_hf_we=1;
2455
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2456
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2457
    if (M1 && T2) begin
2458
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2459
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2460
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
2461
    if (M1 && T3) begin
2462
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2463
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2464
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2465
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2466
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2467
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2468
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2469
                    ctl_flags_sz_we=1;
2470
                    ctl_flags_xy_we=1;
2471
                    ctl_flags_hf_we=1;
2472
                    ctl_flags_pf_we=1;
2473
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2474
                    ctl_flags_cf_we=1; end
2475
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
2476
    if (M2 && T1) begin  fMRead=1;
2477
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
2478
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2479
    if (M2 && T2) begin  fMRead=1; end
2480
    if (M2 && T3) begin  fMRead=1;
2481
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4u=1;
2482
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2483
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2484
                    ctl_flags_xy_we=1; end
2485
    if (M2 && T4) begin  nextM=1; setM1=1;
2486
                    ctl_sw_2d=1;
2487
                    ctl_sw_1d=1;
2488
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2489
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2490
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2491
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2492
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2493
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1;
2494
                    ctl_flags_sz_we=1;
2495
                    ctl_flags_hf_we=1;
2496
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2497
    if (M4 && T1) begin  fMRead=1;
2498
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
2499
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
2500
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2501
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2502
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2503
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2504
                    ctl_ir_we=1; end
2505
    if (M4 && T2) begin  fMRead=1; end
2506
    if (M4 && T3) begin  fMRead=1; end
2507
    if (M4 && T4) begin  nextM=1; setM1=1;
2508
                    ctl_sw_2d=1;
2509
                    ctl_sw_1d=1;
2510
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2511
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2512
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2513
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2514
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2515
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1;
2516
                    ctl_flags_sz_we=1;
2517
                    ctl_flags_hf_we=1;
2518
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2519
end
2520
 
2521
if (~use_ixiy && pla[74] && !pla[55]) begin
2522
    if (M1 && T1) begin
2523
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0}; /* Write 8-bit GP register selected by op[2:0] */
2524
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2525
                    ctl_sw_2u=1;
2526
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2527
                    ctl_alu_res_oe=1; /* Result latch */
2528
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2529
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; end
2530
    if (M1 && T3) begin
2531
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2532
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2533
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2534
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2535
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2536
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2537
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2538
                    ctl_flags_sz_we=1;
2539
                    ctl_flags_xy_we=1;
2540
                    ctl_flags_hf_we=1;
2541
                    ctl_flags_pf_we=1;
2542
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2543
                    ctl_flags_cf_we=1; end
2544
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
2545
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
2546
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2547
                    ctl_sw_2d=1;
2548
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2549
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2550
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2551
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; end
2552
    if (M4 && T1) begin  fMRead=1;
2553
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
2554
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
2555
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2556
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2557
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2558
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2559
                    ctl_ir_we=1; end
2560
    if (M4 && T2) begin  fMRead=1; end
2561
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
2562
                    ctl_sw_2d=1;
2563
                    ctl_sw_1d=1;
2564
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2565
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2566
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2567
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2568
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2569
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; end
2570
    if (M5 && T1) begin  fMWrite=1;
2571
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2572
                    ctl_sw_2u=1;
2573
                    ctl_sw_1u=1;
2574
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2575
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2576
                    ctl_alu_res_oe=1; /* Result latch */
2577
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2578
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; end
2579
    if (M5 && T2) begin  fMWrite=1; end
2580
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2581
end
2582
 
2583
if (~use_ixiy && pla[74] && pla[55]) begin
2584
    if (M1 && T3) begin
2585
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2586
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2587
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2588
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2589
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2590
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2591
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2592
                    ctl_flags_sz_we=1;
2593
                    ctl_flags_xy_we=1;
2594
                    ctl_flags_hf_we=1;
2595
                    ctl_flags_pf_we=1;
2596
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2597
                    ctl_flags_cf_we=1; end
2598
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
2599
    if (M2 && T1) begin  fMRead=1;
2600
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
2601
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2602
    if (M2 && T2) begin  fMRead=1; end
2603
    if (M2 && T3) begin  fMRead=1;
2604
                    ctl_sw_2d=1;
2605
                    ctl_sw_1d=1;
2606
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2607
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2608
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2609
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2610
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; end
2611
    if (M2 && T4) begin  nextM=1; ctl_mWrite=1;
2612
                    ctl_sw_2u=1;
2613
                    ctl_sw_1u=1;
2614
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2615
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2616
                    ctl_alu_res_oe=1; /* Result latch */
2617
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2618
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; end
2619
    if (M3 && T1) begin  fMWrite=1;
2620
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
2621
    if (M3 && T2) begin  fMWrite=1; end
2622
    if (M3 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2623
    if (M4 && T1) begin  fMRead=1;
2624
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
2625
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
2626
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2627
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2628
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2629
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2630
                    ctl_ir_we=1; end
2631
    if (M4 && T2) begin  fMRead=1; end
2632
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
2633
                    ctl_sw_2d=1;
2634
                    ctl_sw_1d=1;
2635
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2636
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2637
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2638
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2639
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2640
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; end
2641
    if (M5 && T1) begin  fMWrite=1;
2642
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2643
                    ctl_sw_2u=1;
2644
                    ctl_sw_1u=1;
2645
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2646
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2647
                    ctl_alu_res_oe=1; /* Result latch */
2648
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2649
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; end
2650
    if (M5 && T2) begin  fMWrite=1; end
2651
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2652
end
2653
 
2654
if (~use_ixiy && pla[73] && !pla[55]) begin
2655
    if (M1 && T1) begin
2656
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0}; /* Write 8-bit GP register selected by op[2:0] */
2657
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2658
                    ctl_sw_2u=1;
2659
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2660
                    ctl_alu_res_oe=1; /* Result latch */
2661
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2662
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_alu_sel_op2_neg=1; end
2663
    if (M1 && T3) begin
2664
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2665
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2666
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2667
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2668
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2669
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2670
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2671
                    ctl_flags_sz_we=1;
2672
                    ctl_flags_xy_we=1;
2673
                    ctl_flags_hf_we=1;
2674
                    ctl_flags_pf_we=1;
2675
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2676
                    ctl_flags_cf_we=1; end
2677
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
2678
                    ctl_reg_gp_sel=op21; ctl_reg_gp_hilo={!rsel0,rsel0};/* Read 8-bit GP register selected by op[2:0] */
2679
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2680
                    ctl_sw_2d=1;
2681
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2682
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2683
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2684
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_alu_sel_op2_neg=1; end
2685
    if (M4 && T1) begin  fMRead=1;
2686
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
2687
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
2688
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2689
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2690
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2691
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2692
                    ctl_ir_we=1; end
2693
    if (M4 && T2) begin  fMRead=1; end
2694
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
2695
                    ctl_sw_2d=1;
2696
                    ctl_sw_1d=1;
2697
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2698
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2699
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2700
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2701
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2702
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_alu_sel_op2_neg=1; end
2703
    if (M5 && T1) begin  fMWrite=1;
2704
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2705
                    ctl_sw_2u=1;
2706
                    ctl_sw_1u=1;
2707
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2708
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2709
                    ctl_alu_res_oe=1; /* Result latch */
2710
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2711
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_alu_sel_op2_neg=1; end
2712
    if (M5 && T2) begin  fMWrite=1; end
2713
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2714
end
2715
 
2716
if (~use_ixiy && pla[73] && pla[55]) begin
2717
    if (M1 && T3) begin
2718
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2719
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2720
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2721
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2722
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2723
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2724
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2725
                    ctl_flags_sz_we=1;
2726
                    ctl_flags_xy_we=1;
2727
                    ctl_flags_hf_we=1;
2728
                    ctl_flags_pf_we=1;
2729
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2730
                    ctl_flags_cf_we=1; end
2731
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
2732
    if (M2 && T1) begin  fMRead=1;
2733
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
2734
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2735
    if (M2 && T2) begin  fMRead=1; end
2736
    if (M2 && T3) begin  fMRead=1;
2737
                    ctl_sw_2d=1;
2738
                    ctl_sw_1d=1;
2739
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2740
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2741
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2742
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2743
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_alu_sel_op2_neg=1; end
2744
    if (M2 && T4) begin  nextM=1; ctl_mWrite=1;
2745
                    ctl_sw_2u=1;
2746
                    ctl_sw_1u=1;
2747
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2748
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2749
                    ctl_alu_res_oe=1; /* Result latch */
2750
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2751
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_alu_sel_op2_neg=1; end
2752
    if (M3 && T1) begin  fMWrite=1;
2753
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
2754
    if (M3 && T2) begin  fMWrite=1; end
2755
    if (M3 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2756
    if (M4 && T1) begin  fMRead=1;
2757
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
2758
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
2759
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2760
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
2761
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2762
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2763
                    ctl_ir_we=1; end
2764
    if (M4 && T2) begin  fMRead=1; end
2765
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mWrite=1;
2766
                    ctl_sw_2d=1;
2767
                    ctl_sw_1d=1;
2768
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2769
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2770
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2771
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2772
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2773
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_alu_sel_op2_neg=1; end
2774
    if (M5 && T1) begin  fMWrite=1;
2775
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2776
                    ctl_sw_2u=1;
2777
                    ctl_sw_1u=1;
2778
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */
2779
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2780
                    ctl_alu_res_oe=1; /* Result latch */
2781
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2782
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_alu_sel_op2_neg=1; end
2783
    if (M5 && T2) begin  fMWrite=1; end
2784
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1; end
2785
end
2786
 
2787
// Input and Output Groups
2788
if (pla[37] && !pla[28]) begin
2789
    if (M1 && T1) begin
2790
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
2791
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2792
                    ctl_sw_2d=1;
2793
                    ctl_sw_1d=1;
2794
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
2795
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
2796
    if (M2 && T1) begin  fMRead=1;
2797
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
2798
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2799
    if (M2 && T2) begin  fMRead=1;
2800
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
2801
                    ctl_inc_cy=pc_inc; /* Increment */
2802
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
2803
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_iorw=1; end
2804
    if (M3 && T1) begin  fIORead=1;
2805
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10; ctl_sw_4d=1; /* Read 8-bit general purpose A register, enable SW4 downstream */
2806
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ /* Which register to be written is decided elsewhere */
2807
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2808
                    ctl_sw_1d=1;
2809
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
2810
    if (M3 && T2) begin  fIORead=1; end
2811
    if (M3 && T3) begin  fIORead=1; end
2812
    if (M3 && T4) begin  fIORead=1; nextM=1; setM1=1; end
2813
end
2814
 
2815
if (pla[27] && !pla[34]) begin
2816
    if (M1 && T1) begin
2817
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=op54; ctl_reg_gp_hilo={!rsel3,rsel3}; /* Write 8-bit GP register */
2818
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2819
                    ctl_sw_2d=1;
2820
                    ctl_sw_1d=1;
2821
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2822
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2823
                    ctl_alu_res_oe=1; /* Result latch */
2824
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2825
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2826
                    ctl_flags_sz_we=1;
2827
                    ctl_flags_xy_we=1;
2828
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P;
2829
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2830
    if (M1 && T2) begin
2831
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2832
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2833
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
2834
    if (M1 && T3) begin
2835
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2836
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2837
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2838
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2839
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2840
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2841
                    ctl_flags_sz_we=1;
2842
                    ctl_flags_xy_we=1;
2843
                    ctl_flags_hf_we=1;
2844
                    ctl_flags_pf_we=1;
2845
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2846
                    ctl_flags_cf_we=1; end
2847
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_iorw=1; end
2848
    if (M2 && T1) begin  fIORead=1;
2849
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit BC, enable SW4 downstream */
2850
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2851
    if (M2 && T2) begin  fIORead=1; end
2852
    if (M2 && T3) begin  fIORead=1; end
2853
    if (M2 && T4) begin  fIORead=1; nextM=1; setM1=1;
2854
                    ctl_sw_2d=1;
2855
                    ctl_sw_1d=1;
2856
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2857
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2858
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2859
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2860
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2861
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2862
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2863
                    ctl_flags_sz_we=1;
2864
                    ctl_flags_xy_we=1;
2865
                    ctl_flags_hf_we=1;
2866
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
2867
end
2868
 
2869
if (pla[37] && pla[28]) begin
2870
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
2871
    if (M2 && T1) begin  fMRead=1;
2872
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
2873
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2874
    if (M2 && T2) begin  fMRead=1;
2875
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
2876
                    ctl_inc_cy=pc_inc; /* Increment */
2877
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
2878
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_iorw=1;
2879
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10; ctl_sw_4d=1; /* Read 8-bit general purpose A register, enable SW4 downstream */
2880
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
2881
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
2882
                    ctl_sw_1d=1;
2883
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
2884
    if (M3 && T1) begin  fIOWrite=1;
2885
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
2886
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
2887
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2888
                    ctl_sw_2u=1;
2889
                    ctl_sw_1u=1;
2890
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
2891
    if (M3 && T2) begin  fIOWrite=1; end
2892
    if (M3 && T3) begin  fIOWrite=1; end
2893
    if (M3 && T4) begin  fIOWrite=1; nextM=1; setM1=1; end
2894
end
2895
 
2896
if (pla[27] && pla[34]) begin
2897
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_iorw=1;
2898
    if (op4 & op5 & !op3) ctl_bus_zero_oe=1;                /* Trying to read flags? Put 0 on the bus instead. */
2899
    else begin ctl_reg_gp_sel=op54; ctl_reg_gp_hilo={!rsel3,rsel3}; end /* Read 8-bit GP register */
2900
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2901
                    ctl_sw_2u=1;
2902
                    ctl_sw_1u=1;
2903
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
2904
    if (M2 && T1) begin  fIOWrite=1;
2905
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit BC, enable SW4 downstream */
2906
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2907
    if (M2 && T2) begin  fIOWrite=1; end
2908
    if (M2 && T3) begin  fIOWrite=1; end
2909
    if (M2 && T4) begin  fIOWrite=1; nextM=1; setM1=1; end
2910
end
2911
 
2912
if (pla[91] && pla[21]) begin
2913
    if (M1 && T1) begin
2914
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2915
                    ctl_alu_res_oe=1; /* Result latch */
2916
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2917
                    ctl_alu_core_R=1; ctl_alu_core_V=0; ctl_alu_core_S=0; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2918
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P; end
2919
    if (M1 && T2) begin
2920
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
2921
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2922
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
2923
    if (M1 && T3) begin
2924
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
2925
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2926
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
2927
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2928
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
2929
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2930
                    ctl_flags_sz_we=1;
2931
                    ctl_flags_xy_we=1;
2932
                    ctl_flags_hf_we=1;
2933
                    ctl_flags_pf_we=1;
2934
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
2935
                    ctl_flags_cf_we=1; end
2936
    if (M1 && T4) begin  validPLA=1; end
2937
    if (M1 && T5) begin  nextM=1; ctl_iorw=1; end
2938
    if (M2 && T1) begin  fIORead=1;
2939
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit BC, enable SW4 downstream */
2940
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2941
    if (M2 && T2) begin  fIORead=1;
2942
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b10;
2943
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
2944
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2945
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2946
                    ctl_alu_op2_sel_zero=1; /* Zero */
2947
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2948
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
2949
 
2950
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
2951
    if (ctl_alu_op_low) begin
2952
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2953
    end else begin
2954
        ctl_alu_core_hf=1;
2955
    end
2956
                    ctl_flags_hf_we=1;
2957
                    ctl_alu_sel_op2_neg=1; end
2958
    if (M2 && T3) begin  fIORead=1;
2959
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b10;
2960
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
2961
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2962
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
2963
                    ctl_alu_res_oe=1; /* Result latch */
2964
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
2965
 
2966
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
2967
    if (ctl_alu_op_low) begin
2968
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
2969
    end else begin
2970
        ctl_alu_core_hf=1;
2971
    end
2972
                    ctl_flags_sz_we=1;
2973
                    ctl_flags_xy_we=1;
2974
                    ctl_flags_cf_we=1;
2975
                    ctl_alu_sel_op2_neg=1; end
2976
    if (M2 && T4) begin  fIORead=1; nextM=1; ctl_mWrite=1;
2977
                    ctl_sw_2d=1;
2978
                    ctl_sw_1d=1;
2979
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
2980
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
2981
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
2982
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
2983
                    ctl_flags_nf_we=1; /* Sign bit, to be used with FLAGT source set to "alu" */
2984
                    ctl_alu_sel_op2_neg=1; end
2985
    if (M3 && T1) begin  fMWrite=1;
2986
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
2987
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2988
    if (M3 && T2) begin  fMWrite=1;
2989
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit HL, enable SW4 upstream */
2990
                    ctl_inc_cy=pc_inc; ctl_inc_dec=op3; /* Decrement if op3 is set; increment otherwise */
2991
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
2992 7 gdevic
    if (M3 && T3) begin  fMWrite=1; nextM=1; setM1=nonRep | flags_zf; end
2993 6 gdevic
    if (M4 && T1) begin
2994
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
2995
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
2996
    if (M4 && T2) begin
2997
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
2998
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
2999
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3000
    if (M4 && T3) begin
3001
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3002
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3003
    if (M4 && T4) begin
3004
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3005
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3006
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3007
    if (M4 && T5) begin  nextM=1; setM1=1; end
3008
end
3009
 
3010
if (pla[91] && pla[20]) begin
3011
    if (M1 && T1) begin
3012
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3013
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3014
                    ctl_alu_res_oe=1; /* Result latch */
3015
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3016
                    ctl_alu_core_R=1; ctl_alu_core_V=0; ctl_alu_core_S=0; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3017
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P; end
3018
    if (M1 && T2) begin
3019
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b01;
3020
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
3021
                    ctl_flags_oe=1; /* Enable FLAGT onto the data bus */ end
3022
    if (M1 && T3) begin
3023
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
3024
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3025
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
3026
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3027
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3028
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3029
                    ctl_flags_sz_we=1;
3030
                    ctl_flags_xy_we=1;
3031
                    ctl_flags_hf_we=1;
3032
                    ctl_flags_pf_we=1;
3033
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
3034
                    ctl_flags_cf_we=1; end
3035
    if (M1 && T4) begin  validPLA=1;
3036
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b10;
3037
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3038
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3039
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3040
                    ctl_alu_op2_sel_zero=1; /* Zero */
3041
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3042
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3043
 
3044
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3045
    if (ctl_alu_op_low) begin
3046
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3047
    end else begin
3048
        ctl_alu_core_hf=1;
3049
    end
3050
                    ctl_flags_hf_we=1;
3051
                    ctl_alu_sel_op2_neg=1; end
3052
    if (M1 && T5) begin  nextM=1; ctl_mRead=1;
3053
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b10;
3054
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
3055
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3056
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3057
                    ctl_alu_res_oe=1; /* Result latch */
3058
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3059
 
3060
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3061
    if (ctl_alu_op_low) begin
3062
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3063
    end else begin
3064
        ctl_alu_core_hf=1;
3065
    end
3066
                    ctl_flags_sz_we=1;
3067
                    ctl_flags_xy_we=1;
3068
                    ctl_alu_sel_op2_neg=1; end
3069
    if (M2 && T1) begin  fMRead=1;
3070
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
3071
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3072
    if (M2 && T2) begin  fMRead=1;
3073
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4u=1; /* Write 16-bit HL, enable SW4 upstream */
3074
                    ctl_inc_cy=pc_inc; ctl_inc_dec=op3; /* Decrement if op3 is set; increment otherwise */
3075
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3076
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_iorw=1;
3077
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b01;
3078
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3079
                    ctl_sw_2d=1;
3080
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3081
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
3082
    if (M3 && T1) begin  fIOWrite=1;
3083
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit BC, enable SW4 downstream */
3084
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3085
    if (M3 && T2) begin  fIOWrite=1;
3086
                    ctl_sw_2d=1;
3087
                    ctl_sw_1d=1;
3088
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3089
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3090
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3091
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3092
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3093
 
3094
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3095
    if (ctl_alu_op_low) begin
3096
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3097
    end else begin
3098
        ctl_alu_core_hf=1;
3099
    end
3100
                    ctl_flags_hf_we=1;
3101
                    ctl_flags_nf_we=1; /* Sign bit, to be used with FLAGT source set to "alu" */ end
3102
    if (M3 && T3) begin  fIOWrite=1;
3103
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3104
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3105
                    ctl_alu_res_oe=1; /* Result latch */
3106
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3107
 
3108
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3109
    if (ctl_alu_op_low) begin
3110
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3111
    end else begin
3112
        ctl_alu_core_hf=1;
3113
    end
3114
                    ctl_flags_cf_we=1; end
3115 7 gdevic
    if (M3 && T4) begin  fIOWrite=1; nextM=1; setM1=nonRep | flags_zf; end
3116 6 gdevic
    if (M4 && T1) begin
3117
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3118
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3119
    if (M4 && T2) begin
3120
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3121
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3122
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3123
    if (M4 && T3) begin
3124
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3125
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3126
    if (M4 && T4) begin
3127
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3128
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3129
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3130
    if (M4 && T5) begin  nextM=1; setM1=1; end
3131
end
3132
 
3133
// Jump Group
3134
if (pla[29]) begin
3135
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
3136
    if (M2 && T1) begin  fMRead=1;
3137
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3138
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3139
    if (M2 && T2) begin  fMRead=1;
3140
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3141
                    ctl_inc_cy=pc_inc; /* Increment */
3142
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3143
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
3144
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3145
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3146
                    ctl_sw_2d=1;
3147
                    ctl_sw_1d=1;
3148
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3149
    if (M3 && T1) begin  fMRead=1;
3150
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3151
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3152
    if (M3 && T2) begin  fMRead=1;
3153
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3154
                    ctl_inc_cy=pc_inc; /* Increment */
3155
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3156
    if (M3 && T3) begin  fMRead=1; nextM=1; setM1=1;
3157
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3158
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3159
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3160
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3161
                    ctl_sw_2d=1;
3162
                    ctl_sw_1d=1;
3163
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3164
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3165
end
3166
 
3167
if (pla[43]) begin
3168
    if (M1 && T3) begin
3169
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
3170
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3171
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
3172
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3173
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3174
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3175
                    ctl_flags_sz_we=1;
3176
                    ctl_flags_xy_we=1;
3177
                    ctl_flags_hf_we=1;
3178
                    ctl_flags_pf_we=1;
3179
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
3180
                    ctl_flags_cf_we=1; end
3181
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
3182
    if (M2 && T1) begin  fMRead=1;
3183
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3184
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3185
    if (M2 && T2) begin  fMRead=1;
3186
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3187
                    ctl_inc_cy=pc_inc; /* Increment */
3188
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3189
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
3190
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3191
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3192
                    ctl_sw_2d=1;
3193
                    ctl_sw_1d=1;
3194
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3195
    if (M3 && T1) begin  fMRead=1;
3196
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3197
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3198
    if (M3 && T2) begin  fMRead=1;
3199
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3200
                    ctl_inc_cy=pc_inc; /* Increment */
3201
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3202
    if (M3 && T3) begin  fMRead=1; nextM=1; setM1=1;
3203
    if (flags_cond_true) begin      /* If cc is true, use WZ instead of PC (for jumps) */
3204
        ctl_reg_not_pc=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1;
3205
    end
3206
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3207
                    ctl_reg_sys_we_hi=flags_cond_true; ctl_reg_sel_wz=flags_cond_true; ctl_reg_sys_hilo[1]=1; /* Conditionally selecting only W */
3208
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3209
                    ctl_sw_2d=1;
3210
                    ctl_sw_1d=1;
3211
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3212
end
3213
 
3214
if (pla[47]) begin
3215
    if (M1 && T3) begin
3216
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
3217
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3218
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
3219
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3220
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3221
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3222
                    ctl_flags_sz_we=1;
3223
                    ctl_flags_xy_we=1;
3224
                    ctl_flags_hf_we=1;
3225
                    ctl_flags_pf_we=1;
3226
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
3227
                    ctl_flags_cf_we=1; end
3228
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
3229
    if (M2 && T1) begin  fMRead=1;
3230
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3231
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3232
    if (M2 && T2) begin  fMRead=1;
3233
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3234
                    ctl_inc_cy=pc_inc; /* Increment */
3235
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3236
    if (M2 && T3) begin  fMRead=1; nextM=1; end
3237
    if (M3 && T1) begin
3238
                    ctl_sw_2d=1;
3239
                    ctl_sw_1d=1;
3240
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3241
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3242
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3243
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3244
                    ctl_flags_sz_we=1; end
3245
    if (M3 && T2) begin
3246
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b01; ctl_sw_4u=1;
3247
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3248
                    ctl_sw_2d=1;
3249
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3250
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3251
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3252
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3253
 
3254
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3255
    if (ctl_alu_op_low) begin
3256
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3257
    end else begin
3258
        ctl_alu_core_hf=1;
3259
    end
3260
                    ctl_flags_hf_we=1; end
3261
    if (M3 && T3) begin
3262
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3263
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3264
                    ctl_sw_2u=1;
3265
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3266
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3267
                    ctl_alu_res_oe=1; /* Result latch */
3268
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3269
 
3270
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3271
    if (ctl_alu_op_low) begin
3272
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3273
    end else begin
3274
        ctl_alu_core_hf=1;
3275
    end
3276
                    ctl_flags_cf_we=1; end
3277
    if (M3 && T4) begin
3278
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b10; ctl_sw_4u=1;
3279
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3280
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3281
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3282
                    ctl_alu_op2_sel_zero=1; /* Zero */
3283
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3284
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3285
 
3286
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3287
    if (!ctl_alu_op_low) begin
3288
        ctl_alu_core_hf=1;
3289
    end
3290
                    ctl_flags_hf_we=1;
3291
                    ctl_alu_sel_op2_neg=flags_sf; end
3292
    if (M3 && T5) begin  nextM=1; setM1=1;
3293
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3294
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3295
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3296
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3297
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3298
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3299
                    ctl_alu_res_oe=1; /* Result latch */
3300
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3301
 
3302
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3303
    if (!ctl_alu_op_low) begin
3304
        ctl_alu_core_hf=1;
3305
    end
3306
                    ctl_alu_sel_op2_neg=flags_sf;
3307
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3308
end
3309
 
3310
if (pla[48]) begin
3311
    if (M1 && T3) begin
3312
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
3313
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3314
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
3315
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3316
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3317
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3318
                    ctl_flags_sz_we=1;
3319
                    ctl_flags_xy_we=1;
3320
                    ctl_flags_hf_we=1;
3321
                    ctl_flags_pf_we=1;
3322
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
3323
                    ctl_flags_cf_we=1; end
3324
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1;
3325
                    ctl_cond_short=1; /* M1/T3 only: force a short flags condition (SS) */ end
3326
    if (M2 && T1) begin  fMRead=1;
3327
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3328
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3329
    if (M2 && T2) begin  fMRead=1;
3330
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3331
                    ctl_inc_cy=pc_inc; /* Increment */
3332
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3333
    if (M2 && T3) begin  fMRead=1; nextM=1; setM1=!flags_cond_true; end
3334
    if (M3 && T1) begin
3335
                    ctl_sw_2d=1;
3336
                    ctl_sw_1d=1;
3337
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3338
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3339
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3340
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3341
                    ctl_flags_sz_we=1; end
3342
    if (M3 && T2) begin
3343
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b01; ctl_sw_4u=1;
3344
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3345
                    ctl_sw_2d=1;
3346
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3347
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3348
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3349
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3350
 
3351
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3352
    if (ctl_alu_op_low) begin
3353
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3354
    end else begin
3355
        ctl_alu_core_hf=1;
3356
    end
3357
                    ctl_flags_hf_we=1; end
3358
    if (M3 && T3) begin
3359
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3360
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3361
                    ctl_sw_2u=1;
3362
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3363
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3364
                    ctl_alu_res_oe=1; /* Result latch */
3365
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3366
 
3367
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3368
    if (ctl_alu_op_low) begin
3369
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3370
    end else begin
3371
        ctl_alu_core_hf=1;
3372
    end
3373
                    ctl_flags_cf_we=1; end
3374
    if (M3 && T4) begin
3375
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b10; ctl_sw_4u=1;
3376
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3377
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3378
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3379
                    ctl_alu_op2_sel_zero=1; /* Zero */
3380
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3381
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3382
 
3383
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3384
    if (!ctl_alu_op_low) begin
3385
        ctl_alu_core_hf=1;
3386
    end
3387
                    ctl_flags_hf_we=1;
3388
                    ctl_alu_sel_op2_neg=flags_sf; end
3389
    if (M3 && T5) begin  nextM=1; setM1=1;
3390
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3391
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3392
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3393
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3394
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3395
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3396
                    ctl_alu_res_oe=1; /* Result latch */
3397
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3398
 
3399
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3400
    if (!ctl_alu_op_low) begin
3401
        ctl_alu_core_hf=1;
3402
    end
3403
                    ctl_alu_sel_op2_neg=flags_sf;
3404
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3405
end
3406
 
3407
if (pla[6]) begin
3408
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
3409
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1; /* Read 16-bit HL, enable SW4 downstream */
3410
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3411
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3412
end
3413
 
3414
if (pla[26]) begin
3415
    if (M1 && T3) begin
3416
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
3417
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3418
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
3419
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3420
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3421
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3422
                    ctl_flags_sz_we=1;
3423
                    ctl_flags_xy_we=1;
3424
                    ctl_flags_hf_we=1;
3425
                    ctl_flags_pf_we=1;
3426
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
3427
                    ctl_flags_cf_we=1; end
3428
    if (M1 && T4) begin  validPLA=1;
3429
                    ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b10;
3430
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3431
                    ctl_sw_2d=1;
3432
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3433
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3434
                    ctl_alu_op2_sel_zero=1; /* Zero */
3435
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3436
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3437
 
3438
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3439
    if (ctl_alu_op_low) begin
3440
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3441
    end else begin
3442
        ctl_alu_core_hf=1;
3443
    end
3444
                    ctl_flags_hf_we=1;
3445
                    ctl_alu_sel_op2_neg=1; end
3446
    if (M1 && T5) begin  nextM=1; ctl_mRead=1;
3447
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_BC; ctl_reg_gp_hilo=2'b10;
3448
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
3449
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3450
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3451
                    ctl_alu_res_oe=1; /* Result latch */
3452
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3453
 
3454
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3455
    if (ctl_alu_op_low) begin
3456
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3457
    end else begin
3458
        ctl_alu_core_hf=1;
3459
    end
3460
                    ctl_flags_sz_we=1;
3461
                    ctl_alu_sel_op2_neg=1; end
3462
    if (M2 && T1) begin  fMRead=1;
3463
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3464
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3465
    if (M2 && T2) begin  fMRead=1;
3466
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3467
                    ctl_inc_cy=pc_inc; /* Increment */
3468
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3469
    if (M2 && T3) begin  fMRead=1; nextM=1; setM1=flags_zf; /* Used in DJNZ */ end
3470
    if (M3 && T1) begin
3471
                    ctl_sw_2d=1;
3472
                    ctl_sw_1d=1;
3473
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3474
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3475
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3476
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3477
                    ctl_flags_sz_we=1; end
3478
    if (M3 && T2) begin
3479
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b01; ctl_sw_4u=1;
3480
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3481
                    ctl_sw_2d=1;
3482
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3483
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3484
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3485
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3486
 
3487
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3488
    if (ctl_alu_op_low) begin
3489
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3490
    end else begin
3491
        ctl_alu_core_hf=1;
3492
    end
3493
                    ctl_flags_hf_we=1; end
3494
    if (M3 && T3) begin
3495
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3496
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3497
                    ctl_sw_2u=1;
3498
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3499
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3500
                    ctl_alu_res_oe=1; /* Result latch */
3501
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3502
 
3503
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3504
    if (ctl_alu_op_low) begin
3505
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
3506
    end else begin
3507
        ctl_alu_core_hf=1;
3508
    end
3509
                    ctl_flags_cf_we=1; end
3510
    if (M3 && T4) begin
3511
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b10; ctl_sw_4u=1;
3512
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3513
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3514
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3515
                    ctl_alu_op2_sel_zero=1; /* Zero */
3516
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3517
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
3518
 
3519
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3520
    if (!ctl_alu_op_low) begin
3521
        ctl_alu_core_hf=1;
3522
    end
3523
                    ctl_flags_hf_we=1;
3524
                    ctl_alu_sel_op2_neg=flags_sf; end
3525
    if (M3 && T5) begin  nextM=1; setM1=1;
3526
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3527
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3528
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3529
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3530
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
3531
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3532
                    ctl_alu_res_oe=1; /* Result latch */
3533
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
3534
 
3535
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
3536
    if (!ctl_alu_op_low) begin
3537
        ctl_alu_core_hf=1;
3538
    end
3539
                    ctl_alu_sel_op2_neg=flags_sf;
3540
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3541
end
3542
 
3543
// Call and Return Group
3544
if (pla[24]) begin
3545
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
3546
    if (M2 && T1) begin  fMRead=1;
3547
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3548
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3549
    if (M2 && T2) begin  fMRead=1;
3550
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3551
                    ctl_inc_cy=pc_inc; /* Increment */
3552
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3553
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
3554
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3555
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3556
                    ctl_sw_2d=1;
3557
                    ctl_sw_1d=1;
3558
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3559
    if (M3 && T1) begin  fMRead=1;
3560
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3561
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3562
    if (M3 && T2) begin  fMRead=1;
3563
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3564
                    ctl_inc_cy=pc_inc; /* Increment */
3565
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3566
    if (M3 && T3) begin  fMRead=1;
3567
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3568
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3569
                    ctl_sw_2d=1;
3570
                    ctl_sw_1d=1;
3571
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3572
    if (M3 && T4) begin  nextM=1; ctl_mWrite=1;
3573
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3574
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3575
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3576
    if (M4 && T1) begin  fMWrite=1;
3577
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3578
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
3579
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b10; ctl_sw_4u=1;
3580
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3581
                    ctl_sw_2u=1;
3582
                    ctl_sw_1u=1;
3583
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
3584
    if (M4 && T2) begin  fMWrite=1;
3585
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3586
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3587
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3588
    if (M4 && T3) begin  fMWrite=1; nextM=1; ctl_mWrite=1;
3589
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3590
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3591
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3592
    if (M5 && T1) begin  fMWrite=1;
3593
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3594
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
3595
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b01; ctl_sw_4u=1;
3596
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3597
                    ctl_sw_2u=1;
3598
                    ctl_sw_1u=1;
3599
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
3600
    if (M5 && T2) begin  fMWrite=1;
3601
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3602
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3603
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3604
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1;
3605
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3606
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3607
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3608
end
3609
 
3610
if (pla[42]) begin
3611
    if (M1 && T3) begin
3612
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
3613
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3614
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
3615
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3616
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3617
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3618
                    ctl_flags_sz_we=1;
3619
                    ctl_flags_xy_we=1;
3620
                    ctl_flags_hf_we=1;
3621
                    ctl_flags_pf_we=1;
3622
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
3623
                    ctl_flags_cf_we=1; end
3624
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
3625
    if (M2 && T1) begin  fMRead=1;
3626
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3627
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3628
    if (M2 && T2) begin  fMRead=1;
3629
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3630
                    ctl_inc_cy=pc_inc; /* Increment */
3631
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3632
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
3633
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3634
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3635
                    ctl_sw_2d=1;
3636
                    ctl_sw_1d=1;
3637
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3638
    if (M3 && T1) begin  fMRead=1;
3639
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3640
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3641
    if (M3 && T2) begin  fMRead=1;
3642
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3643
                    ctl_inc_cy=pc_inc; /* Increment */
3644
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3645
    if (M3 && T3) begin  fMRead=1; nextM=!flags_cond_true; setM1=!flags_cond_true;
3646
                    ctl_reg_sys_we_hi=flags_cond_true; ctl_reg_sel_wz=flags_cond_true; ctl_reg_sys_hilo[1]=1; /* Conditionally selecting only W */
3647
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3648
                    ctl_sw_2d=1;
3649
                    ctl_sw_1d=1;
3650
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3651
    if (M3 && T4) begin  nextM=1; ctl_mWrite=1;
3652
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3653
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3654
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3655
    if (M4 && T1) begin  fMWrite=1;
3656
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3657
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
3658
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b10; ctl_sw_4u=1;
3659
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3660
                    ctl_sw_2u=1;
3661
                    ctl_sw_1u=1;
3662
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
3663
    if (M4 && T2) begin  fMWrite=1;
3664
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3665
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3666
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3667
    if (M4 && T3) begin  fMWrite=1; nextM=1; ctl_mWrite=1;
3668
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3669
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3670
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3671
    if (M5 && T1) begin  fMWrite=1;
3672
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3673
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
3674
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b01; ctl_sw_4u=1;
3675
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3676
                    ctl_sw_2u=1;
3677
                    ctl_sw_1u=1;
3678
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
3679
    if (M5 && T2) begin  fMWrite=1;
3680
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3681
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3682
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3683
    if (M5 && T3) begin  fMWrite=1; nextM=1; setM1=1;
3684
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3685
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3686
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3687
end
3688
 
3689
if (pla[35]) begin
3690
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
3691
    if (M2 && T1) begin  fMRead=1;
3692
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3693
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3694
    if (M2 && T2) begin  fMRead=1;
3695
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3696
                    ctl_inc_cy=pc_inc; /* Increment */
3697
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3698
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
3699
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3700
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3701
                    ctl_sw_2d=1;
3702
                    ctl_sw_1d=1;
3703
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3704
    if (M3 && T1) begin  fMRead=1;
3705
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3706
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3707
    if (M3 && T2) begin  fMRead=1;
3708
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3709
                    ctl_inc_cy=pc_inc; /* Increment */
3710
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3711
    if (M3 && T3) begin  fMRead=1; nextM=1; setM1=1;
3712
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3713
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3714
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3715
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3716
                    ctl_sw_2d=1;
3717
                    ctl_sw_1d=1;
3718
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3719
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3720
end
3721
 
3722
if (pla[45]) begin
3723
    if (M1 && T3) begin
3724
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
3725
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3726
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
3727
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3728
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3729
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3730
                    ctl_flags_sz_we=1;
3731
                    ctl_flags_xy_we=1;
3732
                    ctl_flags_hf_we=1;
3733
                    ctl_flags_pf_we=1;
3734
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
3735
                    ctl_flags_cf_we=1; end
3736
    if (M1 && T4) begin  validPLA=1; end
3737
    if (M1 && T5) begin  nextM=1; ctl_mRead=1; setM1=!flags_cond_true; end
3738
    if (M2 && T1) begin  fMRead=1;
3739
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3740
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3741
    if (M2 && T2) begin  fMRead=1;
3742
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3743
                    ctl_inc_cy=pc_inc; /* Increment */
3744
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3745
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
3746
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3747
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3748
                    ctl_sw_2d=1;
3749
                    ctl_sw_1d=1;
3750
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3751
    if (M3 && T1) begin  fMRead=1;
3752
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3753
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3754
    if (M3 && T2) begin  fMRead=1;
3755
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3756
                    ctl_inc_cy=pc_inc; /* Increment */
3757
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3758
    if (M3 && T3) begin  fMRead=1; nextM=1; setM1=1;
3759
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3760
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3761
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3762
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3763
                    ctl_sw_2d=1;
3764
                    ctl_sw_1d=1;
3765
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3766
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3767
end
3768
 
3769
if (pla[46]) begin
3770
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1;
3771
                    ctl_iff1_iff2=1; /* RETN copies IFF2 into IFF1 */ end
3772
    if (M2 && T1) begin  fMRead=1;
3773
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3774
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3775
    if (M2 && T2) begin  fMRead=1;
3776
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3777
                    ctl_inc_cy=pc_inc; /* Increment */
3778
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3779
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
3780
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3781
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3782
                    ctl_sw_2d=1;
3783
                    ctl_sw_1d=1;
3784
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3785
    if (M3 && T1) begin  fMRead=1;
3786
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3787
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3788
    if (M3 && T2) begin  fMRead=1;
3789
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3790
                    ctl_inc_cy=pc_inc; /* Increment */
3791
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3792
    if (M3 && T3) begin  fMRead=1; nextM=1; setM1=1;
3793
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3794
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3795
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3796
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3797
                    ctl_sw_2d=1;
3798
                    ctl_sw_1d=1;
3799
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3800
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3801
end
3802
 
3803
if (pla[56]) begin
3804
    if (M1 && T3) begin
3805
                    ctl_reg_sys_we=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11;
3806
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
3807
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3808
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3809
                    ctl_alu_op1_oe=1; /* OP1 latch */
3810
                    ctl_alu_op1_sel_zero=1; /* Zero */
3811
                    ctl_sw_mask543_en=!((in_intr & im2) | in_nmi);
3812
                    ctl_sw_1d=!in_nmi; ctl_66_oe=in_nmi;
3813
                    ctl_bus_ff_oe=in_intr & im1; end
3814
    if (M1 && T4) begin  validPLA=1; end
3815
    if (M1 && T5) begin  nextM=1; ctl_mWrite=1;
3816
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3817
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3818
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3819
                    ctl_sw_2d=1;
3820
                    ctl_sw_1d=1;
3821
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3822
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3823
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
3824
    if (M2 && T1) begin  fMWrite=1;
3825
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3826
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
3827
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b10; ctl_sw_4u=1;
3828
                    ctl_reg_out_hi=1; /* From the register file into the ALU high byte only */
3829
                    ctl_sw_2u=1;
3830
                    ctl_sw_1u=1;
3831
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
3832
    if (M2 && T2) begin  fMWrite=1;
3833
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3834
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3835
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3836
    if (M2 && T3) begin  fMWrite=1; nextM=1; ctl_mWrite=1;
3837
                    ctl_reg_use_sp=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_sw_4d=1;/* Read 16-bit SP, enable SW4 downstream */
3838
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3839
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3840
    if (M3 && T1) begin  fMWrite=1;
3841
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3842
                    ctl_apin_mux=1; /* Apin sourced from incrementer */
3843
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b01; ctl_sw_4u=1;
3844
                    ctl_reg_out_lo=1; /* From the register file into the ALU low byte only */
3845
                    ctl_sw_2u=1;
3846
                    ctl_sw_1u=1;
3847
                    ctl_bus_db_we=1; /* Write DB pads with internal data bus value */ end
3848
    if (M3 && T2) begin  fMWrite=1;
3849
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11; ctl_reg_use_sp=1; ctl_sw_4u=1; /* Write 16-bit SP, enable SW4 upstream */
3850
                    ctl_inc_cy=pc_inc; ctl_inc_dec=1; /* Decrement */
3851
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3852
    if (M3 && T3) begin  fMWrite=1; nextM=1; ctl_mRead=in_intr & im2; /* RST38 interrupt extension */ setM1=!(in_intr & im2); /* RST38 interrupt extension */
3853
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3854
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3855
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3856
// INTR IM2 continues here...
3857
    if (M4 && T1) begin  fMRead=1;
3858
                    ctl_reg_sel_ir=1; ctl_reg_sys_hilo=2'b10; ctl_sw_4d=1; /* Select 8-bit I register */
3859
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3860
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3861
                    ctl_sw_2u=1;
3862
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3863
                    ctl_alu_op1_oe=1; /* OP1 latch */ end
3864
    if (M4 && T2) begin  fMRead=1;
3865
                    ctl_sw_4u=1;
3866
                    ctl_inc_cy=pc_inc; /* Increment */
3867
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */
3868
                    ctl_reg_out_lo=1; /* From the register file into the ALU low byte only */
3869
                    ctl_sw_2d=1;
3870
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3871
                    ctl_alu_op1_sel_bus=1; /* Internal bus */ end
3872
    if (M4 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1;
3873
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
3874
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3875
                    ctl_sw_2d=1;
3876
                    ctl_sw_1d=1;
3877
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */ end
3878
    if (M5 && T1) begin  fMRead=1;
3879
                    ctl_reg_sel_ir=1; ctl_reg_sys_hilo=2'b10; ctl_sw_4d=1; /* Select 8-bit I register */
3880
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3881
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
3882
                    ctl_sw_2u=1;
3883
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
3884
                    ctl_alu_op1_oe=1; /* OP1 latch */ end
3885
    if (M5 && T2) begin  fMRead=1;
3886
                    ctl_inc_cy=pc_inc; /* Increment */
3887
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3888
    if (M5 && T3) begin  fMRead=1; nextM=1; setM1=1;
3889
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
3890
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
3891
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
3892
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
3893
                    ctl_sw_2d=1;
3894
                    ctl_sw_1d=1;
3895
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3896
                    ctl_reg_not_pc=1; /* For M1/T1 load from a register other than PC */ end
3897
end
3898
 
3899
// CB-Table opcodes
3900
if (pla[49]) begin
3901
    if (M1 && T3) begin
3902
                    ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b11;
3903
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
3904
                    ctl_flags_bus=1; /* Load FLAGT from the data bus */
3905
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
3906
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3907
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3908
                    ctl_flags_sz_we=1;
3909
                    ctl_flags_xy_we=1;
3910
                    ctl_flags_hf_we=1;
3911
                    ctl_flags_pf_we=1;
3912
                    ctl_flags_nf_we=1; /* Previous NF, to be used when loading FLAGT */
3913
                    ctl_flags_cf_we=1;
3914
                    ctl_state_tbl_cb_set=1; setCBED=1; /* CB-table prefix */ end
3915
    if (M1 && T4) begin  validPLA=1; nextM=1; ctl_mRead=1; end
3916
    if (M2 && T1) begin  fMRead=1;
3917
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3918
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ end
3919
    if (M2 && T2) begin  fMRead=1;
3920
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3921
                    ctl_inc_cy=pc_inc; /* Increment */
3922
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ end
3923
    if (M2 && T3) begin  fMRead=1; nextM=1; ctl_mRead=1; end
3924
    if (M3 && T1) begin  fMRead=1;
3925
                    ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit PC */
3926
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */ ixy_d=1; /* Compute WZ=IX+d */ end
3927
    if (M3 && T2) begin  fMRead=1;
3928
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
3929
                    ctl_inc_cy=pc_inc; /* Increment */
3930
                    ctl_bus_inc_oe=1; /* Output enable incrementer to the register bus */ ixy_d=1; /* Compute WZ=IX+d */ end
3931
    if (M3 && T3) begin  fMRead=1; ixy_d=1; /* Compute WZ=IX+d */ end
3932
    if (M3 && T4) begin  ixy_d=1; /* Compute WZ=IX+d */ end
3933
    if (M3 && T5) begin  nextM=1; ctl_mRead=1; ixy_d=1; /* Compute WZ=IX+d */ end
3934
    if (M4 && T1) begin
3935
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
3936
                    ctl_alu_bs_oe=1; /* Bit-selector unit */
3937
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
3938
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
3939
                    ctl_ir_we=1; end
3940
// Loading a new instruction immediately changes PLA wires and continues into the new effective instructions' M4/T1 cycle
3941
end
3942
 
3943
// Special Purposes PLA Entries
3944
if (pla[3]) begin
3945
    if (M1 && T2) begin
3946
                    ctl_state_ixiy_we=1; ctl_state_iy_set=op5; setIXIY=1; /* IX/IY prefix */ end
3947
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
3948
                    ctl_no_ints=1; /* Disable interrupt generation for this opcode (DI/EI/CB/ED/DD/FD) */ end
3949
end
3950
 
3951
if (pla[44]) begin
3952
    if (M1 && T2) begin
3953
                    ctl_state_tbl_cb_set=1; setCBED=1; /* CB-table prefix */ end
3954
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
3955
                    ctl_no_ints=1; /* Disable interrupt generation for this opcode (DI/EI/CB/ED/DD/FD) */ end
3956
end
3957
 
3958
if (pla[51]) begin
3959
    if (M1 && T2) begin
3960
                    ctl_state_tbl_ed_set=1; setCBED=1; /* ED-table prefix */ end
3961
    if (M1 && T4) begin  validPLA=1; nextM=1; setM1=1;
3962
                    ctl_no_ints=1; /* Disable interrupt generation for this opcode (DI/EI/CB/ED/DD/FD) */ end
3963
end
3964
 
3965
if (pla[76]) begin
3966
    begin
3967
 
3968
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
3969
    if (ctl_alu_op_low) begin
3970
                                                              ctl_flags_cf_set=1;
3971
    end else begin
3972
        ctl_alu_core_hf=1;
3973
    end
3974
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1; end
3975
    if (M1 && T1) begin
3976
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V; end
3977
end
3978
 
3979
if (pla[78]) begin
3980
    begin
3981
 
3982
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
3983
    if (ctl_alu_op_low) begin
3984
                                                              ctl_flags_cf_set=1;
3985
    end else begin
3986
        ctl_alu_core_hf=1;
3987
    end
3988
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1; end
3989
    if (M1 && T1) begin
3990
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
3991
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
3992
                    ctl_flags_xy_we=1;
3993
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V; end
3994
end
3995
 
3996
if (pla[79]) begin
3997
    begin
3998
 
3999
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;                                             ctl_alu_sel_op2_neg=1;
4000
    if (ctl_alu_op_low) begin
4001
                                                                                  ctl_flags_cf_cpl=1;
4002
    end else begin
4003
        ctl_alu_core_hf=1;
4004
    end
4005
                    ctl_flags_nf_we=1; ctl_flags_nf_set=1; end
4006
    if (M1 && T1) begin
4007
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
4008
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
4009
                    ctl_flags_xy_we=1;
4010
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V; end
4011
end
4012
 
4013
if (pla[80]) begin
4014
    begin
4015
 
4016
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
4017
    if (!ctl_alu_op_low) begin
4018
        ctl_alu_core_hf=1;
4019
    end
4020
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
4021
    if (M1 && T1) begin
4022
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
4023
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
4024
                    ctl_flags_xy_we=1;
4025
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V; end
4026
end
4027
 
4028
if (pla[84]) begin
4029
    begin
4030
 
4031
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
4032
    if (ctl_alu_op_low) begin
4033
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
4034
    end else begin
4035
        ctl_alu_core_hf=1;
4036
    end
4037
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
4038
    if (M1 && T1) begin
4039
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
4040
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
4041
                    ctl_flags_xy_we=1;
4042
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_V; end
4043
end
4044
 
4045
if (pla[85]) begin
4046
    begin
4047
                    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=1; ctl_flags_cf_set=1;
4048
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
4049
    if (M1 && T1) begin
4050
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
4051
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
4052
                    ctl_flags_xy_we=1;
4053
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P; end
4054
    if (M1 && T2) begin
4055
                    ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; /* Clear CF going into the ALU core */ end
4056
end
4057
 
4058
if (pla[86]) begin
4059
    begin
4060
                    ctl_alu_core_R=1; ctl_alu_core_V=1; ctl_alu_core_S=1; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
4061
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
4062
    if (M1 && T1) begin
4063
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
4064
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
4065
                    ctl_flags_xy_we=1;
4066
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P; end
4067
    if (M1 && T2) begin
4068
                    ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; /* Clear CF going into the ALU core */ end
4069
end
4070
 
4071
if (pla[88]) begin
4072
    begin
4073
                    ctl_alu_core_R=1; ctl_alu_core_V=0; ctl_alu_core_S=0; ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
4074
                    ctl_flags_nf_we=1; ctl_flags_nf_clr=1; end
4075
    if (M1 && T1) begin
4076
                    ctl_reg_gp_we=1; ctl_reg_gp_sel=`GP_REG_AF; ctl_reg_gp_hilo=2'b10;
4077
                    ctl_reg_in_hi=1; ctl_reg_in_lo=1; /* From the ALU side into the register file */
4078
                    ctl_flags_xy_we=1;
4079
                    ctl_flags_pf_we=1; ctl_pf_sel=`PFSEL_P; end
4080
    if (M1 && T2) begin
4081
                    ctl_flags_cf_set=1; ctl_flags_cf_cpl=1; /* Clear CF going into the ALU core */ end
4082
end
4083
 
4084
// State machine to compute (IX+d)
4085
if (ixy_d) begin
4086
    if (T1) begin
4087
                    ctl_sw_2d=1;
4088
                    ctl_sw_1d=1;
4089
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
4090
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
4091
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
4092
                    ctl_alu_op2_sel_bus=1; /* Internal bus */
4093
                    ctl_flags_sz_we=1; end
4094
    if (T2) begin
4095
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b01;
4096
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
4097
                    ctl_sw_2d=1;
4098
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
4099
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
4100
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
4101
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
4102
 
4103
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
4104
    if (ctl_alu_op_low) begin
4105
                                                              ctl_flags_cf_set=1; ctl_flags_cf_cpl=1;
4106
    end else begin
4107
        ctl_alu_core_hf=1;
4108
    end
4109
                    ctl_flags_hf_we=1; end
4110
    if (T3) begin
4111
                    ctl_reg_sys_we_lo=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[0]=1; /* Selecting only Z */
4112
                    ctl_reg_in_lo=1; /* From the ALU side into the register file low byte only */
4113
                    ctl_sw_2u=1;
4114
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
4115
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
4116
                    ctl_alu_res_oe=1; /* Result latch */
4117
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
4118
 
4119
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
4120
    if (!ctl_alu_op_low) begin
4121
        ctl_alu_core_hf=1;
4122
    end
4123
                    ctl_flags_cf2_we=1; ctl_flags_cf2_sel=0; end
4124
    if (T4) begin
4125
                    ctl_reg_gp_sel=`GP_REG_HL; ctl_reg_gp_hilo=2'b10;
4126
                    ctl_reg_out_hi=1; ctl_reg_out_lo=1; /* From the register file into the ALU */
4127
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
4128
                    ctl_alu_shift_oe=!ctl_alu_bs_oe; /* Shifter unit without shift-enable */
4129
                    ctl_alu_op2_sel_zero=1; /* Zero */
4130
                    ctl_alu_op1_sel_bus=1; /* Internal bus */
4131
                    ctl_alu_op_low=1; /* Activate ALU operation on low nibble */
4132
 
4133
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
4134
    if (!ctl_alu_op_low) begin
4135
        ctl_alu_core_hf=1;
4136
    end
4137
                    ctl_flags_hf_we=1;
4138
                    ctl_flags_use_cf2=1;
4139
                    ctl_alu_sel_op2_neg=flags_sf; end
4140
    if (T5) begin
4141
                    ctl_reg_sel_wz=1; ctl_reg_sys_hilo=2'b11; ctl_sw_4d=1; /* Select 16-bit WZ */
4142
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
4143
                    ctl_reg_sys_we_hi=1; ctl_reg_sel_wz=1; ctl_reg_sys_hilo[1]=1; /* Selecting only W */
4144
                    ctl_reg_in_hi=1; /* From the ALU side into the register file high byte only */
4145
                    ctl_flags_alu=1; /* Load FLAGT from the ALU */
4146
                    ctl_alu_oe=1; /* Enable ALU onto the data bus */
4147
                    ctl_alu_res_oe=1; /* Result latch */
4148
                    ctl_alu_sel_op2_high=1; /* Activate ALU operation on high nibble */
4149
 
4150
    ctl_alu_core_R=0; ctl_alu_core_V=0; ctl_alu_core_S=0;
4151
    if (!ctl_alu_op_low) begin
4152
        ctl_alu_core_hf=1;
4153
    end
4154
                    ctl_flags_xy_we=1;
4155
                    ctl_alu_sel_op2_neg=flags_sf;
4156
                    ctl_state_ixiy_we=1; ctl_state_ixiy_clr=!setIXIY; /* Clear IX/IY flag */ end
4157
end
4158
 
4159
// Default instruction fetch (M1) state machine
4160
if (M1) begin
4161
    if (M1 && T1) begin
4162
                    ctl_reg_sys_we=1; ctl_reg_sel_pc=1; ctl_reg_sys_hilo=2'b11; pc_inc=!(in_halt | in_intr | in_nmi); /* Write 16-bit PC and control incrementer */
4163
                    ctl_inc_cy=pc_inc; /* Increment */
4164
                    ctl_bus_inc_oe=1; ctl_apin_mux2=1; /* Apin sourced from AL */ end
4165
    if (M1 && T2) begin
4166
                    ctl_reg_sel_ir=1; ctl_reg_sys_hilo=2'b11; /* Select 16-bit IR */
4167
                    ctl_al_we=1; /* Write a value from the register bus to the address latch */
4168
                    ctl_bus_db_oe=1; /* Read DB pads to internal data bus */
4169
                    ctl_state_ixiy_we=1; ctl_state_ixiy_clr=!setIXIY; /* Clear IX/IY flag */
4170
                    ctl_state_tbl_clr=!setCBED; /* Clear CB/ED prefix */
4171
                    ctl_ir_we=1;
4172
                    ctl_bus_zero_oe=in_halt; ctl_bus_ff_oe=(in_intr & (im1 | im2)) | in_nmi; end
4173
    if (M1 && T3) begin
4174
                    ctl_reg_sys_we=1; ctl_reg_sel_ir=1; ctl_reg_sys_hilo=2'b11; /* Write 16-bit IR */
4175
                    ctl_inc_cy=pc_inc; /* Increment */
4176
                    ctl_bus_inc_oe=1; ctl_apin_mux2=1; /* Apin sourced from AL */
4177
                    ctl_inc_limit6=1; /* Limit the incrementer to 6 bits */ end
4178
    if (M1 && T4) begin
4179
                    ctl_eval_cond=1; /* Evaluate flags condition based on the opcode[5:3] */ end
4180
end
4181
 

powered by: WebSVN 2.1.0

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