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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [rtl/] [verilog/] [aeMB2_gprf.v] - Blame information for rev 120

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

Line No. Rev Author Line
1 120 sybreon
/* $Id: aeMB2_gprf.v,v 1.2 2008-04-20 16:34:32 sybreon Exp $
2 118 sybreon
**
3
** AEMB2 EDK 6.2 COMPATIBLE CORE
4
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU Lesser General Public License as
10
** published by the Free Software Foundation, either version 3 of the
11
** License, or (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16
** Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
20
*/
21
 
22
/**
23
 * General Purpose Register File
24
 * @aeMB2_gprf.v
25
 
26
 * Dual set of 32 general purpose registers for the core. These are
27
   R0-R31. A zero is written to R0 for both sets during reset and
28
   maintained after that.
29
 
30
 */
31
 
32
module aeMB2_gprf (/*AUTOARG*/
33
   // Outputs
34
   opa_if, opb_if, opd_if,
35
   // Inputs
36
   mux_of, mux_ex, ich_dat, rd_of, rd_ex, sel_mx, rpc_mx, xwb_mx,
37
   dwb_mx, alu_mx, sfr_mx, mul_mx, bsf_mx, gclk, grst, dena, gpha
38
   );
39
   parameter AEMB_HTX = 1;
40
 
41
   // INTERNAL
42
   output [31:0] opa_if,
43
                 opb_if,
44
                 opd_if;
45
 
46
   input [2:0]    mux_of,
47
                 mux_ex;
48
   input [31:0]  ich_dat;
49
   input [4:0]    rd_of,
50
                 rd_ex;
51
 
52
   // DATA SOURCSE
53
   input [3:0]    sel_mx;
54
   input [31:2]  rpc_mx;
55
   input [31:0]  xwb_mx,
56
                 dwb_mx,
57
                 alu_mx,
58
                 sfr_mx,
59
                 mul_mx,
60
                 bsf_mx;
61
 
62
   // SYSTEM
63
   input         gclk,
64
                 grst,
65
                 dena,
66
                 gpha;
67
 
68
   /*AUTOWIRE*/
69
   /*AUTOREG*/
70
 
71
   wire [31:0]    opd_wr;
72
   reg [31:0]     rMEMA[63:0],
73
                 rMEMB[63:0],
74
                 rMEMD[63:0];
75
   reg [31:0]     mem_mx;
76
   reg [31:0]     regd;
77
   reg           wrb_fb;
78
   reg [4:0]      rd_mx;
79
   reg [2:0]      mux_mx;
80
 
81
      // PIPELINE
82
   always @(posedge gclk)
83
     if (grst) begin
84
        /*AUTORESET*/
85
        // Beginning of autoreset for uninitialized flops
86
        mux_mx <= 3'h0;
87
        rd_mx <= 5'h0;
88
        wrb_fb <= 1'h0;
89
        // End of automatics
90
     end else if (dena) begin
91
        wrb_fb <= #1 |rd_ex & |mux_ex; // FIXME: check mux
92
 
93
        rd_mx <= #1 rd_ex;
94
        mux_mx <= #1 mux_ex;
95
     end
96
 
97
   // LOAD SIZER   
98 120 sybreon
   always @(/*AUTOSENSE*/dwb_mx or sel_mx) begin
99 118 sybreon
      case (sel_mx)
100
        // 8'bits
101
        4'h8: mem_mx <= #1 {24'd0, dwb_mx[31:24]};
102
        4'h4: mem_mx <= #1 {24'd0, dwb_mx[23:16]};
103
        4'h2: mem_mx <= #1 {24'd0, dwb_mx[15:8]};
104
        4'h1: mem_mx <= #1 {24'd0, dwb_mx[7:0]};
105
        // 16'bits
106
        4'hC: mem_mx <= #1 {16'd0, dwb_mx[31:16]};
107
        4'h3: mem_mx <= #1 {16'd0, dwb_mx[15:0]};
108
        // 32'bits
109
        4'hF: mem_mx <= #1 dwb_mx;
110 120 sybreon
        //4'h0: mem_mx <= #1 xwb_mx;
111 118 sybreon
        default: mem_mx <= 32'hX;
112
      endcase // case (sel_mx)
113
   end // always @ (...
114
 
115
   // SELECT SOURCE
116
   localparam [2:0] MUX_ALU = 3'o7,
117
                    MUX_SFR = 3'o5,
118
                    MUX_BSF = 3'o4,
119
                    MUX_MUL = 3'o3,
120
                    MUX_MEM = 3'o2,
121
                    MUX_RPC = 3'o1,
122
                    MUX_NOP = 3'o0;
123
 
124
   always @(/*AUTOSENSE*/alu_mx or bsf_mx or mem_mx or mul_mx
125
            or mux_mx or rpc_mx or sfr_mx)
126
     case (mux_mx)
127
       MUX_ALU: regd <= #1 alu_mx; // ALU
128
       MUX_RPC: regd <= #1 {rpc_mx[31:2], 2'o0}; // PC Link
129
       MUX_MEM: regd <= #1 mem_mx; // RAM/FSL
130
       MUX_MUL: regd <= #1 mul_mx; // MULTIPLIER
131
       MUX_BSF: regd <= #1 bsf_mx; // SHIFTER
132
       MUX_NOP: regd <= #1 32'h0;
133
       MUX_SFR: regd <= #1 sfr_mx;
134
       default: regd <= #1 32'hX;
135
     endcase // case (mux_rd)
136
 
137
 
138
   // REGISTER FILE - Infer LUT memory
139
   wire [5:0]     wRD = {gpha, ich_dat[25:21]};
140
   wire [5:0]     wRA = {gpha, ich_dat[20:16]};
141
   wire [5:0]     wRB = {gpha, ich_dat[15:11]};
142
   wire [5:0]     wRW = {!gpha, rd_mx};
143
 
144
   assign        opd_wr = rMEMD[wRW];
145
   assign        opa_if = rMEMA[wRA];
146
   assign        opb_if = rMEMB[wRB];
147
   assign        opd_if = rMEMD[wRD];
148
 
149
   always @(posedge gclk)
150
     if (grst | (dena & wrb_fb)) begin
151
        rMEMA[wRW] <= #1 regd;
152
        rMEMB[wRW] <= #1 regd;
153
        rMEMD[wRW] <= #1 regd;
154
     end
155
 
156
   // synopsys translate_off
157
   // initialise RAM to random contents for simulation only
158
   integer       i;
159
   initial begin
160
      for (i=0;i<64;i=i+1) begin
161
         rMEMA[i] <= $random;
162
         rMEMB[i] <= $random;
163
         rMEMD[i] <= $random;
164
      end
165
   end
166
   // synopsys translate_on
167
 
168
endmodule // aeMB2_gprf
169
 
170
// $Log: not supported by cvs2svn $
171 120 sybreon
// Revision 1.1  2008/04/18 00:21:52  sybreon
172
// Initial import.
173
//

powered by: WebSVN 2.1.0

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