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

Subversion Repositories klc32

[/] [klc32/] [trunk/] [rtl/] [verilog/] [WRITE_FLAGS.v] - Blame information for rev 4

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

Line No. Rev Author Line
1 2 robfinch
// ============================================================================
2
// (C) 2011 Robert Finch
3
// All Rights Reserved.
4
// robfinch<remove>@opencores.org
5
//
6
// KLC32 - 32 bit CPU
7
// WRITE_FLAGS.v - update the CR registers
8
//
9
// This source file is free software: you can redistribute it and/or modify 
10
// it under the terms of the GNU Lesser General Public License as published 
11
// by the Free Software Foundation, either version 3 of the License, or     
12
// (at your option) any later version.                                      
13
//                                                                          
14
// This source file is distributed in the hope that it will be useful,      
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
17
// GNU General Public License for more details.                             
18
//                                                                          
19
// You should have received a copy of the GNU General Public License        
20
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
21
//                                                                          
22
// ============================================================================
23
//
24
WRITE_FLAGS:
25
        begin
26
                state <= IFETCH;
27
                if (opcode==`CMPI || (opcode==`RR && func==`CMP)) begin
28
                        case(Rn[2:0])
29
                        3'd0:   cr0 <= {nf,zf,vf,cf};
30
                        3'd1:   cr1 <= {nf,zf,vf,cf};
31
                        3'd2:   cr2 <= {nf,zf,vf,cf};
32
                        3'd3:   cr3 <= {nf,zf,vf,cf};
33
                        3'd4:   cr4 <= {nf,zf,vf,cf};
34
                        3'd5:   cr5 <= {nf,zf,vf,cf};
35
                        3'd6:   cr6 <= {nf,zf,vf,cf};
36
                        3'd7:   cr7 <= {nf,zf,vf,cf};
37
                        endcase
38
                end
39
                else begin
40
                        case(opcode)
41
                        `R:
42
                                case(func)
43
                                `ABS,`SGN,`NEG,`NOT,`EXTB,`EXTH:
44
                                        cr0 <= {nf,zf,vf,cf};
45
                                default:        ;
46
                                endcase
47
                        `RR:
48
                                case(func)
49
                                `ADD,`SUB,`AND,`OR,`EOR,`NAND,`NOR,`ENOR,
50
                                `MIN,`MAX,
51
                                `BCDADD,`BCDSUB,
52
                                `SHL,`SHR,`ROL,`ROR,
53
                                `LWX,`LHX,`LBX,`LHUX,`LBUX:
54
                                        cr0 <= {nf,zf,vf,cf};
55
                                default:        ;
56
                                endcase
57
                        `ADDI,`SUBI,`ANDI,`ORI,`EORI,`LW,`LH,`LB,`LHU,`LBU,`TAS:
58
                                cr0 <= {nf,zf,vf,cf};
59
                        default:        ;
60
                        endcase
61
                end
62
        end
63
 

powered by: WebSVN 2.1.0

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