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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [rtl/] [verilog/] [aeMB_ibuf.v] - Blame information for rev 200

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

Line No. Rev Author Line
1 105 sybreon
/* $Id: aeMB_ibuf.v,v 1.10 2008-01-21 01:02:26 sybreon Exp $
2 96 sybreon
**
3
** AEMB INSTRUCTION BUFFER
4
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <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 41 sybreon
 
22
module aeMB_ibuf (/*AUTOARG*/
23
   // Outputs
24 96 sybreon
   rIMM, rRA, rRD, rRB, rALT, rOPC, rSIMM, xIREG, rSTALL, iwb_stb_o,
25 41 sybreon
   // Inputs
26 61 sybreon
   rBRA, rMSR_IE, rMSR_BIP, iwb_dat_i, iwb_ack_i, sys_int_i, gclk,
27 103 sybreon
   grst, gena, oena
28 41 sybreon
   );
29
   // INTERNAL
30
   output [15:0] rIMM;
31
   output [4:0]  rRA, rRD, rRB;
32
   output [10:0] rALT;
33
   output [5:0]  rOPC;
34
   output [31:0] rSIMM;
35 61 sybreon
   output [31:0] xIREG;
36 96 sybreon
   output        rSTALL;
37 61 sybreon
 
38 41 sybreon
   input         rBRA;
39 61 sybreon
   //input [1:0]         rXCE;
40
   input         rMSR_IE;
41
   input         rMSR_BIP;
42 41 sybreon
 
43
   // INST WISHBONE
44
   output        iwb_stb_o;
45
   input [31:0]  iwb_dat_i;
46
   input         iwb_ack_i;
47
 
48
   // SYSTEM
49 61 sybreon
   input         sys_int_i;
50
 
51
   // SYSTEM
52 103 sybreon
   input         gclk, grst, gena, oena;
53 41 sybreon
 
54
   reg [15:0]     rIMM;
55
   reg [4:0]      rRA, rRD;
56
   reg [5:0]      rOPC;
57
 
58
   // FIXME: Endian
59
   wire [31:0]    wIDAT = iwb_dat_i;
60
   assign        {rRB, rALT} = rIMM;
61
 
62
   // TODO: Assign to FIFO not full.
63
   assign       iwb_stb_o = 1'b1;
64
 
65
   reg [31:0]    rSIMM, xSIMM;
66 96 sybreon
   reg          rSTALL;
67 61 sybreon
 
68 70 sybreon
   wire [31:0]   wXCEOP = 32'hBA2D0008; // Vector 0x08
69
   wire [31:0]   wINTOP = 32'hB9CE0010; // Vector 0x10
70
   wire [31:0]   wBRKOP = 32'hBA0C0018; // Vector 0x18
71
   wire [31:0]   wBRAOP = 32'h88000000; // NOP for branches
72 41 sybreon
 
73 61 sybreon
   wire [31:0]   wIREG = {rOPC, rRD, rRA, rRB, rALT};
74 41 sybreon
   reg [31:0]    xIREG;
75
 
76 61 sybreon
 
77
   // --- INTERRUPT LATCH --------------------------------------
78 70 sybreon
   // Debounce and latch onto the positive level. This is independent
79 61 sybreon
   // of the pipeline so that stalls do not affect it.
80
 
81
   reg          rFINT;
82
   reg [1:0]     rDINT;
83 70 sybreon
   wire         wSHOT = rDINT[0];
84 61 sybreon
 
85
   always @(posedge gclk)
86
     if (grst) begin
87
        /*AUTORESET*/
88
        // Beginning of autoreset for uninitialized flops
89
        rDINT <= 2'h0;
90
        rFINT <= 1'h0;
91
        // End of automatics
92 105 sybreon
     end else begin
93
        if (rMSR_IE)
94
          rDINT <= #1
95
                   {rDINT[0], sys_int_i};
96
 
97
        rFINT <= #1
98
                 //(wIREG == wINTOP) ? 1'b0 : 
99
                 (rFINT | wSHOT) & rMSR_IE;
100 61 sybreon
     end
101
 
102
   wire         fIMM = (rOPC == 6'o54);
103
   wire         fRTD = (rOPC == 6'o55);
104
   wire         fBRU = ((rOPC == 6'o46) | (rOPC == 6'o56));
105
   wire         fBCC = ((rOPC == 6'o47) | (rOPC == 6'o57));
106
 
107
   // --- DELAY SLOT -------------------------------------------
108
 
109
   always @(/*AUTOSENSE*/fBCC or fBRU or fIMM or fRTD or rBRA or rFINT
110
            or wBRAOP or wIDAT or wINTOP) begin
111
      xIREG <= (rBRA) ? wBRAOP :
112
               (!fIMM & rFINT & !fRTD & !fBRU & !fBCC) ? wINTOP :
113
               wIDAT;
114 44 sybreon
   end
115 61 sybreon
 
116
   always @(/*AUTOSENSE*/fIMM or rBRA or rIMM or wIDAT or xIREG) begin
117
      xSIMM <= (!fIMM | rBRA) ? { {(16){xIREG[15]}}, xIREG[15:0]} :
118
               {rIMM, wIDAT[15:0]};
119
   end
120 41 sybreon
 
121 61 sybreon
   // --- PIPELINE --------------------------------------------
122
 
123 41 sybreon
   always @(posedge gclk)
124
     if (grst) begin
125
        /*AUTORESET*/
126
        // Beginning of autoreset for uninitialized flops
127
        rIMM <= 16'h0;
128
        rOPC <= 6'h0;
129
        rRA <= 5'h0;
130
        rRD <= 5'h0;
131
        rSIMM <= 32'h0;
132
        // End of automatics
133
     end else if (gena) begin
134
        {rOPC, rRD, rRA, rIMM} <= #1 xIREG;
135
        rSIMM <= #1 xSIMM;
136
     end
137 96 sybreon
 
138
   // --- STALL FOR MUL/BSF -----------------------------------
139
 
140
   wire [5:0] wOPC = xIREG[31:26];
141 41 sybreon
 
142 96 sybreon
   wire       fMUL = (wOPC == 6'o20) | (wOPC == 6'o30);
143
   wire       fBSF = (wOPC == 6'o21) | (wOPC == 6'o31);
144 41 sybreon
 
145 96 sybreon
   always @(posedge gclk)
146
     if (grst) begin
147
        /*AUTORESET*/
148
        // Beginning of autoreset for uninitialized flops
149
        rSTALL <= 1'h0;
150
        // End of automatics
151
     end else begin
152 103 sybreon
        rSTALL <= #1 (!rSTALL & (fMUL | fBSF)) | (oena & rSTALL);
153 96 sybreon
     end
154
 
155 41 sybreon
endmodule // aeMB_ibuf
156 96 sybreon
 
157
/*
158
 $Log: not supported by cvs2svn $
159 105 sybreon
 Revision 1.9  2008/01/19 16:01:22  sybreon
160
 Patched problem where memory access followed by dual cycle instructions were not stalling correctly (submitted by M. Ettus)
161
 
162 103 sybreon
 Revision 1.8  2007/12/25 22:15:09  sybreon
163
 Stalls pipeline on MUL/BSF instructions results in minor speed improvements.
164
 
165 96 sybreon
 Revision 1.7  2007/11/22 15:11:15  sybreon
166
 Change interrupt to positive level triggered interrupts.
167
 
168
 Revision 1.6  2007/11/14 23:39:51  sybreon
169
 Fixed interrupt signal synchronisation.
170
 
171
 Revision 1.5  2007/11/14 22:14:34  sybreon
172
 Changed interrupt handling system (reported by M. Ettus).
173
 
174
 Revision 1.4  2007/11/10 16:39:38  sybreon
175
 Upgraded license to LGPLv3.
176
 Significant performance optimisations.
177
 
178
 Revision 1.3  2007/11/03 08:34:55  sybreon
179
 Minor code cleanup.
180
 
181
 Revision 1.2  2007/11/02 19:20:58  sybreon
182
 Added better (beta) interrupt support.
183
 Changed MSR_IE to disabled at reset as per MB docs.
184
 
185
 Revision 1.1  2007/11/02 03:25:40  sybreon
186
 New EDK 3.2 compatible design with optional barrel-shifter and multiplier.
187
 Fixed various minor data hazard bugs.
188
 Code compatible with -O0/1/2/3/s generated code.
189
*/

powered by: WebSVN 2.1.0

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