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

Subversion Repositories aemb

[/] [aemb/] [branches/] [DEV_SYBREON/] [rtl/] [verilog/] [aeMB2_sysc.v] - Blame information for rev 194

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

Line No. Rev Author Line
1 93 sybreon
/* $Id: aeMB2_sysc.v,v 1.5 2007-12-21 22:28:56 sybreon Exp $
2 78 sybreon
**
3
** AEMB2 SYSTEM CONTROL
4
**
5
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
6
**
7
** This file is part of AEMB.
8
**
9
** 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
** You should have received a copy of the GNU Lesser General Public
20
** License along with AEMB. If not, see <http://www.gnu.org/licenses/>.
21
*/
22
 
23
module aeMB2_sysc (/*AUTOARG*/
24
   // Outputs
25 81 sybreon
   rINT, rXCE, pha_o, clk_o, rst_o, ena_o, iwb_stb_o, iwb_wre_o,
26
   dwb_cyc_o, dwb_stb_o, dwb_wre_o, cwb_stb_o, cwb_wre_o,
27 78 sybreon
   // Inputs
28 81 sybreon
   rIMM_OF, rOPC_OF, rRA_OF, rMSR_BE, rMSR_BIP, rMSR_IE, rOPC_IF,
29
   iwb_ack_i, dwb_ack_i, cwb_ack_i, sys_int_i, sys_clk_i, sys_rst_i
30 78 sybreon
   );
31
   parameter TXE = 1;
32 80 sybreon
   parameter FSL = 1;
33 78 sybreon
 
34
   // INTERNAL
35
   input [15:0] rIMM_OF;
36 80 sybreon
   input [5:0]   rOPC_OF;
37
   input [4:0]   rRA_OF;
38 81 sybreon
   input        rMSR_BE,
39 80 sybreon
                rMSR_BIP,
40 81 sybreon
                //rMSR_TXE,
41 80 sybreon
                rMSR_IE;
42 81 sybreon
   input [5:0]   rOPC_IF;
43 78 sybreon
 
44 81 sybreon
   output       rINT,
45
                rXCE;
46
 
47 80 sybreon
   output       pha_o,
48
                clk_o,
49
                rst_o,
50
                ena_o;
51 78 sybreon
 
52 81 sybreon
   // EXTERNAL
53
   output       iwb_stb_o,
54
                iwb_wre_o,
55
                dwb_cyc_o,
56
                dwb_stb_o,
57
                dwb_wre_o,
58
                cwb_stb_o,
59
                cwb_wre_o;
60
 
61
   input        iwb_ack_i,
62
                dwb_ack_i,
63
                cwb_ack_i;
64
 
65 78 sybreon
   // SYSTEM
66
   input       sys_int_i,
67
               sys_clk_i,
68
               sys_rst_i;
69
 
70
   /*AUTOREG*/
71
   // Beginning of automatic regs (for this module's undeclared outputs)
72
   reg                  cwb_stb_o;
73
   reg                  cwb_wre_o;
74
   reg                  dwb_cyc_o;
75
   reg                  dwb_stb_o;
76
   reg                  dwb_wre_o;
77
   reg                  iwb_stb_o;
78
   reg                  pha_o;
79
   reg                  rINT;
80
   reg                  rXCE;
81
   reg                  rst_o;
82
   // End of automatics
83
 
84
 
85
   /* Partial decoding */
86
   wire [5:0]            rOPC = rOPC_OF;
87
   wire [4:0]            rRA = rRA_OF;
88
   wire [4:0]            rRB = rIMM_OF[15:11];
89
 
90
   wire                 fSFT = (rOPC == 6'o44);
91
   wire                 fLOG = ({rOPC[5:4],rOPC[2]} == 3'o4);
92
   wire                 fMUL = (rOPC == 6'o20) | (rOPC == 6'o30);
93
   wire                 fBSF = (rOPC == 6'o21) | (rOPC == 6'o31);
94
   wire                 fDIV = (rOPC == 6'o22);
95
   wire                 fRTD = (rOPC == 6'o55);
96
   wire                 fBCC = (rOPC == 6'o47) | (rOPC == 6'o57);
97
   wire                 fBRU = (rOPC == 6'o46) | (rOPC == 6'o56);
98
   wire                 fBRA = fBRU & rRA[3];
99
   wire                 fIMM = (rOPC == 6'o54);
100
   wire                 fMOV = (rOPC == 6'o45);
101
   wire                 fLOD = ({rOPC[5:4],rOPC[2]} == 3'o6);
102
   wire                 fSTR = ({rOPC[5:4],rOPC[2]} == 3'o7);
103
   wire                 fLDST = (rOPC[5:4] == 2'o3);
104
   wire                 fPUT = (rOPC == 6'o33) & rRB[4];
105
   wire                 fGET = (rOPC == 6'o33) & !rRB[4];
106
 
107
   /* instantiate a clock manager if necessary */
108
 
109
   assign               clk_o = sys_clk_i;
110
 
111
 
112
   /* delay the reset signal for POR */
113
 
114
   always @(posedge clk_o)
115
     if (sys_rst_i) begin
116
        rst_o <= 1'b1;
117
     end else if (!pha_o) begin
118
        rst_o <= #1 1'b0;
119
     end
120
 
121
   /* calculate the async enable signal */
122
 
123
   assign               ena_o = !((cwb_ack_i ^ cwb_stb_o) | // FSL clean
124
                                  (dwb_ack_i ^ dwb_stb_o) | // DWB clean
125
                                  (iwb_ack_i ^ iwb_stb_o)); // IWB clean  
126
 
127
 
128
   /* Toggle the FGMT phase. This toggles twice during POR to reset
129
   /* the various RAM locations (for a LUT based optimisation). */
130
 
131
   always @(posedge clk_o)
132
     if (sys_rst_i) begin
133
        pha_o <= 1'b1;
134
        /*AUTORESET*/
135
     end else if (ena_o) begin
136
        pha_o <= #1 !pha_o;
137
     end
138
 
139
   /* Level triggered interrupt latch flag */
140
 
141
   // check for interrupt acknowledge
142 81 sybreon
   wire                 fINTACK = ena_o & (rOPC_OF == 6'o56) & (rRA_OF == 5'h0E);
143 78 sybreon
 
144
   always @(posedge clk_o)
145
     if (rst_o) begin
146
        /*AUTORESET*/
147
        // Beginning of autoreset for uninitialized flops
148
        rINT <= 1'h0;
149
        // End of automatics
150
     end else if (rMSR_IE) begin
151 84 sybreon
        rINT <= #1 (rINT | sys_int_i) & !fINTACK;
152 78 sybreon
     end
153
 
154
   /* Hardwre exception catcher */
155
 
156
   // check for exception acknowledge
157
   wire                 fXCEACK = ena_o & (rOPC_OF == 6'o56) & (rRA_OF == 5'h0F);
158
 
159
   // check for invalid instruction
160
   wire                 fILLEGAL;
161
   assign               fILLEGAL = ({rOPC_IF[5:4],rOPC_IF[1:0]} == 4'hF) | // LD/ST
162
                                   ((rOPC_IF[5:3] == 3'o3) &
163
                                    ((rOPC_OF[2:0] != 3'o2) |
164
                                     (rOPC_OF[2]))) | // GET/PUT
165
                                   ((rOPC_IF[5:3] == 3'o2) &
166
                                    (rOPC_IF[2:1] != 2'o0)) // MUL/BSF
167
                                     ;
168 81 sybreon
 
169 78 sybreon
   /* Handle wishbone handshakes */
170
 
171
   assign iwb_wre_o = 1'b0;
172
 
173
   always @(posedge clk_o)
174
     if (rst_o) begin
175
        /*AUTORESET*/
176
        // Beginning of autoreset for uninitialized flops
177
        cwb_stb_o <= 1'h0;
178
        cwb_wre_o <= 1'h0;
179
        dwb_cyc_o <= 1'h0;
180
        dwb_stb_o <= 1'h0;
181
        dwb_wre_o <= 1'h0;
182
        iwb_stb_o <= 1'h0;
183
        // End of automatics
184 93 sybreon
     end else if (ena_o) begin
185 81 sybreon
        iwb_stb_o <= #1 (TXE | pha_o);
186 78 sybreon
 
187
        dwb_cyc_o <= #1 fLOD | fSTR | rMSR_BE;
188
        dwb_stb_o <= #1 fLOD | fSTR;
189
        dwb_wre_o <= #1 fSTR;
190
 
191 81 sybreon
        cwb_stb_o <= #1 (FSL) ? (fGET | fPUT) : 1'bX;
192 80 sybreon
        cwb_wre_o <= #1 (FSL) ? fPUT : 1'bX;
193 78 sybreon
     end
194
 
195
 
196
 
197
endmodule // aeMB2_sysc
198
 
199 80 sybreon
/* $Log: not supported by cvs2svn $
200 93 sybreon
/* Revision 1.4  2007/12/16 03:25:02  sybreon
201
/* Added interrupt support.
202
/*
203 84 sybreon
/* Revision 1.3  2007/12/13 20:12:11  sybreon
204
/* Code cleanup + minor speed regression.
205
/*
206 81 sybreon
/* Revision 1.2  2007/12/12 19:16:59  sybreon
207
/* Minor optimisations (~10% faster)
208
/*
209 80 sybreon
/* Revision 1.1  2007/12/11 00:43:17  sybreon
210
/* initial import
211
/* */

powered by: WebSVN 2.1.0

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