2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
7 use work.decode_types.all;
10 -- Processor Version Number
11 constant PVR_MICROWATT : std_ulogic_vector(31 downto 0) := x"00630000";
14 constant MSR_SF : integer := (63 - 0); -- Sixty-Four bit mode
15 constant MSR_EE : integer := (63 - 48); -- External interrupt Enable
16 constant MSR_PR : integer := (63 - 49); -- PRoblem state
17 constant MSR_FP : integer := (63 - 50); -- Floating Point available
18 constant MSR_FE0 : integer := (63 - 52); -- Floating Exception mode
19 constant MSR_SE : integer := (63 - 53); -- Single-step bit of TE field
20 constant MSR_BE : integer := (63 - 54); -- Branch trace bit of TE field
21 constant MSR_FE1 : integer := (63 - 55); -- Floating Exception mode
22 constant MSR_IR : integer := (63 - 58); -- Instruction Relocation
23 constant MSR_DR : integer := (63 - 59); -- Data Relocation
24 constant MSR_PMM : integer := (63 - 61); -- Performance Monitor Mark
25 constant MSR_RI : integer := (63 - 62); -- Recoverable Interrupt
26 constant MSR_LE : integer := (63 - 63); -- Little Endian
29 subtype spr_num_t is integer range 0 to 1023;
31 function decode_spr_num(insn: std_ulogic_vector(31 downto 0)) return spr_num_t;
33 constant SPR_XER : spr_num_t := 1;
34 constant SPR_LR : spr_num_t := 8;
35 constant SPR_CTR : spr_num_t := 9;
36 constant SPR_TAR : spr_num_t := 815;
37 constant SPR_DSISR : spr_num_t := 18;
38 constant SPR_DAR : spr_num_t := 19;
39 constant SPR_TB : spr_num_t := 268;
40 constant SPR_TBU : spr_num_t := 269;
41 constant SPR_DEC : spr_num_t := 22;
42 constant SPR_SRR0 : spr_num_t := 26;
43 constant SPR_SRR1 : spr_num_t := 27;
44 constant SPR_CFAR : spr_num_t := 28;
45 constant SPR_HSRR0 : spr_num_t := 314;
46 constant SPR_HSRR1 : spr_num_t := 315;
47 constant SPR_SPRG0 : spr_num_t := 272;
48 constant SPR_SPRG1 : spr_num_t := 273;
49 constant SPR_SPRG2 : spr_num_t := 274;
50 constant SPR_SPRG3 : spr_num_t := 275;
51 constant SPR_SPRG3U : spr_num_t := 259;
52 constant SPR_HSPRG0 : spr_num_t := 304;
53 constant SPR_HSPRG1 : spr_num_t := 305;
54 constant SPR_PID : spr_num_t := 48;
55 constant SPR_PTCR : spr_num_t := 464;
56 constant SPR_PVR : spr_num_t := 287;
59 constant SPR_UPMC1 : spr_num_t := 771;
60 constant SPR_UPMC2 : spr_num_t := 772;
61 constant SPR_UPMC3 : spr_num_t := 773;
62 constant SPR_UPMC4 : spr_num_t := 774;
63 constant SPR_UPMC5 : spr_num_t := 775;
64 constant SPR_UPMC6 : spr_num_t := 776;
65 constant SPR_UMMCR0 : spr_num_t := 779;
66 constant SPR_UMMCR1 : spr_num_t := 782;
67 constant SPR_UMMCR2 : spr_num_t := 769;
68 constant SPR_UMMCRA : spr_num_t := 770;
69 constant SPR_USIER : spr_num_t := 768;
70 constant SPR_USIAR : spr_num_t := 780;
71 constant SPR_USDAR : spr_num_t := 781;
72 constant SPR_PMC1 : spr_num_t := 787;
73 constant SPR_PMC2 : spr_num_t := 788;
74 constant SPR_PMC3 : spr_num_t := 789;
75 constant SPR_PMC4 : spr_num_t := 790;
76 constant SPR_PMC5 : spr_num_t := 791;
77 constant SPR_PMC6 : spr_num_t := 792;
78 constant SPR_MMCR0 : spr_num_t := 795;
79 constant SPR_MMCR1 : spr_num_t := 798;
80 constant SPR_MMCR2 : spr_num_t := 785;
81 constant SPR_MMCRA : spr_num_t := 786;
82 constant SPR_SIER : spr_num_t := 784;
83 constant SPR_SIAR : spr_num_t := 796;
84 constant SPR_SDAR : spr_num_t := 797;
86 -- GPR indices in the register file (GPR only)
87 subtype gpr_index_t is std_ulogic_vector(4 downto 0);
89 -- Extended GPR index (can hold an SPR or a FPR)
90 subtype gspr_index_t is std_ulogic_vector(6 downto 0);
93 subtype fpr_index_t is std_ulogic_vector(4 downto 0);
95 -- Some SPRs are stored in the register file, they use the magic
96 -- GPR numbers above 31.
98 -- The function fast_spr_num() returns the corresponding fast
99 -- pseudo-GPR number for a given SPR number. The result MSB
100 -- indicates if this is indeed a fast SPR. If clear, then
101 -- the SPR is not stored in the GPR file.
103 -- FPRs are also stored in the register file, using GSPR
104 -- numbers from 64 to 95.
106 function fast_spr_num(spr: spr_num_t) return gspr_index_t;
108 -- Indices conversion functions
109 function gspr_to_gpr(i: gspr_index_t) return gpr_index_t;
110 function gpr_to_gspr(i: gpr_index_t) return gspr_index_t;
111 function gpr_or_spr_to_gspr(g: gpr_index_t; s: gspr_index_t) return gspr_index_t;
112 function is_fast_spr(s: gspr_index_t) return std_ulogic;
113 function fpr_to_gspr(f: fpr_index_t) return gspr_index_t;
115 -- The XER is split: the common bits (CA, OV, SO, OV32 and CA32) are
116 -- in the CR file as a kind of CR extension (with a separate write
117 -- control). The rest is stored as a fast SPR.
118 type xer_common_t is record
125 constant xerc_init : xer_common_t := (others => '0');
128 constant FPSCR_FX : integer := 63 - 32;
129 constant FPSCR_FEX : integer := 63 - 33;
130 constant FPSCR_VX : integer := 63 - 34;
131 constant FPSCR_OX : integer := 63 - 35;
132 constant FPSCR_UX : integer := 63 - 36;
133 constant FPSCR_ZX : integer := 63 - 37;
134 constant FPSCR_XX : integer := 63 - 38;
135 constant FPSCR_VXSNAN : integer := 63 - 39;
136 constant FPSCR_VXISI : integer := 63 - 40;
137 constant FPSCR_VXIDI : integer := 63 - 41;
138 constant FPSCR_VXZDZ : integer := 63 - 42;
139 constant FPSCR_VXIMZ : integer := 63 - 43;
140 constant FPSCR_VXVC : integer := 63 - 44;
141 constant FPSCR_FR : integer := 63 - 45;
142 constant FPSCR_FI : integer := 63 - 46;
143 constant FPSCR_C : integer := 63 - 47;
144 constant FPSCR_FL : integer := 63 - 48;
145 constant FPSCR_FG : integer := 63 - 49;
146 constant FPSCR_FE : integer := 63 - 50;
147 constant FPSCR_FU : integer := 63 - 51;
148 constant FPSCR_VXSOFT : integer := 63 - 53;
149 constant FPSCR_VXSQRT : integer := 63 - 54;
150 constant FPSCR_VXCVI : integer := 63 - 55;
151 constant FPSCR_VE : integer := 63 - 56;
152 constant FPSCR_OE : integer := 63 - 57;
153 constant FPSCR_UE : integer := 63 - 58;
154 constant FPSCR_ZE : integer := 63 - 59;
155 constant FPSCR_XE : integer := 63 - 60;
156 constant FPSCR_NI : integer := 63 - 61;
157 constant FPSCR_RN : integer := 63 - 63;
160 -- REAL_ADDR_BITS is the number of real address bits that we store
161 constant REAL_ADDR_BITS : positive := 56;
162 subtype real_addr_t is std_ulogic_vector(REAL_ADDR_BITS - 1 downto 0);
163 function addr_to_real(addr: std_ulogic_vector(63 downto 0)) return real_addr_t;
165 -- Used for tracking instruction completion and pending register writes
166 constant TAG_COUNT : positive := 4;
167 constant TAG_NUMBER_BITS : natural := log2(TAG_COUNT);
168 subtype tag_number_t is integer range 0 to TAG_COUNT - 1;
169 subtype tag_index_t is unsigned(TAG_NUMBER_BITS - 1 downto 0);
170 type instr_tag_t is record
174 constant instr_tag_init : instr_tag_t := (tag => 0, valid => '0');
175 function tag_match(tag1 : instr_tag_t; tag2 : instr_tag_t) return boolean;
177 subtype intr_vector_t is integer range 0 to 16#fff#;
179 -- For now, fixed 16 sources, make this either a parametric
180 -- package of some sort or an unconstrainted array.
181 type ics_to_icp_t is record
182 -- Level interrupts only, ICS just keeps prsenting the
183 -- highest priority interrupt. Once handling edge, something
184 -- smarter involving handshake & reject support will be needed
185 src : std_ulogic_vector(3 downto 0);
186 pri : std_ulogic_vector(7 downto 0);
189 -- This needs to die...
190 type ctrl_t is record
191 tb: std_ulogic_vector(63 downto 0);
192 dec: std_ulogic_vector(63 downto 0);
193 msr: std_ulogic_vector(63 downto 0);
194 cfar: std_ulogic_vector(63 downto 0);
197 type Fetch1ToIcacheType is record
199 virt_mode : std_ulogic;
200 priv_mode : std_ulogic;
201 big_endian : std_ulogic;
202 stop_mark: std_ulogic;
203 predicted : std_ulogic;
204 pred_ntaken : std_ulogic;
205 nia: std_ulogic_vector(63 downto 0);
208 type IcacheToDecode1Type is record
210 stop_mark: std_ulogic;
211 fetch_failed: std_ulogic;
212 nia: std_ulogic_vector(63 downto 0);
213 insn: std_ulogic_vector(31 downto 0);
214 big_endian: std_ulogic;
215 next_predicted: std_ulogic;
216 next_pred_ntaken: std_ulogic;
219 type IcacheEventType is record
220 icache_miss : std_ulogic;
221 itlb_miss_resolved : std_ulogic;
224 type Decode1ToDecode2Type is record
226 stop_mark : std_ulogic;
227 nia: std_ulogic_vector(63 downto 0);
228 insn: std_ulogic_vector(31 downto 0);
229 ispr1: gspr_index_t; -- (G)SPR used for branch condition (CTR) or mfspr
230 ispr2: gspr_index_t; -- (G)SPR used for branch target (CTR, LR, TAR)
231 ispro: gspr_index_t; -- (G)SPR written with LR or CTR
232 decode: decode_rom_t;
233 br_pred: std_ulogic; -- Branch was predicted to be taken
234 big_endian: std_ulogic;
236 constant Decode1ToDecode2Init : Decode1ToDecode2Type :=
237 (valid => '0', stop_mark => '0', nia => (others => '0'), insn => (others => '0'),
238 ispr1 => (others => '0'), ispr2 => (others => '0'), ispro => (others => '0'),
239 decode => decode_rom_init, br_pred => '0', big_endian => '0');
241 type Decode1ToFetch1Type is record
242 redirect : std_ulogic;
243 redirect_nia : std_ulogic_vector(63 downto 0);
246 type bypass_data_t is record
248 data : std_ulogic_vector(63 downto 0);
250 constant bypass_data_init : bypass_data_t := (tag => instr_tag_init, data => (others => '0'));
252 type cr_bypass_data_t is record
254 data : std_ulogic_vector(31 downto 0);
256 constant cr_bypass_data_init : cr_bypass_data_t := (tag => instr_tag_init, data => (others => '0'));
258 type Decode2ToExecute1Type is record
262 insn_type: insn_type_t;
263 nia: std_ulogic_vector(63 downto 0);
264 instr_tag : instr_tag_t;
265 write_reg: gspr_index_t;
266 write_reg_enable: std_ulogic;
267 read_reg1: gspr_index_t;
268 read_reg2: gspr_index_t;
269 read_data1: std_ulogic_vector(63 downto 0);
270 read_data2: std_ulogic_vector(63 downto 0);
271 read_data3: std_ulogic_vector(63 downto 0);
272 cr: std_ulogic_vector(31 downto 0);
278 invert_a: std_ulogic;
280 invert_out: std_ulogic;
281 input_carry: carry_in_t;
282 output_carry: std_ulogic;
283 input_cr: std_ulogic;
284 output_cr: std_ulogic;
285 output_xer: std_ulogic;
286 is_32bit: std_ulogic;
287 is_signed: std_ulogic;
288 insn: std_ulogic_vector(31 downto 0);
289 data_len: std_ulogic_vector(3 downto 0);
290 byte_reverse : std_ulogic;
291 sign_extend : std_ulogic; -- do we need to sign extend?
292 update : std_ulogic; -- is this an update instruction?
293 reserve : std_ulogic; -- set for larx/stcx
294 br_pred : std_ulogic;
295 result_sel : std_ulogic_vector(2 downto 0); -- select source of result
296 sub_select : std_ulogic_vector(2 downto 0); -- sub-result selection
297 repeat : std_ulogic; -- set if instruction is cracked into two ops
298 second : std_ulogic; -- set if this is the second op
300 constant Decode2ToExecute1Init : Decode2ToExecute1Type :=
301 (valid => '0', unit => NONE, fac => NONE, insn_type => OP_ILLEGAL, instr_tag => instr_tag_init,
302 write_reg_enable => '0',
303 lr => '0', br_abs => '0', rc => '0', oe => '0', invert_a => '0', addm1 => '0',
304 invert_out => '0', input_carry => ZERO, output_carry => '0', input_cr => '0',
305 output_cr => '0', output_xer => '0',
306 is_32bit => '0', is_signed => '0', xerc => xerc_init, reserve => '0', br_pred => '0',
307 byte_reverse => '0', sign_extend => '0', update => '0', nia => (others => '0'),
308 read_data1 => (others => '0'), read_data2 => (others => '0'), read_data3 => (others => '0'),
309 cr => (others => '0'), insn => (others => '0'), data_len => (others => '0'),
310 result_sel => "000", sub_select => "000",
311 repeat => '0', second => '0', others => (others => '0'));
313 type MultiplyInputType is record
315 data1: std_ulogic_vector(63 downto 0);
316 data2: std_ulogic_vector(63 downto 0);
317 addend: std_ulogic_vector(127 downto 0);
318 is_32bit: std_ulogic;
319 not_result: std_ulogic;
321 constant MultiplyInputInit : MultiplyInputType := (valid => '0',
322 is_32bit => '0', not_result => '0',
323 others => (others => '0'));
325 type MultiplyOutputType is record
327 result: std_ulogic_vector(127 downto 0);
328 overflow : std_ulogic;
330 constant MultiplyOutputInit : MultiplyOutputType := (valid => '0', overflow => '0',
331 others => (others => '0'));
333 type Execute1ToDividerType is record
335 dividend: std_ulogic_vector(63 downto 0);
336 divisor: std_ulogic_vector(63 downto 0);
337 is_signed: std_ulogic;
338 is_32bit: std_ulogic;
339 is_extended: std_ulogic;
340 is_modulus: std_ulogic;
341 neg_result: std_ulogic;
343 constant Execute1ToDividerInit: Execute1ToDividerType := (valid => '0', is_signed => '0', is_32bit => '0',
344 is_extended => '0', is_modulus => '0',
345 neg_result => '0', others => (others => '0'));
347 type PMUEventType is record
348 no_instr_avail : std_ulogic;
349 dispatch : std_ulogic;
350 ext_interrupt : std_ulogic;
351 instr_complete : std_ulogic;
352 fp_complete : std_ulogic;
353 ld_complete : std_ulogic;
354 st_complete : std_ulogic;
355 br_taken_complete : std_ulogic;
356 br_mispredict : std_ulogic;
357 ipref_discard : std_ulogic;
358 itlb_miss : std_ulogic;
359 itlb_miss_resolved : std_ulogic;
360 icache_miss : std_ulogic;
361 dc_miss_resolved : std_ulogic;
362 dc_load_miss : std_ulogic;
363 dc_ld_miss_resolved : std_ulogic;
364 dc_store_miss : std_ulogic;
365 dtlb_miss : std_ulogic;
366 dtlb_miss_resolved : std_ulogic;
367 ld_miss_nocache : std_ulogic;
368 ld_fill_nocache : std_ulogic;
370 constant PMUEventInit : PMUEventType := (others => '0');
372 type Execute1ToPMUType is record
375 spr_num : std_ulogic_vector(4 downto 0);
376 spr_val : std_ulogic_vector(63 downto 0);
377 tbbits : std_ulogic_vector(3 downto 0); -- event bits from timebase
378 pmm_msr : std_ulogic; -- PMM bit from MSR
379 pr_msr : std_ulogic; -- PR bit from MSR
381 nia : std_ulogic_vector(63 downto 0);
382 addr : std_ulogic_vector(63 downto 0);
384 occur : PMUEventType;
387 type PMUToExecute1Type is record
388 spr_val : std_ulogic_vector(63 downto 0);
392 type Decode2ToRegisterFileType is record
393 read1_enable : std_ulogic;
394 read1_reg : gspr_index_t;
395 read2_enable : std_ulogic;
396 read2_reg : gspr_index_t;
397 read3_enable : std_ulogic;
398 read3_reg : gspr_index_t;
401 type RegisterFileToDecode2Type is record
402 read1_data : std_ulogic_vector(63 downto 0);
403 read2_data : std_ulogic_vector(63 downto 0);
404 read3_data : std_ulogic_vector(63 downto 0);
407 type Decode2ToCrFileType is record
411 type CrFileToDecode2Type is record
412 read_cr_data : std_ulogic_vector(31 downto 0);
413 read_xerc_data : xer_common_t;
416 type Execute1ToLoadstore1Type is record
418 op : insn_type_t; -- what ld/st or m[tf]spr or TLB op to do
419 nia : std_ulogic_vector(63 downto 0);
420 insn : std_ulogic_vector(31 downto 0);
421 instr_tag : instr_tag_t;
422 addr1 : std_ulogic_vector(63 downto 0);
423 addr2 : std_ulogic_vector(63 downto 0);
424 data : std_ulogic_vector(63 downto 0); -- data to write, unused for read
425 write_reg : gspr_index_t;
426 length : std_ulogic_vector(3 downto 0);
427 ci : std_ulogic; -- cache-inhibited load/store
428 byte_reverse : std_ulogic;
429 sign_extend : std_ulogic; -- do we need to sign extend?
430 update : std_ulogic; -- is this an update instruction?
432 reserve : std_ulogic; -- set for larx/stcx.
433 rc : std_ulogic; -- set for stcx.
434 virt_mode : std_ulogic; -- do translation through TLB
435 priv_mode : std_ulogic; -- privileged mode (MSR[PR] = 0)
436 mode_32bit : std_ulogic; -- trim addresses to 32 bits
437 is_32bit : std_ulogic;
440 msr : std_ulogic_vector(63 downto 0);
442 constant Execute1ToLoadstore1Init : Execute1ToLoadstore1Type :=
443 (valid => '0', op => OP_ILLEGAL, ci => '0', byte_reverse => '0',
444 sign_extend => '0', update => '0', xerc => xerc_init,
445 reserve => '0', rc => '0', virt_mode => '0', priv_mode => '0',
446 nia => (others => '0'), insn => (others => '0'),
447 instr_tag => instr_tag_init,
448 addr1 => (others => '0'), addr2 => (others => '0'), data => (others => '0'),
449 write_reg => (others => '0'),
450 length => (others => '0'),
451 mode_32bit => '0', is_32bit => '0',
452 repeat => '0', second => '0',
453 msr => (others => '0'));
455 type Loadstore1ToExecute1Type is record
457 in_progress : std_ulogic;
458 interrupt : std_ulogic;
461 type Loadstore1ToDcacheType is record
464 load : std_ulogic; -- is this a load
467 reserve : std_ulogic;
468 atomic : std_ulogic; -- part of a multi-transfer atomic op
469 atomic_last : std_ulogic;
470 virt_mode : std_ulogic;
471 priv_mode : std_ulogic;
472 addr : std_ulogic_vector(63 downto 0);
473 data : std_ulogic_vector(63 downto 0); -- valid the cycle after .valid = 1
474 byte_sel : std_ulogic_vector(7 downto 0);
477 type DcacheToLoadstore1Type is record
479 data : std_ulogic_vector(63 downto 0);
480 store_done : std_ulogic;
482 cache_paradox : std_ulogic;
485 type DcacheEventType is record
486 load_miss : std_ulogic;
487 store_miss : std_ulogic;
488 dcache_refill : std_ulogic;
489 dtlb_miss : std_ulogic;
490 dtlb_miss_resolved : std_ulogic;
493 type Loadstore1ToMmuType is record
501 sprn : std_ulogic_vector(9 downto 0);
502 addr : std_ulogic_vector(63 downto 0);
503 rs : std_ulogic_vector(63 downto 0);
506 type MmuToLoadstore1Type is record
509 invalid : std_ulogic;
510 badtree : std_ulogic;
512 perm_error : std_ulogic;
513 rc_error : std_ulogic;
514 sprval : std_ulogic_vector(63 downto 0);
517 type MmuToDcacheType is record
522 addr : std_ulogic_vector(63 downto 0);
523 pte : std_ulogic_vector(63 downto 0);
526 type DcacheToMmuType is record
530 data : std_ulogic_vector(63 downto 0);
533 type MmuToIcacheType is record
537 addr : std_ulogic_vector(63 downto 0);
538 pte : std_ulogic_vector(63 downto 0);
541 type Loadstore1ToWritebackType is record
543 instr_tag : instr_tag_t;
544 write_enable: std_ulogic;
545 write_reg : gspr_index_t;
546 write_data : std_ulogic_vector(63 downto 0);
549 store_done : std_ulogic;
550 interrupt : std_ulogic;
551 intr_vec : intr_vector_t;
552 srr0: std_ulogic_vector(63 downto 0);
553 srr1: std_ulogic_vector(15 downto 0);
555 constant Loadstore1ToWritebackInit : Loadstore1ToWritebackType :=
556 (valid => '0', instr_tag => instr_tag_init, write_enable => '0',
557 write_reg => (others => '0'), write_data => (others => '0'),
558 xerc => xerc_init, rc => '0', store_done => '0',
559 interrupt => '0', intr_vec => 0,
560 srr0 => (others => '0'), srr1 => (others => '0'));
562 type Loadstore1EventType is record
563 load_complete : std_ulogic;
564 store_complete : std_ulogic;
565 itlb_miss : std_ulogic;
568 type Execute1ToWritebackType is record
570 instr_tag : instr_tag_t;
572 mode_32bit : std_ulogic;
573 write_enable : std_ulogic;
574 write_reg: gspr_index_t;
575 write_data: std_ulogic_vector(63 downto 0);
576 write_cr_enable : std_ulogic;
577 write_cr_mask : std_ulogic_vector(7 downto 0);
578 write_cr_data : std_ulogic_vector(31 downto 0);
579 write_xerc_enable : std_ulogic;
581 interrupt : std_ulogic;
582 intr_vec : intr_vector_t;
583 redirect: std_ulogic;
584 redir_mode: std_ulogic_vector(3 downto 0);
585 last_nia: std_ulogic_vector(63 downto 0);
586 br_offset: std_ulogic_vector(63 downto 0);
588 br_taken: std_ulogic;
590 srr1: std_ulogic_vector(15 downto 0);
591 msr: std_ulogic_vector(63 downto 0);
593 constant Execute1ToWritebackInit : Execute1ToWritebackType :=
594 (valid => '0', instr_tag => instr_tag_init, rc => '0', mode_32bit => '0',
595 write_enable => '0', write_cr_enable => '0',
596 write_xerc_enable => '0', xerc => xerc_init,
597 write_data => (others => '0'), write_cr_mask => (others => '0'),
598 write_cr_data => (others => '0'), write_reg => (others => '0'),
599 interrupt => '0', intr_vec => 0, redirect => '0', redir_mode => "0000",
600 last_nia => (others => '0'), br_offset => (others => '0'),
601 br_last => '0', br_taken => '0', abs_br => '0',
602 srr1 => (others => '0'), msr => (others => '0'));
604 type Execute1ToFPUType is record
607 nia : std_ulogic_vector(63 downto 0);
609 insn : std_ulogic_vector(31 downto 0);
611 fe_mode : std_ulogic_vector(1 downto 0);
612 fra : std_ulogic_vector(63 downto 0);
613 frb : std_ulogic_vector(63 downto 0);
614 frc : std_ulogic_vector(63 downto 0);
619 constant Execute1ToFPUInit : Execute1ToFPUType := (valid => '0', op => OP_ILLEGAL, nia => (others => '0'),
620 itag => instr_tag_init,
621 insn => (others => '0'), fe_mode => "00", rc => '0',
622 fra => (others => '0'), frb => (others => '0'),
623 frc => (others => '0'), frt => (others => '0'),
624 single => '0', out_cr => '0');
626 type FPUToExecute1Type is record
628 exception : std_ulogic;
630 constant FPUToExecute1Init : FPUToExecute1Type := (others => '0');
632 type FPUToWritebackType is record
634 interrupt : std_ulogic;
635 instr_tag : instr_tag_t;
636 write_enable : std_ulogic;
637 write_reg : gspr_index_t;
638 write_data : std_ulogic_vector(63 downto 0);
639 write_cr_enable : std_ulogic;
640 write_cr_mask : std_ulogic_vector(7 downto 0);
641 write_cr_data : std_ulogic_vector(31 downto 0);
642 intr_vec : intr_vector_t;
643 srr0 : std_ulogic_vector(63 downto 0);
644 srr1 : std_ulogic_vector(15 downto 0);
646 constant FPUToWritebackInit : FPUToWritebackType :=
647 (valid => '0', interrupt => '0', instr_tag => instr_tag_init,
648 write_enable => '0', write_reg => (others => '0'),
649 write_cr_enable => '0', write_cr_mask => (others => '0'),
650 write_cr_data => (others => '0'),
651 intr_vec => 0, srr1 => (others => '0'),
652 others => (others => '0'));
654 type DividerToExecute1Type is record
656 write_reg_data: std_ulogic_vector(63 downto 0);
657 overflow : std_ulogic;
659 constant DividerToExecute1Init : DividerToExecute1Type := (valid => '0', overflow => '0',
660 others => (others => '0'));
662 type WritebackToFetch1Type is record
663 redirect: std_ulogic;
664 virt_mode: std_ulogic;
665 priv_mode: std_ulogic;
666 big_endian: std_ulogic;
667 mode_32bit: std_ulogic;
668 redirect_nia: std_ulogic_vector(63 downto 0);
669 br_nia : std_ulogic_vector(63 downto 0);
670 br_last : std_ulogic;
671 br_taken : std_ulogic;
673 constant WritebackToFetch1Init : WritebackToFetch1Type :=
674 (redirect => '0', virt_mode => '0', priv_mode => '0', big_endian => '0',
675 mode_32bit => '0', redirect_nia => (others => '0'),
676 br_last => '0', br_taken => '0', br_nia => (others => '0'));
678 type WritebackToRegisterFileType is record
679 write_reg : gspr_index_t;
680 write_data : std_ulogic_vector(63 downto 0);
681 write_enable : std_ulogic;
683 constant WritebackToRegisterFileInit : WritebackToRegisterFileType :=
684 (write_enable => '0', write_data => (others => '0'), others => (others => '0'));
686 type WritebackToCrFileType is record
687 write_cr_enable : std_ulogic;
688 write_cr_mask : std_ulogic_vector(7 downto 0);
689 write_cr_data : std_ulogic_vector(31 downto 0);
690 write_xerc_enable : std_ulogic;
691 write_xerc_data : xer_common_t;
693 constant WritebackToCrFileInit : WritebackToCrFileType := (write_cr_enable => '0', write_xerc_enable => '0',
694 write_xerc_data => xerc_init,
695 write_cr_mask => (others => '0'),
696 write_cr_data => (others => '0'));
698 type WritebackEventType is record
699 instr_complete : std_ulogic;
700 fp_complete : std_ulogic;
705 package body common is
706 function decode_spr_num(insn: std_ulogic_vector(31 downto 0)) return spr_num_t is
708 return to_integer(unsigned(insn(15 downto 11) & insn(20 downto 16)));
710 function fast_spr_num(spr: spr_num_t) return gspr_index_t is
711 variable n : integer range 0 to 31;
712 -- tmp variable introduced as workaround for VCS compilation
713 -- simulation was failing with subtype constraint mismatch error
714 -- see GitHub PR #173
715 variable tmp : std_ulogic_vector(4 downto 0);
719 n := 0; -- N.B. decode2 relies on this specific value
721 n := 1; -- N.B. decode2 relies on this specific value
736 when SPR_SPRG3 | SPR_SPRG3U =>
750 tmp := std_ulogic_vector(to_unsigned(n, 5));
754 function gspr_to_gpr(i: gspr_index_t) return gpr_index_t is
756 return i(4 downto 0);
759 function gpr_to_gspr(i: gpr_index_t) return gspr_index_t is
764 function gpr_or_spr_to_gspr(g: gpr_index_t; s: gspr_index_t) return gspr_index_t is
769 return gpr_to_gspr(g);
773 function is_fast_spr(s: gspr_index_t) return std_ulogic is
778 function fpr_to_gspr(f: fpr_index_t) return gspr_index_t is
783 function tag_match(tag1 : instr_tag_t; tag2 : instr_tag_t) return boolean is
785 return tag1.valid = '1' and tag2.valid = '1' and tag1.tag = tag2.tag;
788 function addr_to_real(addr: std_ulogic_vector(63 downto 0)) return real_addr_t is
790 return addr(real_addr_t'range);