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

Subversion Repositories aemb

[/] [aemb/] [branches/] [AEMB2_712/] [rtl/] [verilog/] [aeMB_ibuf.v] - Blame information for rev 70

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

Line No. Rev Author Line
1 70 sybreon
// $Id: aeMB_ibuf.v,v 1.7 2007-11-22 15:11:15 sybreon Exp $
2 41 sybreon
//
3
// AEMB INSTRUCTION BUFFER
4
// 
5
// Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
6
//  
7 55 sybreon
// This file is part of AEMB.
8 41 sybreon
//
9 55 sybreon
// AEMB is free software: you can redistribute it and/or modify it
10
// under the terms of the GNU Lesser General Public License as
11
// published by the Free Software Foundation, either version 3 of the
12
// License, or (at your option) any later version.
13
//
14
// AEMB is distributed in the hope that it will be useful, but WITHOUT
15
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
17
// Public License for more details.
18
//
19 41 sybreon
// You should have received a copy of the GNU Lesser General Public
20 55 sybreon
// License along with AEMB. If not, see <http://www.gnu.org/licenses/>.
21 41 sybreon
//
22
// $Log: not supported by cvs2svn $
23 70 sybreon
// Revision 1.6  2007/11/14 23:39:51  sybreon
24
// Fixed interrupt signal synchronisation.
25
//
26 63 sybreon
// Revision 1.5  2007/11/14 22:14:34  sybreon
27
// Changed interrupt handling system (reported by M. Ettus).
28
//
29 61 sybreon
// Revision 1.4  2007/11/10 16:39:38  sybreon
30
// Upgraded license to LGPLv3.
31
// Significant performance optimisations.
32
//
33 55 sybreon
// Revision 1.3  2007/11/03 08:34:55  sybreon
34
// Minor code cleanup.
35
//
36 45 sybreon
// Revision 1.2  2007/11/02 19:20:58  sybreon
37
// Added better (beta) interrupt support.
38
// Changed MSR_IE to disabled at reset as per MB docs.
39
//
40 44 sybreon
// Revision 1.1  2007/11/02 03:25:40  sybreon
41
// New EDK 3.2 compatible design with optional barrel-shifter and multiplier.
42
// Fixed various minor data hazard bugs.
43
// Code compatible with -O0/1/2/3/s generated code.
44
//
45 41 sybreon
 
46
module aeMB_ibuf (/*AUTOARG*/
47
   // Outputs
48 61 sybreon
   rIMM, rRA, rRD, rRB, rALT, rOPC, rSIMM, xIREG, iwb_stb_o,
49 41 sybreon
   // Inputs
50 61 sybreon
   rBRA, rMSR_IE, rMSR_BIP, iwb_dat_i, iwb_ack_i, sys_int_i, gclk,
51
   grst, gena
52 41 sybreon
   );
53
   // INTERNAL
54
   output [15:0] rIMM;
55
   output [4:0]  rRA, rRD, rRB;
56
   output [10:0] rALT;
57
   output [5:0]  rOPC;
58
   output [31:0] rSIMM;
59 61 sybreon
   output [31:0] xIREG;
60
 
61 41 sybreon
   input         rBRA;
62 61 sybreon
   //input [1:0]         rXCE;
63
   input         rMSR_IE;
64
   input         rMSR_BIP;
65 41 sybreon
 
66
   // INST WISHBONE
67
   output        iwb_stb_o;
68
   input [31:0]  iwb_dat_i;
69
   input         iwb_ack_i;
70
 
71
   // SYSTEM
72 61 sybreon
   input         sys_int_i;
73
 
74
   // SYSTEM
75 41 sybreon
   input         gclk, grst, gena;
76
 
77
   reg [15:0]     rIMM;
78
   reg [4:0]      rRA, rRD;
79
   reg [5:0]      rOPC;
80
 
81
   // FIXME: Endian
82
   wire [31:0]    wIDAT = iwb_dat_i;
83
   assign        {rRB, rALT} = rIMM;
84
 
85
   // TODO: Assign to FIFO not full.
86
   assign       iwb_stb_o = 1'b1;
87
 
88
   reg [31:0]    rSIMM, xSIMM;
89 61 sybreon
 
90 70 sybreon
   wire [31:0]   wXCEOP = 32'hBA2D0008; // Vector 0x08
91
   wire [31:0]   wINTOP = 32'hB9CE0010; // Vector 0x10
92
   wire [31:0]   wBRKOP = 32'hBA0C0018; // Vector 0x18
93
   wire [31:0]   wBRAOP = 32'h88000000; // NOP for branches
94 41 sybreon
 
95 61 sybreon
   wire [31:0]   wIREG = {rOPC, rRD, rRA, rRB, rALT};
96 41 sybreon
   reg [31:0]    xIREG;
97
 
98 61 sybreon
 
99
   // --- INTERRUPT LATCH --------------------------------------
100 70 sybreon
   // Debounce and latch onto the positive level. This is independent
101 61 sybreon
   // of the pipeline so that stalls do not affect it.
102
 
103
   reg          rFINT;
104
   reg [1:0]     rDINT;
105 70 sybreon
   wire         wSHOT = rDINT[0];
106 61 sybreon
 
107
   always @(posedge gclk)
108
     if (grst) begin
109
        /*AUTORESET*/
110
        // Beginning of autoreset for uninitialized flops
111
        rDINT <= 2'h0;
112
        rFINT <= 1'h0;
113
        // End of automatics
114
     end else if (rMSR_IE) begin
115
        rDINT <= #1 {rDINT[0], sys_int_i};
116 63 sybreon
        rFINT <= #1 (wIREG == wINTOP) ? 1'b0 : (rFINT | wSHOT);
117 61 sybreon
     end
118
 
119
   wire         fIMM = (rOPC == 6'o54);
120
   wire         fRTD = (rOPC == 6'o55);
121
   wire         fBRU = ((rOPC == 6'o46) | (rOPC == 6'o56));
122
   wire         fBCC = ((rOPC == 6'o47) | (rOPC == 6'o57));
123
 
124
   // --- DELAY SLOT -------------------------------------------
125
 
126
   always @(/*AUTOSENSE*/fBCC or fBRU or fIMM or fRTD or rBRA or rFINT
127
            or wBRAOP or wIDAT or wINTOP) begin
128
      xIREG <= (rBRA) ? wBRAOP :
129
               (!fIMM & rFINT & !fRTD & !fBRU & !fBCC) ? wINTOP :
130
               wIDAT;
131 44 sybreon
   end
132 61 sybreon
 
133
   always @(/*AUTOSENSE*/fIMM or rBRA or rIMM or wIDAT or xIREG) begin
134
      xSIMM <= (!fIMM | rBRA) ? { {(16){xIREG[15]}}, xIREG[15:0]} :
135
               {rIMM, wIDAT[15:0]};
136
   end
137 41 sybreon
 
138 61 sybreon
   // --- PIPELINE --------------------------------------------
139
 
140 41 sybreon
   always @(posedge gclk)
141
     if (grst) begin
142
        /*AUTORESET*/
143
        // Beginning of autoreset for uninitialized flops
144
        rIMM <= 16'h0;
145
        rOPC <= 6'h0;
146
        rRA <= 5'h0;
147
        rRD <= 5'h0;
148
        rSIMM <= 32'h0;
149
        // End of automatics
150
     end else if (gena) begin
151
        {rOPC, rRD, rRA, rIMM} <= #1 xIREG;
152
        rSIMM <= #1 xSIMM;
153
     end
154
 
155
 
156
endmodule // aeMB_ibuf

powered by: WebSVN 2.1.0

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