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 53

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

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

powered by: WebSVN 2.1.0

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