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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [rtl/] [verilog/] [aeMB_ctrl.v] - Blame information for rev 50

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

Line No. Rev Author Line
1 50 sybreon
// $Id: aeMB_ctrl.v,v 1.3 2007-11-08 14:17:47 sybreon Exp $
2 41 sybreon
//
3
// AEMB CONTROL UNIT
4
// 
5
// Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
6
//  
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public License
9
// as published by the Free Software Foundation; either version 2.1 of
10
// the License, or (at your option) any later version.
11
//
12
// This library is distributed in the hope that it will be useful, but
13
// WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Lesser General Public License for more details.
16
//  
17
// You should have received a copy of the GNU Lesser General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
// USA
21
//
22
// $Log: not supported by cvs2svn $
23 50 sybreon
// Revision 1.2  2007/11/02 19:20:58  sybreon
24
// Added better (beta) interrupt support.
25
// Changed MSR_IE to disabled at reset as per MB docs.
26
//
27 44 sybreon
// Revision 1.1  2007/11/02 03:25:40  sybreon
28
// New EDK 3.2 compatible design with optional barrel-shifter and multiplier.
29
// Fixed various minor data hazard bugs.
30
// Code compatible with -O0/1/2/3/s generated code.
31
//
32 41 sybreon
 
33
module aeMB_ctrl (/*AUTOARG*/
34
   // Outputs
35 44 sybreon
   rMXDST, rMXSRC, rMXTGT, rMXALT, rMXALU, rRW, rDWBSTB, dwb_stb_o,
36
   dwb_wre_o,
37 41 sybreon
   // Inputs
38 44 sybreon
   rXCE, rDLY, rIMM, rALT, rOPC, rRD, rRA, rRB, rPC, rBRA, rMSR_IE,
39 50 sybreon
   dwb_ack_i, gclk, grst, gena
40 41 sybreon
   );
41
   // INTERNAL   
42
   //output [31:2] rPCLNK;
43
   output [1:0]  rMXDST;
44
   output [1:0]  rMXSRC, rMXTGT, rMXALT;
45
   output [2:0]  rMXALU;
46
   output [4:0]  rRW;
47
   output        rDWBSTB;
48 44 sybreon
   input [1:0]    rXCE;
49 41 sybreon
   input         rDLY;
50
   input [15:0]  rIMM;
51
   input [10:0]  rALT;
52
   input [5:0]    rOPC;
53
   input [4:0]    rRD, rRA, rRB;
54
   input [31:2]  rPC;
55
   input         rBRA;
56
   input         rMSR_IE;
57
 
58
   // DATA WISHBONE
59
   output        dwb_stb_o;
60
   output        dwb_wre_o;
61 50 sybreon
   input         dwb_ack_i;
62 41 sybreon
 
63
   // SYSTEM
64
   input         gclk, grst, gena;
65
 
66
   // --- DECODE INSTRUCTIONS
67
   // TODO: Simplify
68
 
69
   wire          fSFT = (rOPC == 6'o44);
70
   wire          fLOG = ({rOPC[5:4],rOPC[2]} == 3'o4);
71
 
72
   wire          fMUL = (rOPC == 6'o20) | (rOPC == 6'o30);
73
   wire          fBSF = (rOPC == 6'o21) | (rOPC == 6'o31);
74
   wire          fDIV = (rOPC == 6'o22);
75
 
76
   wire          fRTD = (rOPC == 6'o55);
77
   wire          fBCC = (rOPC == 6'o47) | (rOPC == 6'o57);
78
   wire          fBRU = (rOPC == 6'o46) | (rOPC == 6'o56);
79
   wire          fBRA = fBRU & rRA[3];
80
 
81
   wire          fIMM = (rOPC == 6'o54);
82
   wire          fMOV = (rOPC == 6'o45);
83
 
84
   wire          fLOD = ({rOPC[5:4],rOPC[2]} == 3'o6);
85
   wire          fSTR = ({rOPC[5:4],rOPC[2]} == 3'o7);
86
   wire          fLDST = (&rOPC[5:4]);
87
 
88
 
89
   // --- OPERAND SELECTOR ---------------------------------
90
 
91
   wire          fRDWE = |rRW;
92
   wire          fAFWD_M = (rRW == rRA) & (rMXDST == 2'o2) & fRDWE;
93
   wire          fBFWD_M = (rRW == rRB) & (rMXDST == 2'o2) & fRDWE;
94
   wire          fAFWD_R = (rRW == rRA) & (rMXDST == 2'o0) & fRDWE;
95
   wire          fBFWD_R = (rRW == rRB) & (rMXDST == 2'o0) & fRDWE;
96
 
97
   assign        rMXSRC = (fBRU | fBCC) ? 2'o3 : // PC
98
                          (fAFWD_M) ? 2'o2: // RAM
99
                          (fAFWD_R) ? 2'o1: // FWD
100
                          2'o0; // REG
101
 
102
   assign        rMXTGT = (rOPC[3]) ? 2'o3 : // IMM
103
                          (fBFWD_M) ? 2'o2 : // RAM
104
                          (fBFWD_R) ? 2'o1 : // FWD
105
                          2'o0; // REG
106
 
107
   assign        rMXALT = (fAFWD_M) ? 2'o2 : // RAM
108
                          (fAFWD_R) ? 2'o1 : // FWD
109
                          2'o0; // REG
110
 
111
 
112
   // --- ALU CONTROL ---------------------------------------
113
 
114
   reg [2:0]      rMXALU;
115
   always @(/*AUTOSENSE*/fBRA or fBSF or fDIV or fLOG or fMOV or fMUL
116
            or fSFT) begin
117
      rMXALU <= (fBRA | fMOV) ? 3'o3 :
118
                (fSFT) ? 3'o2 :
119
                (fLOG) ? 3'o1 :
120
                (fMUL) ? 3'o4 :
121
                (fBSF) ? 3'o5 :
122
                (fDIV) ? 3'o6 :
123
                3'o0;
124
   end
125
 
126
 
127
   // --- RAM CONTROL ---------------------------------------
128
 
129
   reg           rDWBSTB, xDWBSTB;
130
   reg           rDWBWRE, xDWBWRE;
131
 
132
   assign        dwb_stb_o = rDWBSTB;
133
   assign        dwb_wre_o = rDWBWRE;
134
 
135
   // --- DELAY SLOT REGISTERS ------------------------------
136
 
137
   reg [31:2]    rPCLNK, xPCLNK;
138
   reg [1:0]      rMXDST, xMXDST;
139
   reg [4:0]      rRW, xRW;
140
 
141 50 sybreon
   wire          fSKIP = (rBRA & !rDLY);
142 41 sybreon
 
143 44 sybreon
   always @(/*AUTOSENSE*/fLOD or fSKIP or fSTR or rXCE)
144
     if (fSKIP | |rXCE) begin
145 41 sybreon
        /*AUTORESET*/
146
        // Beginning of autoreset for uninitialized flops
147
        xDWBSTB <= 1'h0;
148
        xDWBWRE <= 1'h0;
149
        // End of automatics
150
     end else begin
151 50 sybreon
        xDWBSTB <= (fLOD | fSTR);
152 41 sybreon
        xDWBWRE <= fSTR;
153
     end
154
 
155
   always @(/*AUTOSENSE*/fBCC or fBRU or fLOD or fRTD or fSKIP or fSTR
156 44 sybreon
            or rRD or rXCE)
157 41 sybreon
     if (fSKIP) begin
158
        /*AUTORESET*/
159
        // Beginning of autoreset for uninitialized flops
160
        xMXDST <= 2'h0;
161
        xRW <= 5'h0;
162
        // End of automatics
163
     end else begin
164
        case (rXCE)
165 44 sybreon
          2'o2: xMXDST <= 2'o1;
166 41 sybreon
          default: xMXDST <= (fSTR | fRTD | fBCC) ? 2'o3 :
167
                             (fLOD) ? 2'o2 :
168
                             (fBRU) ? 2'o1 :
169
                             2'o0;
170 44 sybreon
        endcase
171
 
172 41 sybreon
        case (rXCE)
173 44 sybreon
          2'o2: xRW <= 5'd14;
174 41 sybreon
          default: xRW <= rRD;
175 44 sybreon
        endcase
176 41 sybreon
 
177 44 sybreon
     end // else: !if(fSKIP)
178 41 sybreon
 
179
 
180
   // --- PIPELINE CONTROL DELAY ----------------------------
181
 
182
   always @(posedge gclk)
183
     if (grst) begin
184
        /*AUTORESET*/
185
        // Beginning of autoreset for uninitialized flops
186
        rDWBSTB <= 1'h0;
187
        rDWBWRE <= 1'h0;
188
        rMXDST <= 2'h0;
189
        rRW <= 5'h0;
190
        // End of automatics
191
     end else if (gena) begin
192
        //rPCLNK <= #1 xPCLNK;
193
        rMXDST <= #1 xMXDST;
194
        rRW <= #1 xRW;
195
        rDWBSTB <= #1 xDWBSTB;
196
        rDWBWRE <= #1 xDWBWRE;
197
     end
198
 
199
 
200
endmodule // aeMB_ctrl

powered by: WebSVN 2.1.0

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