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

Subversion Repositories aemb

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

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

Line No. Rev Author Line
1 96 sybreon
/* $Id: aeMB_ibuf.v,v 1.8 2007-12-25 22:15:09 sybreon Exp $
2
**
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
   grst, gena
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 41 sybreon
   input         gclk, grst, gena;
53
 
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
     end else if (rMSR_IE) begin
93
        rDINT <= #1 {rDINT[0], sys_int_i};
94 63 sybreon
        rFINT <= #1 (wIREG == wINTOP) ? 1'b0 : (rFINT | wSHOT);
95 61 sybreon
     end
96
 
97
   wire         fIMM = (rOPC == 6'o54);
98
   wire         fRTD = (rOPC == 6'o55);
99
   wire         fBRU = ((rOPC == 6'o46) | (rOPC == 6'o56));
100
   wire         fBCC = ((rOPC == 6'o47) | (rOPC == 6'o57));
101
 
102
   // --- DELAY SLOT -------------------------------------------
103
 
104
   always @(/*AUTOSENSE*/fBCC or fBRU or fIMM or fRTD or rBRA or rFINT
105
            or wBRAOP or wIDAT or wINTOP) begin
106
      xIREG <= (rBRA) ? wBRAOP :
107
               (!fIMM & rFINT & !fRTD & !fBRU & !fBCC) ? wINTOP :
108
               wIDAT;
109 44 sybreon
   end
110 61 sybreon
 
111
   always @(/*AUTOSENSE*/fIMM or rBRA or rIMM or wIDAT or xIREG) begin
112
      xSIMM <= (!fIMM | rBRA) ? { {(16){xIREG[15]}}, xIREG[15:0]} :
113
               {rIMM, wIDAT[15:0]};
114
   end
115 41 sybreon
 
116 61 sybreon
   // --- PIPELINE --------------------------------------------
117
 
118 41 sybreon
   always @(posedge gclk)
119
     if (grst) begin
120
        /*AUTORESET*/
121
        // Beginning of autoreset for uninitialized flops
122
        rIMM <= 16'h0;
123
        rOPC <= 6'h0;
124
        rRA <= 5'h0;
125
        rRD <= 5'h0;
126
        rSIMM <= 32'h0;
127
        // End of automatics
128
     end else if (gena) begin
129
        {rOPC, rRD, rRA, rIMM} <= #1 xIREG;
130
        rSIMM <= #1 xSIMM;
131
     end
132 96 sybreon
 
133
   // --- STALL FOR MUL/BSF -----------------------------------
134
 
135
   wire [5:0] wOPC = xIREG[31:26];
136 41 sybreon
 
137 96 sybreon
   wire       fMUL = (wOPC == 6'o20) | (wOPC == 6'o30);
138
   wire       fBSF = (wOPC == 6'o21) | (wOPC == 6'o31);
139 41 sybreon
 
140 96 sybreon
   always @(posedge gclk)
141
     if (grst) begin
142
        /*AUTORESET*/
143
        // Beginning of autoreset for uninitialized flops
144
        rSTALL <= 1'h0;
145
        // End of automatics
146
     end else begin
147
        rSTALL <= #1 !rSTALL & (fMUL | fBSF);
148
     end
149
 
150 41 sybreon
endmodule // aeMB_ibuf
151 96 sybreon
 
152
/*
153
 $Log: not supported by cvs2svn $
154
 Revision 1.7  2007/11/22 15:11:15  sybreon
155
 Change interrupt to positive level triggered interrupts.
156
 
157
 Revision 1.6  2007/11/14 23:39:51  sybreon
158
 Fixed interrupt signal synchronisation.
159
 
160
 Revision 1.5  2007/11/14 22:14:34  sybreon
161
 Changed interrupt handling system (reported by M. Ettus).
162
 
163
 Revision 1.4  2007/11/10 16:39:38  sybreon
164
 Upgraded license to LGPLv3.
165
 Significant performance optimisations.
166
 
167
 Revision 1.3  2007/11/03 08:34:55  sybreon
168
 Minor code cleanup.
169
 
170
 Revision 1.2  2007/11/02 19:20:58  sybreon
171
 Added better (beta) interrupt support.
172
 Changed MSR_IE to disabled at reset as per MB docs.
173
 
174
 Revision 1.1  2007/11/02 03:25:40  sybreon
175
 New EDK 3.2 compatible design with optional barrel-shifter and multiplier.
176
 Fixed various minor data hazard bugs.
177
 Code compatible with -O0/1/2/3/s generated code.
178
*/

powered by: WebSVN 2.1.0

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