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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [rtl/] [or1200/] [rtl/] [verilog/] [or1200_if.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
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: or1200_if.v,v $
47
// Revision 1.5  2004/04/05 08:29:57  lampret
48
// Merged branch_qmem into main tree.
49
//
50
// Revision 1.3  2002/03/29 15:16:56  lampret
51
// Some of the warnings fixed.
52
//
53
// Revision 1.2  2002/01/28 01:16:00  lampret
54
// 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.
55
//
56
// Revision 1.1  2002/01/03 08:16:15  lampret
57
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
58
//
59
// Revision 1.10  2001/11/20 18:46:15  simons
60
// Break point bug fixed
61
//
62
// Revision 1.9  2001/11/18 09:58:28  lampret
63
// Fixed some l.trap typos.
64
//
65
// Revision 1.8  2001/11/18 08:36:28  lampret
66
// For GDB changed single stepping and disabled trap exception.
67
//
68
// Revision 1.7  2001/10/21 17:57:16  lampret
69
// 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.
70
//
71
// Revision 1.6  2001/10/14 13:12:09  lampret
72
// MP3 version.
73
//
74
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
75
// no message
76
//
77
// Revision 1.1  2001/08/09 13:39:33  lampret
78
// Major clean-up.
79
//
80
//
81
 
82
// synopsys translate_off
83
`include "timescale.v"
84
// synopsys translate_on
85
`include "or1200_defines.v"
86
 
87
module or1200_if(
88
        // Clock and reset
89
        clk, rst,
90
 
91
        // External i/f to IC
92
        icpu_dat_i, icpu_ack_i, icpu_err_i, icpu_adr_i, icpu_tag_i,
93
 
94
        // Internal i/f
95
        if_freeze, if_insn, if_pc, flushpipe,
96
        if_stall, no_more_dslot, genpc_refetch, rfe,
97
        except_itlbmiss, except_immufault, except_ibuserr
98
);
99
 
100
//
101
// I/O
102
//
103
 
104
//
105
// Clock and reset
106
//
107
input                           clk;
108
input                           rst;
109
 
110
//
111
// External i/f to IC
112
//
113
input   [31:0]                   icpu_dat_i;
114
input                           icpu_ack_i;
115
input                           icpu_err_i;
116
input   [31:0]                   icpu_adr_i;
117
input   [3:0]                    icpu_tag_i;
118
 
119
//
120
// Internal i/f
121
//
122
input                           if_freeze;
123
output  [31:0]                   if_insn;
124
output  [31:0]                   if_pc;
125
input                           flushpipe;
126
output                          if_stall;
127
input                           no_more_dslot;
128
output                          genpc_refetch;
129
input                           rfe;
130
output                          except_itlbmiss;
131
output                          except_immufault;
132
output                          except_ibuserr;
133
 
134
//
135
// Internal wires and regs
136
//
137
reg     [31:0]                   insn_saved;
138
reg     [31:0]                   addr_saved;
139
reg                             saved;
140
 
141
//
142
// IF stage insn
143
//
144
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};
145
assign if_pc = saved ? addr_saved : icpu_adr_i;
146
// assign if_stall = !icpu_err_i & !icpu_ack_i & !saved & !no_more_dslot;
147
assign if_stall = !icpu_err_i & !icpu_ack_i & !saved;
148
assign genpc_refetch = saved & icpu_ack_i;
149
assign except_itlbmiss = icpu_err_i & (icpu_tag_i == `OR1200_ITAG_TE) & !no_more_dslot;
150
assign except_immufault = icpu_err_i & (icpu_tag_i == `OR1200_ITAG_PE) & !no_more_dslot;
151
assign except_ibuserr = icpu_err_i & (icpu_tag_i == `OR1200_ITAG_BE) & !no_more_dslot;
152
 
153
//
154
// Flag for saved insn/address
155
//
156
always @(posedge clk or posedge rst)
157
        if (rst)
158
                saved <= #1 1'b0;
159
        else if (flushpipe)
160
                saved <= #1 1'b0;
161
        else if (icpu_ack_i & if_freeze & !saved)
162
                saved <= #1 1'b1;
163
        else if (!if_freeze)
164
                saved <= #1 1'b0;
165
 
166
//
167
// Store fetched instruction
168
//
169
always @(posedge clk or posedge rst)
170
        if (rst)
171
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000};
172
        else if (flushpipe)
173
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000};
174
        else if (icpu_ack_i & if_freeze & !saved)
175
                insn_saved <= #1 icpu_dat_i;
176
        else if (!if_freeze)
177
                insn_saved <= #1 {`OR1200_OR32_NOP, 26'h041_0000};
178
 
179
//
180
// Store fetched instruction's address
181
//
182
always @(posedge clk or posedge rst)
183
        if (rst)
184
                addr_saved <= #1 32'h00000000;
185
        else if (flushpipe)
186
                addr_saved <= #1 32'h00000000;
187
        else if (icpu_ack_i & if_freeze & !saved)
188
                addr_saved <= #1 icpu_adr_i;
189
        else if (!if_freeze)
190
                addr_saved <= #1 icpu_adr_i;
191
 
192
endmodule

powered by: WebSVN 2.1.0

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