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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [rtl/] [verilog/] [aeMB_bpcu.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_bpcu.v,v 1.1 2007-11-02 03:25:39 sybreon Exp $
2
//
3
// AEMB BRANCH PROGRAMME COUNTER 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
 
24
module aeMB_bpcu (/*AUTOARG*/
25
   // Outputs
26
   iwb_adr_o, rPC, rPCLNK, rBRA, rDLY,
27
   // Inputs
28
   rMXALT, rOPC, rRD, rRA, rRESULT, rDWBDI, rREGA, rXCE, gclk, grst,
29
   gena
30
   );
31
   parameter IW = 24;
32
 
33
   // INST WISHBONE
34
   output [IW-1:2] iwb_adr_o;
35
 
36
   // INTERNAL
37
   output [31:2]   rPC, rPCLNK;
38
   output          rBRA;
39
   output          rDLY;
40
   input [1:0]      rMXALT;
41
   input [5:0]      rOPC;
42
   input [4:0]      rRD, rRA;
43
   input [31:0]    rRESULT; // ALU
44
   input [31:0]    rDWBDI; // RAM
45
   input [31:0]    rREGA;
46
   input [1:0]      rXCE;
47
 
48
   // SYSTEM
49
   input           gclk, grst, gena;
50
 
51
   // BRANCH
52
   wire            fRTD = (rOPC == 6'o55);
53
   wire            fBCC = (rOPC == 6'o47) | (rOPC == 6'o57);
54
   wire            fBRU = (rOPC == 6'o46) | (rOPC == 6'o56);
55
 
56
   wire [31:0]      wREGA;
57
   assign          wREGA = (rMXALT == 2'o2) ? rDWBDI :
58
                           (rMXALT == 2'o1) ? rRESULT :
59
                           rREGA;
60
 
61
   wire            wBEQ = (wREGA == 32'd0);
62
   wire            wBNE = ~wBEQ;
63
   wire            wBLT = wREGA[31];
64
   wire            wBLE = wBLT | wBEQ;
65
   wire            wBGE = ~wBLT;
66
   wire            wBGT = ~wBLE;
67
 
68
   reg             xXCC;
69
   always @(/*AUTOSENSE*/rRD or wBEQ or wBGE or wBGT or wBLE or wBLT
70
            or wBNE)
71
     case (rRD[2:0])
72
       3'o0: xXCC <= wBEQ;
73
       3'o1: xXCC <= wBNE;
74
       3'o2: xXCC <= wBLT;
75
       3'o3: xXCC <= wBLE;
76
       3'o4: xXCC <= wBGT;
77
       3'o5: xXCC <= wBGE;
78
       default: xXCC <= 1'bX;
79
     endcase // case (rRD[2:0])
80
 
81
   // DELAY SLOT
82
   reg             rBRA, xBRA;
83
   reg             rDLY, xDLY;
84
   wire            fSKIP = rBRA & !rDLY;
85
 
86
   always @(/*AUTOSENSE*/fBCC or fBRU or fRTD or rBRA or rRA or rRD
87
            or xXCC)
88
     if (rBRA) begin
89
        /*AUTORESET*/
90
        // Beginning of autoreset for uninitialized flops
91
        xBRA <= 1'h0;
92
        xDLY <= 1'h0;
93
        // End of automatics
94
     end else begin
95
        xDLY <= (fBRU & rRA[4]) | (fBCC & rRD[4]) | fRTD;
96
        xBRA <= (fRTD | fBRU) ? 1'b1 :
97
                (fBCC) ? xXCC :
98
                1'b0;
99
        /*
100
        case (rXCE)
101
          2'o1: xBRA <= 1'b0;
102
          default: xBRA <= (fRTD | fBRU) ? 1'b1 :
103
                           (fBCC) ? xXCC :
104
                           1'b0;
105
        endcase // case (rXCE)
106
         */
107
     end
108
 
109
   reg [31:2] rPCLNK, xPCLNK;
110
   always @(/*AUTOSENSE*/fSKIP or rBRA or rPC or rRESULT)
111
     if (fSKIP) begin
112
        /*AUTORESET*/
113
        // Beginning of autoreset for uninitialized flops
114
        xPCLNK <= 30'h0;
115
        // End of automatics
116
     end else begin
117
        xPCLNK <= (rBRA) ? rRESULT[31:2] : rPC;
118
     end
119
 
120
   // PC Changes - (NXT, BRA, INT)
121
   reg [31:2]      rIPC, xIPC;
122
   reg [31:2]      rPC, xPC;
123
 
124
   assign          iwb_adr_o = rIPC[IW-1:2];
125
   always @(/*AUTOSENSE*/rBRA or rIPC or rRESULT) begin
126
      xIPC <= (rBRA) ? rRESULT[31:2] : (rIPC + 1);
127
      /*
128
      case (rXCE)
129
        2'o1: xIPC <= 32'h04;
130
        default: xIPC <= (rBRA) ? rRESULT[31:2] : (rIPC + 1);
131
      endcase // case (rXCE)
132
       */
133
      xPC <= rIPC;
134
   end
135
 
136
 
137
   // SYNC
138
   always @(posedge gclk)
139
     if (grst) begin
140
        /*AUTORESET*/
141
        // Beginning of autoreset for uninitialized flops
142
        rBRA <= 1'h0;
143
        rDLY <= 1'h0;
144
        rIPC <= 30'h0;
145
        rPC <= 30'h0;
146
        rPCLNK <= 30'h0;
147
        // End of automatics
148
     end else if (gena) begin
149
        rIPC <= #1 xIPC;
150
        rBRA <= #1 xBRA;
151
        rPC <= #1 xPC;
152
        rPCLNK <= #1 xPCLNK;
153
        rDLY <= #1 xDLY;
154
     end
155
 
156
   // synopsys translate_off
157
 
158
 
159
   // synopsys translate_on
160
 
161
endmodule // aeMB_bpcu

powered by: WebSVN 2.1.0

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