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 41

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

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

powered by: WebSVN 2.1.0

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