1 |
2 |
thorn_aitc |
//======================================================
|
2 |
|
|
// Aquarius Project
|
3 |
|
|
// SuperH-2 ISA Compatible RISC CPU
|
4 |
|
|
//------------------------------------------------------
|
5 |
|
|
// Module : `define Definition
|
6 |
|
|
//------------------------------------------------------
|
7 |
|
|
// File : define.v
|
8 |
|
|
// Library : none
|
9 |
|
|
// Description : A definition of Constant Value
|
10 |
|
|
// Simulator : Icarus Verilog (Cygwin)
|
11 |
|
|
// Synthesizer : Xilinx XST (Windows XP)
|
12 |
|
|
// Author : Thorn Aitch
|
13 |
|
|
//------------------------------------------------------
|
14 |
|
|
// Revision Number : 1
|
15 |
|
|
// Date of Change : 15th April 2002
|
16 |
|
|
// Creator : Thorn Aitch
|
17 |
|
|
// Description : Initial Design
|
18 |
|
|
//------------------------------------------------------
|
19 |
|
|
// Revision Number : 2
|
20 |
|
|
// Date of Change : 30th April 2003
|
21 |
|
|
// Modifier : Thorn Aitch
|
22 |
|
|
// Description : Release Version 1.0
|
23 |
|
|
//======================================================
|
24 |
|
|
// Copyright (C) 2002-2003, Thorn Aitch
|
25 |
|
|
//
|
26 |
|
|
// Designs can be altered while keeping list of
|
27 |
|
|
// modifications "the same as in GNU" No money can
|
28 |
|
|
// be earned by selling the designs themselves, but
|
29 |
|
|
// anyone can get money by selling the implementation
|
30 |
|
|
// of the design, such as ICs based on some cores,
|
31 |
|
|
// boards based on some schematics or Layouts, and
|
32 |
|
|
// even GUI interfaces to text mode drivers.
|
33 |
|
|
// "The same as GPL SW" Any update to the design
|
34 |
|
|
// should be documented and returned to the design.
|
35 |
|
|
// Any derivative work based on the IP should be free
|
36 |
|
|
// under OpenIP License. Derivative work means any
|
37 |
|
|
// update, change or improvement on the design.
|
38 |
|
|
// Any work based on the design can be either made
|
39 |
|
|
// free under OpenIP license or protected by any other
|
40 |
|
|
// license. Work based on the design means any work uses
|
41 |
|
|
// the OpenIP Licensed core as a building black without
|
42 |
|
|
// changing anything on it with any other blocks to
|
43 |
|
|
// produce larger design. There is NO WARRANTY on the
|
44 |
|
|
// functionality or performance of the design on the
|
45 |
|
|
// real hardware implementation.
|
46 |
|
|
// On the other hand, the SuperH-2 ISA (Instruction Set
|
47 |
|
|
// Architecture) executed by Aquarius is rigidly
|
48 |
|
|
// the property of Renesas Corp. Then you have all
|
49 |
|
|
// responsibility to judge if there are not any
|
50 |
|
|
// infringements to Renesas's rights regarding your
|
51 |
|
|
// Aquarius adoption into your design.
|
52 |
|
|
// By adopting Aquarius, the user assumes all
|
53 |
|
|
// responsibility for its use.
|
54 |
|
|
// This project may cause any damages around you, for
|
55 |
|
|
// example, loss of properties, data, money, profits,
|
56 |
|
|
// life, or business etc. By adopting this source,
|
57 |
|
|
// the user assumes all responsibility for its use.
|
58 |
|
|
//======================================================
|
59 |
|
|
|
60 |
|
|
//------------------
|
61 |
|
|
// Simulation Timing
|
62 |
|
|
//------------------
|
63 |
|
|
`define HALF_CYCLE 25
|
64 |
|
|
`define CYCLE 50
|
65 |
|
|
`define STROBE 49
|
66 |
|
|
|
67 |
|
|
//-------------
|
68 |
|
|
// ALU Function
|
69 |
|
|
//-------------
|
70 |
|
|
`define ALU_NOP 5'b00000 // Z=0
|
71 |
|
|
`define ALU_THRUX 5'b00001 // Z=X
|
72 |
|
|
`define ALU_THRUY 5'b00010 // Z=Y
|
73 |
|
|
`define ALU_THRUW 5'b00011 // Z=W
|
74 |
|
|
|
75 |
|
|
`define ALU_ADD 5'b00100 // Z=X+Y
|
76 |
|
|
`define ALU_ADDC 5'b00101 // Z=X+Y, T<-Carry
|
77 |
|
|
`define ALU_ADDV 5'b00110 // Z=X+Y, T<-Overflow
|
78 |
|
|
`define ALU_INCX 5'b00111 // Z=X+1
|
79 |
|
|
`define ALU_INCX2 5'b01000 // Z=X+2
|
80 |
|
|
`define ALU_INCX4 5'b01001 // Z=X+4
|
81 |
|
|
`define ALU_ADDCN 5'b01010 // Z=X+CONST
|
82 |
|
|
`define ALU_ADDR0 5'b01011 // Z=X+R0(if necessary, forwarding from WBUS)
|
83 |
|
|
`define ALU_ADDXFC 5'b01100 // Z=(X & FC) + Y
|
84 |
|
|
`define ALU_SWAPW 5'b01101 // Z=SWAPW(Y)
|
85 |
|
|
`define ALU_SWAPB 5'b01110 // Z=SWAPB(Y)
|
86 |
|
|
`define ALU_DIV 5'b01111 // DIV1 Function
|
87 |
|
|
|
88 |
|
|
`define ALU_EXTUB 5'b10000 // Z=EXTUB(Y)
|
89 |
|
|
`define ALU_EXTUW 5'b10001 // Z=EXTUW(Y)
|
90 |
|
|
`define ALU_EXTSB 5'b10010 // Z=EXTSB(Y)
|
91 |
|
|
`define ALU_EXTSW 5'b10011 // Z=EXTSW(Y)
|
92 |
|
|
|
93 |
|
|
`define ALU_SUB 5'b10100 // Z=X-Y
|
94 |
|
|
`define ALU_SUBC 5'b10101 // Z=X-Y, T<-Carry
|
95 |
|
|
`define ALU_SUBV 5'b10110 // Z=X-Y, T<-Overflow
|
96 |
|
|
`define ALU_DECX 5'b10111 // Z=X-1
|
97 |
|
|
`define ALU_DECX2 5'b11000 // Z=X-2
|
98 |
|
|
`define ALU_DECX4 5'b11001 // Z=X-4
|
99 |
|
|
|
100 |
|
|
`define ALU_XTRCT 5'b11010 // Z=XTRCT(X,Y)
|
101 |
|
|
`define ALU_TAS 5'b11011 // Z=X & 32'h00000080
|
102 |
|
|
|
103 |
|
|
`define ALU_AND 5'b11100 // Z=X&Y
|
104 |
|
|
`define ALU_XOR 5'b11101 // Z=X|Y
|
105 |
|
|
`define ALU_OR 5'b11110 // Z=Z^Y
|
106 |
|
|
`define ALU_NOT 5'b11111 // Z=~Y
|
107 |
|
|
|
108 |
|
|
//-----------------
|
109 |
|
|
// Compare Function
|
110 |
|
|
//-----------------
|
111 |
|
|
`define CMPEQ 3'b000 // equal
|
112 |
|
|
`define CMPHS 3'b010 // higher or same (unsigned)
|
113 |
|
|
`define CMPGE 3'b011 // grater or equal(signed)
|
114 |
|
|
`define CMPHI 3'b110 // higher than (unsigned)
|
115 |
|
|
`define CMPGT 3'b111 // grater than (signed)
|
116 |
|
|
`define CMPPL 3'b101 // plus (not 0) (signed)
|
117 |
|
|
`define CMPPZ 3'b001 // plus or zero (signed)
|
118 |
|
|
`define CMPSTR 3'b100 // equal at least 1 byte
|
119 |
|
|
|
120 |
|
|
//-----------------
|
121 |
|
|
// Shifter Function
|
122 |
|
|
//-----------------
|
123 |
|
|
//corresponding to instruction bit5,4,3,2,0
|
124 |
|
|
`define SHLL 5'b00000
|
125 |
|
|
`define SHAL 5'b10000
|
126 |
|
|
`define SHLR 5'b00001
|
127 |
|
|
`define SHAR 5'b10001
|
128 |
|
|
`define ROTL 5'b00010
|
129 |
|
|
`define ROTCL 5'b10010
|
130 |
|
|
`define ROTR 5'b00011
|
131 |
|
|
`define ROTCR 5'b10011
|
132 |
|
|
`define SHLL2 5'b00100
|
133 |
|
|
`define SHLL8 5'b01100
|
134 |
|
|
`define SHLL16 5'b10100
|
135 |
|
|
`define SHLR2 5'b00101
|
136 |
|
|
`define SHLR8 5'b01101
|
137 |
|
|
`define SHLR16 5'b10101
|
138 |
|
|
|
139 |
|
|
//----------------
|
140 |
|
|
// SR bit Position
|
141 |
|
|
//----------------
|
142 |
|
|
`define T 0 // SR[T]
|
143 |
|
|
`define S 1 // SR[S]
|
144 |
|
|
`define I0 4 // SR[I0], SR[I3:I0]
|
145 |
|
|
`define I1 5 // SR[I1], SR[I3:I0]
|
146 |
|
|
`define I2 6 // SR[I2], SR[I3:I0]
|
147 |
|
|
`define I3 7 // SR[I3], SR[I3:I0]
|
148 |
|
|
`define Q 8 // SR[Q]
|
149 |
|
|
`define M 9 // SR[M]
|
150 |
|
|
|
151 |
|
|
//------------------------------------------
|
152 |
|
|
// Decode Unit : Instruction State Parameter
|
153 |
|
|
//------------------------------------------
|
154 |
|
|
`define POWERON_RESET 16'hF700 // Instruction Sequence Code for Power on Reset
|
155 |
|
|
`define NO_EVT 3'b111
|
156 |
|
|
`define MRES 3'b110
|
157 |
|
|
`define DMAERR 3'b011
|
158 |
|
|
`define CPUERR 3'b010
|
159 |
|
|
`define NMI 3'b001
|
160 |
|
|
`define IRQ 3'b000
|
161 |
|
|
`define SLOT_ILGL 16'hFE06
|
162 |
|
|
`define GNRL_ILGL 16'hFF04
|
163 |
|
|
|
164 |
|
|
//---------------------------------------------
|
165 |
|
|
// Memory Access Unit : State Number Assignment
|
166 |
|
|
//---------------------------------------------
|
167 |
|
|
`define S_IDLE 3'h0 // 000
|
168 |
|
|
`define S_IFEX 3'h1 // 001 external bus IF
|
169 |
|
|
`define S_MAEX 3'h2 // 010 external bus MA
|
170 |
|
|
`define S_MAEX_IFPD 3'h3 // 011 external bus MA
|
171 |
|
|
`define S_IDLE_IFKP 3'h4 // 100
|
172 |
|
|
`define S_IFIN 3'h5 // 101
|
173 |
|
|
`define S_MAEX_IFKP 3'h6 // 110 external bus MA
|
174 |
|
|
`define S_MAEX_IFIN 3'h7 // 111 external bus MA
|
175 |
|
|
|
176 |
|
|
//------------------------------------------
|
177 |
|
|
// Multiplier Unit : State Number Assignment
|
178 |
|
|
//------------------------------------------
|
179 |
|
|
`define NOP 4'b0000
|
180 |
|
|
`define DMULSL 4'b0001
|
181 |
|
|
`define DMULSL2 4'b0010
|
182 |
|
|
`define DMULUL 4'b0011
|
183 |
|
|
`define DMULUL2 4'b0100
|
184 |
|
|
`define MACL0 4'b0101
|
185 |
|
|
`define MACL2 4'b0110
|
186 |
|
|
`define MACLS 4'b0111
|
187 |
|
|
`define MACLS2 4'b1000
|
188 |
|
|
`define MACW 4'b1001
|
189 |
|
|
`define MACWS 4'b1010
|
190 |
|
|
`define MULL 4'b1011
|
191 |
|
|
`define MULL2 4'b1100
|
192 |
|
|
`define MULSW 4'b1101
|
193 |
|
|
`define MULUW 4'b1110
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
//======================================================
|
197 |
|
|
// End of Module
|
198 |
|
|
//======================================================
|