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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [or1200/] [or1200_if.v] - Blame information for rev 483

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

Line No. Rev Author Line
1 350 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's instruction fetch                                  ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/project,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
// $Log: or1200_if.v,v $
45
// Revision 2.0  2010/06/30 11:00:00  ORSoC
46
// Major update: 
47
// Structure reordered and bugs fixed. 
48
 
49
// synopsys translate_off
50
`include "timescale.v"
51
// synopsys translate_on
52
`include "or1200_defines.v"
53
 
54
module or1200_if(
55
        // Clock and reset
56
        clk, rst,
57
 
58
        // External i/f to IC
59
        icpu_dat_i, icpu_ack_i, icpu_err_i, icpu_adr_i, icpu_tag_i,
60
 
61
        // Internal i/f
62
        if_freeze, if_insn, if_pc, if_flushpipe, saving_if_insn,
63
        if_stall, no_more_dslot, genpc_refetch, rfe,
64
        except_itlbmiss, except_immufault, except_ibuserr
65
);
66
 
67
//
68
// I/O
69
//
70
 
71
//
72
// Clock and reset
73
//
74
input                           clk;
75
input                           rst;
76
 
77
//
78
// External i/f to IC
79
//
80
input   [31:0]                   icpu_dat_i;
81
input                           icpu_ack_i;
82
input                           icpu_err_i;
83
input   [31:0]                   icpu_adr_i;
84
input   [3:0]                    icpu_tag_i;
85
 
86
//
87
// Internal i/f
88
//
89
input                           if_freeze;
90
output  [31:0]                   if_insn;
91
output  [31:0]                   if_pc;
92
input                           if_flushpipe;
93
output                          saving_if_insn;
94
output                          if_stall;
95
input                           no_more_dslot;
96
output                          genpc_refetch;
97
input                           rfe;
98
output                          except_itlbmiss;
99
output                          except_immufault;
100
output                          except_ibuserr;
101
 
102
//
103
// Internal wires and regs
104
//
105
wire                    save_insn;
106
wire                    if_bypass;
107
reg                     if_bypass_reg;
108
reg     [31:0]           insn_saved;
109
reg     [31:0]           addr_saved;
110
reg     [2:0]            err_saved;
111
reg                     saved;
112
 
113
assign save_insn = (icpu_ack_i | icpu_err_i) & if_freeze & !saved;
114
assign saving_if_insn = !if_flushpipe & save_insn;
115
 
116
//
117
// IF bypass 
118
//
119
assign if_bypass = icpu_adr_i[0] ? 1'b0 : if_bypass_reg | if_flushpipe;
120
 
121 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
122
        if (rst == `OR1200_RST_VALUE)
123 350 julius
                if_bypass_reg <=  1'b0;
124
        else
125
                if_bypass_reg <=  if_bypass;
126
 
127
//
128
// IF stage insn
129
//
130
assign if_insn = no_more_dslot | rfe | if_bypass ? {`OR1200_OR32_NOP, 26'h041_0000} : saved ? insn_saved : icpu_ack_i ? icpu_dat_i : {`OR1200_OR32_NOP, 26'h061_0000};
131
assign if_pc = saved ? addr_saved : {icpu_adr_i[31:2], 2'h0};
132
assign if_stall = !icpu_err_i & !icpu_ack_i & !saved;
133
assign genpc_refetch = saved & icpu_ack_i;
134
assign except_itlbmiss = no_more_dslot ? 1'b0 : saved ? err_saved[0] : icpu_err_i & (icpu_tag_i == `OR1200_ITAG_TE);
135
assign except_immufault = no_more_dslot ? 1'b0 : saved ? err_saved[1] : icpu_err_i & (icpu_tag_i == `OR1200_ITAG_PE);
136
assign except_ibuserr = no_more_dslot ? 1'b0 : saved ? err_saved[2] : icpu_err_i & (icpu_tag_i == `OR1200_ITAG_BE);
137
 
138
//
139
// Flag for saved insn/address
140
//
141 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
142
        if (rst == `OR1200_RST_VALUE)
143 350 julius
                saved <=  1'b0;
144
        else if (if_flushpipe)
145
                saved <=  1'b0;
146
        else if (save_insn)
147
                saved <=  1'b1;
148
        else if (!if_freeze)
149
                saved <=  1'b0;
150
 
151
//
152
// Store fetched instruction
153
//
154 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
155
        if (rst == `OR1200_RST_VALUE)
156 350 julius
                insn_saved <=  {`OR1200_OR32_NOP, 26'h041_0000};
157
        else if (if_flushpipe)
158
                insn_saved <=  {`OR1200_OR32_NOP, 26'h041_0000};
159
        else if (save_insn)
160
                insn_saved <=  icpu_err_i ? {`OR1200_OR32_NOP, 26'h041_0000} : icpu_dat_i;
161
        else if (!if_freeze)
162
                insn_saved <=  {`OR1200_OR32_NOP, 26'h041_0000};
163
 
164
//
165
// Store fetched instruction's address
166
//
167 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
168
        if (rst == `OR1200_RST_VALUE)
169 350 julius
                addr_saved <=  32'h00000000;
170
        else if (if_flushpipe)
171
                addr_saved <=  32'h00000000;
172
        else if (save_insn)
173
                addr_saved <=  {icpu_adr_i[31:2], 2'b00};
174
        else if (!if_freeze)
175
                addr_saved <=  {icpu_adr_i[31:2], 2'b00};
176
 
177
//
178
// Store fetched instruction's error tags 
179
//
180 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
181
        if (rst == `OR1200_RST_VALUE)
182 350 julius
                err_saved <=  3'b000;
183
        else if (if_flushpipe)
184
                err_saved <=  3'b000;
185
        else if (save_insn) begin
186
                err_saved[0] <=  icpu_err_i & (icpu_tag_i == `OR1200_ITAG_TE);
187
                err_saved[1] <=  icpu_err_i & (icpu_tag_i == `OR1200_ITAG_PE);
188
                err_saved[2] <=  icpu_err_i & (icpu_tag_i == `OR1200_ITAG_BE);
189
        end
190
        else if (!if_freeze)
191
                err_saved <=  3'b000;
192
 
193
 
194
endmodule

powered by: WebSVN 2.1.0

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