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

Subversion Repositories klc32

[/] [klc32/] [trunk/] [rtl/] [verilog/] [POP.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
// POP type instructions
8
// POP / UNLK
9
//
10
// This source file is free software: you can redistribute it and/or modify 
11
// it under the terms of the GNU Lesser General Public License as published 
12
// by the Free Software Foundation, either version 3 of the License, or     
13
// (at your option) any later version.                                      
14
//                                                                          
15
// This source file is distributed in the hope that it will be useful,      
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
18
// GNU General Public License for more details.                             
19
//                                                                          
20
// You should have received a copy of the GNU General Public License        
21
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
22
//                                                                          
23
// ============================================================================
24
//
25
POP1:
26
        if (ir[25:1]==25'd0)
27
                state <= IFETCH;
28
        else begin
29
                Rn <= ir[25:21];
30
                ir[25:0] <= {ir[20:1],6'b0};
31 10 robfinch
                if (ir[25:21]!=5'd0)
32
                        state <= POP2;
33 2 robfinch
        end
34
POP2:
35
        begin
36
                fc_o <= {sf,2'b01};
37
                cyc_o <= 1'b1;
38
                stb_o <= 1'b1;
39
                sel_o <= 4'b1111;
40
                adr_o <= sf ? ssp : usp;
41
                state <= POP3;
42
        end
43
POP3:
44
        if (ack_i) begin
45
                cyc_o <= 1'b0;
46
                stb_o <= 1'b0;
47
                sel_o <= 4'b0000;
48
                if (sf)
49
                        ssp <= ssp + 32'd4;
50
                else
51
                        usp <= usp + 32'd4;
52
                res <= dat_i;
53
                state <= WRITEBACK;
54
        end
55
 
56
UNLK:
57
        if (!cyc_o) begin
58
                fc_o <= {sf,2'b01};
59
                cyc_o <= 1'b1;
60
                stb_o <= 1'b1;
61
                sel_o <= 4'b1111;
62
                adr_o <= a;
63
                if (sf)
64
                        ssp <= a;
65
                else
66
                        usp <= a;
67
        end
68
        else if (ack_i) begin
69
                cyc_o <= 1'b0;
70
                stb_o <= 1'b0;
71
                sel_o <= 4'b0000;
72
                if (sf)
73
                        ssp <= ssp + 32'd4;
74
                else
75
                        usp <= usp + 32'd4;
76
                res <= dat_i;
77
                state <= WRITEBACK;
78
        end
79
 

powered by: WebSVN 2.1.0

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