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

Subversion Repositories aemb

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

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
   ich_adr, fet_fb, rpc_if, rpc_mx,
35 118 sybreon
   // Inputs
36 148 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
 
52
   // Cache
53
   output [AEMB_IWB-1:2] ich_adr;
54
   input                 ich_hit;
55
 
56
   // Internal
57
   output                fet_fb;
58
 
59
   output [31:2]         rpc_if,
60
                         rpc_mx;
61
 
62 148 sybreon
   input [7:5]           msr_ex;
63 118 sybreon
   input                 hzd_bpc,
64
                         hzd_fwd;
65
 
66
   input [1:0]            bra_ex;
67
   input [31:2]          bpc_ex;
68
 
69
   // SYS signals
70
   input                 gclk,
71
                         grst,
72
                         dena,
73
                         iena,
74
                         gpha;
75
 
76
   /*AUTOWIRE*/
77
   /*AUTOREG*/
78
   // Beginning of automatic regs (for this module's undeclared outputs)
79
   reg                  iwb_stb_o;
80
   reg [31:2]           rpc_if;
81
   reg [31:2]           rpc_mx;
82
   // End of automatics
83 125 sybreon
   reg [31:2]           rpc_of,
84
                        rpc_ex;
85 118 sybreon
 
86
   // BARREL
87 120 sybreon
   reg [31:2]           rADR, rADR_;
88
   wire [31:2]          wPCINC = (rADR + 1); // incrementer
89
   wire [31:2]          wPCNXT = rADR_;
90
 
91 118 sybreon
   always @(posedge gclk)
92
     if (grst) begin
93
        /*AUTORESET*/
94
        // Beginning of autoreset for uninitialized flops
95
        rADR <= 30'h0;
96
        rADR_ <= 30'h0;
97
        // End of automatics
98 131 sybreon
     end else if (iena) begin
99 120 sybreon
 
100 125 sybreon
        case ({hzd_fwd,bra_ex[1]})
101 120 sybreon
          2'o0: {rADR} <= #1 {rADR_[AEMB_IWB-1:2]}; // normal increment
102
          2'o1: {rADR} <= #1 {bpc_ex[AEMB_IWB-1:2]}; // brach/return/break
103
          2'o2: {rADR} <= #1 {rpc_if[AEMB_IWB-1:2]}; // bubble/hazard
104
          default: {rADR} <= #1 32'hX;
105
          //2'o3: rADR <= #1 rpc_if[AEMB_IWB-1:2]; // bubble/hazard
106
          //2'o3: rADR <= #1 bpc_ex[AEMB_IWB-1:2]; // brach/return/break
107 131 sybreon
        endcase // case ({hzd_fwd,bra_ex[1]})
108 118 sybreon
 
109 120 sybreon
        rADR_ <= #1 wPCINC;
110 118 sybreon
 
111 131 sybreon
     end // if (iena)
112 118 sybreon
 
113 120 sybreon
   assign               ich_adr = rADR;
114
 
115 118 sybreon
   always @(posedge gclk)
116
     if (grst) begin
117
        /*AUTORESET*/
118
        // Beginning of autoreset for uninitialized flops
119
        rpc_ex <= 30'h0;
120
        rpc_if <= 30'h0;
121
        rpc_mx <= 30'h0;
122
        rpc_of <= 30'h0;
123
        // End of automatics
124 120 sybreon
     end else begin
125
        if (dena) begin
126
           {rpc_mx, // PC PIPELINE
127
            rpc_ex,
128
            rpc_of} <= #1 {rpc_ex,
129
                           rpc_of,
130
                           rpc_if};
131
        end
132
        if (iena) begin
133
           rpc_if <= #1 rADR;
134
        end
135 131 sybreon
     end // else: !if(grst)
136 118 sybreon
 
137 120 sybreon
   // WISHBONE SIGNALS
138 118 sybreon
   always @(posedge gclk)
139
     if (grst) begin
140
        /*AUTORESET*/
141
        // Beginning of autoreset for uninitialized flops
142
        iwb_stb_o <= 1'h0;
143
        // End of automatics
144
     end else begin
145 120 sybreon
        iwb_stb_o <= #1 (iwb_stb_o & !iwb_ack_i) | (!iwb_stb_o & !ich_hit);
146 118 sybreon
     end
147
 
148 120 sybreon
   assign               iwb_adr_o = rADR;
149
   assign               iwb_wre_o = 1'b0;
150
   assign               iwb_sel_o = 4'hF;
151
   assign               iwb_cyc_o = iwb_stb_o;
152 148 sybreon
   assign               iwb_tag_o = msr_ex[5];
153
 
154 125 sybreon
   assign               fet_fb = iwb_stb_o ~^ iwb_ack_i; // no WB cycle      
155 118 sybreon
 
156 120 sybreon
endmodule // aeMB2_iwbif
157 118 sybreon
 
158 131 sybreon
/*
159
 $Log: not supported by cvs2svn $
160 148 sybreon
 Revision 1.4  2008/04/26 01:09:06  sybreon
161
 Passes basic tests. Minor documentation changes to make it compatible with iverilog pre-processor.
162
 
163 131 sybreon
 Revision 1.3  2008/04/21 12:11:38  sybreon
164
 Passes arithmetic tests with single thread.
165
 
166
 Revision 1.2  2008/04/20 16:34:32  sybreon
167
 Basic version with some features left out.
168
 
169
 Revision 1.1  2008/04/18 00:21:52  sybreon
170
 Initial import.
171
*/

powered by: WebSVN 2.1.0

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