@ -79,7 +79,7 @@ architecture behaviour of decode1 is
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        28 =>       (ALU,  NONE, OP_AND,       NONE,       CONST_UI,    RS,   RA,   '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', ONE,  '0', '0', NONE), -- andi.
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        29 =>       (ALU,  NONE, OP_AND,       NONE,       CONST_UI_HI, RS,   RA,   '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', ONE,  '0', '0', NONE), -- andis.
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         0 =>       (ALU,  NONE, OP_ATTN,      NONE,       NONE,        NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '1', NONE), -- attn
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        18 =>       (ALU,  NONE, OP_B,         NONE,       CONST_LI,    NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '1', '0', NONE), -- b
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        18 =>       (ALU,  NONE, OP_B,         NONE,       CONST_LI,    NONE, SPR,  '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '1', '0', NONE), -- b
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        16 =>       (ALU,  NONE, OP_BC,        SPR,        CONST_BD,    NONE, SPR , '1', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '1', '0', NONE), -- bc
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        11 =>       (ALU,  NONE, OP_CMP,       RA,         CONST_SI,    NONE, NONE, '0', '1', '1', '0', ONE,  '0', NONE, '0', '0', '0', '0', '0', '1', NONE, '0', '0', NONE), -- cmpi
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        10 =>       (ALU,  NONE, OP_CMP,       RA,         CONST_UI,    NONE, NONE, '0', '1', '1', '0', ONE,  '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0', NONE), -- cmpli
 
			
		 
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
			
			 
			 
			
				@ -597,9 +597,10 @@ begin
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            -- major opcode 31, lots of things
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            v.decode := decode_op_31_array(to_integer(unsigned(f_in.insn(10 downto 1))));
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            -- Work out ispr1/ispr2 independent of v.decode since they seem to be critical path
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            -- Work out ispr1/ispro independent of v.decode since they seem to be critical path
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            sprn := decode_spr_num(f_in.insn);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            v.ispr1 := fast_spr_num(sprn);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            v.ispro := fast_spr_num(sprn);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            if std_match(f_in.insn(10 downto 1), "01-1010011") then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                -- mfspr or mtspr
 
			
		 
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
			
			 
			 
			
				@ -627,6 +628,9 @@ begin
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            -- CTR may be needed as input to bc
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            if f_in.insn(23) = '0' then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                v.ispr1 := fast_spr_num(SPR_CTR);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                v.ispro := fast_spr_num(SPR_CTR);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            elsif f_in.insn(0) = '1' then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                v.ispro := fast_spr_num(SPR_LR);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            end if;
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            -- Predict backward branches as taken, forward as untaken
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            v.br_pred := f_in.insn(15);
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -636,6 +640,9 @@ begin
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            -- Unconditional branches are always taken
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            v.br_pred := '1';
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            br_offset := signed(f_in.insn(25 downto 2));
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            if f_in.insn(0) = '1' then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                v.ispro := fast_spr_num(SPR_LR);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            end if;
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        when 19 =>
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            vi.override := not decode_op_19_valid(to_integer(unsigned(f_in.insn(5 downto 1) & f_in.insn(10 downto 6))));
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -648,8 +655,12 @@ begin
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                -- Branch uses CTR as condition when BO(2) is 0. This is
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                -- also used to indicate that CTR is modified (they go
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                -- together).
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                if f_in.insn(23) = '0' then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                -- bcctr doesn't update CTR or use it in the branch condition
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                if f_in.insn(23) = '0' and (f_in.insn(10) = '0' or f_in.insn(6) = '1') then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                    v.ispr1 := fast_spr_num(SPR_CTR);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                    v.ispro := fast_spr_num(SPR_CTR);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                elsif f_in.insn(0) = '1' then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                    v.ispro := fast_spr_num(SPR_LR);
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                end if;
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                if f_in.insn(10) = '0' then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                    v.ispr2 := fast_spr_num(SPR_LR);