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

Subversion Repositories aemb

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

Go to most recent revision | 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 202 sybreon
   ich_adr, fet_fb, rpc_if, rpc_mx, exc_iwb,
35 118 sybreon
   // Inputs
36 203 sybreon
   iwb_ack_i, iwb_dat_i, ich_hit, msr_ex, hzd_bpc, hzd_fwd,
37 202 sybreon
   bra_ex, 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
                         rpc_mx;
62
 
63 148 sybreon
   input [7:5]           msr_ex;
64 118 sybreon
   input                 hzd_bpc,
65
                         hzd_fwd;
66
 
67
   input [1:0]            bra_ex;
68
   input [31:2]          bpc_ex;
69 202 sybreon
 
70
   output                exc_iwb;
71 118 sybreon
 
72
   // SYS signals
73
   input                 gclk,
74
                         grst,
75
                         dena,
76
                         iena,
77
                         gpha;
78
 
79
   /*AUTOWIRE*/
80
   /*AUTOREG*/
81
   // Beginning of automatic regs (for this module's undeclared outputs)
82
   reg                  iwb_stb_o;
83
   reg [31:2]           rpc_if;
84
   reg [31:2]           rpc_mx;
85
   // End of automatics
86 125 sybreon
   reg [31:2]           rpc_of,
87
                        rpc_ex;
88 118 sybreon
 
89
   // BARREL
90 120 sybreon
   reg [31:2]           rADR, rADR_;
91
   wire [31:2]          wPCINC = (rADR + 1); // incrementer
92
   wire [31:2]          wPCNXT = rADR_;
93
 
94 118 sybreon
   always @(posedge gclk)
95
     if (grst) begin
96
        /*AUTORESET*/
97
        // Beginning of autoreset for uninitialized flops
98
        rADR <= 30'h0;
99
        rADR_ <= 30'h0;
100
        // End of automatics
101 131 sybreon
     end else if (iena) begin
102 120 sybreon
 
103 125 sybreon
        case ({hzd_fwd,bra_ex[1]})
104 120 sybreon
          2'o0: {rADR} <= #1 {rADR_[AEMB_IWB-1:2]}; // normal increment
105
          2'o1: {rADR} <= #1 {bpc_ex[AEMB_IWB-1:2]}; // brach/return/break
106
          2'o2: {rADR} <= #1 {rpc_if[AEMB_IWB-1:2]}; // bubble/hazard
107
          default: {rADR} <= #1 32'hX;
108
          //2'o3: rADR <= #1 rpc_if[AEMB_IWB-1:2]; // bubble/hazard
109
          //2'o3: rADR <= #1 bpc_ex[AEMB_IWB-1:2]; // brach/return/break
110 131 sybreon
        endcase // case ({hzd_fwd,bra_ex[1]})
111 118 sybreon
 
112 120 sybreon
        rADR_ <= #1 wPCINC;
113 118 sybreon
 
114 131 sybreon
     end // if (iena)
115 118 sybreon
 
116 120 sybreon
   assign               ich_adr = rADR;
117
 
118 118 sybreon
   always @(posedge gclk)
119
     if (grst) begin
120
        /*AUTORESET*/
121
        // Beginning of autoreset for uninitialized flops
122
        rpc_ex <= 30'h0;
123
        rpc_if <= 30'h0;
124
        rpc_mx <= 30'h0;
125
        rpc_of <= 30'h0;
126
        // End of automatics
127 120 sybreon
     end else begin
128
        if (dena) begin
129
           {rpc_mx, // PC PIPELINE
130
            rpc_ex,
131
            rpc_of} <= #1 {rpc_ex,
132
                           rpc_of,
133
                           rpc_if};
134
        end
135
        if (iena) begin
136
           rpc_if <= #1 rADR;
137
        end
138 131 sybreon
     end // else: !if(grst)
139 118 sybreon
 
140 120 sybreon
   // WISHBONE SIGNALS
141 118 sybreon
   always @(posedge gclk)
142
     if (grst) begin
143
        /*AUTORESET*/
144
        // Beginning of autoreset for uninitialized flops
145
        iwb_stb_o <= 1'h0;
146
        // End of automatics
147
     end else begin
148 120 sybreon
        iwb_stb_o <= #1 (iwb_stb_o & !iwb_ack_i) | (!iwb_stb_o & !ich_hit);
149 118 sybreon
     end
150
 
151 120 sybreon
   assign               iwb_adr_o = rADR;
152
   assign               iwb_wre_o = 1'b0;
153
   assign               iwb_sel_o = 4'hF;
154
   assign               iwb_cyc_o = iwb_stb_o;
155 148 sybreon
   assign               iwb_tag_o = msr_ex[5];
156
 
157 125 sybreon
   assign               fet_fb = iwb_stb_o ~^ iwb_ack_i; // no WB cycle      
158 202 sybreon
 
159 203 sybreon
   // TODO: enable iwb_err_i exception pass-thru
160
   assign               exc_iwb = 1'b0;
161 118 sybreon
 
162 120 sybreon
endmodule // aeMB2_iwbif
163 118 sybreon
 

powered by: WebSVN 2.1.0

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