1 |
9 |
ns32kum |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2 |
|
|
//
|
3 |
|
|
// This file is part of the M32632 project
|
4 |
|
|
// http://opencores.org/project,m32632
|
5 |
|
|
//
|
6 |
|
|
// Filename: DECODER.v
|
7 |
|
|
// Version: 1.0
|
8 |
|
|
// Date: 30 May 2015
|
9 |
|
|
//
|
10 |
|
|
// Copyright (C) 2015 Udo Moeller
|
11 |
|
|
//
|
12 |
|
|
// This source file may be used and distributed without
|
13 |
|
|
// restriction provided that this copyright statement is not
|
14 |
|
|
// removed from the file and that any derivative work contains
|
15 |
|
|
// the original copyright notice and the associated disclaimer.
|
16 |
|
|
//
|
17 |
|
|
// This source file is free software; you can redistribute it
|
18 |
|
|
// and/or modify it under the terms of the GNU Lesser General
|
19 |
|
|
// Public License as published by the Free Software Foundation;
|
20 |
|
|
// either version 2.1 of the License, or (at your option) any
|
21 |
|
|
// later version.
|
22 |
|
|
//
|
23 |
|
|
// This source is distributed in the hope that it will be
|
24 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied
|
25 |
|
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
26 |
|
|
// PURPOSE. See the GNU Lesser General Public License for more
|
27 |
|
|
// details.
|
28 |
|
|
//
|
29 |
|
|
// You should have received a copy of the GNU Lesser General
|
30 |
|
|
// Public License along with this source; if not, download it
|
31 |
|
|
// from http://www.opencores.org/lgpl.shtml
|
32 |
|
|
//
|
33 |
|
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
34 |
|
|
//
|
35 |
|
|
// Modules contained in this file:
|
36 |
|
|
// DECODER Instruction Decoding and Flow Control
|
37 |
|
|
//
|
38 |
11 |
ns32kum |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
39 |
9 |
ns32kum |
|
40 |
11 |
ns32kum |
module DECODER ( BCLK, BRESET, INT_N, NMI_N, ANZ_VAL, OPREG, CFG, PSR, ACC_DONE, DC_ABORT, IC_ABORT, ACB_ZERO, DONE,
|
41 |
9 |
ns32kum |
PC_SAVE, STRING, INIT_DONE, ILL, UNDEF, TRAPS, IC_READ, STOP_CINV,
|
42 |
11 |
ns32kum |
GENSTAT, DISP, IMME_Q, DISP_BR, USED, NEW, LOAD_PC, NEXT_PCA, RDAA, RDAB, OPER, START, LD_OUT, LD_DIN, LD_IMME,
|
43 |
|
|
INFO_AU, ACC_FELD, WREN, WRADR, WMASKE, WR_REG, DETOIP, MMU_UPDATE, RESTART, STOP_IC, RWVAL, ENA_HK, ILO, COP_OP );
|
44 |
9 |
ns32kum |
|
45 |
|
|
input BCLK,BRESET;
|
46 |
|
|
input INT_N,NMI_N; // external inputs
|
47 |
|
|
input [2:0] ANZ_VAL;
|
48 |
|
|
input [55:0] OPREG; // the OPREG contains the bytes to decode, OPREG[55:32] are don't care
|
49 |
|
|
input [8:0] CFG; // CONFIG : many bits are don't-care
|
50 |
|
|
input [11:0] PSR;
|
51 |
|
|
input ACC_DONE;
|
52 |
|
|
input DC_ABORT,IC_ABORT;
|
53 |
|
|
input ACB_ZERO;
|
54 |
|
|
input DONE;
|
55 |
|
|
input [31:0] PC_SAVE;
|
56 |
|
|
input [4:0] STRING;
|
57 |
|
|
input INIT_DONE;
|
58 |
|
|
input ILL,UNDEF;
|
59 |
|
|
input [5:0] TRAPS;
|
60 |
|
|
input IC_READ;
|
61 |
|
|
input STOP_CINV; // not to mix it up with STOP_IC
|
62 |
|
|
|
63 |
|
|
output [2:0] GENSTAT;
|
64 |
11 |
ns32kum |
output [31:0] DISP,IMME_Q,DISP_BR; // three main data busses : Displacement, Immediate and Displacement for Branch
|
65 |
9 |
ns32kum |
output [2:0] USED;
|
66 |
|
|
output NEW;
|
67 |
|
|
output LOAD_PC;
|
68 |
|
|
output NEXT_PCA;
|
69 |
|
|
output [7:0] RDAA,RDAB;
|
70 |
|
|
output [10:0] OPER;
|
71 |
|
|
output [1:0] START,LD_OUT;
|
72 |
|
|
output LD_DIN,LD_IMME;
|
73 |
|
|
output [6:0] INFO_AU;
|
74 |
|
|
output [14:0] ACC_FELD;
|
75 |
|
|
output WREN;
|
76 |
|
|
output [5:0] WRADR;
|
77 |
|
|
output [1:0] WMASKE;
|
78 |
|
|
output reg WR_REG;
|
79 |
|
|
output [12:0] DETOIP;
|
80 |
|
|
output [1:0] MMU_UPDATE;
|
81 |
|
|
output RESTART;
|
82 |
|
|
output STOP_IC;
|
83 |
|
|
output [2:0] RWVAL;
|
84 |
|
|
output ENA_HK;
|
85 |
|
|
output reg ILO;
|
86 |
|
|
output [23:0] COP_OP;
|
87 |
|
|
|
88 |
|
|
reg [31:0] DISP,disp_val;
|
89 |
|
|
reg [10:0] oper_i;
|
90 |
|
|
reg [2:0] USED;
|
91 |
|
|
reg [14:0] ACC_FELD;
|
92 |
|
|
reg [1:0] ldoreg;
|
93 |
|
|
reg wren_i;
|
94 |
|
|
reg [5:0] wradr_i;
|
95 |
|
|
reg [1:0] wmaske_i;
|
96 |
|
|
reg [1:0] START;
|
97 |
|
|
reg [23:0] COP_OP;
|
98 |
|
|
reg spupd_i;
|
99 |
|
|
reg [3:0] disp_sel;
|
100 |
|
|
reg [52:0] op1_feld;
|
101 |
|
|
reg [47:0] op2_feld;
|
102 |
|
|
reg [47:0] op3_feld;
|
103 |
|
|
reg [47:0] op_feld_reg;
|
104 |
|
|
reg [31:0] imme_i;
|
105 |
|
|
reg [2:0] valid;
|
106 |
|
|
reg [7:0] phase_reg;
|
107 |
|
|
reg [3:0] di_stat; // Displacement Status
|
108 |
|
|
reg [3:0] cc_feld;
|
109 |
|
|
reg [1:0] ex_br_op;
|
110 |
|
|
reg acb_reg;
|
111 |
|
|
reg jsr_flag;
|
112 |
|
|
reg [8:0] waitop,wait_reg;
|
113 |
|
|
reg branch;
|
114 |
|
|
reg [3:0] dim_feld;
|
115 |
|
|
reg [66:0] new_op;
|
116 |
|
|
reg short_op_reg;
|
117 |
|
|
reg [15:0] idx_reg;
|
118 |
|
|
reg [35:0] gen_src1;
|
119 |
|
|
reg [33:0] gen_src2;
|
120 |
|
|
reg qw_flag;
|
121 |
|
|
reg long_reg;
|
122 |
|
|
reg new_spsel;
|
123 |
|
|
reg s_user,old_su;
|
124 |
|
|
reg [1:0] stack_sel; // Stack select for USER and SUPERVISOR
|
125 |
|
|
reg [1:0] s_mod; // Modifier for Stack select
|
126 |
|
|
reg upd_info,dw_info;
|
127 |
|
|
reg [2:0] rpointer;
|
128 |
|
|
reg [5:0] resto; // for RESTORE
|
129 |
|
|
reg init_rlist;
|
130 |
|
|
reg new_fp;
|
131 |
|
|
reg format1;
|
132 |
|
|
reg ldpc_phase;
|
133 |
|
|
reg reti_flag;
|
134 |
|
|
reg no_t2p;
|
135 |
|
|
reg iabort,ia_save;
|
136 |
|
|
reg mmu_sel;
|
137 |
|
|
reg [1:0] nmi_reg;
|
138 |
|
|
reg nmi_flag,int_flag;
|
139 |
|
|
reg type_nmi;
|
140 |
|
|
reg [3:0] exc_vector;
|
141 |
|
|
reg phase_exc;
|
142 |
|
|
reg [3:0] ovf_pipe;
|
143 |
|
|
reg dbg_s,dbg_trap,dbg_en,addr_cmp;
|
144 |
|
|
reg ssrc_flag,sdest_flag;
|
145 |
|
|
reg op_setcfg,setcfg_lsb;
|
146 |
|
|
reg inss_op;
|
147 |
|
|
reg exin_cmd,extract; // EXT/INS
|
148 |
|
|
reg bit_reg; // Flag for Bit opcodes : Source2 = Reg
|
149 |
|
|
reg kurz_st; // Flag for MOVM/CMPM
|
150 |
|
|
reg kill_opt; // Flag for optimized MOVS
|
151 |
|
|
reg cmps_flag; // Flag for CMPS
|
152 |
|
|
reg skps_flag; // Flag for SKPS
|
153 |
|
|
reg mt_flag; // Flag for Match and Translate
|
154 |
|
|
reg spu_block; // block of SP update at Long operation
|
155 |
|
|
reg dia_op,dia_flag; // Flag for DIA
|
156 |
|
|
reg m_ussu,m_usel,dc_user; // MOVUS/SU
|
157 |
|
|
reg rwval_flag,wrval_flag; // RDVAL/WRVAL
|
158 |
|
|
reg cinv_flag; // Flag for CINV
|
159 |
|
|
reg [5:0] lmrreg;
|
160 |
|
|
reg no_init,a_ivar;
|
161 |
|
|
reg index_cmd;
|
162 |
|
|
reg stop_d;
|
163 |
|
|
reg dc_ilo;
|
164 |
|
|
|
165 |
|
|
wire PHASE_0;
|
166 |
|
|
wire [7:0] phase_ein; // Phase after ABORT has changed the content to 0
|
167 |
|
|
wire de_flag,ivec_flag;
|
168 |
|
|
wire next;
|
169 |
|
|
wire [18:0] new_addr,pop_fp,save_pc;
|
170 |
|
|
wire [13:0] new_regs;
|
171 |
|
|
wire [7:0] new_ph,ppfp;
|
172 |
|
|
wire [7:0] new_nx;
|
173 |
|
|
wire op_1byte,op_12byte,op_2byte,op_3byte;
|
174 |
|
|
wire jump;
|
175 |
|
|
wire short_op,short_def;
|
176 |
|
|
wire acb_op,acb_flag;
|
177 |
|
|
wire zero,carry_psr,negativ,larger,flag;
|
178 |
|
|
wire valid_size;
|
179 |
|
|
wire op_ok;
|
180 |
|
|
wire stop;
|
181 |
|
|
wire [47:0] opc_bits;
|
182 |
|
|
wire [47:0] op_feld;
|
183 |
|
|
wire [2:0] atys,atyd;
|
184 |
|
|
wire [3:0] auop_s,auop_d;
|
185 |
|
|
wire long,src2_flag,dest_flag;
|
186 |
|
|
wire [6:0] src_1,src_2,src_1l,src_2l;
|
187 |
|
|
wire [1:0] src1_le,src2_le;
|
188 |
|
|
wire acc1,acc2;
|
189 |
|
|
wire spupd;
|
190 |
|
|
wire [6:0] saver; // for SAVE
|
191 |
|
|
wire [2:0] reg_nr;
|
192 |
|
|
wire save_reg;
|
193 |
|
|
wire ld_disp,disp_ok;
|
194 |
|
|
wire store_pc;
|
195 |
|
|
wire do_xor;
|
196 |
|
|
wire do_long;
|
197 |
|
|
wire [1:0] idx_n,n_idx;
|
198 |
|
|
wire idx;
|
199 |
|
|
wire [1:0] otype;
|
200 |
|
|
wire [10:0] opera,op_str,op_sho;
|
201 |
|
|
wire [5:0] dest_r,dest_rl;
|
202 |
|
|
wire phase_idx;
|
203 |
|
|
wire [15:0] idx_bytes,idx_feld;
|
204 |
|
|
wire [3:0] idx_1,idx_2;
|
205 |
|
|
wire [4:0] src1_addr,src2_addr;
|
206 |
|
|
wire [6:0] usp_1,usp_2;
|
207 |
|
|
wire [33:0] tos_oper;
|
208 |
11 |
ns32kum |
wire [18:0] adrd1,exr11,exr12,adrd2,adwr2,exr22,exw22,re_wr,st_src,st_src2,st_dest,st_len,st_trde,st_trs2;
|
209 |
9 |
ns32kum |
wire [7:0] phrd1,phrd2,phwr2;
|
210 |
|
|
wire [6:0] rega1,irrw1,rega2,irrw2;
|
211 |
|
|
wire [3:0] nxrd1,nxrw2;
|
212 |
|
|
wire rmw;
|
213 |
|
|
wire [6:0] quei1,quet1; // Registeradr
|
214 |
|
|
wire [7:0] endea,goacb,dowait; // Phase
|
215 |
|
|
wire [3:0] diacb; // DIMM access
|
216 |
|
|
wire qword;
|
217 |
|
|
wire [6:0] stack,no_modul,ttstak;
|
218 |
|
|
wire [12:0] pop_1;
|
219 |
|
|
wire mpoi_1,mpoi_2;
|
220 |
|
|
wire [1:0] src1_tos; // the code for REUSE is 2'b11
|
221 |
|
|
wire svc_flag,bpt_flag,flag_flag,trac_flag;
|
222 |
|
|
wire [3:0] misc_vectors;
|
223 |
|
|
wire [2:0] psr_code;
|
224 |
|
|
wire exception;
|
225 |
|
|
wire interrupt;
|
226 |
|
|
wire abort; // DC_ABORT | iabort;
|
227 |
|
|
wire abo_int;
|
228 |
|
|
wire iabo_fall;
|
229 |
|
|
wire abbruch,fpu_trap,dvz_trap;
|
230 |
|
|
wire abbruch2;
|
231 |
|
|
wire dbg_flag;
|
232 |
|
|
wire ovf_op,ovf2_op,ovf_flag;
|
233 |
|
|
wire pc_match;
|
234 |
|
|
wire no_trap;
|
235 |
|
|
wire [10:0] op_psr,op_scp;
|
236 |
|
|
wire [30:0] ai_next;
|
237 |
|
|
wire set_src,set_dest,clr_sflag;
|
238 |
|
|
wire [7:0] rrepa; // Repair Phase of Abort for String opcodes
|
239 |
|
|
wire [7:0] ph_str; // working phase String
|
240 |
|
|
wire ph_match;
|
241 |
|
|
wire t2p;
|
242 |
|
|
wire rw_bit,op_ilo;
|
243 |
|
|
wire setcfg;
|
244 |
|
|
wire string_ende;
|
245 |
|
|
wire wlor; // Flag to generate WR_REG signal
|
246 |
|
|
wire [5:0] wstr0,wstr1,wstr2;
|
247 |
|
|
wire [6:0] rstr0,rstr1,rstr2;
|
248 |
|
|
wire rett_exc;
|
249 |
|
|
wire chk_rmw;
|
250 |
|
|
|
251 |
|
|
// Variables for 2- and 3-Byte Dekoder :
|
252 |
|
|
reg [5:0] hzr_c; // CASE Statement
|
253 |
|
|
wire [1:0] hzl_a;
|
254 |
|
|
wire [2:0] hzl_b;
|
255 |
|
|
wire [5:0] hzr_a,hzr_b,hzr_s;
|
256 |
|
|
wire hdx_a;
|
257 |
|
|
wire hdo_b;
|
258 |
|
|
wire [3:0] hdo_a,hdo_c,hdo_e;
|
259 |
|
|
wire [7:0] hdo_d;
|
260 |
|
|
wire [1:0] hdl_b,hdl_d,hdl_f,hdl_g,hdl_h;
|
261 |
|
|
wire [2:0] hdl_a,hdl_c,hdl_e;
|
262 |
|
|
wire [5:0] hdr_a,hdr_b,hdr_c,hdr_d,hdr_e,hdr_f,hdr_g,hdr_m;
|
263 |
|
|
|
264 |
|
|
wire [66:0] state_0,state_group_50,state_group_60; // for the Gruppe 2 opcodes
|
265 |
|
|
|
266 |
|
|
// Address field : Size:2 RD WR LDEA FULLACC INDEX:4 SPUPD disp_val:4 POST CLRMSW SRC2SEL:2
|
267 |
|
|
|
268 |
|
|
parameter addr_nop = 19'b10_0000_0000_0_0000_0000; // all parameter to 0
|
269 |
|
|
parameter push_op = 19'b10_0111_0000_1_1010_0000; // i.e. for BSR, ENTER ...
|
270 |
|
|
parameter push_ea = 19'b10_0111_0000_1_1010_0011; // SAVE middle
|
271 |
|
|
parameter pop_op = 19'b10_1011_0010_1_0000_1000; // RET/RESTORE
|
272 |
|
|
parameter adddisp = 19'b10_0010_0000_0_0000_0011; // for RET : reuse of EA
|
273 |
|
|
parameter adddispn = 19'b10_0010_0000_0_0000_0000; // for RETT : add Disp to Stack
|
274 |
|
|
parameter save_sp = 19'b10_0000_0000_1_0000_0000; // u.a. RET : update of Stack
|
275 |
|
|
parameter next_po = 19'b10_1011_0010_1_0000_1011; // RESTORE middle
|
276 |
|
|
parameter dispmin = 19'b10_0010_0000_0_0100_0011; // Reuse for ENTER
|
277 |
11 |
ns32kum |
parameter rmod_rxp = 19'b10_1001_0000_1_0000_0100; // MODUL+0 read : SB , SP Update , therefore no LDEA
|
278 |
9 |
ns32kum |
parameter rmod_rtt = 19'b10_1001_0000_0_0000_0100; // MODUL+0 read : SB , no LDEA
|
279 |
|
|
parameter rmod_4 = 19'b10_1011_0000_0_0001_0100; // MODUL+4 read : Link Table Base
|
280 |
|
|
parameter rmod_8 = 19'b10_1011_0000_0_0010_0100; // MODUL+8 read : Program Base
|
281 |
|
|
parameter rdltab = 19'b10_1010_0000_0_1000_0000; // Link table read - EA Phase
|
282 |
|
|
parameter ea_push = 19'b10_0110_0000_0_1010_0011; // CXP : 2. Push EA Phase
|
283 |
|
|
parameter ea_min8 = 19'b10_1010_0000_0_1011_0011; // CXP : reuse of MOD+8
|
284 |
|
|
parameter pop_ru = 19'b10_1010_0010_0_0000_1011; // RXP : EA Phase MOD POP
|
285 |
|
|
parameter rd_icu = 19'b00_1001_0000_0_1100_0010; // Read ICU : Byte of fix address
|
286 |
|
|
parameter get_vec = 19'b10_1001_0000_0_01xx_0000; // Read Exception-Vector : Index Exception No.
|
287 |
11 |
ns32kum |
parameter get_veci = 19'b10_1001_0110_0_0000_0000; // Read Exception-Vector : Index external Interrupt
|
288 |
9 |
ns32kum |
parameter load_ea = 19'b10_0010_0000_0_0000_0000; // used for store of TEAR and MSR
|
289 |
|
|
parameter save_msr = 19'b10_0010_0001_0_0000_0000; // used for store of TEAR and MSR
|
290 |
|
|
parameter ivar_adr = 19'b10_0000_0100_0_0000_0010; // only pass SRC1
|
291 |
|
|
parameter st_trans = 19'b00_1001_0100_0_0000_0000; // Translate at String : SRC1 + SRC2 , Byte
|
292 |
|
|
parameter src_x = 7'hxx;
|
293 |
|
|
parameter dest_x = 6'hxx;
|
294 |
|
|
parameter imme = {1'b1,6'hxx};
|
295 |
|
|
parameter frame = 7'h18;
|
296 |
|
|
parameter ibase = 7'h1E;
|
297 |
|
|
parameter modul = 7'h1F;
|
298 |
|
|
parameter w_msr = 6'h0A;
|
299 |
|
|
parameter w_tear = 6'h0B;
|
300 |
|
|
parameter fsr_r = 6'h17; // not defined register for FSR for opcodes LFSR and SFSR
|
301 |
|
|
parameter temp_l = 6'h3C;
|
302 |
|
|
parameter temp_h = 6'h3D; // second last space for 8B TEMP register
|
303 |
|
|
parameter temp_1 = 6'h3E; // Backup for register at String operations
|
304 |
|
|
parameter temp_2 = 6'h3F;
|
305 |
|
|
parameter rtmpl = 7'h3C;
|
306 |
|
|
parameter rtmph = 7'h3D;
|
307 |
|
|
parameter rtmp1 = 7'h3E;
|
308 |
|
|
parameter rtmp2 = 7'h3F;
|
309 |
|
|
parameter op_mov = {3'bxxx,8'h45};
|
310 |
|
|
parameter op_adr = {3'bxxx,8'h49};
|
311 |
|
|
parameter op_add = 11'h340; // for CXP
|
312 |
|
|
parameter op_flip = 11'h364; // for CXP : LSHD -16,Ri
|
313 |
|
|
parameter op_lmr = 11'h36A; // for LPR CFG, LMR and CINV
|
314 |
|
|
parameter op_wrp = 11'h387; // for CXP : write PSR , used also for Exception processing
|
315 |
|
|
parameter op_ldp = 11'h388; // for RETT and RETI : load of PSR from Stack
|
316 |
|
|
parameter op_zex = 11'h076; // Zero Extension for ICU Vector - is also used at String Option "T"
|
317 |
|
|
parameter op_cop = 8'hDD; // Coprozessor Opcode
|
318 |
|
|
|
319 |
11 |
ns32kum |
// ++++++++++++++++++++++++++ The switch logic for the state machine +++++++++++++++++++++++++++++
|
320 |
9 |
ns32kum |
|
321 |
|
|
always @(ANZ_VAL)
|
322 |
|
|
case (ANZ_VAL)
|
323 |
|
|
3'd0 : valid = 3'b000;
|
324 |
|
|
3'd1 : valid = 3'b001;
|
325 |
|
|
3'd2 : valid = 3'b011;
|
326 |
|
|
default : valid = 3'b111;
|
327 |
|
|
endcase
|
328 |
|
|
|
329 |
|
|
assign next = ( PHASE_0 ? op_ok : // Opcode decoded or Exception processed
|
330 |
|
|
// Displacement or Immediate operand and external memory access can happen in parallel
|
331 |
|
|
// i.e. addressing mode Memory Relative
|
332 |
|
|
( ((~dim_feld[0] | ACC_DONE) & (~dim_feld[3] | di_stat[0])) // ACC_DONE resets dim_feld
|
333 |
|
|
// long operation
|
334 |
|
|
& ~(long_reg & ~DONE) ) )
|
335 |
|
|
// hard break : abort or fpu_trap or dvz_trap or ovf_flag
|
336 |
|
|
| abbruch ;
|
337 |
|
|
|
338 |
|
|
always @(posedge BCLK or negedge BRESET)
|
339 |
|
|
if (!BRESET) long_reg <= 1'b0;
|
340 |
|
|
else
|
341 |
|
|
long_reg <= next ? do_long : long_reg; // START[1]
|
342 |
|
|
|
343 |
|
|
always @(posedge BCLK or negedge BRESET) // the central phase register
|
344 |
|
|
if (!BRESET) phase_reg <= 8'h0;
|
345 |
|
|
else
|
346 |
|
|
if (next) phase_reg <= new_op[47:40];
|
347 |
|
|
|
348 |
|
|
always @(*) // next switch of micro program counter
|
349 |
|
|
casex ({PHASE_0,op_ok,dim_feld[3],di_stat[0]})
|
350 |
|
|
4'b11_xx : USED = {1'b0,~op_1byte,(op_1byte | op_3byte)};
|
351 |
|
|
4'b0x_11 : USED = di_stat[3:1];
|
352 |
|
|
default : USED = 3'd0;
|
353 |
|
|
endcase
|
354 |
|
|
|
355 |
|
|
// Special phases
|
356 |
|
|
|
357 |
|
|
assign PHASE_0 = (phase_reg == 8'h00); // During Phase 0 the opcode is decoded
|
358 |
|
|
|
359 |
|
|
assign NEXT_PCA = PHASE_0 & ~ovf_flag & ~dbg_flag;
|
360 |
|
|
|
361 |
|
|
// Pulse to transfer from Trace Bit to Pending Trace Bit, only once in the beginning of phase 0
|
362 |
|
|
// The priority is such that a TRACE exception is served before an UNDEFINED/ILLEGAL exception
|
363 |
|
|
always @(posedge BCLK) no_t2p <= PHASE_0 & ~op_ok;
|
364 |
|
|
assign t2p = PHASE_0 & ~no_t2p; // signal to I_PFAD
|
365 |
|
|
|
366 |
|
|
// ++++++++++++++++++++++++++ global control signals ++++++++++++++++
|
367 |
|
|
|
368 |
|
|
assign de_flag = CFG[8];
|
369 |
|
|
assign ivec_flag = CFG[0];
|
370 |
|
|
assign dvz_trap = TRAPS[1];
|
371 |
|
|
assign fpu_trap = TRAPS[0];
|
372 |
|
|
|
373 |
11 |
ns32kum |
always @(posedge BCLK) nmi_reg <= {nmi_reg[0],NMI_N}; // one clock sync and than falling edge detection
|
374 |
9 |
ns32kum |
|
375 |
|
|
always @(posedge BCLK or negedge BRESET)
|
376 |
|
|
if (!BRESET) nmi_flag <= 1'b0;
|
377 |
|
|
else nmi_flag <= (nmi_reg == 2'b10) | (nmi_flag & ~(phase_reg == 8'h82));
|
378 |
|
|
|
379 |
|
|
always @(posedge BCLK) int_flag <= PSR[11] & ~INT_N; // one clock to synchronise
|
380 |
|
|
|
381 |
11 |
ns32kum |
assign stop = (int_flag | nmi_flag) & PHASE_0 & ~stop_d; // neccesary if FPU_TRAP and INT at the same time
|
382 |
9 |
ns32kum |
assign interrupt = (int_flag | nmi_flag) & (~PHASE_0 | stop_d);
|
383 |
|
|
|
384 |
|
|
always @(posedge BCLK or negedge BRESET)
|
385 |
|
|
if (!BRESET) stop_d <= 1'd0;
|
386 |
|
|
else stop_d <= stop;
|
387 |
|
|
|
388 |
|
|
// ++++++++++++++++++++++++++ Exception processing +++++++++++++++
|
389 |
|
|
|
390 |
|
|
// IC_ABORT is valid if Opcode Decoder cannot continue
|
391 |
|
|
assign iabo_fall = IC_ABORT & (PHASE_0 ? ~op_ok : (~di_stat[0] & dim_feld[3]));
|
392 |
|
|
|
393 |
|
|
always @(posedge BCLK) iabort <= iabo_fall & ~ia_save; // DC_ABORT ist a pulse
|
394 |
|
|
always @(posedge BCLK) ia_save <= iabo_fall;
|
395 |
|
|
|
396 |
|
|
// mmu_sel is used in ADDR_UNIT
|
397 |
|
|
always @(posedge BCLK) mmu_sel <= DC_ABORT | (mmu_sel & ~iabort); // 1 = DCACHE , 0 = ICACHE
|
398 |
|
|
assign MMU_UPDATE[0] = mmu_sel;
|
399 |
|
|
|
400 |
|
|
assign abort = DC_ABORT | iabort;
|
401 |
|
|
|
402 |
|
|
// that is the end of String loops where interrupts are checked : 8'hC7 & 8'hCF
|
403 |
11 |
ns32kum |
assign string_ende = (phase_reg[7:4] == 4'hC) & (phase_reg[2:0] == 3'b111); // attention : 8'hCF does not exist
|
404 |
9 |
ns32kum |
|
405 |
11 |
ns32kum |
always @(posedge BCLK) if (PHASE_0 || string_ende) type_nmi <= nmi_flag; // during processing kept stable
|
406 |
9 |
ns32kum |
|
407 |
|
|
assign svc_flag = (OPREG[7:0] == 8'hE2) & valid[0]; // Vector 5 : 0101 , Illegal Vector 4 : 0100
|
408 |
|
|
assign bpt_flag = (OPREG[7:0] == 8'hF2) & valid[0]; // Vector 8 : 1000 , Undefined Vec. 10 : 1010
|
409 |
|
|
assign flag_flag = (phase_reg == 8'h89) & flag; // Vector 7 - has an own state
|
410 |
|
|
assign trac_flag = t2p & PSR[10]; // Vector 9 : 1001 , PSR[10] = P Bit , Pending Trace
|
411 |
|
|
assign ovf_flag = (ovf_pipe[3] & flag) | (ovf_pipe[1] & TRAPS[2]); // Vector 13 : 1101
|
412 |
|
|
assign dbg_flag = dbg_trap | (dbg_s & PHASE_0); // Vector 14 : 1110
|
413 |
|
|
|
414 |
|
|
// abort + dvz_trap during a opcode, fpu_trap + ovf_flag + dbg_flag later
|
415 |
|
|
assign abbruch = abort | fpu_trap | dvz_trap | ovf_flag | dbg_flag; // this 5 stop everything
|
416 |
|
|
assign abbruch2 = abort | fpu_trap | dvz_trap | ovf_flag; // for exc_vector generation
|
417 |
|
|
|
418 |
|
|
// forces the next step of state machine (op_ok), generates otype="11" for Trap Service
|
419 |
|
|
assign exception = interrupt | svc_flag | bpt_flag | ILL | UNDEF | trac_flag | abbruch;
|
420 |
|
|
|
421 |
|
|
// a TRACE Exception is done before the opcode execution
|
422 |
11 |
ns32kum |
assign misc_vectors = trac_flag ? 4'h9 : {(bpt_flag | UNDEF),(svc_flag | ILL),UNDEF,svc_flag}; // the vectors are exclusiv
|
423 |
9 |
ns32kum |
|
424 |
|
|
always @(posedge BCLK)
|
425 |
|
|
if (PHASE_0 || abbruch) // ABORTs, fpu_trap, dvz_trap + ovf_flag can happen every time
|
426 |
|
|
begin
|
427 |
11 |
ns32kum |
exc_vector <= abbruch ? (abbruch2 ? {ovf_flag,(dvz_trap | ovf_flag),~ovf_flag,(fpu_trap | ovf_flag)} : 4'hE)
|
428 |
9 |
ns32kum |
: (interrupt ? {3'b0,nmi_flag} : misc_vectors); // misc_vectors is default
|
429 |
|
|
end
|
430 |
|
|
else
|
431 |
|
|
if (flag_flag) exc_vector <= 4'h7; // FLAG-Trap
|
432 |
|
|
else
|
433 |
|
|
if (interrupt && string_ende) exc_vector <= {3'b0,nmi_flag};
|
434 |
|
|
|
435 |
11 |
ns32kum |
assign psr_code[2] = ~psr_code[1]; // Absicht : codiert das Sichern des PSR bei Exception-Entry
|
436 |
|
|
assign psr_code[1] = abort | ILL | UNDEF | trac_flag; // enable for reseting the P-Bit during write of PSR to stack
|
437 |
9 |
ns32kum |
assign psr_code[0] = (interrupt & ~fpu_trap) | abort; // enable for reseting the I-Bit of new PSR
|
438 |
|
|
|
439 |
|
|
// valid codes are x'89 to x'8F
|
440 |
11 |
ns32kum |
assign op_psr = {8'b0_00_1000_1,psr_code}; // is used during first clock cylce after exception, is transfered as OPCODE to I_PFAD
|
441 |
9 |
ns32kum |
|
442 |
11 |
ns32kum |
// Specialitiies : ABORT stores address & flags , the Interrrupts read vectors : all is used in big CASE
|
443 |
9 |
ns32kum |
assign abo_int = (exc_vector == 4'h2) | (exc_vector[3:1] == 3'b000);
|
444 |
|
|
assign ai_next = (exc_vector == 4'h2) ? {load_ea,8'h84,4'h0} : {rd_icu,8'h82,4'h1};
|
445 |
|
|
|
446 |
11 |
ns32kum |
assign save_pc = {7'b10_0010_0,dia_flag,7'b00_0_0000,dia_flag,3'b001}; // Exception : PC_ARCHI => EA, special case DIA
|
447 |
|
|
assign no_trap = ~fpu_trap & ~ovf_flag & ~dbg_flag; // suppresion of WREN and LD_OUT[1] and ADDR_UNIT operation
|
448 |
9 |
ns32kum |
|
449 |
|
|
// ++++++++++++++++++++++++++ Overflow Trap ++++++++++++++
|
450 |
|
|
|
451 |
|
|
always @(posedge BCLK)
|
452 |
|
|
if (ovf_flag || !PSR[4]) ovf_pipe <= 4'd0;
|
453 |
|
|
else
|
454 |
11 |
ns32kum |
if (PHASE_0) ovf_pipe <= {ovf_pipe[2],(ovf_op & op_ok),ovf_pipe[0],(ovf2_op & op_ok)}; // V-Bit switches on
|
455 |
9 |
ns32kum |
|
456 |
|
|
assign ovf_op = ( ((OPREG[6:2] == 5'b000_11) // ADDQi
|
457 |
|
|
| (OPREG[3:2] == 2'b00)) & (OPREG[1:0] != 2'b10)) // ADDi,ADDCi,SUBi,SUBCi
|
458 |
|
|
| ((OPREG[7:0] == 8'h4E) & OPREG[13] & (OPREG[11:10] == 2'b00)) // NEGi,ABSi
|
459 |
|
|
| ((OPREG[7:0] == 8'hEE) & ~OPREG[10]); // CHECKi
|
460 |
|
|
|
461 |
11 |
ns32kum |
assign ovf2_op = ((OPREG[6:2] == 5'b100_11) & (OPREG[1:0] != 2'b10)) // ACBi, these overflows have no FLAG
|
462 |
9 |
ns32kum |
| ((OPREG[13:10] == 4'h1) & (OPREG[7:0] == 8'h4E)) // ASHi
|
463 |
|
|
| ( OPREG[13] & (OPREG[11] == OPREG[10]) & (OPREG[7:0] == 8'hCE)); // MULi,DEIi,QUOi,DIVi
|
464 |
|
|
|
465 |
|
|
// ++++++++++++++++++++++++++ Debug Trap ++++++++++++++
|
466 |
|
|
|
467 |
|
|
always @(posedge BCLK or negedge BRESET)
|
468 |
|
|
if (!BRESET) dbg_s <= 1'b0;
|
469 |
|
|
else dbg_s <= dbg_trap | (dbg_s & ~((exc_vector == 4'hE) & (phase_reg == 8'h81)));
|
470 |
|
|
|
471 |
|
|
always @(posedge BCLK) dbg_en <= op_ok | ~PHASE_0;
|
472 |
|
|
|
473 |
|
|
assign pc_match = dbg_en & TRAPS[3] & PHASE_0 & ~exception; // TRAPS[3] is only combinatorical
|
474 |
|
|
|
475 |
11 |
ns32kum |
always @(posedge BCLK) dbg_trap <= (pc_match | (addr_cmp & PHASE_0)) & TRAPS[5]; // TRAPS[5] = Enable Trap
|
476 |
9 |
ns32kum |
|
477 |
|
|
always @(posedge BCLK) addr_cmp <= TRAPS[4] | (addr_cmp & ~PHASE_0); // TRAPS[4] = CAR HIT
|
478 |
|
|
|
479 |
|
|
// ++++++++++++++++++++++++++ Special case String Abort ++++++++++++++
|
480 |
|
|
|
481 |
11 |
ns32kum |
// Flags cleared if entry and exit of string operation and during Abort sequence, not valid for MOVM/CMPM
|
482 |
9 |
ns32kum |
// special case UNTIL/WHILE : reset if exit (op_feld_reg[17] = 1 = UNTIL)
|
483 |
11 |
ns32kum |
assign clr_sflag = (phase_reg == 8'hC0) | (phase_reg == 8'hC7) | (phase_reg == 8'hC8) | (phase_reg == 8'h81)
|
484 |
9 |
ns32kum |
| (((phase_reg == 8'hD7) | (phase_reg == 8'hDF)) & ~(STRING[3] ^ op_feld_reg[17])) ;
|
485 |
|
|
assign set_src = (phase_reg == 8'hC1) | (phase_reg == 8'hC9);
|
486 |
|
|
assign set_dest = (phase_reg == 8'hC4) | (phase_reg == 8'hCC);
|
487 |
|
|
|
488 |
|
|
always @(posedge BCLK or negedge BRESET) // R1 is modified
|
489 |
|
|
if (!BRESET) ssrc_flag <= 1'b0;
|
490 |
|
|
else ssrc_flag <= (set_src & ~kurz_st) | (ssrc_flag & ~clr_sflag);
|
491 |
|
|
|
492 |
|
|
always @(posedge BCLK or negedge BRESET) // R2 is modified
|
493 |
|
|
if (!BRESET) sdest_flag <= 1'b0;
|
494 |
|
|
else sdest_flag <= (set_dest & ~kurz_st) | (sdest_flag & ~clr_sflag);
|
495 |
|
|
|
496 |
|
|
assign rrepa = {7'b1000_011,~sdest_flag}; // R1 and if necessary R2 restore
|
497 |
|
|
|
498 |
|
|
// ++++++++++++++++++++++++++ The one byte opcodes +++++++++++++++++++
|
499 |
|
|
|
500 |
11 |
ns32kum |
// The one byte opcodes have a special case : one byte opcode but the second byte should be valid too
|
501 |
9 |
ns32kum |
// Used with SAVE, RESTORE, ENTER and EXIT with their reg list.
|
502 |
|
|
// The advantage is that the reg list is store in op_feld_reg.
|
503 |
|
|
|
504 |
|
|
// [52:34] addressing
|
505 |
|
|
// [33:20] register
|
506 |
|
|
// [19:18] 1 or 2 Byte opcode
|
507 |
|
|
// [17:16] BSR/BR
|
508 |
|
|
// [15:8] next phase
|
509 |
|
|
// [7:4] START + LD_OUT
|
510 |
|
|
// [3:0] operand access : Displacement or Speicher
|
511 |
|
|
|
512 |
|
|
always @(*) // SVC (E2) and BPT (F2) decode as exception
|
513 |
|
|
casex (OPREG[7:0])
|
514 |
|
|
8'hxA : op1_feld = {addr_nop, src_x, src_x, 2'b01,2'b01,8'h01,4'h0,4'hE}; // Bcc , DISP read
|
515 |
|
|
8'h02 : op1_feld = {addr_nop, src_x, src_x, 2'b01,2'b10,8'h01,4'h0,4'hE}; // BSR , DISP read
|
516 |
|
|
8'h12 : op1_feld = {pop_op , src_x, stack, 2'b01,2'b00,8'h2A,4'h0,4'h1}; // RET , DISP later
|
517 |
|
|
8'h22 : op1_feld = {rmod_4 , src_x, modul, 2'b01,2'b00,8'h35,4'h0,4'h1}; // CXP
|
518 |
|
|
8'h32 : op1_feld = {pop_op, src_x, stack, 2'b01,2'b00,8'h40,4'h0,4'h1}; // RXP
|
519 |
|
|
8'h42 : op1_feld = {pop_op, src_x, stack, 2'b01,2'b00,8'h46,4'h0,4'h1}; // RETT
|
520 |
|
|
8'h52 : op1_feld = {rd_icu, src_x, src_x, 2'b01,2'b00,8'h45,4'h0,4'h1}; // RETI
|
521 |
|
|
8'h62 : op1_feld = {addr_nop, src_x, src_x, 2'b10,2'b00,8'h30,4'h0,4'h0}; // SAVE
|
522 |
|
|
8'h72 : op1_feld = {addr_nop, src_x, src_x, 2'b10,2'b00,8'h32,4'h0,4'h0}; // RESTORE
|
523 |
|
|
8'h82 : op1_feld = {push_op , frame, stack, 2'b10,2'b00,8'h2D,4'h2,4'h1}; // ENTER : PUSH FP
|
524 |
|
|
8'h92 : op1_feld = {addr_nop, src_x, src_x, 2'b10,2'b00,8'h32,4'h0,4'h0}; // EXIT : POP FP
|
525 |
|
|
8'hA2 : op1_feld = {addr_nop, src_x, src_x, 2'b01,2'b00,8'h00,4'h0,4'h0}; // NOP
|
526 |
|
|
8'hB2 : op1_feld = {addr_nop, src_x, src_x, 2'b01,2'b00,8'h88,4'h0,4'h0}; // WAIT
|
527 |
|
|
8'hC2 : op1_feld = {addr_nop, src_x, src_x, 2'b01,2'b00,8'h88,4'h0,4'h0}; // DIA
|
528 |
|
|
8'hD2 : op1_feld = {addr_nop, src_x, src_x, 2'b01,2'b00,8'h89,4'h0,4'h0}; // FLAG
|
529 |
|
|
default : op1_feld = {19'hxxxxx,14'hxxxx, 2'b00,2'b00,16'hxxxx};
|
530 |
|
|
endcase
|
531 |
|
|
|
532 |
|
|
assign op_1byte = op1_feld[18] & valid[0];
|
533 |
|
|
assign op_12byte = op1_feld[19] & (valid[1:0] == 2'b11);
|
534 |
|
|
|
535 |
|
|
assign new_addr = op1_feld[52:34];
|
536 |
|
|
assign new_regs = op1_feld[33:20];
|
537 |
|
|
assign new_ph = op1_feld[15:8];
|
538 |
|
|
assign new_nx = op1_feld[7:0]; // at Bcond DISP read
|
539 |
|
|
|
540 |
|
|
assign pop_fp = new_fp ? pop_op : addr_nop;
|
541 |
|
|
assign ppfp = new_fp ? 8'h34 : 8'h00;
|
542 |
|
|
|
543 |
|
|
always @(posedge BCLK)
|
544 |
|
|
if (PHASE_0)
|
545 |
|
|
begin
|
546 |
|
|
ex_br_op <= op1_feld[17:16]; // BSR/BR
|
547 |
|
|
cc_feld <= OPREG[7:4];
|
548 |
|
|
new_fp <= (OPREG[7:6] == 2'b10); // not decoded complete but is sufficient
|
549 |
|
|
reti_flag <= OPREG[4]; // only difference between RETI and RETT is important
|
550 |
|
|
dia_op <= OPREG[6]; // only difference between DIA and WAIT is important
|
551 |
|
|
end
|
552 |
|
|
|
553 |
11 |
ns32kum |
always @(posedge BCLK) dia_flag <= dia_op & (phase_reg == 8'h88); // special case DIA compared to WAIT : Addr DIA to Stack
|
554 |
9 |
ns32kum |
|
555 |
11 |
ns32kum |
always @(posedge BCLK) // Format 1 opcodes write always DWord to reg, the same is true for Exceptions
|
556 |
9 |
ns32kum |
if (PHASE_0 || abbruch) format1 <= (valid[0] & (OPREG[3:0] == 4'h2)) | exception;
|
557 |
|
|
else
|
558 |
|
|
if (flag_flag || (interrupt && string_ende)) format1 <= 1'b1;
|
559 |
|
|
|
560 |
|
|
// Branch etc. CXP CXPD
|
561 |
11 |
ns32kum |
assign store_pc = (phase_reg == 8'd1) | (phase_reg == 8'h37) | (phase_reg == 8'h6B); // only save in DIN Reg of DATENPFAD
|
562 |
9 |
ns32kum |
assign jump = (ex_br_op[0] & branch) | (acb_reg & ~ACB_ZERO) | ex_br_op[1];
|
563 |
|
|
|
564 |
11 |
ns32kum |
always @(posedge BCLK) ldpc_phase <= (phase_reg == 8'h3E) // PC load at CXP/Traps , all one clock cycle guaranted
|
565 |
9 |
ns32kum |
| (phase_reg == 8'h43) // PC load at RXP
|
566 |
|
|
| ((phase_reg == 8'h49) & reti_flag) // PC load at RETI
|
567 |
|
|
| (phase_reg == 8'h4E) // PC load at RETT
|
568 |
|
|
| (phase_reg == 8'h66) // PC load at JUMP/JSR/CASE
|
569 |
|
|
| (phase_reg == 8'h7B); // PC load at DE = Direct Exception
|
570 |
|
|
|
571 |
|
|
assign NEW = ((phase_reg == 8'd1) & jump & di_stat[0]) | LOAD_PC;
|
572 |
11 |
ns32kum |
assign LOAD_PC = ((phase_reg == 8'h2B) & di_stat[0]) // only one pulse, but DISP must be ok => di_stat[0] (RET)
|
573 |
9 |
ns32kum |
| ldpc_phase;
|
574 |
|
|
|
575 |
|
|
assign no_modul = de_flag ? {1'b0,dest_x} : {1'b1,modul[5:0]};
|
576 |
|
|
|
577 |
|
|
assign negativ = PSR[7];
|
578 |
|
|
assign zero = PSR[6];
|
579 |
|
|
assign flag = PSR[5];
|
580 |
|
|
assign larger = PSR[2];
|
581 |
|
|
assign carry_psr = PSR[0];
|
582 |
|
|
|
583 |
11 |
ns32kum |
assign rett_exc = ~reti_flag & (phase_reg == 8'h4B); // special case RETT : Stack can change during opcode
|
584 |
9 |
ns32kum |
always @(posedge BCLK) phase_exc <= (phase_reg == 8'h80); // 1. Exception phase
|
585 |
11 |
ns32kum |
always @(negedge BCLK) if (PHASE_0 || phase_exc || rett_exc) s_user <= PSR[9]; // Select Bit for Stack, delayed update
|
586 |
9 |
ns32kum |
always @(negedge BCLK)
|
587 |
|
|
if (PHASE_0 || phase_exc) s_mod <= {PSR[9],~PSR[9]};
|
588 |
|
|
else
|
589 |
|
|
if (rett_exc) s_mod <= s_mod | {PSR[9],~PSR[9]}; // Both can be updated
|
590 |
|
|
|
591 |
|
|
always @(cc_feld or zero or carry_psr or larger or negativ or flag)
|
592 |
|
|
case (cc_feld)
|
593 |
|
|
4'h0 : branch = zero; // EQual
|
594 |
|
|
4'h1 : branch = ~zero; // Not Equal
|
595 |
|
|
4'h2 : branch = carry_psr; // Carry Set
|
596 |
|
|
4'h3 : branch = ~carry_psr; // Carry Clear
|
597 |
|
|
4'h4 : branch = larger; // Higher
|
598 |
|
|
4'h5 : branch = ~larger; // Lower or Same
|
599 |
|
|
4'h6 : branch = negativ; // Greater Than
|
600 |
|
|
4'h7 : branch = ~negativ; // Less or Equal
|
601 |
|
|
4'h8 : branch = flag; // Flag Set
|
602 |
|
|
4'h9 : branch = ~flag; // Flag Clear
|
603 |
|
|
4'hA : branch = ~larger & ~zero; // LOwer
|
604 |
|
|
4'hB : branch = larger | zero; // Higher or Same
|
605 |
|
|
4'hC : branch = ~negativ & ~zero; // Less Than
|
606 |
|
|
4'hD : branch = negativ | zero; // Greater or Equal
|
607 |
|
|
4'hE : branch = 1'b1; // True
|
608 |
|
|
4'hF : branch = 1'b0; // False
|
609 |
|
|
endcase
|
610 |
|
|
|
611 |
|
|
// +++++++++++++++++++++++ Register List Processing ++++++++++++++++++++++++++++
|
612 |
|
|
|
613 |
|
|
always @(posedge BCLK) init_rlist <= PHASE_0 | (phase_reg == 8'h2E);
|
614 |
|
|
|
615 |
|
|
always @(posedge BCLK)
|
616 |
|
|
if (PHASE_0) rpointer <= 3'b000;
|
617 |
|
|
else
|
618 |
|
|
if (ACC_DONE || init_rlist) rpointer <= reg_nr;
|
619 |
|
|
|
620 |
11 |
ns32kum |
REG_LIST scanner ( .DIN(op_feld_reg[22:15]), .INIT(init_rlist), .IPOS(rpointer), .VALID(save_reg), .OPOS(reg_nr) );
|
621 |
9 |
ns32kum |
|
622 |
|
|
assign saver = {4'h0,reg_nr};
|
623 |
|
|
|
624 |
11 |
ns32kum |
always @(posedge BCLK) if (ACC_DONE || init_rlist) resto <= {3'h0,~reg_nr}; // EXIT and RESTORE have the list mirrored : R0...R7
|
625 |
9 |
ns32kum |
|
626 |
11 |
ns32kum |
// ++++++++++++++++++++++++++ Processing of Displacement and Immediate Operand +++++++++++++++++++
|
627 |
9 |
ns32kum |
|
628 |
|
|
always @(posedge BCLK or negedge BRESET) // Flag for DISP and IMME access
|
629 |
|
|
if (!BRESET) dim_feld[3] <= 1'b0;
|
630 |
|
|
else dim_feld[3] <= next ? new_op[3] : ~di_stat[0] & dim_feld[3];
|
631 |
|
|
|
632 |
|
|
always @(posedge BCLK) if (next) dim_feld[2:1] <= new_op[2:1];
|
633 |
|
|
|
634 |
|
|
always @(posedge BCLK or negedge BRESET) // Flag for external access
|
635 |
|
|
if (!BRESET) dim_feld[0] <= 1'b0;
|
636 |
|
|
else dim_feld[0] <= next ? new_op[0] : ~ACC_DONE & dim_feld[0];
|
637 |
|
|
|
638 |
|
|
// special case QWORD, last term for security
|
639 |
|
|
always @(posedge BCLK) qw_flag <= dim_feld[0] & ACC_DONE & (ACC_FELD[13:12] == 2'b11) & ~qw_flag;
|
640 |
|
|
|
641 |
11 |
ns32kum |
assign LD_IMME = (dim_feld[3] & (dim_feld[2:1] != 2'b11)) | short_op | store_pc; // Data multiplexer
|
642 |
|
|
assign LD_DIN = (di_stat[0] & dim_feld[3] & (dim_feld[2:1] != 2'b11)) // Enable for DIN Register
|
643 |
|
|
| (ACC_DONE & dim_feld[0]) | qw_flag | short_op | store_pc; // next not possible : i.e. immediate and disp parallel
|
644 |
9 |
ns32kum |
assign ld_disp = (dim_feld[3:1] == 3'b111); // Enable for DISP Register
|
645 |
|
|
|
646 |
|
|
// Signal to ADDR_UNIT , only Displacement critical
|
647 |
|
|
assign disp_ok = ld_disp ? di_stat[0] : 1'b1;
|
648 |
|
|
|
649 |
11 |
ns32kum |
always @(dim_feld or OPREG or valid or ANZ_VAL) // Bit 0 is "Data ok", the upper 3 bits are for USED
|
650 |
9 |
ns32kum |
casex ({dim_feld[2:1],OPREG[7:6]})
|
651 |
|
|
4'b00_xx : di_stat = {3'b001,valid[0]};
|
652 |
|
|
4'b01_xx : di_stat = {3'b010,(valid[1] & valid[0])};
|
653 |
|
|
4'b10_xx : di_stat = {3'b100,ANZ_VAL[2]};
|
654 |
|
|
4'b11_0x : di_stat = {3'b001,valid[0]};
|
655 |
|
|
4'b11_10 : di_stat = {3'b010,(valid[1] & valid[0])};
|
656 |
|
|
4'b11_11 : di_stat = {3'b100,ANZ_VAL[2]};
|
657 |
|
|
endcase
|
658 |
|
|
|
659 |
|
|
always @(OPREG)
|
660 |
|
|
casex (OPREG[7:6])
|
661 |
|
|
2'b0x : disp_val = {{26{OPREG[6]}},OPREG[5:0]};
|
662 |
|
|
2'b10 : disp_val = {{19{OPREG[5]}},OPREG[4:0],OPREG[15:8]};
|
663 |
|
|
2'b11 : disp_val = {{3{OPREG[5]}},OPREG[4:0],OPREG[15:8],OPREG[23:16],OPREG[31:24]};
|
664 |
|
|
endcase
|
665 |
|
|
|
666 |
|
|
assign DISP_BR = disp_val; // DISP is also used for Bcc opcode
|
667 |
|
|
|
668 |
|
|
// The generator for DISP : data is used in ADDR_UNIT
|
669 |
|
|
always @(*)
|
670 |
|
|
casex ({ld_disp,disp_sel}) // disp_sel from new_op
|
671 |
|
|
5'b1_00xx : DISP = disp_val;
|
672 |
|
|
5'b1_01xx : DISP = 32'h0 - disp_val; // special case for ENTER
|
673 |
|
|
5'b1_1xxx : DISP = {disp_val[29:0],2'b00}; // DISP*4 for External Address Mode
|
674 |
|
|
5'b0_11xx : DISP = {20'hFFFFF,3'h7,type_nmi,8'h00}; // Interrupt Service Address
|
675 |
|
|
5'b0_1000 : DISP = 32'hFFFF_FFFF; // PUSH Byte
|
676 |
|
|
5'b0_1001 : DISP = 32'hFFFF_FFFE; // PUSH Word
|
677 |
|
|
5'b0_1010 : DISP = 32'hFFFF_FFFC; // PUSH DWord
|
678 |
|
|
5'b0_1011 : DISP = 32'hFFFF_FFF8; // PUSH QWord
|
679 |
|
|
5'b0_01xx : DISP = {26'h0,exc_vector,2'b00}; // the exception vector as Offset for INTBASE
|
680 |
|
|
5'b0_00xx : DISP = {28'h0,disp_sel[1:0],2'b00}; // 0,+4,+8,+12 used with MOD, default is 0
|
681 |
|
|
endcase
|
682 |
|
|
|
683 |
|
|
always @(short_op or dim_feld or OPREG or op_setcfg or setcfg_lsb)
|
684 |
|
|
casex ({short_op,dim_feld[2:1]})
|
685 |
|
|
3'b000 : imme_i = op_setcfg ? {28'h0000_00F,OPREG[2:0],setcfg_lsb} : {24'hxx_xxxx,OPREG[7:0]};
|
686 |
|
|
3'b001 : imme_i = {16'hxxxx,OPREG[7:0],OPREG[15:8]};
|
687 |
|
|
3'b01x : imme_i = {OPREG[7:0],OPREG[15:8],OPREG[23:16],OPREG[31:24]};
|
688 |
|
|
3'b1xx : imme_i = {{29{OPREG[10]}},OPREG[9:7]}; // for MOVQ etc. only OPREG can be used
|
689 |
|
|
endcase
|
690 |
|
|
|
691 |
|
|
assign IMME_Q = store_pc ? PC_SAVE : imme_i;
|
692 |
|
|
|
693 |
|
|
// ++++++++++++++ Stack Control +++++++++++++++++
|
694 |
|
|
|
695 |
|
|
always @(posedge BCLK or negedge BRESET)
|
696 |
|
|
if (!BRESET) new_spsel <= 1'b0;
|
697 |
|
|
else new_spsel <= spupd | (new_spsel & ~PHASE_0 & ~fpu_trap & ~dvz_trap);
|
698 |
|
|
|
699 |
11 |
ns32kum |
always @(posedge BCLK) upd_info <= PHASE_0 & new_spsel; // one clock cycle earlier a change occurs, i.e. ADDF TOS,F0 => fpu_trap
|
700 |
9 |
ns32kum |
|
701 |
|
|
assign do_xor = fpu_trap ? upd_info : (PHASE_0 & new_spsel);
|
702 |
|
|
|
703 |
|
|
always @(negedge BCLK or negedge BRESET)
|
704 |
|
|
if (!BRESET) stack_sel <= 2'b00;
|
705 |
|
|
else
|
706 |
|
|
if (do_xor) stack_sel <= stack_sel ^ s_mod;
|
707 |
|
|
|
708 |
|
|
// Special case RETT
|
709 |
11 |
ns32kum |
always @(posedge BCLK) if (!phase_reg[1]) old_su <= s_user; // is tested in state x'49 and used in x'4B
|
710 |
9 |
ns32kum |
assign ttstak = {1'b0,((old_su == PSR[9]) ^ stack_sel[PSR[9]]),3'b110,PSR[9],1'b1};
|
711 |
|
|
|
712 |
|
|
// ++++++++++++++ 2 byte opcodes +++++++++++++++++
|
713 |
|
|
|
714 |
|
|
// Hint : short_op is decoded separatly
|
715 |
|
|
|
716 |
|
|
// [47:45] Source : [2] TOS=>(SP), [1] Ri => (Ri), [0] 1=access of memory
|
717 |
|
|
// [44:42] Destination : like [47:45]
|
718 |
|
|
// [41] long opcode [41:39] only for standard sequenz - not Gruppe 2
|
719 |
|
|
// [40] src2_flag - Source 2 is read
|
720 |
|
|
// [39] dest_flag - a target operand exists
|
721 |
|
|
// [38:33] src1_r Register field, no message about Immediate
|
722 |
|
|
// [32:27] src2_r Register field
|
723 |
|
|
// [26:25] src1_le Length of Source1 - this is used for qword
|
724 |
|
|
// [24:23] src2_le Length of Source2 : 00=1/01=2/10=4/11=8 Bytes => WMASKE
|
725 |
|
|
// [22:18] src1 field
|
726 |
|
|
// [17:13] src2 field
|
727 |
|
|
// [12:11] op_type 2 Bit for sort of opcode
|
728 |
|
|
// [10] FL : F=1/L=0
|
729 |
|
|
// [9:8] original BWD : B=00/W=01/D=11
|
730 |
|
|
// [7:0] opcode: operation code
|
731 |
|
|
|
732 |
11 |
ns32kum |
assign valid_size = (OPREG[1:0] != 2'b10) & (valid[1:0] == 2'b11); // valid size + valid OPREG-Bytes
|
733 |
9 |
ns32kum |
|
734 |
|
|
assign hzl_a = (OPREG[1:0] == 2'b11) ? 2'b10 : OPREG[1:0]; // length field recoded
|
735 |
|
|
assign hzl_b = {1'b0,OPREG[1:0]}; // standard Length field
|
736 |
|
|
assign hzr_a = {3'b000,OPREG[13:11]}; // SRC2 or SRC1 regfield
|
737 |
|
|
assign hzr_b = {3'b000,OPREG[8:6]}; // SRC2 regfield
|
738 |
11 |
ns32kum |
assign hzr_s = {((OPREG[15:11] == 5'h17) ^ stack_sel[s_user]),3'b110,s_user,1'b1}; // USER or SUPERVISOR Stack, TOS special case
|
739 |
9 |
ns32kum |
// Special case LPR & SPR regfield:
|
740 |
|
|
always @(OPREG or stack_sel or s_user)
|
741 |
|
|
casex ({OPREG[10:7]})
|
742 |
|
|
4'b1001 : hzr_c = {stack_sel[s_user],3'b110,s_user,1'b1}; // USER or SUPERVISOR Stack
|
743 |
|
|
4'b1011 : hzr_c = {stack_sel[1] ,3'b110,1'b1, 1'b1}; // USER Stack
|
744 |
|
|
4'b1100 : hzr_c = OPREG[6] ? temp_h : 6'h1C; // CFG special case : LPR : SPR
|
745 |
|
|
default : hzr_c = {2'b01,OPREG[10:7]};
|
746 |
|
|
endcase
|
747 |
|
|
|
748 |
11 |
ns32kum |
// Unfortunately SETCFG must be implemented : it is transformed to a two byte opcode with one byte IMM operand
|
749 |
9 |
ns32kum |
assign setcfg = (OPREG[13:0] == 14'h0B0E) & (valid[1:0] == 2'b11);
|
750 |
|
|
|
751 |
|
|
always @(*)
|
752 |
|
|
casex ({setcfg,OPREG[10:2]})
|
753 |
|
|
// Short-Op Codes , ACB is an ADD with following jump
|
754 |
11 |
ns32kum |
10'b0xxxx_x0011 : op2_feld = {6'o11,3'o3,6'hxx,hzr_a,hzl_a,hzl_a,5'h14,OPREG[15:11],2'b00,hzl_b,8'h40}; // ADDQ ACB
|
755 |
|
|
10'b0xxxx_00111 : op2_feld = {6'o11,3'o2,6'hxx,hzr_a,hzl_a,hzl_a,5'h14,OPREG[15:11],2'b00,hzl_b,8'h41}; // CMPQ
|
756 |
|
|
10'b0xxxx_01011 : op2_feld = {6'o11,3'o1,hzr_c,hzr_a,hzl_a,hzl_a,5'h00,OPREG[15:11],2'b00,hzl_b,8'h45}; // SPR
|
757 |
9 |
ns32kum |
// Scond is moving the SHORT operand in the Integer area as condition field
|
758 |
11 |
ns32kum |
10'b0xxxx_01111 : op2_feld = {6'o11,3'o1,6'hxx,hzr_a,hzl_a,hzl_a,5'h14,OPREG[15:11],2'b00,hzl_b,8'h7A}; // Format 7, A=(UNDEF)
|
759 |
|
|
10'b0xxxx_10111 : op2_feld = {6'o11,3'o1,6'hxx,hzr_a,hzl_a,hzl_a,5'h14,OPREG[15:11],2'b00,hzl_b,8'h45}; // MOVQ
|
760 |
|
|
10'b0xxxx_11011 : op2_feld = {6'o11,3'o1,hzr_a,hzr_c,hzl_a,2'b10,OPREG[15:11],5'h00,2'b00,hzl_b,8'h76}; // LPR => MOVZiD
|
761 |
9 |
ns32kum |
// Format 3 opcodes :
|
762 |
11 |
ns32kum |
10'b00x10_11111 : op2_feld = {6'o11,3'o1,hzr_a,6'h1D,hzl_a,hzl_a,OPREG[15:11],5'h00,2'b00,hzl_b,4'h3,OPREG[10:7]}; // BIC/SPSR
|
763 |
|
|
10'b0x100_11111 : op2_feld = {6'o61,3'o1,hzr_a,hzr_b,hzl_a,hzl_a,OPREG[15:11],5'h00,2'b10,hzl_b,4'h3,OPREG[10:7]}; // JUMP/JSR
|
764 |
|
|
10'b01110_11111 : op2_feld = {6'o11,3'o1,hzr_a,hzr_b,hzl_a,hzl_a,OPREG[15:11],5'h00,2'b10,hzl_b,4'h3,OPREG[10:7]}; // CASE
|
765 |
9 |
ns32kum |
// Format 4 opcodes : main group
|
766 |
11 |
ns32kum |
10'b0xxxx_xxxx0 : op2_feld = {6'o11,3'o3,hzr_a,hzr_b,hzl_a,hzl_a,OPREG[15:6], 2'b00,hzl_b,4'h4,OPREG[5:2]};
|
767 |
|
|
10'b0xxxx_x0001 : op2_feld = {6'o11,3'o2,hzr_a,hzr_b,hzl_a,hzl_a,OPREG[15:6], 2'b00,hzl_b,4'h4,OPREG[5:2]}; //CMP no WR
|
768 |
|
|
10'b0xxxx_x0101 : op2_feld = {6'o11,3'o1,hzr_a,hzr_b,hzl_a,hzl_a,OPREG[15:6], 2'b00,hzl_b,4'h4,OPREG[5:2]}; //MOV no 2.Op
|
769 |
9 |
ns32kum |
10'b0xxxx_x1101 : op2_feld = (OPREG[10:9] == 2'b00) ? // target is Register => standard flow
|
770 |
|
|
{6'o11,3'o2,hzr_a,hzr_b,hzl_a,2'bxx,OPREG[15:6], 2'b00,hzl_b,4'h4,OPREG[5:2]} // TBIT
|
771 |
|
|
: {6'o14,3'o2,hzr_a,hzr_b,hzl_a,2'b00,OPREG[15:6], 2'b10,hzl_b,4'h4,OPREG[5:2]};
|
772 |
|
|
// ADJSPi
|
773 |
11 |
ns32kum |
10'b01010_11111 : op2_feld = {6'o11,3'o3,hzr_a,hzr_s,hzl_a,2'b10,OPREG[15:11],5'h00,2'b00,hzl_b,8'h48}; // is a SUBD
|
774 |
9 |
ns32kum |
// ADDR, length field not valid
|
775 |
|
|
10'b0xxxx_x1001 : op2_feld = {6'o61,3'o1,hzr_a,hzr_b,hzl_a,hzl_a,OPREG[15:6], 2'b00,hzl_b,8'h49};
|
776 |
11 |
ns32kum |
10'b00000_11111 : op2_feld = {6'o71,3'o1,hzr_a,hzr_b,hzl_a,hzl_a,OPREG[15:11],5'h00,2'b10,hzl_b,4'h3,OPREG[10:7]}; // CXPD no Opcode
|
777 |
9 |
ns32kum |
// SETCFG => MOV Befehl , SRC1 is genrated for 32 bit , target is Register temp_h
|
778 |
|
|
10'b1xxxx_xxxxx : op2_feld = {40'b001001_001_000000_111101_00_10_10100_00000_00_011, 8'h76};
|
779 |
|
|
default : op2_feld = {40'hxx_xxxx_xxxx,4'hA,4'hx};
|
780 |
|
|
endcase
|
781 |
|
|
|
782 |
11 |
ns32kum |
assign op_2byte = (valid_size | setcfg) & ~op2_feld[7]; // it must be for sure shown "Invalid Opcode"
|
783 |
9 |
ns32kum |
|
784 |
|
|
// Special case : the quick opcodes with the exception SPR and LPR
|
785 |
11 |
ns32kum |
assign short_op = ((~OPREG[5]) | (OPREG[6:4] == 3'b011)) & (OPREG[3:2] == 2'b11) & valid_size & PHASE_0;
|
786 |
9 |
ns32kum |
always @(posedge BCLK) if (PHASE_0) short_op_reg <= short_op;
|
787 |
|
|
assign short_def = PHASE_0 ? short_op : short_op_reg; // for the big state machine
|
788 |
11 |
ns32kum |
assign op_sho = (OPREG[6:4] == 3'b011) ? 11'h07A : op_mov; // Special case Scond at Index as Dest. , used only in Phase 0
|
789 |
9 |
ns32kum |
|
790 |
|
|
// 2. special case ACB
|
791 |
|
|
assign acb_op = (OPREG[6:2] == 5'h13) & valid_size;
|
792 |
|
|
always @(posedge BCLK) if (PHASE_0) acb_reg <= acb_op;
|
793 |
|
|
assign acb_flag = PHASE_0 ? acb_op : acb_reg;
|
794 |
11 |
ns32kum |
assign goacb = acb_flag ? 8'h28 : 8'h00; // x'28 = 40 , wait jump at REG operation - short-op special case
|
795 |
9 |
ns32kum |
|
796 |
11 |
ns32kum |
// 3. special case load of PSR and Init-Done opcodes : because of U bit in PSR a restart must follow,
|
797 |
9 |
ns32kum |
// CINV and LMR PTB must wait until Init-Done and than Restart.
|
798 |
|
|
// All variants of LPR and BIC/S have an extra cycle due to TRACE operation
|
799 |
|
|
always @(OPREG)
|
800 |
|
|
casex (OPREG[18:0])
|
801 |
|
|
19'bxxx_xxxxx_1101_110_11_xx : waitop = 9'h14C; // LPRi PSR,...
|
802 |
|
|
19'bxxx_xxxxx_1100_110_11_xx : waitop = 9'h174; // LPRi CFG,...
|
803 |
|
|
19'bxxx_xxxxx_0x10_111_11_xx : waitop = 9'h14C; // BICPSRi/BISPSRi ...
|
804 |
|
|
19'bxxxx_x_0010_xx_0000_1110 : waitop = 9'h174; // SETCFG []
|
805 |
|
|
19'bxxxx_0_0010_xx_0001_1110 : waitop = 9'h174; // LMR - at the end Restart
|
806 |
|
|
19'bxxxx_0_1001_xx_0001_1110 : waitop = 9'h174; // CINV - at the end Restart
|
807 |
|
|
default : waitop = 9'h000;
|
808 |
|
|
endcase
|
809 |
|
|
|
810 |
|
|
assign dowait = waitop[7:0]; // is used in Phase 0 if PSR is loaded from Register
|
811 |
|
|
always @(posedge BCLK) if (PHASE_0) wait_reg <= waitop;
|
812 |
|
|
|
813 |
|
|
// Here 2. and 3. special case are coming together:
|
814 |
|
|
// Phase definition, end over jump for ACB , not used in Phase 0
|
815 |
|
|
assign endea = acb_reg ? 8'h01 : (wait_reg[8] ? wait_reg[7:0] : 8'h00);
|
816 |
|
|
assign diacb = acb_reg ? 4'hE : 4'h0; // load Disp ?
|
817 |
|
|
|
818 |
|
|
// special case ADJSPi : SP=SRC2 always 32 Bit
|
819 |
|
|
always @(posedge BCLK)
|
820 |
|
|
if (PHASE_0) dw_info <= (OPREG[10:2] == 9'b1010_11111);
|
821 |
|
|
else dw_info <= dw_info & ~phase_reg[7]; // for security at ABORT
|
822 |
|
|
|
823 |
|
|
// SETCFG : Flag to transform the Byte Immeadiate operand
|
824 |
|
|
always @(posedge BCLK) if (PHASE_0) op_setcfg <= setcfg;
|
825 |
|
|
always @(posedge BCLK) if (PHASE_0) setcfg_lsb <= OPREG[15];
|
826 |
|
|
|
827 |
|
|
always @(posedge BCLK) if (PHASE_0) jsr_flag <= (OPREG[10:2] == 9'b1100_11111); // JSR : for PUSH
|
828 |
|
|
always @(posedge BCLK) // Bit opcodes to Register and EXT:SRC1 / INS:SRC2
|
829 |
11 |
ns32kum |
if (PHASE_0) bit_reg <= ((OPREG[3] ? ((OPREG[7:6] == 2'd0) ? OPREG[23:22] : OPREG[18:17]) : OPREG[10:9]) == 2'b00);
|
830 |
|
|
always @(posedge BCLK) if (PHASE_0) exin_cmd <= (~OPREG[10] & (OPREG[6:0] == 7'h2E)) & (valid[2:0] == 3'b111);
|
831 |
9 |
ns32kum |
always @(posedge BCLK) if (PHASE_0) extract <= ~OPREG[7];
|
832 |
11 |
ns32kum |
always @(posedge BCLK) if (PHASE_0) inss_op <= (OPREG[13:10] == 4'h2) & (OPREG[7:0] == 8'hCE) & (valid[2:0] == 3'b111); // INSS
|
833 |
9 |
ns32kum |
|
834 |
|
|
// ++++++++++++++ 3 byte opcodes +++++++++++++++++
|
835 |
|
|
|
836 |
|
|
// [47:45] Source : [2] TOS=>(SP), [1] Ri => (Ri), [0] 1=access of memory
|
837 |
|
|
// [44:42] Destination : like [47:45]
|
838 |
|
|
// [41] long opcode [41:39] only for standard sequenz - not Gruppe 2
|
839 |
|
|
// [40] src2_flag - Source 2 is read
|
840 |
|
|
// [39] dest_flag - a target operand exists
|
841 |
|
|
// [38:33] src1_r Register field, no message about Immediate
|
842 |
|
|
// [32:27] src2_r Register field
|
843 |
|
|
// [26:25] src1_le Length of Source1 - this is used for qword
|
844 |
|
|
// [24:23] src2_le Length of Source2 : 00=1/01=2/10=4/11=8 Bytes => WMASKE
|
845 |
|
|
// [22:18] src1 field
|
846 |
|
|
// [17:13] src2 field
|
847 |
|
|
// [12:11] op_type 2 Bit for sort of opcode
|
848 |
|
|
// [10] FL : F=1/L=0
|
849 |
|
|
// [9:8] original BWD : B=00/W=01/D=11
|
850 |
|
|
// [7:0] opcode: operation code
|
851 |
|
|
|
852 |
|
|
assign hdx_a = OPREG[7] ? OPREG[8] : OPREG[10];
|
853 |
|
|
assign hdo_a = OPREG[13:10];
|
854 |
|
|
assign hdo_b = ~hdx_a; // long operation if L
|
855 |
|
|
assign hdo_c = {1'b0,OPREG[10],OPREG[7:6]}; // Format 8 opcodes
|
856 |
|
|
assign hdo_d = {6'b0101_00,OPREG[10],1'b0}; // CMPM/S or MOVM/S : 8'h52 or 8'h50
|
857 |
|
|
assign hdo_e = {3'b011,OPREG[10]}; // Special codes for LOGB and SCALB due to DP_OUT datapath
|
858 |
|
|
// Definitions of length
|
859 |
|
|
assign hdl_a = {1'b0,OPREG[9:8]}; // i size, is used in OPER
|
860 |
11 |
ns32kum |
assign hdl_b = (OPREG[9:8] == 2'b11) ? 2'b10 : OPREG[9:8]; // recode length field, is used in ACC field
|
861 |
9 |
ns32kum |
assign hdl_c = OPREG[10:8]; // FL + BWD
|
862 |
|
|
assign hdl_d = {1'b1,~hdx_a}; // length FP
|
863 |
|
|
assign hdl_e = {OPREG[8],2'bxx}; // BWD don't care
|
864 |
11 |
ns32kum |
assign hdl_f = (OPREG[18:17] == 2'b00) ? OPREG[9:8] : {OPREG[8],~(OPREG[9] ^ OPREG[8])}; // exclusiv for DEI
|
865 |
9 |
ns32kum |
assign hdl_g = {(OPREG[9:8] != 2'b00),(OPREG[9:8] == 2'b00)}; // exclusiv for EXT/EXTS base operand
|
866 |
|
|
assign hdl_h = {(OPREG[9:8] != 2'b00),(OPREG[9:8] != 2'b01)}; // exclusiv for CHECK bound operand
|
867 |
|
|
// Register definitions
|
868 |
|
|
assign hdr_a = {3'b000,OPREG[21:19]}; // SRC1 Integer Register
|
869 |
|
|
assign hdr_b = {3'b000,OPREG[16:14]}; // SRC2 Integer Register
|
870 |
|
|
assign hdr_c = hdx_a ? {2'b10,OPREG[21:20],1'b0,OPREG[19]} : {2'b10,OPREG[21:19],1'b1};
|
871 |
|
|
assign hdr_d = hdx_a ? {2'b10,OPREG[16:15],1'b0,OPREG[14]} : {2'b10,OPREG[16:14],1'b1};
|
872 |
|
|
assign hdr_e = OPREG[11] ? {2'b10,OPREG[21:20],1'b0,OPREG[19]} : {2'b10,OPREG[21:19],1'b1};
|
873 |
|
|
assign hdr_f = OPREG[11] ? {2'b10,OPREG[16:14],1'b1} : {2'b10,OPREG[16:15],1'b0,OPREG[14]};
|
874 |
|
|
assign hdr_g = {3'b000,OPREG[16:15],1'b1}; // exclusiv for DEI
|
875 |
|
|
assign hdr_m = {3'b001,OPREG[17:15]}; // MMU Register Index 8-15
|
876 |
|
|
|
877 |
|
|
always @(*)
|
878 |
|
|
casex (OPREG[13:3])
|
879 |
11 |
ns32kum |
11'b1000_xx_1100x : op3_feld = {6'o11,3'o3,hdr_a,hdr_b, hdl_b,hdl_b,OPREG[23:14],2'b00,hdl_a,4'h7,hdo_a}; // MULi
|
880 |
|
|
11'b000x_xx_0100x : op3_feld = {6'o11,3'o3,hdr_a,hdr_b, 2'b00,hdl_b,OPREG[23:14],2'b00,hdl_a,4'h6,hdo_a}; // ROTi,ASHi
|
881 |
|
|
11'b0101_xx_0100x : op3_feld = {6'o11,3'o3,hdr_a,hdr_b, 2'b00,hdl_b,OPREG[23:14],2'b00,hdl_a,4'h6,hdo_a}; // LSHi
|
882 |
|
|
11'b1x0x_xx_0100x : op3_feld = {6'o11,3'o1,hdr_a,hdr_b, hdl_b,hdl_b,OPREG[23:14],2'b00,hdl_a,4'h6,hdo_a}; // NEGi,NOTi,ABSi,COMi
|
883 |
|
|
11'b010x_xx_1100x : op3_feld = {6'o11,3'o1,hdr_a,hdr_b, hdl_b,2'b01,OPREG[23:14],2'b00,hdl_a,4'h7,hdo_a}; // MOVX/ZiW
|
884 |
|
|
11'b011x_xx_1100x : op3_feld = {6'o11,3'o1,hdr_a,hdr_b, hdl_b,2'b10,OPREG[23:14],2'b00,hdl_a,4'h7,hdo_a}; // MOVX/ZiD
|
885 |
|
|
11'b0001_xx_0110x : op3_feld = {6'o11,3'o3,hdr_a,hdr_b, hdl_b,2'b00,OPREG[23:14],2'b00,hdl_a,4'h8,hdo_c}; // FFSi
|
886 |
9 |
ns32kum |
// Floating Point opcodes
|
887 |
11 |
ns32kum |
11'b000x_xx_0011x : op3_feld = {6'o11,hdo_b,2'b01,hdr_a,hdr_d, hdl_b,hdl_d,OPREG[23:14],2'b00,hdl_c,4'h9,hdo_a}; // MOVif
|
888 |
|
|
11'b010x_xx_0011x : op3_feld = {6'o11, 3'o5,hdr_e,hdr_f, 2'b11,2'b10,OPREG[23:14],2'b00,hdl_c,4'h9,hdo_a}; // MOVLF
|
889 |
|
|
11'b011x_xx_0011x : op3_feld = {6'o11, 3'o5,hdr_e,hdr_f, 2'b10,2'b11,OPREG[23:14],2'b00,hdl_c,4'h9,hdo_a}; // MOVFL
|
890 |
|
|
11'b10xx_xx_0011x : op3_feld = {6'o11,hdo_b,2'b01,hdr_c,hdr_b, hdl_d,hdl_b,OPREG[23:14],2'b00,hdl_c,4'h9,hdo_a}; // ROUNDi,TRUNCi
|
891 |
|
|
11'b111x_xx_00111 : op3_feld = {6'o11,hdo_b,2'b01,hdr_c,hdr_b, hdl_d,hdl_b,OPREG[23:14],2'b00,hdl_c,4'h9,hdo_a}; // FLOORi
|
892 |
|
|
11'b111x_xx_00110 : op3_feld = {6'o11, 3'o5,hdr_c,hdr_b, hdl_d,hdl_b,OPREG[23:14],2'b00,hdl_c,op_cop}; // SEARCH
|
893 |
|
|
11'b0x00_0x_10111 : op3_feld = {6'o11,hdo_b,2'b11,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,4'hB,hdo_a}; // ADDf,SUBf
|
894 |
|
|
11'bxx00_0x_10110 : op3_feld = {6'o11, 3'o7,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,op_cop}; // Coprocessor
|
895 |
|
|
11'b1000_0x_10111 : op3_feld = {6'o11, 3'o7,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,4'hB,hdo_a}; // DIVf
|
896 |
|
|
11'b1100_0x_10111 : op3_feld = {6'o11,hdo_b,2'b11,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,4'hB,hdo_a}; // MULf
|
897 |
|
|
11'b0010_0x_1011x : op3_feld = {6'o11,hdo_b,2'b10,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,4'hB,hdo_a}; // CMPf
|
898 |
|
|
11'b0001_0x_10111 : op3_feld = {6'o11, 3'o1,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,4'hB,hdo_a}; // MOVf
|
899 |
|
|
11'bx101_0x_10111 : op3_feld = {6'o11, 3'o1,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,4'hB,hdo_a}; // NEGf,ABSf
|
900 |
|
|
11'b001x_11_00111 : op3_feld = {6'o11,3'o1,hdr_a,fsr_r, 2'b10,2'b10,OPREG[23:19],5'b0,2'b00,3'o3,8'h92}; // LFSR
|
901 |
|
|
11'b110x_11_00111 : op3_feld = {6'o11,3'o1,fsr_r,hdr_b, 2'b10,2'b10,5'b0,OPREG[18:14],2'b00,3'o3,8'h9C}; // SFSR
|
902 |
9 |
ns32kum |
// MMU opcodes
|
903 |
11 |
ns32kum |
11'b0010_11_0001x : op3_feld = {6'o11,3'o1,hdr_a,temp_h,2'b10,2'b10,OPREG[23:19],5'b0,2'b00, 3'o3,8'h45}; // LMR
|
904 |
|
|
11'b0011_11_0001x : op3_feld = {6'o11,3'o1,hdr_m,hdr_a, 2'b10,2'b10,5'b0,OPREG[23:19],2'b00, 3'o3,8'h45}; // SMR
|
905 |
9 |
ns32kum |
// String opcodes
|
906 |
11 |
ns32kum |
11'b000x_xx_0000x : op3_feld = {6'o11,3'o0,6'hxx,6'hxx, 2'bxx,2'b10,OPREG[23:14], 2'b10,hdl_c,hdo_d}; // MOVS,CMPS
|
907 |
|
|
11'b0011_xx_0000x : op3_feld = {6'o11,3'o0,6'hxx,6'hxx, 2'bxx,2'b10,OPREG[23:14], 2'b10,hdl_c,hdo_d}; // SKPS
|
908 |
9 |
ns32kum |
// Custom opcodes
|
909 |
11 |
ns32kum |
11'bxx01_0x_10110 : op3_feld = {6'o11, 3'o5,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,op_cop};
|
910 |
9 |
ns32kum |
// Integer Divisionen : QUOi REMi DIVi MODi and DEIi + MEIi
|
911 |
11 |
ns32kum |
11'b11xx_xx_1100x : op3_feld = {6'o11,3'o7,hdr_a,hdr_b, hdl_b,hdl_b,OPREG[23:14],2'b00,hdl_a,4'h7,hdo_a};
|
912 |
|
|
11'b10x1_xx_1100x : op3_feld = {6'o11,3'o7,hdr_a,hdr_g, hdl_b,hdl_f,OPREG[23:14],2'b10,hdl_a,4'h7,hdo_a}; // DEI/MEI
|
913 |
9 |
ns32kum |
// Gruppe 2 opcodes
|
914 |
11 |
ns32kum |
11'b0x11_xx_1010x : op3_feld = {6'o77,3'o1,hdr_a,hdr_b, hdl_b,hdl_b,OPREG[23:14],2'b00,hdl_a,8'h45}; // MOVUS,MOVSU
|
915 |
|
|
11'b000x_xx_1100x : op3_feld = {6'o66,3'o0,hdr_a,hdr_b, 2'bxx,2'b10,OPREG[23:14],2'b10,hdl_c, hdo_d}; // MOVM/CMPM
|
916 |
|
|
11'b001x_0x_1111x : op3_feld = {6'o11,3'o0,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b10,hdl_e,4'hC,hdo_a}; // DOTf,POLYf
|
917 |
|
|
11'b0101_0x_1111x : op3_feld = {6'o11,3'o5,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b00,hdl_e,4'hB,hdo_e}; // LOGB
|
918 |
|
|
11'b0100_0x_1111x : op3_feld = {6'o11,3'o0,hdr_c,hdr_d, hdl_d,hdl_d,OPREG[23:14],2'b10,hdl_e,4'hB,hdo_e}; // SCALB
|
919 |
|
|
11'b0011_xx_1100x : op3_feld = {6'o50,3'o0,hdr_a,hdr_b, hdl_g,hdl_b,OPREG[23:14],2'b10,hdl_c,4'h7,hdo_a}; // EXTS
|
920 |
|
|
11'bxxx0_xx_1110x : op3_feld = {6'o71,3'o0,hdr_a,hdr_b, hdl_h,hdl_b,OPREG[23:14],2'b10,hdl_c,4'h8,hdo_c}; // CHECK
|
921 |
9 |
ns32kum |
11'b0x1x_xx_0100x : op3_feld = (OPREG[18:17] == 2'b00) ? // target is register => standard flow
|
922 |
|
|
{6'o11,3'o3,hdr_a,hdr_b, hdl_b,2'b10,OPREG[23:14],2'b00,hdl_a,4'h6,hdo_a} // SBIT/CBIT
|
923 |
|
|
: {6'o14,3'o3,hdr_a,hdr_b, hdl_b,2'b00,OPREG[23:14],2'b10,hdl_a,4'h6,hdo_a};
|
924 |
|
|
11'b1110_xx_0100x : op3_feld = (OPREG[18:17] == 2'b00) ? // target is register => standard flow
|
925 |
|
|
{6'o11,3'o3,hdr_a,hdr_b, hdl_b,2'b10,OPREG[23:14],2'b00,hdl_a,4'h6,hdo_a} // IBIT
|
926 |
|
|
: {6'o14,3'o3,hdr_a,hdr_b, hdl_b,2'b00,OPREG[23:14],2'b10,hdl_a,4'h6,hdo_a};
|
927 |
11 |
ns32kum |
11'b1x11_xx_0100x : op3_feld = {6'o11,3'o7,hdr_a,hdr_b, hdl_b,hdl_b,OPREG[23:14],2'b00,hdl_a,4'h6,hdo_a}; // ADDP,SUBP
|
928 |
|
|
11'bxxx0_xx_0010x : op3_feld = {6'o40,3'o0,hdr_a,hdr_b, hdl_g,hdl_b,OPREG[23:14],2'b10,hdl_c,4'h8,hdo_c}; // EXT
|
929 |
|
|
11'bxxx0_xx_1010x : op3_feld = {6'o14,3'o0,hdr_a,hdr_b, hdl_b,2'b10,OPREG[23:14],2'b10, 3'o3,4'h8,hdo_c}; // INS
|
930 |
|
|
11'b0010_xx_1100x : op3_feld = {6'o14,3'o0,hdr_a,hdr_b, hdl_b,2'b10,OPREG[23:14],2'b10, 3'o3,4'h8,hdo_a}; // INSS
|
931 |
|
|
11'bxxx0_xx_0110x : op3_feld = {6'o61,3'o0,hdr_a,hdr_b, hdl_b,2'b10,OPREG[23:14],2'b10, 3'o3,4'h8,hdo_c}; // CVTP no Opcode
|
932 |
|
|
11'bxxx1_xx_0010x : op3_feld = {6'o11,3'o0,hdr_a,hdr_b, hdl_b,hdl_b,OPREG[23:14],2'b10, 3'o3,8'h84}; // INDEX
|
933 |
|
|
// Gruppe 2 opcodes can have dedicated operation codes. Therefore the operation code definition here is "don't care"
|
934 |
|
|
11'b000x_xx_0001x : op3_feld = {6'o70,3'o0,hdr_a,hdr_b, 2'b00,2'b10,OPREG[23:19],5'b0,2'b10,3'o0,8'h45}; // RDVAL+WRVAL
|
935 |
|
|
11'b1001_11_0001x : op3_feld = {6'o11,3'o1,hdr_a,temp_h,2'b10,2'b10,OPREG[23:19],5'b0,2'b00,3'o3,8'h45}; // CINV
|
936 |
9 |
ns32kum |
|
937 |
|
|
default : op3_feld = {40'hxx_xxxx_xxxx,4'hA,4'hx};
|
938 |
|
|
endcase
|
939 |
|
|
|
940 |
11 |
ns32kum |
assign op_3byte = (valid[2:0] == 3'b111) & (OPREG[2:0] == 3'b110) & (op3_feld[7:4] != 4'hA); // valid for all incl. CUSTOM
|
941 |
9 |
ns32kum |
|
942 |
|
|
// +++++++++++++ Evaluation for 2 and 3 byte opcodes ++++++++++++++++++
|
943 |
|
|
|
944 |
|
|
// for one byte opcodes special treatmant neccessary
|
945 |
|
|
assign opc_bits = op_3byte ? op3_feld : op2_feld;
|
946 |
|
|
|
947 |
11 |
ns32kum |
assign op_ok = (op_1byte | op_12byte | op_2byte | op_3byte | exception) & ~stop; // used for computation of USED
|
948 |
9 |
ns32kum |
|
949 |
|
|
always @(posedge BCLK) if (PHASE_0) op_feld_reg <= opc_bits;
|
950 |
|
|
assign op_feld = PHASE_0 ? opc_bits : op_feld_reg; // constant for all following cycles
|
951 |
|
|
|
952 |
|
|
// Evaluation of op_feld :
|
953 |
|
|
|
954 |
|
|
assign atys = op_feld[47:45]; // [2] : TOS=>(SP), [1] : Ri => (Ri), [0] : 1=access of memory
|
955 |
|
|
assign atyd = op_feld[44:42]; // [2] : TOS=>(SP), [1] : Ri => (Ri), [0] : 1=access of memory
|
956 |
|
|
assign long = op_feld[41];
|
957 |
|
|
assign src2_flag = op_feld[40];
|
958 |
|
|
assign dest_flag = op_feld[39];
|
959 |
|
|
|
960 |
|
|
assign src_1 = {1'b0,op_feld[38:33]};
|
961 |
|
|
assign src_2 = {1'b0,op_feld[32:27]};
|
962 |
|
|
assign src1_le = op_feld[26:25];
|
963 |
|
|
assign src2_le = op_feld[24:23];
|
964 |
11 |
ns32kum |
assign acc1 = (op_feld[22:21] != 2'b00) | atys[1]; // external access Source1 or "addr" : Reg => (Reg)
|
965 |
|
|
assign acc2 = (op_feld[17:16] != 2'b00) | atyd[1]; // external access Source2 or "addr" : Reg => (Reg)
|
966 |
9 |
ns32kum |
assign wlor = dest_flag & ~acc2;
|
967 |
11 |
ns32kum |
assign idx_n = {1'b0,(op_feld[22:20] == 3'b111)} + {1'b0,(op_feld[17:15] == 3'b111)}; // Index : 0,1 or 2
|
968 |
9 |
ns32kum |
assign idx = (idx_n != 2'b00); // Index is active
|
969 |
|
|
assign n_idx = idx_n - 2'b01;
|
970 |
|
|
|
971 |
|
|
// The field otype is used only in Phase 0
|
972 |
11 |
ns32kum |
assign otype = exception ? 2'b11 : ((op_1byte | op_12byte) ? 2'b01 : opc_bits[12:11]); // string opcodes use code 2'b10
|
973 |
9 |
ns32kum |
|
974 |
|
|
assign opera = op_feld[10:0];
|
975 |
|
|
|
976 |
|
|
assign dest_r = src_2[5:0];
|
977 |
|
|
assign dest_rl = {dest_r[5:1],1'b0};
|
978 |
|
|
|
979 |
|
|
// +++++++++++++++++++++++++ Coprocessor operations field ++++++++++++++++++++++++++++++
|
980 |
|
|
|
981 |
|
|
always @(posedge BCLK) if (PHASE_0) COP_OP <= OPREG[23:0];
|
982 |
|
|
|
983 |
|
|
// +++++++++++++++++++++++++ Special signals for LMR and CINV ++++++++++++++++++++++++++
|
984 |
|
|
// op_lmr is constant = parameter
|
985 |
|
|
|
986 |
|
|
assign STOP_IC = (phase_reg == 8'h74) | (phase_reg == 8'h75);
|
987 |
|
|
|
988 |
|
|
// CINV uses Register x'30 - x'37 : CINV = 110... , LMR = 001... otherwise CFG
|
989 |
11 |
ns32kum |
always @(posedge BCLK) if (PHASE_0) lmrreg <= op_3byte ? {{2{OPREG[13]}},~OPREG[13],OPREG[17:15]} : 6'h1C;
|
990 |
9 |
ns32kum |
|
991 |
11 |
ns32kum |
always @(posedge BCLK) no_init <= (lmrreg[5:4] == 2'b00) & (lmrreg[3:1] != 3'b110); // LMR waits for INIT at PTB0/1
|
992 |
9 |
ns32kum |
// a_ivar = "Addresse IVAR0/1"
|
993 |
11 |
ns32kum |
always @(posedge BCLK) a_ivar <= STOP_IC; // Phase 74 & 75, is used at INFO_AU together with IC_READ
|
994 |
9 |
ns32kum |
|
995 |
|
|
// CINV detection for IC_CACHE
|
996 |
|
|
always @(posedge BCLK)
|
997 |
|
|
if (PHASE_0) cinv_flag <= OPREG[13] & (OPREG[7:0] == 8'h1E);
|
998 |
|
|
else cinv_flag <= cinv_flag & ~phase_reg[7]; // reset at exception
|
999 |
|
|
|
1000 |
|
|
assign ENA_HK = ~(cinv_flag & STOP_IC); // always "1", if CINV then "0"
|
1001 |
|
|
|
1002 |
|
|
// +++++++++++++++++++++++++ USER flag for MOVUS & MOVSU ++++++++++++++++++++++++
|
1003 |
|
|
|
1004 |
|
|
always @(posedge BCLK)
|
1005 |
|
|
if (PHASE_0) m_ussu <= (~OPREG[13] & (OPREG[11:10] == 2'b11) & (OPREG[7:0] == 8'hAE));
|
1006 |
|
|
else m_ussu <= m_ussu & ~phase_reg[7]; // reset at exception
|
1007 |
|
|
|
1008 |
|
|
always @(posedge BCLK) if (PHASE_0) m_usel <= OPREG[12];
|
1009 |
|
|
|
1010 |
|
|
// +++++++++++++++++++++++++ USER flag for RDVAL & WRVAL ++++++++++++++++++++++++
|
1011 |
|
|
|
1012 |
|
|
always @(posedge BCLK)
|
1013 |
|
|
if (PHASE_0) rwval_flag <= (OPREG[13:11] == 3'd0) & (OPREG[7:0] == 8'h1E);
|
1014 |
|
|
else rwval_flag <= rwval_flag & ~phase_reg[7]; // reset at exception
|
1015 |
|
|
|
1016 |
|
|
always @(posedge BCLK) if (PHASE_0) wrval_flag <= OPREG[10]; // Difference RDVAL=0 and WRVAL=1
|
1017 |
|
|
|
1018 |
|
|
// +++++++++++++++++++++++++ Flags for CBIT/I+SBIT/I+IBIT +++++++++++++++++++++++
|
1019 |
|
|
|
1020 |
11 |
ns32kum |
assign rw_bit = (op_feld_reg[7:4] == 4'd6) & ((~op_feld_reg[3] & op_feld_reg[1]) | (op_feld_reg[3:0] == 4'hE));
|
1021 |
9 |
ns32kum |
assign op_ilo = rw_bit & op_feld_reg[0]; // Interlocked : CBITI and SBITI
|
1022 |
|
|
|
1023 |
|
|
// +++++++++++++++++++++++++++++ Operations for String processing +++++++++++++++++
|
1024 |
|
|
// Address field : Size:2 RD WR LDEA FULLACC INDEX:4 SPUPD disp_val:4 POST CLRMSW SRC2SEL:2
|
1025 |
|
|
|
1026 |
11 |
ns32kum |
assign st_src = {STRING[1:0],5'b1010_0,(op_feld_reg[15] & ~kurz_st),STRING[1:0],9'b0_0000_1000}; // [15] = BACKWARD
|
1027 |
|
|
assign st_src2 = {STRING[1:0],5'b1010_0,(op_feld_reg[15] & ~kurz_st),STRING[1:0],9'b0_0000_1011}; // Reuse EA
|
1028 |
|
|
assign st_dest = {STRING[1:0],5'b0110_0,(op_feld_reg[15] & ~kurz_st),STRING[1:0],9'b0_0000_1011}; // Reuse EA
|
1029 |
|
|
assign st_trde = {2'b00, 5'b0110_0, op_feld_reg[15], 2'b00, 9'b0_0000_1000}; // after Translate to Dest
|
1030 |
|
|
assign st_trs2 = {STRING[1:0],5'b1010_0, op_feld_reg[15], STRING[1:0],9'b0_0000_1000}; // after Match to SRC2
|
1031 |
9 |
ns32kum |
assign st_len = {STRING[1:0],17'b0000_0000_0_0000_0000}; // length important for qw_flag
|
1032 |
|
|
|
1033 |
|
|
// Signals of DETOIP go to I_PFAD
|
1034 |
11 |
ns32kum |
always @(posedge BCLK) if (PHASE_0) kill_opt <= ~OPREG[7] & (OPREG[17:15] != 3'b000); // watch difference of MOVM and MOVS
|
1035 |
9 |
ns32kum |
assign ph_match = (phase_reg[7:4] == 4'hD) & (phase_reg[2:0] == 3'd7); // Phase D7 and DF
|
1036 |
|
|
|
1037 |
|
|
assign op_str = {op_feld_reg[10:8],6'b0101_00,op_feld_reg[1],1'b1}; // Opcode 8'h51 or 8'h53;
|
1038 |
|
|
assign op_scp = {op_feld_reg[10:8],8'h41}; // normal CMPi
|
1039 |
|
|
assign ph_str = {4'hC,op_feld_reg[1],3'b001}; // Phase 8'hC1 (MOVS/M) or 8'hC9 (CMPS/M)
|
1040 |
|
|
|
1041 |
11 |
ns32kum |
always @(posedge BCLK) kurz_st <= (phase_reg == 8'h65) | (kurz_st & ~PHASE_0); // Flag for MOVM/CMPM
|
1042 |
|
|
always @(posedge BCLK) if (PHASE_0) cmps_flag <= ~OPREG[7] & (OPREG[11:10] == 2'b01); // Flag for CMPS
|
1043 |
|
|
always @(posedge BCLK) if (PHASE_0) skps_flag <= ~OPREG[7] & (OPREG[11:10] == 2'b11); // Flag for SKPS
|
1044 |
|
|
always @(posedge BCLK) if (PHASE_0) mt_flag <= ~OPREG[7] & (OPREG[17] | OPREG[15]); // Flag for Match and Translate
|
1045 |
9 |
ns32kum |
|
1046 |
|
|
assign wstr0 = {{4{kurz_st}},2'b00};
|
1047 |
|
|
assign wstr1 = {{4{kurz_st}},2'b01};
|
1048 |
|
|
assign wstr2 = {{4{kurz_st}},2'b10};
|
1049 |
|
|
assign rstr0 = {1'b0,wstr0};
|
1050 |
|
|
assign rstr1 = {1'b0,wstr1};
|
1051 |
|
|
assign rstr2 = {1'b0,wstr2};
|
1052 |
|
|
|
1053 |
|
|
// +++++++++++++++++++++++++++++++++++ Index processing +++++++++++++++++++++++++++++++++++++++++
|
1054 |
|
|
|
1055 |
|
|
assign phase_idx = (phase_reg == 8'h02) | (phase_reg == 8'h50);
|
1056 |
|
|
|
1057 |
|
|
assign idx_bytes = idx_1[2] ? OPREG[15:0] : {OPREG[7:0],OPREG[7:0]}; // here last access of OPREG
|
1058 |
|
|
always @(posedge BCLK) if (phase_idx) idx_reg <= idx_bytes;
|
1059 |
|
|
assign idx_feld = (phase_idx) ? idx_bytes : idx_reg;
|
1060 |
|
|
|
1061 |
|
|
// +++++++++++++++++++++++++++++++++++ The big state machine ++++++++++++++++++++++++++++++++++++
|
1062 |
|
|
|
1063 |
|
|
// Hints :
|
1064 |
|
|
// 1. At short-op SRC1 is out of memory to use TEMP
|
1065 |
|
|
// 2. At SRC2 rmw suppresed TOS and changed it to (SP)
|
1066 |
|
|
// 3. The Long-operation path takes the dest_r address to write if WR_REG activ
|
1067 |
11 |
ns32kum |
// 4. It is ok, that an extra cycle for the read of the index registers is needed - then data could be written ins Out register
|
1068 |
9 |
ns32kum |
|
1069 |
|
|
// Source 1
|
1070 |
|
|
|
1071 |
|
|
assign idx_1 = {1'b0,(op_feld[22:20] == 3'b111),op_feld[19:18]};
|
1072 |
|
|
assign src1_addr = idx_1[2] ? idx_feld[7:3] : op_feld[22:18];
|
1073 |
|
|
assign stack = {1'b0,stack_sel[s_user],3'b110,s_user,1'b1};
|
1074 |
|
|
assign usp_1 = src1_addr[0] ? stack : {5'b0_0110,src1_addr[1:0]};
|
1075 |
|
|
assign src_1l = {src_1[6:1],1'b0};
|
1076 |
|
|
assign pop_1 = {2'b00,src1_le,9'h108}; // SP update, DISP=0 and POST
|
1077 |
11 |
ns32kum |
assign mpoi_1 = (src1_addr[4:2] == 3'b100) | (src1_addr == 5'h16); // Pointer in memory always DWord
|
1078 |
9 |
ns32kum |
assign auop_s = atys[0] ? 4'b1011 : 4'b0010; // Only make effective address ?
|
1079 |
|
|
assign src1_tos = (op_feld[22:18] == 5'h17) ? 2'b11 : 2'b00; // Source 1 is true TOS
|
1080 |
|
|
|
1081 |
|
|
// Nextfield : 11=DISP read
|
1082 |
|
|
// Address field : Size:2 RD WR LDEA FULLACC INDEX:4 SPUPD disp_val:4 POST CLRMSW SRC2SEL:2
|
1083 |
|
|
always @(*)
|
1084 |
|
|
casex (src1_addr) // RWLF IDX ADDR_F NEUP SRC_REG NEXT
|
1085 |
11 |
ns32kum |
// Special case which is only valid at INDEX or "addr" : REG -> ADDR , DISP=0 : starts immediate at read
|
1086 |
9 |
ns32kum |
5'b00xxx : gen_src1 = {auop_s, idx_1,9'h000,8'h07,4'h0,src1_addr[2:0],3'b000,atys[0]};
|
1087 |
|
|
// Register relativ : 0(R0)
|
1088 |
|
|
5'b01xxx : gen_src1 = {auop_s, idx_1,9'h000,8'h07,4'h0,src1_addr[2:0],3'b111,atys[0]};
|
1089 |
|
|
// Memory relativ : 0(0(SB))
|
1090 |
11 |
ns32kum |
5'b100xx : gen_src1 = {4'b1011,4'h0, 9'h000,8'h06,usp_1, 4'b1111}; // 1. access always full
|
1091 |
9 |
ns32kum |
// Immediate
|
1092 |
|
|
5'b10100 : gen_src1 = (src1_le == 2'b11) ?
|
1093 |
|
|
{4'h0, 4'h0, 9'h000,8'h0B,src_x, 1'b1,2'b10,1'b0} // load in DWord pieces
|
1094 |
|
|
: {4'h0, 4'h0, 9'h000,8'h07,src_x, 1'b1,src1_le,1'b0};
|
1095 |
11 |
ns32kum |
5'b10101 : gen_src1 = {auop_s, idx_1,9'h002,8'h07,src_x, 3'b111,atys[0]}; // Absolut Addressing
|
1096 |
|
|
5'b10110 : gen_src1 = {4'b1011,4'h0, 9'h014,8'h05,7'h1F, 4'b0001}; // External with MOD Register +4
|
1097 |
9 |
ns32kum |
5'b10111 : gen_src1 = (idx_1[2] | atys[2]) ? // Access class "addr" ?
|
1098 |
|
|
{auop_s, idx_1,9'h000,8'h07,stack, 3'b000,atys[0]} // 0(SP) : no TOS flag
|
1099 |
|
|
: {4'b1011,pop_1, 8'h07,stack, 4'b0001}; // TOS
|
1100 |
|
|
// Memory Space : 0(SB)
|
1101 |
11 |
ns32kum |
5'b110x0 : gen_src1 = {auop_s, idx_1,9'h000,8'h07,5'b0_0110,src1_addr[1:0],3'b111,atys[0]}; // SB+FP
|
1102 |
9 |
ns32kum |
5'b11001 : gen_src1 = {auop_s, idx_1,9'h000,8'h07,stack, 3'b111,atys[0]}; // SP
|
1103 |
|
|
5'b11011 : gen_src1 = {auop_s, idx_1,9'h001,8'h07,src_x, 3'b111,atys[0]}; // PC relativ
|
1104 |
|
|
default : gen_src1 = 36'hx_xxxx_xxxx; // don't care
|
1105 |
|
|
endcase
|
1106 |
|
|
|
1107 |
|
|
assign adrd1 = {(mpoi_1 ? 2'b10 : src1_le),gen_src1[35:19]}; // Addressfield : 19 Bits
|
1108 |
|
|
assign phrd1 = gen_src1[18:11]; // next phase
|
1109 |
|
|
assign rega1 = gen_src1[10:4]; // Source 1 Register
|
1110 |
|
|
assign irrw1 = {4'b0,idx_feld[2:0]}; // Index-Register
|
1111 |
|
|
assign nxrd1 = gen_src1[3:0]; // Memory/Disp/Immediate operation
|
1112 |
|
|
assign exr11 = {2'b10 ,4'b1011,4'h0 ,9'h080}; // 2. access external with Mem.-Pointer + 4* Disp
|
1113 |
|
|
assign exr12 = {src1_le,auop_s,idx_1,9'h000}; // for Memory Relative and EXT in last step
|
1114 |
|
|
|
1115 |
|
|
// Source 2 resp. Destination
|
1116 |
|
|
|
1117 |
|
|
assign rmw = src2_flag & dest_flag;
|
1118 |
|
|
assign idx_2 = {1'b0,(op_feld[17:15] == 3'b111),op_feld[14:13]}; // 4 bits
|
1119 |
|
|
assign src2_addr = idx_2[2] ? idx_feld[15:11] : op_feld[17:13];
|
1120 |
|
|
assign usp_2 = src2_addr[0] ? stack : {5'b0_0110,src2_addr[1:0]};
|
1121 |
|
|
assign src_2l = {src_2[6:1],1'b0};
|
1122 |
11 |
ns32kum |
assign mpoi_2 = (src2_addr[4:2] == 3'b100) | (src2_addr == 5'h16); // Pointer in memory always DWord
|
1123 |
9 |
ns32kum |
assign auop_d = atyd[0] ? 4'b1011 : 4'b0010; // Only make effective address ?
|
1124 |
|
|
|
1125 |
|
|
// The next assessment processes TOS separated for PUSH and POP
|
1126 |
|
|
assign tos_oper = src2_flag ?
|
1127 |
11 |
ns32kum |
{2'b00,atyd[0],2'b01,atyd[0],2'b00,src2_le,7'b1_0000_10, src1_tos,4'h7,stack,3'b0,atyd[0]} // POP
|
1128 |
|
|
: {1'b0,atyd[0],3'b001,atyd[0],4'h0, 1'b1,2'b10,src2_le,2'b0,src1_tos,4'h7,stack,3'b0,atyd[0]}; // PUSH
|
1129 |
9 |
ns32kum |
|
1130 |
|
|
// Nextfield : 11=DISP read
|
1131 |
|
|
// Address field : Size:2 RD WR LDEA FULLACC INDEX:4 SPUPD disp_val:4 POST CLRMSW SRC2SEL:2
|
1132 |
|
|
always @(*)
|
1133 |
|
|
casex (src2_addr) // RW:W RW:R LF IDX ADDR_F NEUP SRC_REG NEXT
|
1134 |
11 |
ns32kum |
// Special case which is only valid at INDEX or "addr" : REG -> ADDR , DISP=0 : starts immediate at read
|
1135 |
|
|
5'b00xxx : gen_src2 = {1'b0,atyd[0],auop_d, idx_2,9'h000,4'h7,4'h0,src2_addr[2:0],3'b000,atyd[0]};
|
1136 |
9 |
ns32kum |
// Register relativ : 0(R0)
|
1137 |
11 |
ns32kum |
5'b01xxx : gen_src2 = {1'b0,atyd[0],auop_d, idx_2,9'h000,4'h7,4'h0,src2_addr[2:0],3'b111,atyd[0]};
|
1138 |
9 |
ns32kum |
// Memory relativ : 0(0(SB))
|
1139 |
11 |
ns32kum |
5'b100xx : gen_src2 = {2'b10,2'b10,2'b11,4'h0, 9'h000,4'h6,usp_2, 4'b1111}; // 1. access always full
|
1140 |
9 |
ns32kum |
// Immediate
|
1141 |
|
|
5'b10100 : gen_src2 = (src2_le == 2'b11) ?
|
1142 |
|
|
{2'b00,2'b00,2'b00,4'h0, 9'h000,4'hB,src_x, 1'b1,2'b10,1'b0} // load in DWord pieces
|
1143 |
|
|
: {2'b00,2'b00,2'b00,4'h0, 9'h000,4'h7,src_x, 1'b1,src2_le,1'b0};
|
1144 |
11 |
ns32kum |
5'b10101 : gen_src2 = {1'b0,atyd[0],auop_d, idx_2,9'h002,4'h7,src_x, 3'b111,atyd[0]}; // Absolut with special coding
|
1145 |
|
|
5'b10110 : gen_src2 = {2'b10,2'b10,2'b11,4'h0, 9'h014,4'h5,7'h1F, 4'b0001}; // External with MOD Register +4
|
1146 |
9 |
ns32kum |
5'b10111 : gen_src2 = (idx_2[2] | rmw | atyd[2]) ?
|
1147 |
11 |
ns32kum |
{1'b0,atyd[0],auop_d, idx_2,7'b0_0000_00,src1_tos,4'h7,stack, 3'b000,atyd[0]} // 0(SP) : TOS + DISP=0
|
1148 |
9 |
ns32kum |
: tos_oper; // TOS : 2 cases for PUSH and POP
|
1149 |
|
|
// Memory Space
|
1150 |
11 |
ns32kum |
5'b110x0 : gen_src2 = {1'b0,atyd[0],auop_d, idx_2,9'h000,4'h7,5'b0_0110,src2_addr[1:0],3'b111,atyd[0]};
|
1151 |
9 |
ns32kum |
5'b11001 : gen_src2 = {1'b0,atyd[0],auop_d, idx_2,9'h000,4'h7,stack, 3'b111,atyd[0]};
|
1152 |
11 |
ns32kum |
5'b11011 : gen_src2 = {1'b0,atyd[0],auop_d, idx_2,9'h001,4'h7,src_x, 3'b111,atyd[0]}; // PC relativ
|
1153 |
9 |
ns32kum |
default : gen_src2 = 34'hx_xxxx_xxxx; // don't care
|
1154 |
|
|
endcase
|
1155 |
|
|
|
1156 |
|
|
assign adrd2 = {(mpoi_2 ? 2'b10 : src2_le),gen_src2[31:15]};
|
1157 |
|
|
assign adwr2 = {(mpoi_2 ? 2'b10 : src2_le),gen_src2[33:32],gen_src2[29:15]};
|
1158 |
|
|
assign phrd2 = {4'h1,gen_src2[14:11]}; // Phase for Read Source 2
|
1159 |
|
|
assign phwr2 = {4'h2,gen_src2[14:11]}; // Phase for Write Destination
|
1160 |
|
|
assign rega2 = gen_src2[10:4];
|
1161 |
|
|
assign nxrw2 = gen_src2[3:0];
|
1162 |
|
|
assign irrw2 = {4'b0,idx_feld[10:8]};
|
1163 |
|
|
assign re_wr = {src2_le,4'b0101,4'h0, 9'h003}; // REUSE Address : Write of rmw
|
1164 |
11 |
ns32kum |
assign exr22 = {src2_le,atyd[0],1'b0,1'b1,atyd[0],idx_2,9'h000}; // for Memory Relative and EXT in last step
|
1165 |
|
|
assign exw22 = {src2_le,1'b0,atyd[0],1'b1,atyd[0],idx_2,9'h000}; // for Memory Relative and EXT in last step
|
1166 |
9 |
ns32kum |
|
1167 |
|
|
// Special case :
|
1168 |
|
|
|
1169 |
|
|
assign quei1 = acc1 ? imme : src_1l; // 8B passing either from register or from extern
|
1170 |
|
|
// 8B is requested from both operands but only to certain times
|
1171 |
|
|
assign qword = (phase_reg[7:4] != 4'h0) ? (src2_le == 2'b11) : (src1_le == 2'b11);
|
1172 |
|
|
assign quet1 = acc1 ? temp_h : src_1; // select source during calculation
|
1173 |
|
|
|
1174 |
|
|
// Output data of state machine
|
1175 |
|
|
// LOAD if PULS if simple
|
1176 |
|
|
// NEXT -> ENABLE ENABLE out
|
1177 |
|
|
// [66:48] 19 ADDR : X ; Op-length REUSE RD/WR etc.
|
1178 |
|
|
// [47:40] 8 new phase X
|
1179 |
|
|
// [39:33] 7 SRC1 X
|
1180 |
|
|
// [32:26] 7 SRC2 X
|
1181 |
|
|
// [25] 1 WREN X
|
1182 |
|
|
// [24:19] 6 DEST X
|
1183 |
|
|
// [18:8] 11 OPER X
|
1184 |
|
|
// [7:6] 2 START X
|
1185 |
|
|
// [5:4] 2 LD_OUT X
|
1186 |
|
|
// [3] 1 ID Load X
|
1187 |
|
|
// [2:1] 2 ID Type X ; 0 = DISP
|
1188 |
|
|
// [0] 1 MEM Access X
|
1189 |
|
|
|
1190 |
|
|
// State acc2-src2_flag-dest_flag
|
1191 |
|
|
// no SRC2 x 0 x
|
1192 |
|
|
// SRC2=REG 0 1 0 ; CMP+TBIT
|
1193 |
|
|
// SRC2=REG 0 1 1 ; all else
|
1194 |
|
|
// SRC2=MEM 1 1 0 ; CMP+TBIT
|
1195 |
|
|
// SRC2=MEM 1 1 1 ; all else
|
1196 |
|
|
|
1197 |
|
|
// Input data for state machine
|
1198 |
|
|
|
1199 |
|
|
// 8 phase_reg : phase of state machine
|
1200 |
|
|
// 2 otype : Opcode type
|
1201 |
|
|
|
1202 |
|
|
// 1 idx : Index is available : 1 or 2 , only PHASE_0
|
1203 |
|
|
// 1 short_op : short opcodes like ADDQ
|
1204 |
|
|
// 1 long : "long" opcode
|
1205 |
|
|
// 1 qword : 8B access at Source (Exception DEI+MEI)
|
1206 |
|
|
|
1207 |
|
|
// 1 acc1 : Reg/Extern SRC1
|
1208 |
|
|
// 1 acc2 : Reg/Extern SRC2
|
1209 |
|
|
// 1 src2_flag : the 2. operand is being read
|
1210 |
|
|
// 1 dest_flag : there is a target operand : only CMP and TBIT have none
|
1211 |
|
|
|
1212 |
|
|
assign phase_ein = abbruch ? 8'h00 : phase_reg;
|
1213 |
|
|
|
1214 |
|
|
always @(*) // "_" "_"
|
1215 |
|
|
casex ({phase_ein,otype, idx,short_def,long,qword, acc1,acc2,src2_flag,dest_flag})
|
1216 |
11 |
ns32kum |
{8'h00,10'b00_1xxx_xxxx}: // Index must be loaded : phase 2 : in any case load TEMP for Short-Op and generate LD_OUT
|
1217 |
9 |
ns32kum |
new_op = short_op ? // START LD_OUT
|
1218 |
|
|
{addr_nop,8'h02, imme, src_x, 1'b1,temp_h, op_sho, 2'b00,2'b10, 1'b1,n_idx,1'b0}
|
1219 |
|
|
: {addr_nop,8'h02, src_1,src_1l,1'b0,dest_x, opera, 2'b00,~src2_flag,2'b1_1,n_idx,1'b0};
|
1220 |
|
|
{8'h00,10'b00_01xx_x0xx}: // Short-Op to register, LD_OUT because of CMPQ
|
1221 |
|
|
new_op = {addr_nop,goacb, imme, src_2,dest_flag,dest_r, opera, 2'b00,2'b10, 4'h0};
|
1222 |
|
|
{8'h00,10'b00_01xx_x11x}: // Short-Op : external operand read : SRC2 ! Data in TEMP ! Here no Index
|
1223 |
|
|
new_op = {adrd2, phrd2, imme, rega2, 1'b1,temp_h, op_mov, 2'b00,2'b00, nxrw2};
|
1224 |
|
|
{8'h00,10'b00_01xx_x10x}: // MOVQ to Mem
|
1225 |
|
|
new_op = {adwr2, phwr2, imme, rega2, 1'b0,dest_x, opera, 2'b00,2'b10, nxrw2};
|
1226 |
|
|
{8'h00,10'b00_0000_00xx}: // simple register operation : dest_flag controls WREN, LD_OUT for CMP
|
1227 |
|
|
new_op = {addr_nop,dowait,src_1,src_2, dest_flag,dest_r,opera, 2'b00,2'b10, 4'h0};
|
1228 |
|
|
{8'h00,10'b00_0001_00xx}: // "simple" Reg-Op of 8B, phase 8 after 2. DWord , not via LONG-path
|
1229 |
|
|
new_op = {addr_nop,8'h08, src_1,src_x, 1'b1,dest_r, opera, 2'b00,2'b00, 4'h0};
|
1230 |
|
|
{8'h00,10'b00_0010_00xx}: // long register operation i.e. DIV - phase 31
|
1231 |
|
|
new_op = {addr_nop,8'h1F, src_1,src_2, wlor,dest_r, opera, 2'b11,2'b00, 4'h0};
|
1232 |
|
|
{8'h00,10'b00_0011_001x}: // long register operation with QWORD - phase 26 then wait
|
1233 |
|
|
new_op = {addr_nop,8'h1A, src_1,src_2, 1'b0,dest_r, opera, 2'b01,2'b00, 4'h0};
|
1234 |
|
|
{8'h00,10'b00_00xx_1xxx}: // Source 1 in memory - first to read , here no Index
|
1235 |
|
|
new_op = {adrd1, phrd1, src_x,rega1, 1'b0,dest_x, opera, 2'b00,2'b00, nxrd1};
|
1236 |
|
|
{8'h00,10'b00_00xx_011x}: // Source 2 in memory - first to read (Source 1 in register)
|
1237 |
|
|
new_op = {adrd2, phrd2, src_x,rega2, 1'b0,dest_x, opera, 2'b00,2'b00, nxrw2};
|
1238 |
|
|
{8'h00,10'b00_0000_0101}: // Source 1 store in Dest : "pass through" for MOV,NEG,ABS
|
1239 |
|
|
new_op = {adwr2, phwr2, src_1,rega2, 1'b0,dest_x, opera, 2'b00,2'b10, nxrw2};
|
1240 |
11 |
ns32kum |
{8'h00,10'b00_0001_0101}: // Source 1 store in Dest : "pass through" for MOV,NEG,ABS for Long operands
|
1241 |
|
|
new_op = //(op_feld[17:13] == 5'h17) ? // TOS : special case , first 8B out of Reg and then read SP
|
1242 |
9 |
ns32kum |
{addr_nop,8'h1C, src_1,src_1l,1'b0,dest_x, opera, 2'b00,2'b11, 4'h0};
|
1243 |
|
|
{8'h00,10'b00_0010_0101}: // SRC1 -> DEST with short operands
|
1244 |
|
|
new_op = {addr_nop,8'h1F, src_1,src_x, 1'b0,dest_r, opera, 2'b11,2'b00, 4'h0};
|
1245 |
|
|
{8'h00,10'b00_0011_0x01}: // SRC1 -> DEST i.e. ROUNDLi
|
1246 |
|
|
new_op = {addr_nop,8'h1F, src_1,src_1l,wlor,dest_r, opera, 2'b11,2'b00, 4'h0};
|
1247 |
|
|
|
1248 |
|
|
// Phase 2 : after read of Index nearly everything is repeated from PHASE_0
|
1249 |
|
|
{8'h02,10'bxx_x1xx_x11x}: // Short-Op : external operand read
|
1250 |
|
|
new_op = {adrd2, phrd2, irrw2,rega2, 1'b0,dest_x, opera, 2'b00,2'b00, nxrw2};
|
1251 |
|
|
{8'h02,10'bxx_x1xx_x101}: // MOVQ to Mem, data is in Out-Register
|
1252 |
|
|
new_op = {adwr2, phwr2, irrw2,rega2, 1'b0,dest_x, opera, 2'b00,2'b00, nxrw2};
|
1253 |
|
|
{8'h02,10'bxx_x0xx_1xxx}: // Source 1 in memory - first to read
|
1254 |
|
|
new_op = {adrd1, phrd1, irrw1,rega1, 1'b0,dest_x, opera, 2'b00,2'b00, nxrd1};
|
1255 |
|
|
{8'h02,10'bxx_x0xx_011x}: // Source 2 in memory - first to read
|
1256 |
|
|
new_op = {adrd2, phrd2, irrw2,rega2, 1'b0,dest_x, opera, 2'b00,2'b00, nxrw2};
|
1257 |
11 |
ns32kum |
{8'h02,10'bxx_x00x_0101}: // Source 1 store in Dest : "pass through" , data is already in Out-Register
|
1258 |
9 |
ns32kum |
new_op = {adwr2, phwr2, irrw2,rega2, 1'b0,dest_x, opera, 2'b00,2'b00, nxrw2};
|
1259 |
|
|
{8'h02,10'bxx_x010_0101}: // SRC1 -> DEST with short operands
|
1260 |
|
|
new_op = {addr_nop,8'h1F, src_1,src_x, 1'b0,dest_x, opera, 2'b11,2'b00, 4'h0};
|
1261 |
|
|
{8'h02,10'bxx_x011_0101}: // SRC1 -> DEST i.e. ROUNDLi
|
1262 |
|
|
new_op = {addr_nop,8'h1F, src_1,src_1l,1'b0,dest_x, opera, 2'b11,2'b00, 4'h0};
|
1263 |
|
|
|
1264 |
|
|
// +++++++++++++++++ SRC1 operand loading +++++++++++++++++++
|
1265 |
|
|
|
1266 |
|
|
// Phase 5 : wait for data and Disp2 for External addressing : part 2 EA = (MOD+4)+4*DISP1
|
1267 |
|
|
// next phase fix : 6
|
1268 |
11 |
ns32kum |
{8'h05,10'bxx_xxxx_xxxx}: new_op = {exr11, 8'h06, src_x,imme , 1'b0,dest_x, opera, 2'b00,2'b00, 4'b1111};
|
1269 |
9 |
ns32kum |
// Phase 6 : Memory-Pointer for Memory Relative and last access External
|
1270 |
|
|
// next phase fix : 7 , add Index
|
1271 |
11 |
ns32kum |
{8'h06,10'bxx_xxxx_xxxx}: new_op = {exr12, 8'h07, irrw1,imme , 1'b0,dest_x, opera, 2'b00,2'b00, 3'b111,atys[0]};
|
1272 |
9 |
ns32kum |
|
1273 |
|
|
// Phase 7 : wait for final data , direct from PHASE_0 if TOS without Index
|
1274 |
|
|
// next phase : if 8B data phase 8 is neccessary
|
1275 |
|
|
// if SRC2=REG execution started (otherwise store data in TEMP) and PHASE_0
|
1276 |
11 |
ns32kum |
{8'h07,10'bxx_xx00_x0xx}: // into Register , short operation execution , but LD_OUT for PSR Update ! dest_flag => WREN
|
1277 |
9 |
ns32kum |
new_op = {addr_nop,endea, imme, src_2, dest_flag,dest_r,opera, 2'b00,2'b10, diacb};
|
1278 |
|
|
{8'h07,10'bxx_xx01_x0xx}: // into Reg but with a step om between for ABSL etc. : phase 8
|
1279 |
|
|
new_op = {addr_nop,8'h08, imme, src_x, 1'b1,dest_r, opera, 2'b00,2'b00, 4'h0};
|
1280 |
|
|
{8'h07,10'bxx_xx10_x0xx}: // execute long operation , wait in phase 31
|
1281 |
|
|
new_op = {addr_nop,8'h1F, imme, src_2, wlor,dest_r, opera, 2'b11,2'b00, 4'h0};
|
1282 |
11 |
ns32kum |
{8'h07,10'bxx_xx11_xx0x}: // execute long operation : 2. operand only Dest , load LSD , phase 24 , wait in phase 31
|
1283 |
9 |
ns32kum |
new_op = {addr_nop,8'h18, imme, src_x, 1'b1,temp_l, op_mov, 2'b01,2'b00, 4'h0};
|
1284 |
|
|
{8'h07,10'bxx_xx11_x01x}: // lange Operation ausfuehren , LSD laden , phase 25 , warten in phase 31
|
1285 |
|
|
new_op = {addr_nop,8'h19, imme, src_2, 1'b0,dest_r, opera, 2'b01,2'b00, 4'h0};
|
1286 |
|
|
{8'h07,10'bxx_xxx0_x11x}: // Data into TEMP , read 2. operand , is there Index ? Yes -> phase 15
|
1287 |
|
|
new_op = idx_2[2] ?
|
1288 |
|
|
{addr_nop,8'h0F, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'h0}
|
1289 |
|
|
: {adrd2, phrd2, imme, rega2, 1'b1,temp_h, op_mov, 2'b00,2'b00, nxrw2};
|
1290 |
11 |
ns32kum |
{8'h07,10'bxx_xxx1_x11x}: // 8B data in TEMP , step in between then 2. Op read : phase 10 - can only be "long" operation
|
1291 |
9 |
ns32kum |
new_op = {addr_nop,8'h0A, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'h0};
|
1292 |
|
|
{8'h07,10'bxx_xx00_x101}: // something like ABSi , execute and store (LD_OUT)
|
1293 |
|
|
new_op = idx_2[2] ?
|
1294 |
|
|
{addr_nop,8'h10, imme, src_x, 1'b0,dest_x, opera, 2'b00,2'b10, 4'h0}
|
1295 |
|
|
: {adwr2, phwr2, imme, rega2, 1'b0,dest_x, opera, 2'b00,2'b10, nxrw2};
|
1296 |
11 |
ns32kum |
{8'h07,10'bxx_xx01_x101}: // ABS etc. : LSD data over SRC2 in 2. OUT-Reg , MSD data see opcode ABS/NEG/MOV , phase 9
|
1297 |
9 |
ns32kum |
new_op = {addr_nop,8'h09, imme, src_x, 1'b0,dest_x, opera, 2'b00,2'b10, 4'h0};
|
1298 |
|
|
{8'h07,10'bxx_xx10_x101}: // opcodes like MOVFL
|
1299 |
|
|
new_op = {addr_nop,8'h1F, imme, src_x, 1'b0,dest_x, opera, 2'b11,2'b00, 4'h0};
|
1300 |
|
|
|
1301 |
|
|
// Phase 8 : 2. part of 64 bit data : can be reached from PHASE_0 if 8B data
|
1302 |
11 |
ns32kum |
{8'h08,10'bxx_xxxx_xxxx}: new_op = {addr_nop,endea, quei1,src_x, 1'b1,dest_rl, op_mov, 2'b00,2'b00, diacb};
|
1303 |
9 |
ns32kum |
// Phase 9 : step in between to get data in OUT-Reg Low , SRC1 is not possible
|
1304 |
|
|
{8'h09,10'bxx_xxxx_xxxx}: // afterwards to data write
|
1305 |
|
|
new_op = {addr_nop,8'h10, src_x,imme , 1'b0,dest_x, op_mov, 2'b00,2'b01, 4'h0};
|
1306 |
|
|
// Phase 10 : LSD data write in TEMP , source can be IMME data to
|
1307 |
|
|
{8'h0A,10'bxx_xxxx_xxxx}: // 8B , after TEMP there can only be a 2. operand
|
1308 |
|
|
new_op = idx_2[2] ?
|
1309 |
|
|
{addr_nop,8'h0F, imme, src_x, 1'b1,temp_l, op_mov, 2'b00,2'b00, 4'h0}
|
1310 |
|
|
: {adrd2, phrd2, imme, rega2, 1'b1,temp_l, op_mov, 2'b00,2'b00, nxrw2};
|
1311 |
|
|
|
1312 |
|
|
// Phase 11 : wait for 8B IMME data : switch over at address decoder , qword flag is for sure "1"
|
1313 |
|
|
{8'h0B,10'bxx_xx0x_x0xx}: // into Reg with step in between for ABSL etc. : phase 12
|
1314 |
|
|
new_op = {addr_nop,8'h0C, imme, src_x, 1'b1,dest_r, opera, 2'b00,2'b00, 4'b1100};
|
1315 |
|
|
{8'h0B,10'bxx_xx1x_x01x}: // execute long operation , load LSD , phase 25 , wait in phase 31
|
1316 |
|
|
new_op = {addr_nop,8'h19, imme, src_2, 1'b0,dest_r, opera, 2'b01,2'b00, 4'b1100};
|
1317 |
11 |
ns32kum |
{8'h0B,10'bxx_xxxx_x11x}: // 8B data into TEMP , step in between then read 2. Op : phase 10 - can only be "long" operation
|
1318 |
9 |
ns32kum |
new_op = {addr_nop,8'h0A, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'b1100};
|
1319 |
11 |
ns32kum |
{8'h0B,10'bxx_xx0x_x10x}: // ABS etc. : LSD data via SRC2 into 2. OUT-Reg , MSD data see opcode ABS/NEG/MOV , phase 9
|
1320 |
9 |
ns32kum |
new_op = {addr_nop,8'h09, imme, src_x, 1'b0,dest_x, opera, 2'b00,2'b10, 4'b1100};
|
1321 |
11 |
ns32kum |
{8'h0B,10'bxx_xx1x_xx0x}: // MOVLF with 8B IMME data ? Must be possible, the end in phase 24 like SRC1=MEM
|
1322 |
9 |
ns32kum |
new_op = {addr_nop,8'h18, imme, src_x, 1'b1,temp_l, op_mov, 2'b01,2'b00, 4'b1100};
|
1323 |
|
|
// Phase 12 : wait for 2. part of 64 bit IMME data : after phase 0
|
1324 |
11 |
ns32kum |
{8'h0C,10'bxx_xxxx_xxxx}: new_op = {addr_nop,endea, imme ,src_x, 1'b1,dest_rl, op_mov, 2'b00,2'b00, diacb};
|
1325 |
9 |
ns32kum |
|
1326 |
|
|
// Phase 15 : secure in TEMP with Index continue and read 2. operand
|
1327 |
11 |
ns32kum |
{8'h0F,10'bxx_xxxx_xxxx}: new_op = {adrd2, phrd2, irrw2,rega2, 1'b0,dest_x, opera, 2'b00,2'b00, nxrw2};
|
1328 |
9 |
ns32kum |
// Phase 16 : after LD_OUT continue with Index and store 1. operand
|
1329 |
11 |
ns32kum |
{8'h10,10'bxx_xxxx_xxxx}: new_op = {adwr2, phwr2, irrw2,rega2, 1'b0,dest_x, opera, 2'b00,2'b00, nxrw2};
|
1330 |
9 |
ns32kum |
|
1331 |
|
|
// +++++++++++++++++ SRC2 operand loading : phase SRC1 + 16 +++++++++++++++++++
|
1332 |
|
|
|
1333 |
|
|
// Phase 21 : wait for data and Disp2 for external addressing : part 2 EA = (MOD+4)+4*DISP1
|
1334 |
|
|
// next phase fix : 22
|
1335 |
11 |
ns32kum |
{8'h15,10'bxx_xxxx_xxxx}: new_op = {exr11, 8'h16, src_x,imme , 1'b0,dest_x, opera, 2'b00,2'b00, 4'b1111};
|
1336 |
9 |
ns32kum |
// Phase 22 : Memory-Pointer for Memory Relative and last access external
|
1337 |
|
|
// next phase fix : 23 , add Index
|
1338 |
11 |
ns32kum |
{8'h16,10'bxx_xxxx_xxxx}: new_op = {exr22, 8'h17, irrw2,imme , 1'b0,dest_x, opera, 2'b00,2'b00, 3'b111,atyd[0]};
|
1339 |
9 |
ns32kum |
|
1340 |
|
|
// Phase 23 : wait for final data , direct from PHASE_0 if TOS without Index
|
1341 |
|
|
// next phase : if 8B data phase 24 is used
|
1342 |
11 |
ns32kum |
{8'h17,10'bxx_xx0x_xxx1}: // execute short operation and write data into memory , no WREN -> phase 39 ACC_DONE
|
1343 |
9 |
ns32kum |
new_op = {re_wr, 8'h27, quet1,imme , 1'b0,dest_r, opera, 2'b00,2'b10, 4'b0001};
|
1344 |
|
|
{8'h17,10'bxx_xx0x_xxx0}: // execute short operation , no WREN -> phase 0 , CMP(+TBIT)
|
1345 |
|
|
new_op = {addr_nop,endea, quet1,imme , 1'b0,dest_r, opera, 2'b00,2'b10, diacb};
|
1346 |
|
|
{8'h17,10'bxx_xx10_xxxx}: // execute long operation , wait in phase 31
|
1347 |
|
|
new_op = {addr_nop,8'h1F, quet1,imme , wlor,dest_r, opera, 2'b11,2'b00, 4'h0};
|
1348 |
|
|
{8'h17,10'bxx_xx11_xxxx}: // execute long operation , load LSD in phase 24
|
1349 |
|
|
new_op = {addr_nop,8'h18, quet1,imme , 1'b0,dest_r, opera, 2'b01,2'b00, 4'h0};
|
1350 |
11 |
ns32kum |
// Phase 24 : load 2. part of 64 bit data : with and without wait - from 28 the phase waits , from 23 not
|
1351 |
9 |
ns32kum |
{8'h18,10'bxx_xxxx_0xxx}: // execute long operation , wait in phase 31
|
1352 |
|
|
new_op = {addr_nop,8'h1F, src_1l,imme, wlor,dest_r, opera, 2'b10,2'b00, 4'h0};
|
1353 |
11 |
ns32kum |
{8'h18,10'bxx_xxxx_1xxx}: // execute long operation , wait in phase 31 , data from TEMP, used also for ROUNDLi
|
1354 |
9 |
ns32kum |
new_op = {addr_nop,8'h1F, rtmpl,imme, wlor,dest_r, opera, 2'b10,2'b00, 4'h0};
|
1355 |
|
|
// Phase 25 : load 2. part of 64 bit data : SRC1 from memory and SRC2 from Reg
|
1356 |
|
|
{8'h19,10'bxx_xxxx_xxxx}: // execute long operation , wait in phase 31
|
1357 |
|
|
new_op = {addr_nop,8'h1F, imme, src_2l,wlor,dest_r, opera, 2'b10,2'b00, 4'h0};
|
1358 |
|
|
// Phase 26 : load 2. part of 64 bit data : SRC1 from Reg and SRC2 from Reg
|
1359 |
|
|
{8'h1A,10'bxx_xxxx_xxxx}: // execute long operation , wait in phase 31
|
1360 |
|
|
new_op = {addr_nop,8'h1F, src_1l,src_2l,wlor,dest_r, opera, 2'b10,2'b00, 4'h0};
|
1361 |
|
|
|
1362 |
|
|
// Phase 27 : wait for 8B IMME data : switch over at address decoder , qword flag is for sure "1"
|
1363 |
|
|
{8'h1B,10'bxx_xxxx_xxxx}: // execute long operation , load LSD in phase 24
|
1364 |
|
|
new_op = {addr_nop,8'h18, quet1,imme , 1'b0,dest_r, opera, 2'b01,2'b00, 4'b1100};
|
1365 |
|
|
|
1366 |
|
|
// +++++++++++++++++ special case ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
1367 |
|
|
// Phase 28 : TOS with 8B SRC1 operand , no Index ! Jump to phase 39
|
1368 |
|
|
{8'h1C,10'bxx_xxxx_xxxx}: // store Source 1 in Dest : "pass through" for MOV,NEG,ABS
|
1369 |
|
|
new_op = {adwr2, phwr2, src_x,rega2, 1'b0,dest_x, opera, 2'b00,2'b00, nxrw2};
|
1370 |
|
|
// +++++++++++++++++ close operation : write out DEST , TOS update +++++++++++++++++++
|
1371 |
|
|
|
1372 |
|
|
// Phase 31 : wait for DONE of long operation
|
1373 |
|
|
{8'h1F,10'bxx_xxxx_xxx0}: // CMP done -> phase 0
|
1374 |
|
|
new_op = {addr_nop,8'h00, src_x,src_x, 1'b0,dest_r, opera, 2'b00,2'b10, 4'h0}; // no ACB
|
1375 |
|
|
{8'h1F,10'bxx_xxxx_x0x1}: // operation closed , data into register
|
1376 |
|
|
new_op = {addr_nop,8'h00, src_x,src_x, 1'b0,dest_r, opera, 2'b00,2'b00, 4'h0}; // no ACB
|
1377 |
11 |
ns32kum |
{8'h1F,10'bxx_xxxx_x101}: // operation closed , data into memory - first calculate address phase 32+x
|
1378 |
9 |
ns32kum |
new_op = {adwr2, phwr2, irrw2,rega2, 1'b0,dest_r, opera, 2'b00,2'b00, nxrw2};
|
1379 |
|
|
{8'h1F,10'bxx_xxxx_x111}: // operation closed , data into memory - address reuse phase 39 ACC_DONE
|
1380 |
|
|
new_op = {re_wr, 8'h27, src_x,src_x, 1'b0,dest_r, opera, 2'b00,2'b00, 4'b0001};
|
1381 |
|
|
|
1382 |
|
|
// Destination address calculate
|
1383 |
|
|
// Phase 37 : wait for data and Disp2 for External addressing : part 2 EA = (MOD+4)+4*DISP1
|
1384 |
|
|
// next phase fix : 38
|
1385 |
11 |
ns32kum |
{8'h25,10'bxx_xxxx_xxxx}: new_op = {exr11, 8'h26, src_x,imme , 1'b0,dest_x, opera, 2'b00,2'b00, 4'b1111};
|
1386 |
9 |
ns32kum |
// Phase 38 : Memory-Pointer for Memory Relative and letzter Zugriff External
|
1387 |
|
|
// next phase fix : 39 , add Index and write
|
1388 |
11 |
ns32kum |
{8'h26,10'bxx_xxxx_xxxx}: new_op = {exw22, 8'h27, irrw2,imme , 1'b0,dest_x, opera, 2'b00,2'b00, 4'b1111};
|
1389 |
9 |
ns32kum |
|
1390 |
|
|
// Phase 39 : wait for ACC_DONE : consequent numbering : 7+32
|
1391 |
|
|
{8'h27,10'bxx_xxxx_xxxx}: // now operation closed , only ACB could follow
|
1392 |
|
|
new_op = {addr_nop,endea, src_x,src_x, 1'b0,dest_x, opera, 2'b00,2'b00, diacb};
|
1393 |
|
|
|
1394 |
|
|
// +++++++++++++++ special case : ACB to Reg is to fast ! One wait cycle for ZERO-Flag
|
1395 |
11 |
ns32kum |
{8'h28,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h01,src_x, src_x, 1'b0,dest_x, opera, 2'b00,2'b00, 4'b1110};
|
1396 |
9 |
ns32kum |
|
1397 |
|
|
// +++++++++++++++ The other opcodes are following ++++++++++++++++++
|
1398 |
|
|
|
1399 |
11 |
ns32kum |
{8'h00,10'b01_xxxx_xxxx}: new_op = {new_addr,new_ph,new_regs, 1'b0,dest_x, op_mov, new_nx}; // 1 Byte Opcodes
|
1400 |
9 |
ns32kum |
|
1401 |
|
|
// Phase 1 : used for Bcond and ACB :
|
1402 |
|
|
{8'h01,10'bxx_xxxx_xxxx}: new_op = (ex_br_op[1] | jsr_flag) ? // BSR or JSR ?
|
1403 |
|
|
{push_op, 8'h27, imme, stack, 1'b0,dest_x, op_mov, 2'b00,2'b10, 4'b0001} // wait at end
|
1404 |
|
|
: {addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1405 |
|
|
|
1406 |
|
|
// Phase 42 : RET : read of PC from Stack and DIN via SRC1 to PC
|
1407 |
11 |
ns32kum |
{8'h2A,10'bxx_xxxx_xxxx}: new_op = {adddisp, 8'h2B, imme, src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'hE};
|
1408 |
|
|
// Phase 43 : RET : Displacement add to Stack. Attention : "imme" important to keep source constant for PC
|
1409 |
|
|
{8'h2B,10'bxx_xxxx_xxxx}: new_op = {save_sp, 8'h2C, imme, src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1410 |
9 |
ns32kum |
// Phase 44 : RET : Update of Stack : fixed phase
|
1411 |
11 |
ns32kum |
{8'h2C,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1412 |
9 |
ns32kum |
|
1413 |
|
|
// Phase 45 : ENTER Entry
|
1414 |
11 |
ns32kum |
{8'h2D,10'bxx_xxxx_xxxx}: new_op = {dispmin, 8'h2E, src_x,src_x, 1'b1,temp_l, op_adr, 2'b00,2'b00, 4'hE};
|
1415 |
9 |
ns32kum |
// Phase 46 : ENTER Stack longer
|
1416 |
11 |
ns32kum |
{8'h2E,10'bxx_xxxx_xxxx}: new_op = {save_sp ,8'h31, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1417 |
9 |
ns32kum |
// Phase 48 : SAVE/ENTER : Init phase , phases 48 & 49 very similar
|
1418 |
|
|
{8'h30,10'bxx_xxxx_xxxx}: new_op = save_reg ?
|
1419 |
|
|
{push_op, 8'h31, saver,stack, 1'b0,dest_x, op_mov, 2'b00,2'b10, 4'h1} // 1. load SP=>EA
|
1420 |
11 |
ns32kum |
: {addr_nop,8'h00, rtmpl,src_x,new_fp,frame[5:0],op_mov, 2'b00,2'b00, 4'h0}; // At ENTER FP Update
|
1421 |
9 |
ns32kum |
// Phase 49 : SAVE/ENTER : at the same time memory access and detection of next Reg
|
1422 |
|
|
{8'h31,10'bxx_xxxx_xxxx}: new_op = save_reg ?
|
1423 |
|
|
{push_ea, 8'h31, saver,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b10, 4'h1} // one more
|
1424 |
11 |
ns32kum |
: {addr_nop,8'h00, rtmpl,src_x,new_fp,frame[5:0],op_mov, 2'b00,2'b00, 4'h0}; // At ENTER FP Update
|
1425 |
9 |
ns32kum |
|
1426 |
|
|
// Phase 50 : RESTORE/EXIT Entry
|
1427 |
|
|
{8'h32,10'bxx_xxxx_xxxx}: new_op = save_reg ?
|
1428 |
|
|
{pop_op, 8'h33, src_x,stack, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1}
|
1429 |
|
|
: {pop_fp, ppfp, src_x,frame, 1'b0,dest_x, op_mov, 2'b00,2'b00, 3'h0,new_fp};
|
1430 |
|
|
// Phase 51 : RESTORE/EXIT next reg
|
1431 |
|
|
{8'h33,10'bxx_xxxx_xxxx}: new_op = save_reg ?
|
1432 |
|
|
{next_po, 8'h33, imme, src_x, 1'b1,resto, op_mov, 2'b00,2'b00, 4'h1}
|
1433 |
|
|
: {pop_fp, ppfp, imme, frame, 1'b1,resto, op_mov, 2'b00,2'b00, 3'h0,new_fp};
|
1434 |
|
|
// Phase 52 : EXIT End
|
1435 |
11 |
ns32kum |
{8'h34,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h00, imme, src_x, 1'b1,frame[5:0], op_mov, 2'b00,2'b00, 4'h0};
|
1436 |
9 |
ns32kum |
|
1437 |
|
|
// Phase 53 : CXP Entry : this opcode needs 12 States and 16 cycles minimum ...
|
1438 |
11 |
ns32kum |
{8'h35,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h36, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'h0};
|
1439 |
9 |
ns32kum |
// Phase 54 : CXP : Store Address Link table
|
1440 |
11 |
ns32kum |
{8'h36,10'bxx_xxxx_xxxx}: new_op = {rdltab, 8'h37, src_x,rtmph, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'hE}; // EA Phase : DISP read
|
1441 |
9 |
ns32kum |
// Phase 55 : CXP : DISP is worked on, the return address => temp_l
|
1442 |
11 |
ns32kum |
{8'h37,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h38, imme, rtmph, 1'b1,temp_l, op_mov, 2'b00,2'b00, 4'h1}; // Access
|
1443 |
9 |
ns32kum |
// Phase 56 : CXP : Access to Link table => Result is MOD-Entry => store in temp_h
|
1444 |
11 |
ns32kum |
{8'h38,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h39, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'h0};
|
1445 |
9 |
ns32kum |
// Phase 57 : CXP : store and PUSH MOD prepare , Entry from Exception Processing
|
1446 |
11 |
ns32kum |
{8'h39,10'bxx_xxxx_xxxx}: new_op = {push_op, 8'h3A, modul,stack, 1'b0,dest_x, op_wrp, 2'b00,2'b10, 4'h1};
|
1447 |
9 |
ns32kum |
// Phase 58 : CXP : PUSH of MOD ongoing, PUSH PC prepare
|
1448 |
11 |
ns32kum |
{8'h3A,10'bxx_xxxx_xxxx}: new_op = {ea_push, 8'h3B, rtmpl,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b10, 4'h0};
|
1449 |
9 |
ns32kum |
// Phase 59 : CXP : New EA for PC
|
1450 |
11 |
ns32kum |
{8'h3B,10'bxx_xxxx_xxxx}: new_op = {save_sp, 8'h3C, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1};
|
1451 |
9 |
ns32kum |
// Phase 60 : CXP : write of PC, calculate of Offset
|
1452 |
11 |
ns32kum |
{8'h3C,10'bxx_xxxx_xxxx}: new_op = {rmod_8, 8'h3D, rtmph,rtmph, 1'b1,temp_l, op_flip,2'b00,2'b00, 4'h1};
|
1453 |
9 |
ns32kum |
// Phase 61 : CXP : read from (MOD:New+8)
|
1454 |
11 |
ns32kum |
{8'h3D,10'bxx_xxxx_xxxx}: new_op = {ea_min8, 8'h3E, imme, rtmpl, 1'b1,temp_l, op_add, 2'b00,2'b00, 4'h0}; // Reuse of EA
|
1455 |
9 |
ns32kum |
// Phase 62 : CXP : EA Phase of SB read , new PC calculated
|
1456 |
11 |
ns32kum |
{8'h3E,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h3F, rtmpl,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1};
|
1457 |
9 |
ns32kum |
// Phase 63 : CXP : read of SB , new PC to ICache
|
1458 |
11 |
ns32kum |
{8'h3F,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h2F, imme, src_x, 1'b1,6'h1A, op_mov, 2'b00,2'b00, 4'h0}; // SB load
|
1459 |
9 |
ns32kum |
// Phase 47 : CXP : Last phase update of MOD prepare
|
1460 |
11 |
ns32kum |
{8'h2F,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h00, rtmph,src_x, 1'b1,modul[5:0], op_mov, 2'b00,2'b00, 4'h0}; // MOD load
|
1461 |
9 |
ns32kum |
|
1462 |
|
|
// Phase 64 : RXP Entry : POP of PC , full Access
|
1463 |
11 |
ns32kum |
{8'h40,10'bxx_xxxx_xxxx}: new_op = {pop_ru, 8'h41, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'h0};
|
1464 |
9 |
ns32kum |
// Phase 65 : RXP : PC is read, next POP prepare
|
1465 |
11 |
ns32kum |
{8'h41,10'bxx_xxxx_xxxx}: new_op = {adddisp, 8'h42, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'hF};
|
1466 |
9 |
ns32kum |
// Phase 66 : RXP : DISP is addeed to Stack and MOD is read
|
1467 |
11 |
ns32kum |
{8'h42,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h43, imme, src_x, 1'b1,modul[5:0], op_mov, 2'b00,2'b00, 4'h0};
|
1468 |
9 |
ns32kum |
// Phase 67 : RXP : MOD is new
|
1469 |
11 |
ns32kum |
{8'h43,10'bxx_xxxx_xxxx}: new_op = {rmod_rxp,8'h44, rtmph,modul, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1};
|
1470 |
9 |
ns32kum |
// Phase 68 : RXP : wait for SB data, parallel SP update
|
1471 |
11 |
ns32kum |
{8'h44,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h00, imme, src_x, 1'b1,6'h1A, op_mov, 2'b00,2'b00, 4'h0}; // SB load
|
1472 |
9 |
ns32kum |
|
1473 |
|
|
// Phase 69 : RETI : read of ICU for End-of-Interrupt Cycle , prepare read PC from Stack
|
1474 |
11 |
ns32kum |
{8'h45,10'bxx_xxxx_xxxx}: new_op = {pop_op, 8'h46, src_x,stack, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1};
|
1475 |
9 |
ns32kum |
// Phase 70 : RETI/ RETT Entry : POP of PC , full Access
|
1476 |
11 |
ns32kum |
{8'h46,10'bxx_xxxx_xxxx}: new_op = {pop_ru, 8'h47, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'h0};
|
1477 |
9 |
ns32kum |
// Phase 71 : RETI/RETT : PC is read, next POP prepare
|
1478 |
11 |
ns32kum |
{8'h47,10'bxx_xxxx_xxxx}: new_op = {save_sp, 8'h48, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1};
|
1479 |
9 |
ns32kum |
// Phase 72 : RETI/RETT : DISP is added to Stack , PSR load and MOD is loaded if DE off
|
1480 |
11 |
ns32kum |
{8'h48,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h49, imme, src_x, no_modul, op_ldp, 2'b00,2'b00, 4'h0};
|
1481 |
9 |
ns32kum |
// Phase 73 : RETI/RETT : different paths
|
1482 |
|
|
{8'h49,10'bxx_xxxx_xxxx}: new_op = de_flag ?
|
1483 |
|
|
( reti_flag ?
|
1484 |
|
|
{addr_nop,8'h4A, rtmph,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0}
|
1485 |
|
|
: {addr_nop,8'h4B, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0} )
|
1486 |
|
|
: {rmod_rtt,8'h4B, rtmph,modul, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1};
|
1487 |
|
|
// Phase 74 : RETI/RETT : one pause cycle if DE on
|
1488 |
11 |
ns32kum |
{8'h4A,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1489 |
9 |
ns32kum |
// Phase 75 : RETI/RETT : SB read if DE off
|
1490 |
|
|
{8'h4B,10'bxx_xxxx_xxxx}: new_op = reti_flag ?
|
1491 |
|
|
{addr_nop,8'h00, imme, src_x, 1'b1,6'h1A, op_mov, 2'b00,2'b00, 4'h0}
|
1492 |
|
|
: ( de_flag ?
|
1493 |
|
|
{adddispn,8'h4E, src_x,ttstak,1'b0,dest_x, op_mov, 2'b00,2'b00, 4'hE}
|
1494 |
|
|
: {adddispn,8'h4E, imme, ttstak,1'b1,6'h1A, op_mov, 2'b00,2'b00, 4'hE} );
|
1495 |
|
|
// Phase 78 : RETT : SP update
|
1496 |
11 |
ns32kum |
{8'h4E,10'bxx_xxxx_xxxx}: new_op = {save_sp, 8'h4A, rtmph,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1497 |
9 |
ns32kum |
|
1498 |
|
|
// +++++++++++++++ special wait states for PSR and the Cache/MMU system +++++++++++
|
1499 |
|
|
|
1500 |
|
|
// Phase 76 : PSR in Word case simple delay of 2 cycles : 1. cycle does nothing
|
1501 |
11 |
ns32kum |
{8'h4C,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h4D, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1502 |
|
|
// Phase 77 : PSR in Word case simple delay of 2 cycles : 2. cycle does Restart of instruction processing
|
1503 |
|
|
{8'h4D,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1504 |
9 |
ns32kum |
// Phase 79 : Wait for INIT_DONE from Cachesystem
|
1505 |
|
|
{8'h4F,10'bxx_xxxx_xxxx}: new_op = (INIT_DONE | no_init) ?
|
1506 |
|
|
{addr_nop,8'h4D, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0}
|
1507 |
|
|
: {addr_nop,8'h4F, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1508 |
|
|
|
1509 |
|
|
// +++++++++++++++ Direct Exception procession similar to CXP ++++++++++++++++++++
|
1510 |
|
|
|
1511 |
|
|
// Phase 121 : CXP : store and PUSH PSR prepare , Entry of Exception Processing
|
1512 |
11 |
ns32kum |
{8'h79,10'bxx_xxxx_xxxx}: new_op = {push_op, 8'h7A, modul,stack, 1'b0,dest_x, op_wrp, 2'b00,2'b10, 4'h1};
|
1513 |
9 |
ns32kum |
// Phase 122 : CXP : PUSH of PSR running, PUSH PC prepare - MOD like normal Exception-Flow
|
1514 |
11 |
ns32kum |
{8'h7A,10'bxx_xxxx_xxxx}: new_op = {ea_push, 8'h7B, rtmpl,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b10, 4'h0};
|
1515 |
|
|
// Phase 123 : CXP : New EA for PC , Output of Interrupt-Vector and LOAD_PC generation, continue at standard exit
|
1516 |
|
|
{8'h7B,10'bxx_xxxx_xxxx}: new_op = {save_sp, 8'h4A, rtmph,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1};
|
1517 |
9 |
ns32kum |
|
1518 |
|
|
// +++++++++++++++ here comes the general Exception Processing ++++++++++++++++++
|
1519 |
|
|
|
1520 |
|
|
// Phase 0 : Entry with saving of PC_ARCHI and PSR
|
1521 |
11 |
ns32kum |
{8'h00,10'b11_xxxx_xxxx}: new_op = {save_pc, 8'h80, src_x,src_x, 1'b0,dest_x, op_psr, 2'b00,2'b00, 4'h0};
|
1522 |
9 |
ns32kum |
// Phase 128 : different paths to three cases
|
1523 |
|
|
{8'h80,10'bxx_xxxx_xxxx}: new_op = abo_int ?
|
1524 |
|
|
{ai_next[30:4], src_x,src_x, 1'b1,temp_l, op_adr, 2'b00,2'b00, ai_next[3:0]}
|
1525 |
|
|
: {get_vec, 8'h81, src_x,ibase, 1'b1,temp_l, op_adr, 2'b00,2'b00, 4'h1};
|
1526 |
|
|
// Phase 129 : read of Exception-Vectors and store in TEMP_H , then continue at CXP if DE off
|
1527 |
|
|
{8'h81,10'bxx_xxxx_xxxx}: new_op = de_flag ?
|
1528 |
|
|
{addr_nop,8'h79, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'h0}
|
1529 |
|
|
: {addr_nop,8'h39, imme, src_x, 1'b1,temp_h, op_mov, 2'b00,2'b00, 4'h0};
|
1530 |
|
|
// Phase 130 : read of Interrupt-Vectors, Zero-Extension of Byte => TEMP_H
|
1531 |
11 |
ns32kum |
{8'h82,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h83, imme, src_x, 1'b1,temp_h, op_zex, 2'b00,2'b00, 4'h0};
|
1532 |
9 |
ns32kum |
// Phase 131 : access of Exception-Vector
|
1533 |
|
|
{8'h83,10'bxx_xxxx_xxxx}: new_op = (type_nmi | ~ivec_flag) ? // NMI or non-vectored INT ?
|
1534 |
|
|
{get_vec, 8'h81, src_x,ibase, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1}
|
1535 |
|
|
: {get_veci,8'h81, rtmph,ibase, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1};
|
1536 |
|
|
|
1537 |
|
|
// Phase 132 : ABORT : store TEAR
|
1538 |
11 |
ns32kum |
{8'h84,10'bxx_xxxx_xxxx}: new_op = {save_msr,8'h85, src_x,src_x, 1'b1,w_tear, op_adr, 2'b00,2'b00, 4'h0};
|
1539 |
9 |
ns32kum |
// Phase 133 : store MSR
|
1540 |
|
|
{8'h85,10'bxx_xxxx_xxxx}: new_op = (ssrc_flag | sdest_flag) ?
|
1541 |
|
|
{addr_nop,rrepa, src_x,src_x, 1'b1,w_msr, op_adr, 2'b00,2'b00, 4'h0}
|
1542 |
|
|
: {get_vec ,8'h81, src_x,ibase, 1'b1,w_msr, op_adr, 2'b00,2'b00, 4'h1};
|
1543 |
|
|
// Phase 134 : reload of pointers for string opcodes : R2 Dest
|
1544 |
11 |
ns32kum |
{8'h86,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h87, rtmp1,src_x, 1'b1,6'h02, op_mov, 2'b00,2'b00, 4'h0};
|
1545 |
9 |
ns32kum |
// Phase 135 : reload of pointers for string opcodes : R1 Source
|
1546 |
11 |
ns32kum |
{8'h87,10'bxx_xxxx_xxxx}: new_op = {get_vec ,8'h81, rtmph,ibase, 1'b1,6'h01, op_mov, 2'b00,2'b00, 4'h1};
|
1547 |
9 |
ns32kum |
|
1548 |
|
|
// +++++++++++++++++ WAIT +++++++++++++++++++++++++++++++++
|
1549 |
|
|
{8'h88,10'bxx_xxxx_xxxx}: new_op = interrupt ?
|
1550 |
|
|
{addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0} // wait ...
|
1551 |
|
|
: {addr_nop,8'h88, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0}; // Loop
|
1552 |
|
|
|
1553 |
|
|
// +++++++++++++++++ FLAG +++++++++++++++++++++++++++++++++
|
1554 |
|
|
{8'h89,10'bxx_xxxx_xxxx}: new_op = flag ?
|
1555 |
|
|
{save_pc, 8'h80, src_x,src_x, 1'b0,dest_x, op_psr, 2'b00,2'b00, 4'h0} // TRAP
|
1556 |
|
|
: {addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0}; // continue
|
1557 |
|
|
|
1558 |
|
|
// +++++++++++++++++ The Opcodes of Gruppe 2 +++++++++++++++
|
1559 |
|
|
|
1560 |
|
|
{8'h00,10'b10_0xxx_xxxx}: new_op = state_0;
|
1561 |
|
|
// Now the case with Index , the Long Operand is copied to OUT
|
1562 |
11 |
ns32kum |
{8'h00,10'b10_1xxx_xxxx}: new_op = {addr_nop,8'h50, src_1,src_1l,1'b0,dest_x, opera, 2'b00,~src2_flag,2'b1_1,n_idx,1'b0};
|
1563 |
9 |
ns32kum |
|
1564 |
|
|
{8'h5x,10'bxx_xxxx_xxxx}: new_op = state_group_50; // Gruppe 2 Opcodes
|
1565 |
|
|
{8'h6x,10'bxx_xxxx_xxxx}: new_op = state_group_60; // Gruppe 2 Opcodes
|
1566 |
|
|
|
1567 |
|
|
// that is only for CVTP :
|
1568 |
11 |
ns32kum |
{8'h73,10'bxx_xxxx_x0xx}: new_op = {addr_nop,8'h00, src_x,src_x, 1'b1,dest_r, op_adr, 2'b00,2'b00, 4'h0};
|
1569 |
|
|
{8'h73,10'bxx_xxxx_x1xx}: new_op = {adwr2, phwr2, irrw2,rega2, 1'b0,dest_x, op_adr, 2'b00,2'b10, nxrw2};
|
1570 |
9 |
ns32kum |
|
1571 |
|
|
// that is only for LMR and CINV :
|
1572 |
|
|
{8'h74,10'bxx_xxxx_xxxx}: new_op = (IC_READ | STOP_CINV) ?
|
1573 |
|
|
{ivar_adr,8'h74, rtmph,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0} // wait ...
|
1574 |
|
|
: {ivar_adr,8'h75, rtmph,src_x, 1'b1,lmrreg, op_lmr, 2'b00,2'b00, 4'h0}; // continue
|
1575 |
11 |
ns32kum |
{8'h75,10'bxx_xxxx_xxxx}: new_op = {ivar_adr,8'h4F, rtmph,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1576 |
9 |
ns32kum |
|
1577 |
|
|
// +++++++++++++++++ The String Opcodes +++++++++++++++++++++
|
1578 |
|
|
|
1579 |
|
|
// Phase 192 : R0=0 ?
|
1580 |
|
|
{8'hC0,10'bxx_xxxx_xxxx}: new_op = STRING[2] ? // Is R0<>0 ?
|
1581 |
|
|
{st_src, ph_str,rstr1,rstr1, ~kurz_st,temp_h, op_mov, 2'b00,2'b00, 4'h0}
|
1582 |
|
|
: {addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0};
|
1583 |
|
|
// Phase 193 : 1. part read of SRC-Register => EA
|
1584 |
11 |
ns32kum |
{8'hC1,10'bxx_xxxx_xxxx}: new_op = {st_len, 8'hC2, src_x,src_x, 1'b1,wstr1, op_adr, 2'b00,2'b00, 4'h1};
|
1585 |
9 |
ns32kum |
// Phase 194 : memory operation : read
|
1586 |
|
|
{8'hC2,10'bxx_xxxx_xxxx}: new_op = mt_flag ?
|
1587 |
|
|
{addr_nop,8'hD3, imme, src_x, 1'b1,temp_2, (op_feld_reg[14] ? op_zex : op_mov),
|
1588 |
|
|
2'b00,2'b00, 4'h0}
|
1589 |
|
|
: {load_ea, 8'hC3, imme, rstr2, 1'b0,dest_x, op_mov, 2'b00,2'b10, 4'h0};
|
1590 |
|
|
// Phase 195 : Data in output register and at the same time R2 to EA
|
1591 |
11 |
ns32kum |
{8'hC3,10'bxx_xxxx_xxxx}: new_op = {st_dest, 8'hC4, rstr2,imme, ~kurz_st,temp_1, op_mov, 2'b00,2'b01, 4'h0};
|
1592 |
9 |
ns32kum |
// Phase 196 : 1. part reuse EA and LSD of 8B data to Out-Register
|
1593 |
11 |
ns32kum |
{8'hC4,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'hC5, src_x,src_x, 1'b1,wstr2, op_adr, 2'b00,2'b00, 4'h1};
|
1594 |
9 |
ns32kum |
// Phase 197 : memory operation : write
|
1595 |
11 |
ns32kum |
{8'hC5,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'hC7, rstr0,src_x, 1'b1,wstr0, op_str, 2'b00,2'b00, 4'h0};
|
1596 |
9 |
ns32kum |
// Phase 199 : Test for End and Interrupt
|
1597 |
|
|
{8'hC7,10'bxx_xxxx_xxxx}: new_op = (interrupt & ~kurz_st) ?
|
1598 |
|
|
{save_pc, 8'h80, src_x,src_x, 1'b0,dest_x, op_psr, 2'b00,2'b00, 4'h0} // Interrupt !
|
1599 |
|
|
: ( STRING[2] ? // Is R0<>0 ?
|
1600 |
|
|
{st_src, ph_str,rstr1,rstr1, ~kurz_st,temp_h, op_mov, 2'b00,2'b00, 4'h0}
|
1601 |
|
|
: {addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0} );
|
1602 |
|
|
// String Compare :
|
1603 |
|
|
// Phase 201 : 1. part read of SRC-Register => EA
|
1604 |
11 |
ns32kum |
{8'hC9,10'bxx_xxxx_xxxx}: new_op = {st_len, 8'hCA, src_x,src_x, 1'b1,wstr1, op_adr, 2'b00,2'b00, 4'h1};
|
1605 |
9 |
ns32kum |
// Phase 202 : memory operation : read
|
1606 |
|
|
{8'hCA,10'bxx_xxxx_xxxx}: new_op = mt_flag ?
|
1607 |
|
|
{addr_nop,8'hDB, imme, src_x, 1'b1,temp_2, (op_feld_reg[14] ? op_zex : op_mov),
|
1608 |
|
|
2'b00,2'b00, 4'h0}
|
1609 |
|
|
: ( skps_flag ? // SKPS read only String1
|
1610 |
|
|
{addr_nop,8'hC7, rstr0,src_x, 1'b1,wstr0, op_str, 2'b00,2'b00, 4'h0}
|
1611 |
|
|
: {load_ea, 8'hCB, imme, rstr2, 1'b1,temp_2, op_mov, 2'b00,2'b00, 4'h0} );
|
1612 |
|
|
// Phase 203 : Data to output register and at the same time R2 to EA
|
1613 |
11 |
ns32kum |
{8'hCB,10'bxx_xxxx_xxxx}: new_op = {st_src2, 8'hCC, rstr2,src_x, ~kurz_st,temp_1, op_mov, 2'b00,2'b00, 4'h0};
|
1614 |
9 |
ns32kum |
// Phase 204 : 1. part reuse EA
|
1615 |
11 |
ns32kum |
{8'hCC,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'hCD, src_x,src_x, 1'b1,wstr2, op_adr, 2'b00,2'b00, 4'h1};
|
1616 |
9 |
ns32kum |
// Phase 205 : memory operation : read and prepare compare
|
1617 |
11 |
ns32kum |
{8'hCD,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'hCE, rtmp2,imme, 1'b0,dest_x, op_scp, 2'b00,2'b10, 4'h0};
|
1618 |
9 |
ns32kum |
// Phase 206 : compare of data
|
1619 |
11 |
ns32kum |
{8'hCE,10'bxx_xxxx_xxxx}: new_op = STRING[3] ? // Elements equal ? Same as ACB_ZERO without delay of 1 cycle
|
1620 |
9 |
ns32kum |
{addr_nop,8'hC7, rstr0,src_x, 1'b1,wstr0, op_str, 2'b00,2'b00, 4'h0}
|
1621 |
|
|
: ( kurz_st ? // at CMPM direct end
|
1622 |
|
|
{addr_nop,8'h00, src_x,src_x, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h0}
|
1623 |
|
|
: {addr_nop,8'hC8, rtmph,src_x, 1'b1,6'h01, op_mov, 2'b00,2'b00, 4'h0} );
|
1624 |
|
|
// Phase 200 : reload of R1 at CMPS, prepare reload of R2
|
1625 |
11 |
ns32kum |
{8'hC8,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'h00, rtmp1,src_x, 1'b1,6'h02, op_mov, 2'b00,2'b00, 4'h0};
|
1626 |
9 |
ns32kum |
// String Options Match and Translate for MOVS
|
1627 |
|
|
// Phase 211 : Test if Translate
|
1628 |
|
|
{8'hD3,10'bxx_xxxx_xxxx}: new_op = op_feld_reg[14] ? // Translate ? Translate Base is Register 3
|
1629 |
|
|
{st_trans,8'hD4, rtmp2,7'h03, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1}
|
1630 |
|
|
: {addr_nop,8'hD7, rtmp2,7'h04, 1'b0,dest_x, op_scp, 2'b00,2'b10, 4'h0}; // Match
|
1631 |
|
|
// Phase 212 : memory operation : read
|
1632 |
11 |
ns32kum |
{8'hD4,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'hD5, imme, src_x, 1'b1,temp_2, op_mov, 2'b00,2'b10, 4'h0};
|
1633 |
9 |
ns32kum |
// Phase 213 : Test if Match
|
1634 |
|
|
{8'hD5,10'bxx_xxxx_xxxx}: new_op = op_feld_reg[16] ? // Match ? Reference Value is Register 4
|
1635 |
|
|
{addr_nop,8'hD7, rtmp2,7'h04, 1'b0,dest_x, op_scp, 2'b00,2'b10, 4'h0}
|
1636 |
|
|
: {st_trde, 8'hC4, 7'h02,7'h02, 1'b1,temp_1, op_mov, 2'b00,2'b00, 4'h0}; // back to MOVS
|
1637 |
|
|
// Phase 215 : Match result evaluation
|
1638 |
11 |
ns32kum |
{8'hD7,10'bxx_xxxx_xxxx}: new_op = (STRING[3] ^ op_feld_reg[17]) ? // Not equal? (op_feld_reg[17] = 1 = UNTIL)
|
1639 |
9 |
ns32kum |
{load_ea, 8'hC3, rtmp2,7'h02, 1'b0,dest_x, op_mov, 2'b00,2'b10, 4'h0} // back to MOVS
|
1640 |
11 |
ns32kum |
: {addr_nop,8'h00, rtmph,src_x, 1'b1,6'h01, op_mov, 2'b00,2'b00, 4'h0}; // Abort, R1 back
|
1641 |
9 |
ns32kum |
// String Options Match and Translate for CMPS and SKPS - to many options to get it in one state
|
1642 |
|
|
// Phase 218 : Test if Translate
|
1643 |
|
|
{8'hDB,10'bxx_xxxx_xxxx}: new_op = op_feld_reg[14] ? // Translate ? Translate Base is Register 3
|
1644 |
|
|
{st_trans,8'hDC, rtmp2,7'h03, 1'b0,dest_x, op_mov, 2'b00,2'b00, 4'h1}
|
1645 |
|
|
: {addr_nop,8'hDF, rtmp2,7'h04, 1'b0,dest_x, op_scp, 2'b00,2'b10, 4'h0}; // Match
|
1646 |
|
|
// Phase 220 : memory operation : read
|
1647 |
11 |
ns32kum |
{8'hDC,10'bxx_xxxx_xxxx}: new_op = {addr_nop,8'hDD, imme, src_x, 1'b1,temp_2, op_mov, 2'b00,2'b10, 4'h0};
|
1648 |
9 |
ns32kum |
// Phase 221 : Test if Match
|
1649 |
|
|
{8'hDD,10'bxx_xxxx_xxxx}: new_op = op_feld_reg[16] ? // Match ? Reference value is Register 4
|
1650 |
|
|
{addr_nop,8'hDF, rtmp2,7'h04, 1'b0,dest_x, op_scp, 2'b00,2'b10, 4'h0}
|
1651 |
|
|
: ( skps_flag ? // SKPS read only String1
|
1652 |
|
|
{addr_nop,8'hC7, 7'h00,src_x, 1'b1,6'h00, op_str, 2'b00,2'b00, 4'h0} // back to SKPS
|
1653 |
11 |
ns32kum |
: {st_trs2, 8'hCC, 7'h02,7'h02, 1'b1,temp_1, op_mov, 2'b00,2'b00, 4'h0}); // back to CMPS
|
1654 |
9 |
ns32kum |
// Phase 223 : Match result evaluation
|
1655 |
11 |
ns32kum |
{8'hDF,10'bxx_xxxx_xxxx}: new_op = (STRING[3] ^ op_feld_reg[17]) ? // Not equal? (op_feld_reg[17] = 1 = UNTIL)
|
1656 |
9 |
ns32kum |
( skps_flag ? // SKPS read only String1
|
1657 |
|
|
{addr_nop,8'hC7, 7'h00,src_x, 1'b1,6'h00, op_str, 2'b00,2'b00, 4'h0} // back to SKPS
|
1658 |
11 |
ns32kum |
: {st_trs2, 8'hCC, 7'h02,7'h02, 1'b1,temp_1, op_mov, 2'b00,2'b00, 4'h0} ) // back to CMPS
|
1659 |
|
|
: {addr_nop,8'h00, rtmph,src_x, 1'b1,6'h01, op_mov, 2'b00,2'b00, 4'h0}; // Abort, R1 back
|
1660 |
9 |
ns32kum |
|
1661 |
|
|
default : new_op = 67'hx_xxxx_xxxx_xxxx_xxxx;
|
1662 |
|
|
endcase
|
1663 |
|
|
|
1664 |
|
|
// ++++++++++++++++++++++++ Deliver data of state machine ++++++++++++++++++++++++++++
|
1665 |
|
|
|
1666 |
|
|
// not all new_op bits are evaluated here ...
|
1667 |
|
|
|
1668 |
|
|
always @(posedge BCLK or negedge BRESET)
|
1669 |
|
|
if (!BRESET) ACC_FELD[11:10] <= 2'b00; // RD WR
|
1670 |
|
|
else if (next) ACC_FELD[11:10] <= new_op[64:63];
|
1671 |
|
|
|
1672 |
|
|
always @(posedge BCLK or negedge BRESET)
|
1673 |
|
|
if (!BRESET) spupd_i <= 1'b0; // Stack Pointer Update
|
1674 |
|
|
else if (next) spupd_i <= new_op[56];
|
1675 |
|
|
|
1676 |
|
|
always @(posedge BCLK or negedge BRESET)
|
1677 |
|
|
if (!BRESET) oper_i <= 11'b0;
|
1678 |
|
|
else if (next) oper_i <= new_op[18:8];
|
1679 |
|
|
|
1680 |
|
|
always @(posedge BCLK)
|
1681 |
|
|
if (next)
|
1682 |
|
|
begin
|
1683 |
|
|
ACC_FELD[13:12] <= new_op[66:65]; // ASIZE[1:0]
|
1684 |
|
|
ACC_FELD[8:0] <= {new_op[61:57],new_op[51:48]}; // FULLACC INDEX[3:0] POST CLRMSW SRC2SEL[1:0]
|
1685 |
|
|
disp_sel <= new_op[55:52];
|
1686 |
|
|
wradr_i <= new_op[24:19];
|
1687 |
|
|
end
|
1688 |
|
|
|
1689 |
|
|
always @(posedge BCLK) wmaske_i <= src2_le; // to simple ?
|
1690 |
|
|
|
1691 |
|
|
always @(posedge BCLK) index_cmd <= (phase_reg == 8'h60); // that only for INDEX
|
1692 |
|
|
|
1693 |
11 |
ns32kum |
// WMASKE : SP always 32 Bit, opcodes in Format 1, Reg-Nr. >31 , INDEX opcodes and the CHECK operand too
|
1694 |
|
|
assign WMASKE = {(spupd | format1 | wradr_i[5] | wmaske_i[1] | index_cmd | (oper_i[7:0] == 8'h83)),wmaske_i[0]};
|
1695 |
9 |
ns32kum |
assign WRADR = spupd ? {~stack[5],stack[4:0]} : wradr_i;
|
1696 |
|
|
assign WREN = (spupd | wren_i) & no_trap;
|
1697 |
|
|
assign OPER = spupd ? op_adr : oper_i;
|
1698 |
|
|
|
1699 |
11 |
ns32kum |
always @(posedge BCLK) ACC_FELD[14] <= next & (new_op[64] | new_op[63] | new_op[62]); // NEWACC is important
|
1700 |
9 |
ns32kum |
always @(posedge BCLK) ACC_FELD[9] <= next & new_op[62]; // LDEA is only one pulse
|
1701 |
|
|
|
1702 |
|
|
always @(posedge BCLK) START <= next ? new_op[7:6] : 2'b00;
|
1703 |
|
|
always @(posedge BCLK) ldoreg <= next ? new_op[5:4] : 2'b00; // [1] = LD_OUT , [0] = LD_LDQ
|
1704 |
11 |
ns32kum |
always @(posedge BCLK) wren_i <= next & new_op[25] & ~new_op[7]; // only if no START[1] from Long-Op
|
1705 |
9 |
ns32kum |
|
1706 |
|
|
assign LD_OUT = {(ldoreg[1] & no_trap),ldoreg[0]}; // [1] = LD_OUT (for CMP too) , [0] = LD_LDQ
|
1707 |
|
|
|
1708 |
11 |
ns32kum |
assign spupd = spupd_i & ~wren_i & ~ldoreg[1] & ~spu_block; // no Stack Update if OUT Register load or already Write-Register
|
1709 |
9 |
ns32kum |
|
1710 |
|
|
assign do_long = new_op[7]; // START[1] for long_reg
|
1711 |
|
|
|
1712 |
|
|
assign RDAA = {next,new_op[39:33]}; // Source 1
|
1713 |
|
|
assign RDAB = {next,new_op[32:26]}; // Source 2
|
1714 |
|
|
|
1715 |
11 |
ns32kum |
always @(posedge BCLK) if (next) WR_REG = new_op[25] & new_op[7]; // START[1] : if WR then LONG path has register as Destination
|
1716 |
9 |
ns32kum |
|
1717 |
|
|
// special case : example is POLYL F2,TOS
|
1718 |
|
|
always @(posedge BCLK) spu_block <= DONE & WR_REG;
|
1719 |
|
|
|
1720 |
|
|
assign MMU_UPDATE[1] = (phase_reg == 8'h84) | (phase_reg == 8'h85); // serving the MMU at ABORT
|
1721 |
|
|
|
1722 |
|
|
// only the real access gets USER Status : important for Memory Relative & External
|
1723 |
|
|
always @(posedge BCLK) // MOVUS MOVSU RDVAL/WRVAL
|
1724 |
11 |
ns32kum |
if (ACC_FELD[14]) dc_user <= PSR[8] | (m_ussu & (m_usel ? (phase_reg == 8'h07) : (phase_reg == 8'h27))) | RWVAL[1];
|
1725 |
9 |
ns32kum |
else dc_user <= dc_user & ~abort;
|
1726 |
|
|
|
1727 |
|
|
always @(posedge BCLK) dc_ilo <= op_ilo & (phase_reg == 8'h59);
|
1728 |
|
|
always @(posedge BCLK) ILO <= op_ilo & ((phase_reg == 8'h59) | (phase_reg == 8'h27));
|
1729 |
|
|
|
1730 |
11 |
ns32kum |
assign RWVAL = {dc_ilo,(rwval_flag & (phase_reg == 8'h53)),wrval_flag}; // is used for DCACHE ILO too
|
1731 |
9 |
ns32kum |
|
1732 |
|
|
// Signals for the I_PATH + Debug
|
1733 |
11 |
ns32kum |
assign DETOIP = {pc_match,cmps_flag,ph_match,op_feld_reg[17],kill_opt,inss_op,exin_cmd,extract,bit_reg,kurz_st,dw_info,acb_reg,t2p};
|
1734 |
9 |
ns32kum |
|
1735 |
|
|
// Signals for the ADDR_UNIT : [5]=RMW Signal
|
1736 |
11 |
ns32kum |
assign chk_rmw = (phase_reg == 8'h17) | (phase_reg == 8'h58) | ((phase_reg == 8'h59) & rw_bit); // right Gruppe 2 opcodes
|
1737 |
|
|
assign INFO_AU = {no_trap,chk_rmw,(op_feld_reg[40:39] == 2'b11),RWVAL[1],(a_ivar & ~IC_READ),dc_user,disp_ok};
|
1738 |
9 |
ns32kum |
|
1739 |
|
|
assign RESTART = (phase_reg == 8'h4D);
|
1740 |
|
|
|
1741 |
|
|
// Signals to generate external STATUS
|
1742 |
|
|
assign GENSTAT[2] = (phase_reg == 8'h88); // WAIT Signal
|
1743 |
|
|
assign GENSTAT[1] = (phase_reg == 8'h82); // Interrupt Acknowlege Cycle
|
1744 |
|
|
assign GENSTAT[0] = (phase_reg == 8'h45); // End-of-Interrupt Cycle
|
1745 |
|
|
|
1746 |
|
|
// ++++++++++++++++++++ Here is the Sub-Modul for the opcodes of Gruppe 2 ++++++++++++++++
|
1747 |
|
|
|
1748 |
|
|
GRUPPE_2 reste_ops (.BCLK(BCLK), .PHASE_0(PHASE_0), .OPREG(OPREG[13:0]), .PHASE(phase_ein[3:0]),
|
1749 |
|
|
.SRC_1(src_1), .SRC_2(src_2), .REGA1(rega1), .REGA2(rega2), .IRRW1(irrw1), .IRRW2(irrw2),
|
1750 |
11 |
ns32kum |
.ADRD1(adrd1), .ADRD2(adrd2), .EXR12(exr12), .EXR22(exr22), .PHRD1(phrd1[3:0]), .PHRD2(phrd2[3:0]),
|
1751 |
9 |
ns32kum |
.NXRD1(nxrd1), .NXRW2(nxrw2), .ACCA({acc1,1'b0,acc2,1'b0}), .OPERA(opera),
|
1752 |
|
|
.STATE_0(state_0), .STATE_GROUP_50(state_group_50), .STATE_GROUP_60(state_group_60) );
|
1753 |
|
|
|
1754 |
|
|
endmodule
|