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

Subversion Repositories aemb

[/] [aemb/] [tags/] [AEMB_7_05/] [rtl/] [verilog/] [aeMB_control.v] - Blame information for rev 191

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 sybreon
/*
2 36 sybreon
 * $Id: aeMB_control.v,v 1.6 2007-05-17 09:08:21 sybreon Exp $
3 3 sybreon
 *
4 14 sybreon
 * AE68 System Control Unit
5 25 sybreon
 * Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>
6 3 sybreon
 *
7 25 sybreon
 * 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 3 sybreon
 *
12 25 sybreon
 * 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 3 sybreon
 *
17 25 sybreon
 * 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 3 sybreon
 *
22
 * DESCRIPTION
23
 * Controls the state of the processor.
24
 *
25
 * HISTORY
26
 * $Log: not supported by cvs2svn $
27 36 sybreon
 * Revision 1.5  2007/05/16 12:32:21  sybreon
28
 * Added async BRA/DLY signals for future clock, reset, and interrupt features.
29
 *
30 35 sybreon
 * Revision 1.4  2007/04/27 00:23:55  sybreon
31
 * Added code documentation.
32
 * Improved size & speed of rtl/verilog/aeMB_aslu.v
33
 *
34 25 sybreon
 * Revision 1.3  2007/04/11 04:30:43  sybreon
35
 * Added pipeline stalling from incomplete bus cycles.
36
 * Separated sync and async portions of code.
37
 *
38 16 sybreon
 * Revision 1.2  2007/04/04 14:08:34  sybreon
39
 * Added initial interrupt/exception support.
40
 *
41 14 sybreon
 * Revision 1.1  2007/03/09 17:52:17  sybreon
42
 * initial import
43
 *
44 3 sybreon
 */
45
 
46
module aeMB_control (/*AUTOARG*/
47
   // Outputs
48 36 sybreon
   rFSM, nclk, prst, prun, frun, drun,
49 3 sybreon
   // Inputs
50 16 sybreon
   sys_rst_i, sys_clk_i, sys_int_i, sys_exc_i, rIWBSTB, iwb_ack_i,
51
   rDWBSTB, dwb_ack_i, rBRA, rDLY
52 3 sybreon
   );
53
   // System
54
   input        sys_rst_i, sys_clk_i;
55
   input        sys_int_i;
56
   input        sys_exc_i;
57
 
58
   // Instruction WB
59
   input        rIWBSTB;
60
   input        iwb_ack_i;
61
 
62
   // Data WB
63
   input        rDWBSTB;
64
   input        dwb_ack_i;
65
 
66
   // Internal
67
   input        rBRA, rDLY;
68
   output [1:0] rFSM;
69
   //, rLDST;
70 36 sybreon
   output       nclk, prst, prun;
71 3 sybreon
   output       frun, drun;
72
 
73 25 sybreon
   /**
74
    RUN Signal
75
    ----------
76
    This master run signal will pause or run the entire pipeline. It
77
    will pause for any incomplete bus transaction.
78
    */
79
 
80 36 sybreon
   assign       prun = ~((rDWBSTB ^ dwb_ack_i) | ((rIWBSTB ^ iwb_ack_i)));
81 3 sybreon
 
82 25 sybreon
   /**
83
    Debounce
84
    --------
85
    The following external signals are debounced and synchronised:
86
    - Interrupt
87
    */
88
 
89 3 sybreon
   reg [2:0] rEXC, rINT;
90 36 sybreon
   always @(negedge nclk)
91
     if (prst) begin
92 3 sybreon
        /*AUTORESET*/
93
        // Beginning of autoreset for uninitialized flops
94
        rINT <= 3'h0;
95
        // End of automatics
96 36 sybreon
     end else if (prun) begin
97 25 sybreon
        //rEXC <= #1 {rEXC[1:0], sys_exc_i};
98 3 sybreon
        rINT <= #1 {rINT[1:0], sys_int_i};
99
     end
100
 
101 25 sybreon
   /**
102
    Machine States
103
    --------------
104
    The internal machine state is affected by external interrupt,
105
    exception and software exceptions. Only interrupts are
106
    implemented.
107
 
108
    TODO: Implement exceptions.
109
    */
110 3 sybreon
   parameter [1:0]
111
                FSM_RUN = 2'o0,
112
                FSM_SWEXC = 2'o3,
113
                FSM_HWEXC = 2'o2,
114
                FSM_HWINT = 2'o1;
115
 
116
   reg [1:0]       rFSM, rNXT;
117 36 sybreon
   always @(negedge nclk)
118
     if (prst) begin
119 3 sybreon
        /*AUTORESET*/
120
        // Beginning of autoreset for uninitialized flops
121
        rFSM <= 2'h0;
122
        // End of automatics
123 36 sybreon
     end else if (prun) begin
124 3 sybreon
        rFSM <= #1 rNXT;
125
     end
126
 
127 25 sybreon
   always @(/*AUTOSENSE*/rFSM or rINT)
128 3 sybreon
     case (rFSM)
129
       FSM_HWEXC: rNXT <= FSM_RUN;
130
       //FSM_SWEXC: rNXT <= FSM_RUN;     
131
       FSM_HWINT: rNXT <= FSM_RUN;
132
       default: begin
133 25 sybreon
          rNXT <= //(rEXC == 3'h3) ? FSM_HWEXC :
134 3 sybreon
                  (rINT == 3'h3) ? FSM_HWINT :
135
                  FSM_RUN;
136
       end
137 16 sybreon
     endcase // case (rFSM)
138 3 sybreon
 
139 25 sybreon
   /**
140
    Bubble
141
    ------
142
    Pipeline bubbles are introduced during a branch or interrupt.
143
 
144
    TODO: Implement interrupt bubble.
145
    */
146
 
147 35 sybreon
   reg [1:0]    rRUN, xRUN;
148 36 sybreon
   assign       {drun,frun} = xRUN;
149 35 sybreon
 
150
   always @(/*AUTOSENSE*/rBRA or rDLY) begin
151
       xRUN <= {~(rBRA ^ rDLY), ~rBRA};
152
   end
153 25 sybreon
 
154
   /**
155
    Clock/Reset
156
    -----------
157
    This controls the internal clock/reset signal for the core. Any
158
    DCM/PLL/DPLL can be instantiated here if needed.
159
    */
160 14 sybreon
 
161 36 sybreon
   reg [1:0]     rRST;
162 25 sybreon
   assign       nclk = sys_clk_i;
163 36 sybreon
   assign       prst = rRST[1];
164 25 sybreon
 
165 36 sybreon
   always @(negedge nclk)
166
     if (!sys_rst_i) begin
167
        rRST <= 2'h3;
168
        /*AUTORESET*/
169
     end else begin
170
        rRST <= {rRST[0],1'b0};
171
     end
172
 
173 25 sybreon
 
174 3 sybreon
endmodule // aeMB_control

powered by: WebSVN 2.1.0

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