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

Subversion Repositories klc32

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

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 12 robfinch
                        $display("Writing flags to Cr%d",Rn[4:2]);
29 10 robfinch
                        case(Rn[4:2])
30 2 robfinch
                        3'd0:   cr0 <= {nf,zf,vf,cf};
31
                        3'd1:   cr1 <= {nf,zf,vf,cf};
32
                        3'd2:   cr2 <= {nf,zf,vf,cf};
33
                        3'd3:   cr3 <= {nf,zf,vf,cf};
34
                        3'd4:   cr4 <= {nf,zf,vf,cf};
35
                        3'd5:   cr5 <= {nf,zf,vf,cf};
36
                        3'd6:   cr6 <= {nf,zf,vf,cf};
37
                        3'd7:   cr7 <= {nf,zf,vf,cf};
38
                        endcase
39
                end
40
                else begin
41
                        case(opcode)
42
                        `R:
43
                                case(func)
44
                                `ABS,`SGN,`NEG,`NOT,`EXTB,`EXTH:
45 10 robfinch
                                        if (Rcbit) cr0 <= {nf,zf,vf,cf};
46 2 robfinch
                                default:        ;
47
                                endcase
48
                        `RR:
49
                                case(func)
50 10 robfinch
                                `MULU,`MULS,`MULUH,`MULSH,`DIVU,`DIVS,`MODU,`MODS,
51
                                `ADD,`SUB,`AND,`ANDC,`OR,`ORC,`EOR,`NAND,`NOR,`ENOR,
52 2 robfinch
                                `MIN,`MAX,
53
                                `BCDADD,`BCDSUB,
54
                                `SHL,`SHR,`ROL,`ROR,
55
                                `LWX,`LHX,`LBX,`LHUX,`LBUX:
56 10 robfinch
                                        if (Rcbit) cr0 <= {nf,zf,vf,cf};
57 2 robfinch
                                default:        ;
58 10 robfinch
                        endcase
59
                        `MULUI,`MULSI,`DIVUI,`DIVSI,
60 2 robfinch
                        `ADDI,`SUBI,`ANDI,`ORI,`EORI,`LW,`LH,`LB,`LHU,`LBU,`TAS:
61
                                cr0 <= {nf,zf,vf,cf};
62
                        default:        ;
63
                        endcase
64
                end
65
        end
66
 

powered by: WebSVN 2.1.0

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