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 61

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

Line No. Rev Author Line
1 61 sybreon
// $Id: aeMB_ibuf.v,v 1.5 2007-11-14 22:14:34 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 61 sybreon
// Revision 1.4  2007/11/10 16:39:38  sybreon
24
// Upgraded license to LGPLv3.
25
// Significant performance optimisations.
26
//
27 55 sybreon
// Revision 1.3  2007/11/03 08:34:55  sybreon
28
// Minor code cleanup.
29
//
30 45 sybreon
// Revision 1.2  2007/11/02 19:20:58  sybreon
31
// Added better (beta) interrupt support.
32
// Changed MSR_IE to disabled at reset as per MB docs.
33
//
34 44 sybreon
// Revision 1.1  2007/11/02 03:25:40  sybreon
35
// New EDK 3.2 compatible design with optional barrel-shifter and multiplier.
36
// Fixed various minor data hazard bugs.
37
// Code compatible with -O0/1/2/3/s generated code.
38
//
39 41 sybreon
 
40
module aeMB_ibuf (/*AUTOARG*/
41
   // Outputs
42 61 sybreon
   rIMM, rRA, rRD, rRB, rALT, rOPC, rSIMM, xIREG, iwb_stb_o,
43 41 sybreon
   // Inputs
44 61 sybreon
   rBRA, rMSR_IE, rMSR_BIP, iwb_dat_i, iwb_ack_i, sys_int_i, gclk,
45
   grst, gena
46 41 sybreon
   );
47
   // INTERNAL
48
   output [15:0] rIMM;
49
   output [4:0]  rRA, rRD, rRB;
50
   output [10:0] rALT;
51
   output [5:0]  rOPC;
52
   output [31:0] rSIMM;
53 61 sybreon
   output [31:0] xIREG;
54
 
55 41 sybreon
   input         rBRA;
56 61 sybreon
   //input [1:0]         rXCE;
57
   input         rMSR_IE;
58
   input         rMSR_BIP;
59 41 sybreon
 
60
   // INST WISHBONE
61
   output        iwb_stb_o;
62
   input [31:0]  iwb_dat_i;
63
   input         iwb_ack_i;
64
 
65
   // SYSTEM
66 61 sybreon
   input         sys_int_i;
67
 
68
   // SYSTEM
69 41 sybreon
   input         gclk, grst, gena;
70
 
71
   reg [15:0]     rIMM;
72
   reg [4:0]      rRA, rRD;
73
   reg [5:0]      rOPC;
74
 
75
   // FIXME: Endian
76
   wire [31:0]    wIDAT = iwb_dat_i;
77
   assign        {rRB, rALT} = rIMM;
78
 
79
   // TODO: Assign to FIFO not full.
80
   assign       iwb_stb_o = 1'b1;
81
 
82
   reg [31:0]    rSIMM, xSIMM;
83 61 sybreon
 
84
   wire [31:0]   wXCEOP = 32'hB9CE0008;
85
   wire [31:0]   wINTOP = 32'hB9CE0010;
86
   wire [31:0]   wBRKOP = 32'hB9CE0018;
87
   wire [31:0]   wBRAOP = 32'h88000000;
88 41 sybreon
 
89 61 sybreon
   wire [31:0]   wIREG = {rOPC, rRD, rRA, rRB, rALT};
90 41 sybreon
   reg [31:0]    xIREG;
91
 
92 61 sybreon
 
93
   // --- INTERRUPT LATCH --------------------------------------
94
   // Debounce and latch onto the positive edge. This is independent
95
   // of the pipeline so that stalls do not affect it.
96
 
97
   reg          rFINT;
98
   reg [1:0]     rDINT;
99
   //wire       wSHOT = rDINT[0] & !rDINT[1] & sys_int_i;
100
   wire         wSHOT = !rDINT[0] & sys_int_i;
101
 
102
   always @(posedge gclk)
103
     if (grst) begin
104
        /*AUTORESET*/
105
        // Beginning of autoreset for uninitialized flops
106
        rDINT <= 2'h0;
107
        rFINT <= 1'h0;
108
        // End of automatics
109
     end else if (rMSR_IE) begin
110
        rDINT <= #1 {rDINT[0], sys_int_i};
111
        rFINT <= (wIREG == wINTOP) ? 1'b0 : (rFINT | wSHOT);
112
     end
113
 
114
   wire         fIMM = (rOPC == 6'o54);
115
   wire         fRTD = (rOPC == 6'o55);
116
   wire         fBRU = ((rOPC == 6'o46) | (rOPC == 6'o56));
117
   wire         fBCC = ((rOPC == 6'o47) | (rOPC == 6'o57));
118
 
119
   // --- DELAY SLOT -------------------------------------------
120
 
121
   always @(/*AUTOSENSE*/fBCC or fBRU or fIMM or fRTD or rBRA or rFINT
122
            or wBRAOP or wIDAT or wINTOP) begin
123
      xIREG <= (rBRA) ? wBRAOP :
124
               (!fIMM & rFINT & !fRTD & !fBRU & !fBCC) ? wINTOP :
125
               wIDAT;
126 44 sybreon
   end
127 61 sybreon
 
128
   always @(/*AUTOSENSE*/fIMM or rBRA or rIMM or wIDAT or xIREG) begin
129
      //xSIMM <= (!fIMM | rBRA | |rXCE) ? { {(16){wIDAT[15]}}, wIDAT[15:0]} : {rIMM, wIDAT[15:0]};
130
      xSIMM <= (!fIMM | rBRA) ? { {(16){xIREG[15]}}, xIREG[15:0]} :
131
               {rIMM, wIDAT[15:0]};
132
   end
133 41 sybreon
 
134 61 sybreon
   // --- PIPELINE --------------------------------------------
135
 
136 41 sybreon
   always @(posedge gclk)
137
     if (grst) begin
138
        /*AUTORESET*/
139
        // Beginning of autoreset for uninitialized flops
140
        rIMM <= 16'h0;
141
        rOPC <= 6'h0;
142
        rRA <= 5'h0;
143
        rRD <= 5'h0;
144
        rSIMM <= 32'h0;
145
        // End of automatics
146
     end else if (gena) begin
147
        {rOPC, rRD, rRA, rIMM} <= #1 xIREG;
148
        rSIMM <= #1 xSIMM;
149
     end
150
 
151
 
152
endmodule // aeMB_ibuf

powered by: WebSVN 2.1.0

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