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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_if.v] - Blame information for rev 788

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's instruction fetch                                  ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  PC, instruction fetch, interface to IC.                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 788 lampret
// Revision 1.2  2002/01/28 01:16:00  lampret
48
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
49
//
50 617 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
51
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
52
//
53 504 lampret
// Revision 1.10  2001/11/20 18:46:15  simons
54
// Break point bug fixed
55
//
56
// Revision 1.9  2001/11/18 09:58:28  lampret
57
// Fixed some l.trap typos.
58
//
59
// Revision 1.8  2001/11/18 08:36:28  lampret
60
// For GDB changed single stepping and disabled trap exception.
61
//
62
// Revision 1.7  2001/10/21 17:57:16  lampret
63
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
64
//
65
// Revision 1.6  2001/10/14 13:12:09  lampret
66
// MP3 version.
67
//
68
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
69
// no message
70
//
71
// Revision 1.1  2001/08/09 13:39:33  lampret
72
// Major clean-up.
73
//
74
//
75
 
76
// synopsys translate_off
77
`include "timescale.v"
78
// synopsys translate_on
79
`include "or1200_defines.v"
80
 
81
module or1200_if(
82
        // Clock and reset
83
        clk, rst,
84
 
85
        // External i/f to IC
86 788 lampret
        icpu_dat_i, icpu_ack_i, icpu_err_i, icpu_adr_i, icpu_tag_i,
87 504 lampret
 
88
        // Internal i/f
89
        if_freeze, if_insn, if_pc, flushpipe,
90 788 lampret
        if_stall, no_more_dslot, genpc_refetch, rfe,
91 504 lampret
        except_itlbmiss, except_immufault, except_ibuserr
92
);
93
 
94
//
95
// I/O
96
//
97
 
98
//
99
// Clock and reset
100
//
101
input                           clk;
102
input                           rst;
103
 
104
//
105
// External i/f to IC
106
//
107
input   [31:0]                   icpu_dat_i;
108
input                           icpu_ack_i;
109
input                           icpu_err_i;
110
input   [31:0]                   icpu_adr_i;
111
input   [3:0]                    icpu_tag_i;
112
 
113
//
114
// Internal i/f
115
//
116
input                           if_freeze;
117
output  [31:0]                   if_insn;
118
output  [31:0]                   if_pc;
119
input                           flushpipe;
120
output                          if_stall;
121 617 lampret
input                           no_more_dslot;
122 504 lampret
output                          genpc_refetch;
123
input                           rfe;
124
output                          except_itlbmiss;
125
output                          except_immufault;
126
output                          except_ibuserr;
127
 
128
//
129
// Internal wires and regs
130
//
131
reg     [31:0]                   insn_saved;
132
reg     [31:0]                   addr_saved;
133
reg                             saved;
134
 
135
//
136
// IF stage insn
137
//
138 617 lampret
assign if_insn = icpu_err_i | no_more_dslot | rfe ? {`OR1200_OR32_NOP, 26'h041_0000} : saved ? insn_saved : icpu_ack_i ? icpu_dat_i : {`OR1200_OR32_NOP, 26'h061_0000};
139 504 lampret
assign if_pc = saved ? addr_saved : icpu_adr_i;
140 617 lampret
// assign if_stall = !icpu_err_i & !icpu_ack_i & !saved & !no_more_dslot;
141 504 lampret
assign if_stall = !icpu_err_i & !icpu_ack_i & !saved;
142
assign genpc_refetch = saved & icpu_ack_i;
143 617 lampret
assign except_itlbmiss = icpu_err_i & (icpu_tag_i == `OR1200_ITAG_TE) & !no_more_dslot;
144
assign except_immufault = icpu_err_i & (icpu_tag_i == `OR1200_ITAG_PE) & !no_more_dslot;
145
assign except_ibuserr = icpu_err_i & (icpu_tag_i == `OR1200_ITAG_BE) & !no_more_dslot;
146 504 lampret
 
147
//
148
// Flag for saved insn/address
149
//
150
always @(posedge clk or posedge rst)
151
        if (rst)
152
                saved <= #1 1'b0;
153
        else if (flushpipe)
154
                saved <= #1 1'b0;
155
        else if (icpu_ack_i & if_freeze & !saved)
156
                saved <= #1 1'b1;
157
        else if (!if_freeze)
158
                saved <= #1 1'b0;
159
 
160
//
161
// Store fetched instruction
162
//
163
always @(posedge clk or posedge rst)
164
        if (rst)
165 617 lampret
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000};
166 504 lampret
        else if (flushpipe)
167 617 lampret
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000};
168 504 lampret
        else if (icpu_ack_i & if_freeze & !saved)
169
                insn_saved <= #1 icpu_dat_i;
170
        else if (!if_freeze)
171 617 lampret
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000};
172 504 lampret
 
173
//
174
// Store fetched instruction's address
175
//
176
always @(posedge clk or posedge rst)
177
        if (rst)
178
                addr_saved <= #1 32'h00000000;
179
        else if (flushpipe)
180
                addr_saved <= #1 32'h00000000;
181
        else if (icpu_ack_i & if_freeze & !saved)
182
                addr_saved <= #1 icpu_adr_i;
183
        else if (!if_freeze)
184
                addr_saved <= #1 icpu_adr_i;
185
 
186
endmodule

powered by: WebSVN 2.1.0

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