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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [rtl/] [verilog/] [aeMB2_iwbif.v] - Blame information for rev 209

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 sybreon
/* $Id: aeMB2_iwbif.v,v 1.5 2008-04-27 19:52:31 sybreon Exp $
2 118 sybreon
**
3
** AEMB2 EDK 6.2 COMPATIBLE CORE
4
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU Lesser General Public License as
10
** published by the Free Software Foundation, either version 3 of the
11
** License, or (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16
** Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
20
*/
21
/**
22
 * Instruction Wishbone Interface
23
 * @file aeMB2_iwbif.v
24
 
25
  * This handles the instruction fetch portion of the pipeline. It
26
    alternates the PC and performs bubble/branch insertion. Bus
27
    transactions are independent of the pipeline.
28
 
29
 */
30
 
31
module aeMB2_iwbif (/*AUTOARG*/
32
   // Outputs
33 148 sybreon
   iwb_adr_o, iwb_stb_o, iwb_sel_o, iwb_wre_o, iwb_cyc_o, iwb_tag_o,
34 209 sybreon
   ich_adr, fet_fb, rpc_if, rpc_ex, rpc_mx, exc_iwb,
35 118 sybreon
   // Inputs
36 209 sybreon
   iwb_ack_i, iwb_dat_i, ich_hit, msr_ex, hzd_bpc, hzd_fwd, bra_ex,
37
   bpc_ex, gclk, grst, dena, iena, gpha
38 118 sybreon
   );
39
   parameter AEMB_IWB = 32;
40
   parameter AEMB_HTX = 1;
41
 
42
   // Wishbone
43
   output [AEMB_IWB-1:2] iwb_adr_o;
44
   output                iwb_stb_o;
45
   output [3:0]   iwb_sel_o;
46
   output                iwb_wre_o;
47 148 sybreon
   output                iwb_cyc_o;
48
   output                iwb_tag_o;
49 118 sybreon
   input                 iwb_ack_i;
50
   input [31:0]   iwb_dat_i;
51 203 sybreon
   //input               iwb_err_i; // bus error exception
52 118 sybreon
 
53
   // Cache
54
   output [AEMB_IWB-1:2] ich_adr;
55
   input                 ich_hit;
56
 
57
   // Internal
58
   output                fet_fb;
59
 
60
   output [31:2]         rpc_if,
61 209 sybreon
                         rpc_ex,
62 118 sybreon
                         rpc_mx;
63
 
64 148 sybreon
   input [7:5]           msr_ex;
65 118 sybreon
   input                 hzd_bpc,
66
                         hzd_fwd;
67
 
68
   input [1:0]            bra_ex;
69
   input [31:2]          bpc_ex;
70 202 sybreon
 
71
   output                exc_iwb;
72 118 sybreon
 
73
   // SYS signals
74
   input                 gclk,
75
                         grst,
76
                         dena,
77
                         iena,
78
                         gpha;
79
 
80
   /*AUTOWIRE*/
81
   /*AUTOREG*/
82
   // Beginning of automatic regs (for this module's undeclared outputs)
83
   reg                  iwb_stb_o;
84
   reg [31:2]           rpc_if;
85
   reg [31:2]           rpc_mx;
86
   // End of automatics
87 125 sybreon
   reg [31:2]           rpc_of,
88
                        rpc_ex;
89 118 sybreon
 
90
   // BARREL
91 120 sybreon
   reg [31:2]           rADR, rADR_;
92
   wire [31:2]          wPCINC = (rADR + 1); // incrementer
93
   wire [31:2]          wPCNXT = rADR_;
94
 
95 118 sybreon
   always @(posedge gclk)
96
     if (grst) begin
97
        /*AUTORESET*/
98
        // Beginning of autoreset for uninitialized flops
99
        rADR <= 30'h0;
100
        rADR_ <= 30'h0;
101
        // End of automatics
102 131 sybreon
     end else if (iena) begin
103 120 sybreon
 
104 125 sybreon
        case ({hzd_fwd,bra_ex[1]})
105 120 sybreon
          2'o0: {rADR} <= #1 {rADR_[AEMB_IWB-1:2]}; // normal increment
106
          2'o1: {rADR} <= #1 {bpc_ex[AEMB_IWB-1:2]}; // brach/return/break
107
          2'o2: {rADR} <= #1 {rpc_if[AEMB_IWB-1:2]}; // bubble/hazard
108
          default: {rADR} <= #1 32'hX;
109
          //2'o3: rADR <= #1 rpc_if[AEMB_IWB-1:2]; // bubble/hazard
110
          //2'o3: rADR <= #1 bpc_ex[AEMB_IWB-1:2]; // brach/return/break
111 131 sybreon
        endcase // case ({hzd_fwd,bra_ex[1]})
112 118 sybreon
 
113 120 sybreon
        rADR_ <= #1 wPCINC;
114 118 sybreon
 
115 131 sybreon
     end // if (iena)
116 118 sybreon
 
117 120 sybreon
   assign               ich_adr = rADR;
118
 
119 118 sybreon
   always @(posedge gclk)
120
     if (grst) begin
121
        /*AUTORESET*/
122
        // Beginning of autoreset for uninitialized flops
123
        rpc_ex <= 30'h0;
124
        rpc_if <= 30'h0;
125
        rpc_mx <= 30'h0;
126
        rpc_of <= 30'h0;
127
        // End of automatics
128 120 sybreon
     end else begin
129
        if (dena) begin
130
           {rpc_mx, // PC PIPELINE
131
            rpc_ex,
132
            rpc_of} <= #1 {rpc_ex,
133
                           rpc_of,
134
                           rpc_if};
135
        end
136
        if (iena) begin
137
           rpc_if <= #1 rADR;
138
        end
139 131 sybreon
     end // else: !if(grst)
140 118 sybreon
 
141 120 sybreon
   // WISHBONE SIGNALS
142 118 sybreon
   always @(posedge gclk)
143
     if (grst) begin
144
        /*AUTORESET*/
145
        // Beginning of autoreset for uninitialized flops
146
        iwb_stb_o <= 1'h0;
147
        // End of automatics
148
     end else begin
149 120 sybreon
        iwb_stb_o <= #1 (iwb_stb_o & !iwb_ack_i) | (!iwb_stb_o & !ich_hit);
150 118 sybreon
     end
151
 
152 120 sybreon
   assign               iwb_adr_o = rADR;
153
   assign               iwb_wre_o = 1'b0;
154
   assign               iwb_sel_o = 4'hF;
155
   assign               iwb_cyc_o = iwb_stb_o;
156 148 sybreon
   assign               iwb_tag_o = msr_ex[5];
157
 
158 125 sybreon
   assign               fet_fb = iwb_stb_o ~^ iwb_ack_i; // no WB cycle      
159 202 sybreon
 
160 203 sybreon
   // TODO: enable iwb_err_i exception pass-thru
161
   assign               exc_iwb = 1'b0;
162 118 sybreon
 
163 120 sybreon
endmodule // aeMB2_iwbif
164 118 sybreon
 

powered by: WebSVN 2.1.0

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