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

Subversion Repositories klc32

[/] [klc32/] [trunk/] [rtl/] [verilog/] [WRITE_FLAGS.v] - Rev 2

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

// ============================================================================
// (C) 2011 Robert Finch
// All Rights Reserved.
// robfinch<remove>@opencores.org
//
// KLC32 - 32 bit CPU
// WRITE_FLAGS.v - update the CR registers
//
// This source file is free software: you can redistribute it and/or modify 
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation, either version 3 of the License, or     
// (at your option) any later version.                                      
//                                                                          
// This source file is distributed in the hope that it will be useful,      
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
// GNU General Public License for more details.                             
//                                                                          
// You should have received a copy of the GNU General Public License        
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
//                                                                          
// ============================================================================
//
WRITE_FLAGS:
	begin
		state <= IFETCH;
		if (opcode==`CMPI || (opcode==`RR && func==`CMP)) begin
			case(Rn[2:0])
			3'd0:	cr0 <= {nf,zf,vf,cf};
			3'd1:	cr1 <= {nf,zf,vf,cf};
			3'd2:	cr2 <= {nf,zf,vf,cf};
			3'd3:	cr3 <= {nf,zf,vf,cf};
			3'd4:	cr4 <= {nf,zf,vf,cf};
			3'd5:	cr5 <= {nf,zf,vf,cf};
			3'd6:	cr6 <= {nf,zf,vf,cf};
			3'd7:	cr7 <= {nf,zf,vf,cf};
			endcase
		end
		else begin
			case(opcode)
			`R:
				case(func)
				`ABS,`SGN,`NEG,`NOT,`EXTB,`EXTH:
					cr0 <= {nf,zf,vf,cf};
				default:	;
				endcase
			`RR:
				case(func)
				`ADD,`SUB,`AND,`OR,`EOR,`NAND,`NOR,`ENOR,
				`MIN,`MAX,
				`BCDADD,`BCDSUB,
				`SHL,`SHR,`ROL,`ROR,
				`LWX,`LHX,`LBX,`LHUX,`LBUX:
					cr0 <= {nf,zf,vf,cf};
				default:	;
				endcase
			`ADDI,`SUBI,`ANDI,`ORI,`EORI,`LW,`LH,`LB,`LHU,`LBU,`TAS:
				cr0 <= {nf,zf,vf,cf};
			default:	;
			endcase
		end
	end
 
 

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

powered by: WebSVN 2.1.0

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