`timescale 1ns/100ps
// Copyright 2008 Actel Corporation.  All rights reserved.
// ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN
// ACCORDANCE WITH THE ACTEL LICENSE AGREEMENT AND MUST BE APPROVED
// IN ADVANCE IN WRITING.
// Rev: 2.4   24Jan08 IPB  : Production Release
// SVN Revision Information:
// SVN $Revision: 14026 $
module
Top_Waveform_COREABC_0_INSTRUCTNVM
(
CLK
,
RSTN
,
START
,
STALL
,
ADDRESS
,
INSTRUCTION
,
PSEL
,
PENABLE
,
PWRITE
,
PADDR
,
PWDATA
,
PRDATA
,
PSLVERR
,
PREADY
)
;
parameter
MAX_NVMDWIDTH
=
32
;
parameter
AWIDTH
=
8
;
parameter
DWIDTH
=
8
;
parameter
SWIDTH
=
1
;
parameter
ICWIDTH
=
8
;
parameter
ABCOI
=
256
;
parameter
IWWIDTH
=
58
;
parameter
ACT_CALIBRATIONDATA
=
1
;
parameter
IMEM_APB_ACCESS
=
2
;
parameter
UNIQ_STRING_LENGTH
=
10
;
// Copyright 2008 Actel Corporation.  All rights reserved.
// ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN
// ACCORDANCE WITH THE ACTEL LICENSE AGREEMENT AND MUST BE APPROVED
// IN ADVANCE IN WRITING.
// Rev: 2.4   24Jan08 IPB  : Production Release
// SVN Revision Information:
// SVN $Revision: 12260 $
localparam
BLANK
=
-
1
;
localparam
iNOP
=
256
*
1
;
localparam
iLOAD
=
256
*
2
;
localparam
iINCB
=
256
*
3
;
localparam
iAND
=
256
*
4
;
localparam
iOR
=
256
*
5
;
localparam
iXOR
=
256
*
6
;
localparam
iADD
=
256
*
7
;
localparam
iSUB
=
256
*
8
;
localparam
iSHL0
=
256
*
9
;
localparam
iSHL1
=
256
*
10
;
localparam
iSHLE
=
256
*
11
;
localparam
iROL
=
256
*
12
;
localparam
iSHR0
=
256
*
13
;
localparam
iSHR1
=
256
*
14
;
localparam
iSHRE
=
256
*
15
;
localparam
iROR
=
256
*
16
;
localparam
iCMP
=
256
*
17
;
localparam
iCMPLEQ
=
256
*
18
;
localparam
iBITCLR
=
256
*
19
;
localparam
iBITSET
=
256
*
20
;
localparam
iBITTST
=
256
*
21
;
localparam
iAPBREAD
=
256
*
22
;
localparam
iAPBWRT
=
256
*
23
;
localparam
iLOADZ
=
256
*
24
;
localparam
iDECZ
=
256
*
25
;
localparam
iINCZ
=
256
*
26
;
localparam
iIOWRT
=
256
*
27
;
localparam
iRAMREAD
=
256
*
28
;
localparam
iRAMWRT
=
256
*
29
;
localparam
iPUSH
=
256
*
30
;
localparam
iPOP
=
256
*
31
;
localparam
iIOREAD
=
256
*
32
;
localparam
iUSER
=
256
*
33
;
localparam
iJUMPB
=
256
*
34
;
localparam
iCALLB
=
256
*
35
;
localparam
iRETURNB
=
256
*
36
;
localparam
iRETISRB
=
256
*
37
;
localparam
iWAITB
=
256
*
38
;
localparam
iHALTB
=
256
*
38
;
localparam
iMULT
=
256
*
39
;
localparam
iDEC
=
256
*
40
;
localparam
iAPBREADZ
=
256
*
41
;
localparam
iAPBWRTZ
=
256
*
42
;
localparam
iADDZ
=
256
*
43
;
localparam
iSUBZ
=
256
*
44
;
localparam
iDAT
=
10
;
localparam
iDAT8
=
11
;
localparam
iDAT16
=
12
;
localparam
iDAT32
=
13
;
localparam
iACM
=
14
;
localparam
iACC
=
15
;
localparam
iRAM
=
16
;
localparam
ABClI
=
10
;
localparam
DAT8
=
11
;
localparam
DAT16
=
12
;
localparam
DAT32
=
13
;
localparam
ACM
=
14
;
localparam
ACC
=
15
;
localparam
RAM
=
16
;
localparam
iIFNOT
=
0
;
localparam
iNOTIF
=
0
;
localparam
iIF
=
1
;
localparam
iUNTIL
=
0
;
localparam
iNOTUNTIL
=
1
;
localparam
iUNTILNOT
=
1
;
localparam
iWHILE
=
1
;
localparam
iZZERO
=
8
'h
08
;
localparam
iNEGATIVE
=
8
'h
04
;
localparam
iZERO
=
8
'h
02
;
localparam
iLTE_ZERO
=
8
'h
06
;
localparam
iALWAYS
=
8
'h
01
;
localparam
iINPUT0
=
12
'h
010
;
localparam
iINPUT1
=
12
'h
020
;
localparam
iINPUT2
=
12
'h
040
;
localparam
iINPUT3
=
12
'h
080
;
localparam
iINPUT4
=
12
'h
100
;
localparam
iINPUT5
=
12
'h
200
;
localparam
iINPUT6
=
12
'h
400
;
localparam
iINPUT7
=
12
'h
800
;
localparam
iINPUT8
=
16
'h
1000
;
localparam
iINPUT9
=
16
'h
2000
;
localparam
iINPUT10
=
16
'h
4000
;
localparam
iINPUT11
=
16
'h
8000
;
localparam
iINPUT12
=
20
'h
10000
;
localparam
iINPUT13
=
20
'h
20000
;
localparam
iINPUT14
=
20
'h
40000
;
localparam
iINPUT15
=
20
'h
80000
;
localparam
iINPUT16
=
24
'h
100000
;
localparam
iINPUT17
=
24
'h
200000
;
localparam
iINPUT18
=
24
'h
400000
;
localparam
iINPUT19
=
24
'h
800000
;
localparam
iINPUT20
=
28
'h
1000000
;
localparam
iINPUT21
=
28
'h
2000000
;
localparam
iINPUT22
=
28
'h
4000000
;
localparam
iINPUT23
=
28
'h
8000000
;
localparam
iINPUT24
=
32
'h
10000000
;
localparam
iINPUT25
=
32
'h
20000000
;
localparam
iINPUT26
=
32
'h
40000000
;
localparam
iINPUT27
=
32
'h
80000000
;
localparam
iANYINPUT
=
32
'h
7FFFFFF0
;
localparam
ALWAYS
=
8
'h
01
;
localparam
ZZERO
=
8
'h
08
;
localparam
NEGATIVE
=
8
'h
04
;
localparam
ZERO
=
8
'h
02
;
localparam
LTE_ZERO
=
8
'h
06
;
localparam
INPUT0
=
12
'h
010
;
localparam
INPUT1
=
12
'h
020
;
localparam
INPUT2
=
12
'h
040
;
localparam
INPUT3
=
12
'h
080
;
localparam
INPUT4
=
12
'h
100
;
localparam
INPUT5
=
12
'h
200
;
localparam
INPUT6
=
12
'h
400
;
localparam
INPUT7
=
12
'h
800
;
localparam
INPUT8
=
16
'h
1000
;
localparam
INPUT9
=
16
'h
2000
;
localparam
INPUT10
=
16
'h
3000
;
localparam
INPUT11
=
16
'h
8000
;
localparam
INPUT12
=
20
'h
10000
;
localparam
INPUT13
=
20
'h
20000
;
localparam
INPUT14
=
20
'h
40000
;
localparam
INPUT15
=
20
'h
80000
;
localparam
INPUT16
=
24
'h
100000
;
localparam
INPUT17
=
24
'h
200000
;
localparam
INPUT18
=
24
'h
300000
;
localparam
INPUT19
=
24
'h
800000
;
localparam
INPUT20
=
28
'h
1000000
;
localparam
INPUT21
=
28
'h
2000000
;
localparam
INPUT22
=
28
'h
4000000
;
localparam
INPUT23
=
28
'h
8000000
;
localparam
INPUT24
=
32
'h
10000000
;
localparam
INPUT25
=
32
'h
20000000
;
localparam
INPUT26
=
32
'h
40000000
;
localparam
INPUT27
=
32
'h
40000000
;
localparam
ANYINPUT
=
32
'h
7FFFFFF0
;
localparam
iLOADLOOP
=
256
*
24
;
localparam
iDECLOOP
=
256
*
25
;
localparam
iINCLOOP
=
256
*
26
;
localparam
iLOOPZ
=
8
;
localparam
LOOPZ
=
8
;
localparam
EN_USER
=
0
;
function
[
57
:
0
]
ABCOl
;
input
[
2
:
0
]
ABCIl
;
input
[
2
:
0
]
ABCll
;
input
[
3
:
0
]
ABCO0
;
input
[
15
:
0
]
ABCI0
;
input
[
31
:
0
]
ABCl0
;
reg
[
32
+
16
+
4
+
6
-
1
:
0
]
ABCO1
;
begin
ABCO1
=
{
ABCl0
,
ABCI0
,
ABCO0
,
ABCll
,
ABCIl
}
;
ABCOl
=
ABCO1
;
end
endfunction
function
[
57
:
0
]
doins
;
input
ABCI1
;
integer
ABCI1
;
input
ABCl1
;
integer
ABCl1
;
input
ABCOOI
;
integer
ABCOOI
;
input
ABCIOI
;
integer
ABCIOI
;
input
ABClOI
;
integer
ABClOI
;
input
ABCOII
;
integer
ABCOII
;
reg
[
2
:
0
]
ABCIl
;
reg
[
2
:
0
]
ABCll
;
reg
[
3
:
0
]
ABCO0
;
reg
[
15
:
0
]
ABCI0
;
reg
[
31
:
0
]
ABCl0
;
localparam
[
31
:
0
]
ABCIII
=
{
32
{
1
'b
1
}
}
;
localparam
[
31
:
0
]
ZERO
=
{
32
{
1
'b
0
}
}
;
integer
ABClII
;
integer
FFW
;
integer
ABCOlI
;
begin
ABCIl
=
3
'b
xxx
;
ABCll
=
3
'b
xxx
;
ABCO0
=
4
'b
xxx0
;
ABCI0
=
{
16
{
1
'b
x
}
}
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
ABClII
=
ABCl1
/
256
;
FFW
=
ABCl1
-
ABClII
*
256
;
ABClII
=
ABClII
*
256
;
case
(
ABClII
)
iLOAD
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
111
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
ABCOOI
;
if
(
ABCI1
>=
3
)
begin
case
(
ABCOOI
)
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iINCB
:
begin
if
(
FFW
>
0
)
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
100
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
1
;
end
else
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
000
;
ABCO0
[
0
]
=
1
'b
0
;
end
end
iDEC
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
100
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
{
32
{
1
'b
1
}
}
;
end
iAND
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
001
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
ABCOOI
;
if
(
ABCI1
>=
3
)
begin
case
(
ABCOOI
)
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iOR
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
010
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
ABCOOI
;
if
(
ABCI1
>=
3
)
begin
case
(
ABCOOI
)
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iXOR
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
011
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
ABCOOI
;
if
(
ABCI1
>=
3
)
begin
case
(
ABCOOI
)
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iADD
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
100
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
ABCOOI
;
if
(
ABCI1
>=
3
)
begin
case
(
ABCOOI
)
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iMULT
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
000
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
ABCOOI
;
if
(
ABCI1
>=
3
)
begin
case
(
ABCOOI
)
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iSUB
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
100
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
~
(
ABCOOI
-
1
)
;
if
(
ABCI1
>=
3
)
begin
ABCl0
=
~
(
ABCIOI
-
1
)
;
case
(
ABCOOI
)
iDAT
:
begin
end
iDAT8
:
begin
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
1
}
}
;
end
iDAT16
:
begin
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
1
}
}
;
end
iDAT32
:
begin
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iSHL0
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
101
;
ABCl0
[
1
:
0
]
=
2
'b
00
;
ABCO0
[
0
]
=
1
'b
0
;
end
iSHL1
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
101
;
ABCl0
[
1
:
0
]
=
2
'b
01
;
ABCO0
[
0
]
=
1
'b
0
;
end
iSHLE
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
101
;
ABCl0
[
1
:
0
]
=
2
'b
10
;
ABCO0
[
0
]
=
1
'b
0
;
end
iROL
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
101
;
ABCl0
[
1
:
0
]
=
2
'b
11
;
ABCO0
[
0
]
=
1
'b
0
;
end
iSHR0
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
110
;
ABCl0
[
1
:
0
]
=
2
'b
00
;
ABCO0
[
0
]
=
1
'b
0
;
end
iSHR1
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
110
;
ABCl0
[
1
:
0
]
=
2
'b
01
;
ABCO0
[
0
]
=
1
'b
0
;
end
iSHRE
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
110
;
ABCl0
[
1
:
0
]
=
2
'b
10
;
ABCO0
[
0
]
=
1
'b
0
;
end
iROR
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
110
;
ABCl0
[
1
:
0
]
=
2
'b
11
;
ABCO0
[
0
]
=
1
'b
0
;
end
iCMP
:
begin
ABCIl
=
3
'b
001
;
ABCll
=
3
'b
011
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
ABCOOI
;
if
(
ABCI1
>=
3
)
begin
case
(
ABCOOI
)
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iCMPLEQ
:
begin
ABCIl
=
3
'b
001
;
ABCll
=
3
'b
100
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
~
(
ABCOOI
-
1
)
;
if
(
ABCI1
>=
3
)
begin
ABCl0
=
~
(
ABCIOI
-
1
)
;
case
(
ABCOOI
)
iDAT
:
begin
end
iDAT8
:
begin
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
end
iRAM
:
begin
ABCI0
[
7
:
0
]
=
ABCIOI
;
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
default
:
begin
end
endcase
end
end
iBITCLR
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
001
;
ABCl0
=
ABCIII
;
ABCl0
[
ABCOOI
]
=
1
'b
0
;
ABCO0
[
0
]
=
1
'b
0
;
end
iBITSET
:
begin
ABCIl
=
3
'b
000
;
ABCll
=
3
'b
010
;
ABCl0
=
ZERO
;
ABCl0
[
ABCOOI
]
=
1
'b
1
;
ABCO0
[
0
]
=
1
'b
0
;
end
iBITTST
:
begin
ABCIl
=
3
'b
001
;
ABCll
=
3
'b
001
;
ABCl0
=
ZERO
;
ABCl0
[
ABCOOI
]
=
1
'b
1
;
ABCO0
[
0
]
=
1
'b
0
;
end
iAPBREAD
:
begin
ABCIl
=
3
'b
010
;
ABCll
=
3
'b
011
;
ABCO0
=
ABCOOI
;
ABCI0
=
ABCIOI
;
end
iAPBWRT
:
begin
ABCIl
=
3
'b
010
;
ABCll
=
3
'b
xxx
;
ABCO0
=
ABCIOI
;
ABCI0
=
ABClOI
;
case
(
ABCOOI
)
iACM
:
ABCll
=
3
'b
010
;
iACC
:
ABCll
=
3
'b
000
;
iDAT
:
begin
ABCll
=
3
'b
001
;
ABCl0
=
ABCOII
;
end
iDAT8
:
begin
ABCll
=
3
'b
001
;
ABCl0
=
ABCOII
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCll
=
3
'b
001
;
ABCl0
=
ABCOII
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCll
=
3
'b
001
;
ABCl0
=
ABCOII
;
end
default
:
begin
end
endcase
end
iAPBREADZ
:
begin
ABCIl
=
3
'b
010
;
ABCll
=
3
'b
111
;
ABCO0
=
ABCOOI
;
end
iAPBWRTZ
:
begin
ABCIl
=
3
'b
010
;
ABCll
=
3
'b
xxx
;
ABCO0
=
ABCIOI
;
case
(
ABCOOI
)
iACM
:
ABCll
=
3
'b
110
;
iACC
:
ABCll
=
3
'b
100
;
iDAT
:
begin
ABCll
=
3
'b
101
;
ABCl0
=
ABClOI
;
end
iDAT8
:
begin
ABCll
=
3
'b
101
;
ABCl0
=
ABClOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCll
=
3
'b
101
;
ABCl0
=
ABClOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCll
=
3
'b
101
;
ABCl0
=
ABClOI
;
end
default
:
begin
end
endcase
end
iLOADZ
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
000
;
ABCO0
[
0
]
=
1
'b
0
;
case
(
ABCOOI
)
iACC
:
begin
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
default
:
begin
end
endcase
end
iDECZ
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
001
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
{
32
{
1
'b
1
}
}
;
end
iINCZ
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
001
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
1
;
end
iADDZ
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
001
;
ABCO0
[
0
]
=
1
'b
0
;
case
(
ABCOOI
)
iACC
:
begin
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
default
:
begin
end
endcase
end
iSUBZ
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
001
;
ABCO0
[
0
]
=
1
'b
0
;
ABCl0
=
~
(
ABCIOI
-
1
)
;
case
(
ABCOOI
)
iACC
:
begin
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
iDAT
:
begin
end
iDAT8
:
begin
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
1
}
}
;
end
iDAT16
:
begin
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
1
}
}
;
end
iDAT32
:
begin
end
default
:
begin
end
endcase
end
iIOWRT
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
111
;
ABCO0
[
0
]
=
1
'b
0
;
case
(
ABCOOI
)
iACC
:
begin
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
default
:
begin
end
endcase
end
iIOREAD
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
110
;
end
iRAMREAD
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
011
;
ABCI0
=
ABCOOI
;
end
iRAMWRT
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
010
;
ABCI0
=
ABCOOI
;
ABCO0
[
0
]
=
1
'b
1
;
if
(
ABCI1
>=
3
)
begin
ABCO0
[
0
]
=
1
'b
0
;
ABCI0
=
ABCOOI
;
case
(
ABCIOI
)
iACC
:
begin
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
iDAT
:
begin
ABCl0
=
ABClOI
;
end
iDAT8
:
begin
ABCl0
=
ABClOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABClOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABClOI
;
end
default
:
begin
end
endcase
end
end
iPUSH
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
100
;
ABCO0
[
0
]
=
1
'b
0
;
case
(
ABCOOI
)
BLANK
:
begin
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
iACC
:
begin
ABCO0
[
0
]
=
1
'b
1
;
ABCl0
=
{
32
{
1
'b
x
}
}
;
end
iDAT
:
begin
ABCl0
=
ABCIOI
;
end
iDAT8
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
8
]
=
{
24
{
1
'b
x
}
}
;
end
iDAT16
:
begin
ABCl0
=
ABCIOI
;
ABCl0
[
31
:
16
]
=
{
16
{
1
'b
x
}
}
;
end
iDAT32
:
begin
ABCl0
=
ABCIOI
;
end
default
:
begin
end
endcase
end
iPOP
:
begin
ABCIl
=
3
'b
011
;
ABCll
=
3
'b
101
;
end
iJUMPB
:
begin
ABCIl
=
3
'b
100
;
ABCll
=
3
'b
x01
;
if
(
ABCI1
>=
4
)
begin
ABCll
[
0
]
=
ABCIlI
(
ABCOOI
)
;
ABCl0
=
ABCIOI
;
ABCI0
=
ABClOI
;
end
else
begin
ABCl0
[
0
]
=
1
'b
1
;
ABCI0
=
ABCOOI
;
end
for
(
ABCOlI
=
31
;
ABCOlI
>=
FFW
+
4
;
ABCOlI
=
ABCOlI
-
1
)
ABCl0
[
ABCOlI
]
=
1
'b
x
;
end
iWAITB
:
begin
ABCIl
=
3
'b
100
;
ABCll
=
3
'b
x11
;
if
(
ABCI1
>=
3
)
begin
ABCll
[
0
]
=
ABCIlI
(
ABCOOI
)
;
ABCl0
=
ABCIOI
;
end
else
begin
ABCl0
[
0
]
=
1
'b
1
;
end
for
(
ABCOlI
=
31
;
ABCOlI
>=
FFW
+
4
;
ABCOlI
=
ABCOlI
-
1
)
ABCl0
[
ABCOlI
]
=
1
'b
x
;
end
iCALLB
:
begin
ABCIl
=
3
'b
101
;
ABCll
=
3
'b
x01
;
if
(
ABCI1
>=
4
)
begin
ABCll
[
0
]
=
ABCIlI
(
ABCOOI
)
;
ABCl0
=
ABCIOI
;
ABCI0
=
ABClOI
;
end
else
begin
ABCl0
[
0
]
=
1
'b
1
;
ABCI0
=
ABCOOI
;
end
for
(
ABCOlI
=
31
;
ABCOlI
>=
FFW
+
4
;
ABCOlI
=
ABCOlI
-
1
)
ABCl0
[
ABCOlI
]
=
1
'b
x
;
end
iRETURNB
:
begin
ABCIl
=
3
'b
110
;
ABCll
=
3
'b
x01
;
if
(
ABCI1
>=
3
)
begin
ABCll
[
0
]
=
ABCIlI
(
ABCOOI
)
;
ABCl0
=
ABCIOI
;
end
else
begin
ABCl0
[
0
]
=
1
'b
1
;
end
for
(
ABCOlI
=
31
;
ABCOlI
>=
FFW
+
4
;
ABCOlI
=
ABCOlI
-
1
)
ABCl0
[
ABCOlI
]
=
1
'b
x
;
end
iRETISRB
:
begin
ABCIl
=
3
'b
110
;
ABCll
=
3
'b
x11
;
if
(
ABCI1
>=
3
)
begin
ABCll
[
0
]
=
ABCIlI
(
ABCOOI
)
;
ABCl0
=
ABCIOI
;
end
else
begin
ABCl0
[
0
]
=
1
'b
1
;
end
for
(
ABCOlI
=
31
;
ABCOlI
>=
FFW
+
4
;
ABCOlI
=
ABCOlI
-
1
)
ABCl0
[
ABCOlI
]
=
1
'b
x
;
end
iNOP
:
begin
ABCIl
=
3
'b
111
;
if
(
EN_USER
==
1
)
begin
ABCll
=
3
'b
000
;
end
end
iUSER
:
begin
ABCIl
=
3
'b
111
;
ABCll
[
0
]
=
1
'b
1
;
ABCll
=
ABCOOI
;
ABCl0
=
ABCIOI
;
ABCI0
=
ABClOI
;
ABCO0
=
ABCOII
;
end
default
:
begin
end
endcase
doins
=
ABCOl
(
ABCIl
,
ABCll
,
ABCO0
,
ABCI0
,
ABCl0
)
;
end
endfunction
function
[
57
:
0
]
doins5
;
input
ABCl1
;
input
ABCOOI
;
input
ABCIOI
;
input
ABClOI
;
input
ABCOII
;
integer
ABCl1
;
integer
ABCOOI
;
integer
ABCIOI
;
integer
ABClOI
;
integer
ABCOII
;
integer
ABCllI
;
begin
ABCllI
=
-
1
;
doins5
=
doins
(
5
,
ABCl1
,
ABCOOI
,
ABCIOI
,
ABClOI
,
ABCOII
)
;
end
endfunction
function
[
57
:
0
]
doins4
;
input
ABCl1
;
input
ABCOOI
;
input
ABCIOI
;
input
ABClOI
;
integer
ABCl1
;
integer
ABCOOI
;
integer
ABCIOI
;
integer
ABClOI
;
integer
ABCllI
;
begin
ABCllI
=
-
1
;
doins4
=
doins
(
4
,
ABCl1
,
ABCOOI
,
ABCIOI
,
ABClOI
,
ABCllI
)
;
end
endfunction
function
[
57
:
0
]
doins3
;
input
ABCl1
;
input
ABCOOI
;
input
ABCIOI
;
integer
ABCl1
;
integer
ABCOOI
;
integer
ABCIOI
;
integer
ABCllI
;
begin
ABCllI
=
-
1
;
doins3
=
doins
(
3
,
ABCl1
,
ABCOOI
,
ABCIOI
,
ABCllI
,
ABCllI
)
;
end
endfunction
function
[
57
:
0
]
doins2
;
input
ABCl1
;
input
ABCOOI
;
integer
ABCl1
;
integer
ABCOOI
;
integer
ABCllI
;
begin
ABCllI
=
-
1
;
doins2
=
doins
(
2
,
ABCl1
,
ABCOOI
,
ABCllI
,
ABCllI
,
ABCllI
)
;
end
endfunction
function
[
57
:
0
]
doins1
;
input
ABCl1
;
integer
ABCl1
;
integer
ABCllI
;
begin
ABCllI
=
-
1
;
doins1
=
doins
(
1
,
ABCl1
,
ABCllI
,
ABCllI
,
ABCllI
,
ABCllI
)
;
end
endfunction
function
[
57
:
0
]
ABCIlI
;
input
ABCO0I
;
integer
ABCO0I
;
begin
if
(
ABCO0I
!=
0
)
begin
ABCIlI
=
1
'b
1
;
end
else
begin
ABCIlI
=
1
'b
0
;
end
end
endfunction
function
[
57
:
0
]
ABCI0I
;
input
ABCO0I
;
begin
if
(
ABCO0I
)
begin
ABCI0I
=
1
'b
1
;
end
else
begin
ABCI0I
=
1
'b
0
;
end
end
endfunction
function
integer
ABCl0I
;
input
ABCO1I
;
integer
ABCO1I
;
input
ABCI1I
;
integer
ABCI1I
;
input
ABCl1I
;
integer
ABCl1I
;
input
ABCOOl
;
integer
ABCOOl
;
integer
ABCIOl
;
integer
ABClOl
;
begin
ABCIOl
=
0
;
ABClOl
=
0
;
if
(
ABCI1I
==
1
)
begin
ABClOl
=
8
;
if
(
ABCOOl
>
8
)
begin
ABClOl
=
16
;
end
end
if
(
ABCO1I
==
1
)
begin
ABCIOl
=
ABCl1I
;
end
if
(
ABCIOl
>
ABClOl
)
begin
ABCl0I
=
ABCIOl
;
end
else
if
(
ABClOl
>
0
)
begin
ABCl0I
=
ABClOl
;
end
else
begin
ABCl0I
=
1
;
end
end
endfunction
function
integer
calc_swidth
;
input
ABCOIl
;
integer
ABCOIl
;
begin
if
(
ABCOIl
>=
9
)
begin
calc_swidth
=
4
;
end
else
if
(
ABCOIl
>=
5
)
begin
calc_swidth
=
3
;
end
else
if
(
ABCOIl
>=
3
)
begin
calc_swidth
=
2
;
end
else
if
(
ABCOIl
>=
2
)
begin
calc_swidth
=
1
;
end
else
begin
calc_swidth
=
0
;
end
end
endfunction
function
integer
log2r
;
input
ABCOIl
;
integer
ABCOIl
;
begin
if
(
ABCOIl
>=
65536
)
begin
log2r
=
17
;
end
else
if
(
ABCOIl
>=
32768
)
begin
log2r
=
16
;
end
else
if
(
ABCOIl
>=
16384
)
begin
log2r
=
15
;
end
else
if
(
ABCOIl
>=
8192
)
begin
log2r
=
14
;
end
else
if
(
ABCOIl
>=
4096
)
begin
log2r
=
13
;
end
else
if
(
ABCOIl
>=
2048
)
begin
log2r
=
12
;
end
else
if
(
ABCOIl
>=
1024
)
begin
log2r
=
11
;
end
else
if
(
ABCOIl
>=
512
)
begin
log2r
=
10
;
end
else
if
(
ABCOIl
>=
256
)
begin
log2r
=
9
;
end
else
if
(
ABCOIl
>=
128
)
begin
log2r
=
8
;
end
else
if
(
ABCOIl
>=
64
)
begin
log2r
=
7
;
end
else
if
(
ABCOIl
>=
32
)
begin
log2r
=
6
;
end
else
if
(
ABCOIl
>=
16
)
begin
log2r
=
5
;
end
else
if
(
ABCOIl
>=
8
)
begin
log2r
=
4
;
end
else
if
(
ABCOIl
>=
4
)
begin
log2r
=
3
;
end
else
if
(
ABCOIl
>=
2
)
begin
log2r
=
2
;
end
else
if
(
ABCOIl
>=
1
)
begin
log2r
=
1
;
end
else
begin
log2r
=
1
;
end
end
endfunction
function
integer
calc_initwidth
;
input
AWIDTH
;
integer
AWIDTH
;
input
DWIDTH
;
integer
DWIDTH
;
input
ABCl
;
integer
ABCl
;
input
ICWIDTH
;
integer
ICWIDTH
;
integer
SWIDTH
;
integer
ABCIIl
;
integer
ABClIl
;
integer
ABCOll
;
integer
ABCIll
;
integer
ABClll
;
integer
ABCO0l
;
integer
ABCI0l
;
begin
SWIDTH
=
calc_swidth
(
ABCl
)
;
if
(
ABCl
==
0
)
SWIDTH
=
1
;
ABCIIl
=
2
**
ICWIDTH
;
ABClIl
=
AWIDTH
+
DWIDTH
+
SWIDTH
+
6
;
ABCOll
=
1
+
(
ABCIIl
-
1
)
/
512
;
ABCIll
=
1
+
(
ABClIl
-
1
)
/
9
;
ABClll
=
ABCIll
*
ABCOll
;
ABCO0l
=
ABClll
*
512
;
ABCI0l
=
log2r
(
ABCO0l
)
;
if
(
ABCI0l
>
16
)
ABCI0l
=
16
;
calc_initwidth
=
ABCI0l
;
end
endfunction
function
integer
max
;
input
ABCl0l
,
ABCO1l
;
integer
ABCl0l
,
ABCO1l
;
begin
if
(
ABCl0l
>
ABCO1l
)
max
=
ABCl0l
;
else
max
=
ABCO1l
;
end
endfunction
function
integer
min
;
input
ABCl0l
,
ABCO1l
;
integer
ABCl0l
,
ABCO1l
;
begin
if
(
ABCl0l
<
ABCO1l
)
min
=
ABCl0l
;
else
min
=
ABCO1l
;
end
endfunction
input
CLK
;
input
RSTN
;
input
START
;
output
STALL
;
input
[
ICWIDTH
-
1
:
0
]
ADDRESS
;
output
[
IWWIDTH
-
1
:
0
]
INSTRUCTION
;
input
PSEL
;
input
PENABLE
;
input
PWRITE
;
input
[
AWIDTH
-
1
:
0
]
PADDR
;
input
[
DWIDTH
-
1
:
0
]
PWDATA
;
output
[
DWIDTH
-
1
:
0
]
PRDATA
;
output
PSLVERR
;
output
PREADY
;
endmodule
