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

Subversion Repositories aemb

[/] [aemb/] [branches/] [DEV_SYBREON/] [rtl/] [verilog/] [aeMB_regf.v] - Blame information for rev 191

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 55 sybreon
// $Id: aeMB_regf.v,v 1.3 2007-11-10 16:39:38 sybreon Exp $
2 41 sybreon
//
3
// AEMB REGISTER FILE
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 55 sybreon
// Revision 1.2  2007/11/09 20:51:52  sybreon
24
// Added GET/PUT support through a FSL bus.
25
//
26 53 sybreon
// Revision 1.1  2007/11/02 03:25:41  sybreon
27
// New EDK 3.2 compatible design with optional barrel-shifter and multiplier.
28
// Fixed various minor data hazard bugs.
29
// Code compatible with -O0/1/2/3/s generated code.
30
//
31 41 sybreon
 
32
module aeMB_regf (/*AUTOARG*/
33
   // Outputs
34 53 sybreon
   rREGA, rREGB, rDWBDI, dwb_dat_o, fsl_dat_o,
35 41 sybreon
   // Inputs
36
   rOPC, rRA, rRB, rRW, rRD, rMXDST, rPCLNK, rRESULT, rDWBSEL, rBRA,
37 53 sybreon
   rDLY, dwb_dat_i, fsl_dat_i, gclk, grst, gena
38 41 sybreon
   );
39
   // INTERNAL
40
   output [31:0] rREGA, rREGB;
41
   output [31:0] rDWBDI;
42
   input [5:0]    rOPC;
43
   input [4:0]    rRA, rRB, rRW, rRD;
44
   input [1:0]    rMXDST;
45
   input [31:2]  rPCLNK;
46
   input [31:0]  rRESULT;
47
   input [3:0]    rDWBSEL;
48
   input         rBRA, rDLY;
49
 
50
   // DATA WISHBONE
51
   output [31:0] dwb_dat_o;
52
   input [31:0]  dwb_dat_i;
53 53 sybreon
 
54
   // FSL WISHBONE
55
   output [31:0] fsl_dat_o;
56
   input [31:0]   fsl_dat_i;
57 41 sybreon
 
58
   // SYSTEM
59
   input         gclk, grst, gena;
60
 
61
   // --- LOAD SIZER ----------------------------------------------
62
   // Moves the data bytes around depending on the size of the
63
   // operation.
64
 
65 53 sybreon
   wire [31:0]    wDWBDI = dwb_dat_i; // FIXME: Endian
66
   wire [31:0]    wFSLDI = fsl_dat_i; // FIXME: Endian
67
 
68 41 sybreon
   reg [31:0]     rDWBDI;
69 55 sybreon
   reg [1:0]      rSIZ;
70 41 sybreon
 
71 55 sybreon
   always @(/*AUTOSENSE*/rDWBSEL or wDWBDI or wFSLDI) begin
72
      /* 51.2
73
       case (rSIZ)
74
        // FSL
75
        2'o3: rDWBDI <= wFSLDI;
76
        // 32'bit
77
        2'o2: rDWBDI <= wDWBDI;
78
        // 16'bit
79
        2'o1: case (rRESULT[1])
80
                1'b0: rDWBDI <= {16'd0, wDWBDI[31:16]};
81
                1'b1: rDWBDI <= {16'd0, wDWBDI[15:0]};
82
              endcase // case (rRESULT[1])
83
        // 8'bit
84
        2'o0: case (rRESULT[1:0])
85
                2'o0: rDWBDI <= {24'd0, wDWBDI[31:24]};
86
                2'o1: rDWBDI <= {24'd0, wDWBDI[23:16]};
87
                2'o2: rDWBDI <= {24'd0, wDWBDI[15:8]};
88
                2'o3: rDWBDI <= {24'd0, wDWBDI[7:0]};
89
              endcase // case (rRESULT[1:0])
90
      endcase // case (rSIZ)
91
      */
92
 
93
      /* 50.6
94
      case ({rSIZ, rRESULT[1:0]})
95
        // FSL
96
        4'hC, 4'hD, 4'hE, 4'hF: rDWBDI <= wFSLDI;
97
        // 32'bit
98
        4'h8: rDWBDI <= wDWBDI;
99
        // 16'bit
100
        4'h4: rDWBDI <= {16'd0, wDWBDI[31:16]};
101
        4'h6: rDWBDI <= {16'd0, wDWBDI[15:0]};
102
        // 8'bit
103
        4'h0: rDWBDI <= {24'd0, wDWBDI[31:24]};
104
        4'h1: rDWBDI <= {24'd0, wDWBDI[23:16]};
105
        4'h2: rDWBDI <= {24'd0, wDWBDI[15:8]};
106
        4'h3: rDWBDI <= {24'd0, wDWBDI[7:0]};
107
        default: rDWBDI <= 32'hX;
108
      endcase // case (rSIZ)
109
      */
110
 
111
      // 52.0
112
      case (rDWBSEL)
113
        // 8'bit
114
        4'h8: rDWBDI <= {24'd0, wDWBDI[31:24]};
115
        4'h4: rDWBDI <= {24'd0, wDWBDI[23:16]};
116
        4'h2: rDWBDI <= {24'd0, wDWBDI[15:8]};
117
        4'h1: rDWBDI <= {24'd0, wDWBDI[7:0]};
118
        // 16'bit
119
        4'hC: rDWBDI <= {16'd0, wDWBDI[31:16]};
120
        4'h3: rDWBDI <= {16'd0, wDWBDI[15:0]};
121
        // 32'bit
122
        4'hF: rDWBDI <= wDWBDI;
123
        // FSL
124
        4'h0: rDWBDI <= wFSLDI;
125
        // Undefined
126
        default: rDWBDI <= 32'hX;
127
      endcase
128
 
129
   end
130
 
131
   always @(posedge gclk)
132
     if (grst) begin
133
        /*AUTORESET*/
134
        // Beginning of autoreset for uninitialized flops
135
        rSIZ <= 2'h0;
136
        // End of automatics
137
     end else if (gena) begin
138
        rSIZ <= rOPC[1:0];
139
     end
140 41 sybreon
 
141
   // --- GENERAL PURPOSE REGISTERS (R0-R31) -----------------------
142
   // LUT RAM implementation is smaller and faster. R0 gets written
143
   // during reset with 0x00 and doesn't change after.
144
 
145
   reg [31:0]     mARAM[0:31],
146
                 mBRAM[0:31],
147
                 mDRAM[0:31];
148
 
149
   wire [31:0]    rREGW = mDRAM[rRW];
150
   wire [31:0]    rREGD = mDRAM[rRD];
151
   assign        rREGA = mARAM[rRA];
152
   assign        rREGB = mBRAM[rRB];
153
 
154
   wire          fRDWE = |rRW;
155
 
156
   reg [31:0]     xWDAT;
157
 
158
   always @(/*AUTOSENSE*/rDWBDI or rMXDST or rPCLNK or rREGW
159
            or rRESULT)
160
     case (rMXDST)
161
       2'o2: xWDAT <= rDWBDI;
162
       2'o1: xWDAT <= {rPCLNK, 2'o0};
163
       2'o0: xWDAT <= rRESULT;
164
       2'o3: xWDAT <= rREGW; // No change       
165
     endcase // case (rMXDST)
166
 
167
   always @(posedge gclk)
168
     if (grst | fRDWE) begin
169
        mARAM[rRW] <= xWDAT;
170
        mBRAM[rRW] <= xWDAT;
171
        mDRAM[rRW] <= xWDAT;
172
     end
173
 
174
   // --- STORE SIZER ---------------------------------------------
175
   // Replicates the data bytes across depending on the size of the
176
   // operation.
177
 
178 55 sybreon
   reg [31:0]     rDWBDO, xDWBDO;
179
 
180 53 sybreon
   wire [31:0]    xFSL;
181
   wire          fFFWD_M = (rRA == rRW) & (rMXDST == 2'o2) & fRDWE;
182
   wire          fFFWD_R = (rRA == rRW) & (rMXDST == 2'o0) & fRDWE;
183
 
184
   assign        fsl_dat_o = rDWBDO;
185
   assign        xFSL = (fFFWD_M) ? rDWBDI :
186
                        (fFFWD_R) ? rRESULT :
187
                        rREGA;
188
 
189 41 sybreon
   wire [31:0]    xDST;
190
   wire          fDFWD_M = (rRW == rRD) & (rMXDST == 2'o2) & fRDWE;
191
   wire          fDFWD_R = (rRW == rRD) & (rMXDST == 2'o0) & fRDWE;
192
 
193
   assign        dwb_dat_o = rDWBDO;
194
   assign        xDST = (fDFWD_M) ? rDWBDI :
195
                        (fDFWD_R) ? rRESULT :
196
                        rREGD;
197
 
198 53 sybreon
   always @(/*AUTOSENSE*/rOPC or xDST or xFSL)
199 41 sybreon
     case (rOPC[1:0])
200
       // 8'bit
201
       2'h0: xDWBDO <= {(4){xDST[7:0]}};
202
       // 16'bit
203
       2'h1: xDWBDO <= {(2){xDST[15:0]}};
204
       // 32'bit
205
       2'h2: xDWBDO <= xDST;
206 53 sybreon
       // FSL
207
       2'h3: xDWBDO <= xFSL;
208
       //default: xDWBDO <= 32'hX;       
209 41 sybreon
     endcase // case (rOPC[1:0])   
210
 
211
   always @(posedge gclk)
212
     if (grst) begin
213
        /*AUTORESET*/
214
        // Beginning of autoreset for uninitialized flops
215
        rDWBDO <= 32'h0;
216
        // End of automatics
217
     end else if (gena) begin
218
        rDWBDO <= #1 xDWBDO;
219
     end
220
 
221
   // --- SIMULATION ONLY ------------------------------------------
222
   // Randomise memory to simulate real-world memory
223
   // synopsys translate_off
224
 
225
   integer i;
226
   initial begin
227
      for (i=0; i<32; i=i+1) begin
228
         mARAM[i] <= $random;
229
         mBRAM[i] <= $random;
230
         mDRAM[i] <= $random;
231
      end
232
   end
233
 
234
   // synopsys translate_on
235
 
236
 
237
endmodule // aeMB_regf

powered by: WebSVN 2.1.0

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