Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
Wishbone slave generator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
24
Issues
24
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Wishbone slave generator
Commits
7f478544
Commit
7f478544
authored
Apr 19, 2013
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated squished binary
parent
f4b155be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
370 additions
and
306 deletions
+370
-306
wbgen2
wbgen2
+370
-306
No files found.
wbgen2
View file @
7f478544
#!/usr/bin/env lua
#!/usr/bin/env lua
package.preload
[
'alt_getopt'
]
=
(
function
(
...
)
package.preload
[
'alt_getopt'
]
=
(
function
(
...
)
local
o
,
d
,
u
,
a
,
i
=
type
,
pairs
,
ipairs
,
io
,
os
local
n
,
r
,
u
,
a
,
o
=
type
,
pairs
,
ipairs
,
io
,
os
module
(
"alt_getopt"
)
module
(
"alt_getopt"
)
local
function
c
(
t
)
local
function
i
(
t
)
local
e
=
1
local
e
=
1
local
e
=#
t
local
e
=#
t
local
e
=
{}
local
e
=
{}
...
@@ -11,19 +11,19 @@ e[a]=#t
...
@@ -11,19 +11,19 @@ e[a]=#t
end
end
return
e
return
e
end
end
local
function
r
(
t
,
e
)
local
function
d
(
t
,
e
)
a
.
stderr
:
write
(
t
)
a
.
stderr
:
write
(
t
)
i
.
exit
(
e
)
o
.
exit
(
e
)
end
end
local
function
a
(
e
)
local
function
a
(
e
)
r
(
"Unknown option `-"
..
d
(
"Unknown option `-"
..
(
#
e
>
1
and
"-"
or
""
)
..
e
..
"'\n"
,
1
)
(
#
e
>
1
and
"-"
or
""
)
..
e
..
"'\n"
,
1
)
end
end
local
function
l
(
t
,
e
)
local
function
l
(
t
,
e
)
if
not
t
[
e
]
then
if
not
t
[
e
]
then
a
(
e
)
a
(
e
)
end
end
while
o
(
t
[
e
])
==
"string"
do
while
n
(
t
[
e
])
==
"string"
do
e
=
t
[
e
]
e
=
t
[
e
]
if
not
t
[
e
]
then
if
not
t
[
e
]
then
a
(
e
)
a
(
e
)
...
@@ -34,11 +34,11 @@ end
...
@@ -34,11 +34,11 @@ end
function
get_ordered_opts
(
n
,
a
,
s
)
function
get_ordered_opts
(
n
,
a
,
s
)
local
t
=
1
local
t
=
1
local
e
=
1
local
e
=
1
local
i
=
{}
local
o
=
{}
local
h
=
{}
local
h
=
{}
local
o
=
c
(
a
)
local
i
=
i
(
a
)
for
e
,
t
in
d
(
s
)
do
for
t
,
e
in
r
(
s
)
do
o
[
e
]
=
t
i
[
t
]
=
e
end
end
while
t
<=#
n
do
while
t
<=#
n
do
local
a
=
n
[
t
]
local
a
=
n
[
t
]
...
@@ -51,46 +51,46 @@ elseif a:sub(1,2)=="--"then
...
@@ -51,46 +51,46 @@ elseif a:sub(1,2)=="--"then
local
s
=
a
:
find
(
"="
,
1
,
true
)
local
s
=
a
:
find
(
"="
,
1
,
true
)
if
s
then
if
s
then
local
t
=
a
:
sub
(
3
,
s
-
1
)
local
t
=
a
:
sub
(
3
,
s
-
1
)
t
=
l
(
o
,
t
)
t
=
l
(
i
,
t
)
if
o
[
t
]
==
0
then
if
i
[
t
]
==
0
then
r
(
"Bad usage of option `"
..
a
..
"'\n"
,
1
)
d
(
"Bad usage of option `"
..
a
..
"'\n"
,
1
)
end
end
h
[
e
]
=
a
:
sub
(
s
+
1
)
h
[
e
]
=
a
:
sub
(
s
+
1
)
i
[
e
]
=
t
o
[
e
]
=
t
else
else
local
s
=
a
:
sub
(
3
)
local
s
=
a
:
sub
(
3
)
s
=
l
(
o
,
s
)
s
=
l
(
i
,
s
)
if
o
[
s
]
==
0
then
if
i
[
s
]
==
0
then
i
[
e
]
=
s
o
[
e
]
=
s
else
else
if
t
==#
n
then
if
t
==#
n
then
r
(
"Missed value for option `"
..
a
..
"'\n"
,
1
)
d
(
"Missed value for option `"
..
a
..
"'\n"
,
1
)
end
end
h
[
e
]
=
n
[
t
+
1
]
h
[
e
]
=
n
[
t
+
1
]
i
[
e
]
=
s
o
[
e
]
=
s
t
=
t
+
1
t
=
t
+
1
end
end
end
end
e
=
e
+
1
e
=
e
+
1
elseif
a
:
sub
(
1
,
1
)
==
"-"
then
elseif
a
:
sub
(
1
,
1
)
==
"-"
then
local
s
local
s
for
d
=
2
,
a
:
len
()
do
for
r
=
2
,
a
:
len
()
do
local
s
=
l
(
o
,
a
:
sub
(
d
,
d
))
local
s
=
l
(
i
,
a
:
sub
(
r
,
r
))
if
o
[
s
]
==
0
then
if
i
[
s
]
==
0
then
i
[
e
]
=
s
o
[
e
]
=
s
e
=
e
+
1
e
=
e
+
1
elseif
a
:
len
()
==
d
then
elseif
a
:
len
()
==
r
then
if
t
==#
n
then
if
t
==#
n
then
r
(
"Missed value for option `-"
..
s
..
"'\n"
,
1
)
d
(
"Missed value for option `-"
..
s
..
"'\n"
,
1
)
end
end
h
[
e
]
=
n
[
t
+
1
]
h
[
e
]
=
n
[
t
+
1
]
i
[
e
]
=
s
o
[
e
]
=
s
t
=
t
+
1
t
=
t
+
1
e
=
e
+
1
e
=
e
+
1
break
break
else
else
h
[
e
]
=
a
:
sub
(
d
+
1
)
h
[
e
]
=
a
:
sub
(
r
+
1
)
i
[
e
]
=
s
o
[
e
]
=
s
e
=
e
+
1
e
=
e
+
1
break
break
end
end
...
@@ -100,16 +100,16 @@ break
...
@@ -100,16 +100,16 @@ break
end
end
t
=
t
+
1
t
=
t
+
1
end
end
return
i
,
t
,
h
return
o
,
t
,
h
end
end
function
get_opts
(
a
,
t
,
o
)
function
get_opts
(
t
,
o
,
a
)
local
e
=
{}
local
e
=
{}
local
t
,
i
,
o
=
get_ordered_opts
(
a
,
t
,
o
)
local
a
,
i
,
t
=
get_ordered_opts
(
t
,
o
,
a
)
for
t
,
a
in
u
(
t
)
do
for
a
,
o
in
u
(
a
)
do
if
o
[
t
]
then
if
t
[
a
]
then
e
[
a
]
=
o
[
t
]
e
[
o
]
=
t
[
a
]
else
else
e
[
a
]
=
1
e
[
o
]
=
1
end
end
end
end
return
e
,
i
return
e
,
i
...
@@ -176,22 +176,22 @@ die(t.." expected.");
...
@@ -176,22 +176,22 @@ die(t.." expected.");
end
end
return
e
;
return
e
;
end
end
function
range2bits
(
t
)
function
range2bits
(
e
)
local
e
=
t
[
1
];
local
t
=
e
[
1
];
local
a
=
t
[
2
];
local
a
=
e
[
2
];
local
t
;
local
e
;
if
(
math.abs
(
e
)
>
math.abs
(
a
))
then
if
(
math.abs
(
t
)
>
math.abs
(
a
))
then
t
=
math.abs
(
e
);
e
=
math.abs
(
t
);
else
else
t
=
math.abs
(
a
);
e
=
math.abs
(
a
);
end
end
local
t
=
math.ceil
(
math.log
(
t
)
/
math.log
(
2
));
local
e
=
math.ceil
(
math.log
(
e
)
/
math.log
(
2
));
if
(
e
<
0
)
then
if
(
t
<
0
)
then
t
=
t
+
1
;
e
=
e
+
1
;
end
end
return
t
;
return
e
;
end
end
function
calc_size
(
e
,
a
)
function
calc_size
(
e
,
t
)
if
(
e
.
type
==
MONOSTABLE
or
e
.
type
==
BIT
)
then
if
(
e
.
type
==
MONOSTABLE
or
e
.
type
==
BIT
)
then
e
.
size
=
1
;
e
.
size
=
1
;
elseif
(
e
.
type
==
SLV
or
e
.
type
==
PASS_THROUGH
)
then
elseif
(
e
.
type
==
SLV
or
e
.
type
==
PASS_THROUGH
)
then
...
@@ -212,7 +212,7 @@ end
...
@@ -212,7 +212,7 @@ end
elseif
(
e
.
type
==
ENUM
)
then
elseif
(
e
.
type
==
ENUM
)
then
die
(
"ENUM-type fields are not yet supported. Sorry :("
);
die
(
"ENUM-type fields are not yet supported. Sorry :("
);
end
end
a
.
total_size
=
a
.
total_size
+
e
.
size
;
t
.
total_size
=
t
.
total_size
+
e
.
size
;
end
end
function
foreach_reg
(
t
,
a
,
e
)
function
foreach_reg
(
t
,
a
,
e
)
if
(
e
==
nil
)
then
if
(
e
==
nil
)
then
...
@@ -286,15 +286,15 @@ if(t==e)then return true;end
...
@@ -286,15 +286,15 @@ if(t==e)then return true;end
end
end
return
false
;
return
false
;
end
end
function
inset
(
e
,
t
)
function
inset
(
t
,
e
)
for
a
,
t
in
ipairs
(
t
)
do
if
(
e
==
t
)
then
return
true
;
end
end
for
a
,
e
in
ipairs
(
e
)
do
if
(
t
==
e
)
then
return
true
;
end
end
return
false
;
return
false
;
end
end
function
csel
(
a
,
e
,
t
)
function
csel
(
e
,
t
,
a
)
if
(
a
)
then
if
(
e
)
then
return
e
;
else
return
t
;
return
t
;
else
return
a
;
end
end
end
end
function
check_field_types
(
e
)
function
check_field_types
(
e
)
...
@@ -318,13 +318,13 @@ return e;
...
@@ -318,13 +318,13 @@ return e;
end
end
return
e
;
return
e
;
end
end
function
default_access
(
e
,
o
,
a
,
t
)
function
default_access
(
e
,
a
,
t
,
o
)
if
(
e
.
type
==
o
)
then
if
(
e
.
type
==
a
)
then
if
(
e
.
access_bus
==
nil
)
then
if
(
e
.
access_bus
==
nil
)
then
e
.
access_bus
=
a
;
e
.
access_bus
=
t
;
end
end
if
(
e
.
access_dev
==
nil
)
then
if
(
e
.
access_dev
==
nil
)
then
e
.
access_dev
=
t
;
e
.
access_dev
=
o
;
end
end
end
end
end
end
...
@@ -412,11 +412,11 @@ end);
...
@@ -412,11 +412,11 @@ end);
address_bus_width
=
o
+
a
;
address_bus_width
=
o
+
a
;
address_bus_select_bits
=
a
;
address_bus_select_bits
=
a
;
end
end
function
find_max
(
e
,
a
)
function
find_max
(
e
,
t
)
local
t
=
0
;
local
a
=
0
;
local
o
,
o
;
local
o
,
o
;
for
o
,
e
in
pairs
(
e
)
do
if
(
type
(
e
)
==
'table'
and
e
[
a
]
~=
nil
and
e
[
a
]
>
t
)
then
t
=
e
[
a
];
end
end
for
o
,
e
in
pairs
(
e
)
do
if
(
type
(
e
)
==
'table'
and
e
[
t
]
~=
nil
and
e
[
t
]
>
a
)
then
a
=
e
[
t
];
end
end
return
t
;
return
a
;
end
end
function
table_join
(
t
,
e
)
function
table_join
(
t
,
e
)
local
a
,
a
;
local
a
,
a
;
...
@@ -426,32 +426,32 @@ table.insert(t,e);
...
@@ -426,32 +426,32 @@ table.insert(t,e);
end
end
end
end
function
tree_2_table
(
e
)
function
tree_2_table
(
e
)
local
t
=
{};
local
a
=
{};
foreach_reg
({
TYPE_REG
,
TYPE_RAM
,
TYPE_FIFO
,
TYPE_IRQ
},
function
(
a
)
foreach_reg
({
TYPE_REG
,
TYPE_RAM
,
TYPE_FIFO
,
TYPE_IRQ
},
function
(
t
)
if
(
a
[
e
]
~=
nil
)
then
if
(
t
[
e
]
~=
nil
)
then
if
(
type
(
a
[
e
])
==
'table'
)
then
if
(
type
(
t
[
e
])
==
'table'
)
then
table_join
(
t
,
a
[
e
]);
table_join
(
a
,
t
[
e
]);
else
else
table.insert
(
t
,
a
[
e
]);
table.insert
(
a
,
t
[
e
]);
end
end
end
end
foreach_subfield
(
a
,
function
(
a
,
o
)
foreach_subfield
(
t
,
function
(
t
,
o
)
if
(
a
[
e
]
~=
nil
)
then
if
(
t
[
e
]
~=
nil
)
then
if
(
type
(
a
[
e
])
==
'table'
)
then
if
(
type
(
t
[
e
])
==
'table'
)
then
table_join
(
t
,
a
[
e
]);
table_join
(
a
,
t
[
e
]);
else
else
table.insert
(
t
,
a
[
e
]);
table.insert
(
a
,
t
[
e
]);
end
end
end
end
end
);
end
);
end
);
end
);
return
t
;
return
a
;
end
end
function
remove_duplicates
(
a
)
function
remove_duplicates
(
a
)
function
count_entries
(
a
,
t
)
function
count_entries
(
t
,
a
)
local
o
,
o
,
e
;
local
o
,
o
,
e
;
e
=
0
;
e
=
0
;
for
o
,
a
in
ipairs
(
a
)
do
if
(
a
==
t
)
then
e
=
e
+
1
;
end
end
for
o
,
t
in
ipairs
(
t
)
do
if
(
t
==
a
)
then
e
=
e
+
1
;
end
end
return
e
;
return
e
;
end
end
local
e
=
{};
local
e
=
{};
...
@@ -465,37 +465,37 @@ return e;
...
@@ -465,37 +465,37 @@ return e;
end
end
function
wbgen_count_subblocks
()
function
wbgen_count_subblocks
()
local
o
=
0
;
local
o
=
0
;
local
t
=
0
;
local
a
=
0
;
local
a
=
0
;
local
e
=
0
;
local
e
=
0
;
local
t
=
0
;
foreach_reg
({
TYPE_RAM
},
function
(
e
)
o
=
o
+
1
;
end
);
foreach_reg
({
TYPE_RAM
},
function
(
e
)
o
=
o
+
1
;
end
);
foreach_reg
({
TYPE_REG
},
function
(
t
)
e
=
e
+
1
;
end
);
foreach_reg
({
TYPE_REG
},
function
(
e
)
a
=
a
+
1
;
end
);
foreach_reg
({
TYPE_FIFO
},
function
(
e
)
a
=
a
+
1
;
end
);
foreach_reg
({
TYPE_FIFO
},
function
(
e
)
t
=
t
+
1
;
end
);
foreach_reg
({
TYPE_IRQ
},
function
(
e
)
t
=
t
+
1
;
end
);
foreach_reg
({
TYPE_IRQ
},
function
(
t
)
e
=
e
+
1
;
end
);
periph
.
ramcount
=
o
;
periph
.
ramcount
=
o
;
periph
.
fifocount
=
a
;
periph
.
fifocount
=
t
;
periph
.
regcount
=
e
;
periph
.
regcount
=
a
;
periph
.
irqcount
=
t
;
periph
.
irqcount
=
e
;
if
(
o
+
a
+
e
+
t
==
0
)
then
if
(
o
+
t
+
a
+
e
==
0
)
then
die
(
"Can't generate an empty peripheral. Define some regs, RAMs, FIFOs or IRQs, please..."
);
die
(
"Can't generate an empty peripheral. Define some regs, RAMs, FIFOs or IRQs, please..."
);
end
end
end
end
function
deepcopy
(
i
)
function
deepcopy
(
i
)
local
o
=
{}
local
o
=
{}
local
function
a
(
e
)
local
function
t
(
e
)
if
type
(
e
)
~=
"table"
then
if
type
(
e
)
~=
"table"
then
return
e
return
e
elseif
o
[
e
]
then
elseif
o
[
e
]
then
return
o
[
e
]
return
o
[
e
]
end
end
local
t
=
{}
local
a
=
{}
o
[
e
]
=
t
o
[
e
]
=
a
for
e
,
o
in
pairs
(
e
)
do
for
o
,
e
in
pairs
(
e
)
do
t
[
a
(
e
)]
=
a
(
o
)
a
[
t
(
o
)]
=
t
(
e
)
end
end
return
setmetatable
(
t
,
getmetatable
(
e
))
return
setmetatable
(
a
,
getmetatable
(
e
))
end
end
return
a
(
i
)
return
t
(
i
)
end
end
function
va
(
a
,
t
)
function
va
(
a
,
t
)
local
e
=
{};
local
e
=
{};
...
@@ -504,27 +504,27 @@ e.dst=a;
...
@@ -504,27 +504,27 @@ e.dst=a;
e
.
src
=
t
;
e
.
src
=
t
;
return
e
;
return
e
;
end
end
function
vi
(
o
,
t
,
a
)
function
vi
(
t
,
a
,
o
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"index"
;
e
.
t
=
"index"
;
e
.
name
=
o
;
e
.
name
=
t
;
e
.
h
=
t
;
e
.
h
=
a
;
e
.
l
=
a
;
e
.
l
=
o
;
return
e
;
return
e
;
end
end
function
vinstance
(
t
,
a
,
o
)
function
vinstance
(
t
,
o
,
a
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"instance"
;
e
.
t
=
"instance"
;
e
.
name
=
t
;
e
.
name
=
t
;
e
.
component
=
a
;
e
.
component
=
o
;
e
.
maps
=
o
;
e
.
maps
=
a
;
return
e
;
return
e
;
end
end
function
vpm
(
a
,
t
)
function
vpm
(
t
,
a
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"portmap"
;
e
.
t
=
"portmap"
;
e
.
to
=
a
;
e
.
to
=
t
;
e
.
from
=
t
;
e
.
from
=
a
;
return
e
;
return
e
;
end
end
function
vgm
(
t
,
a
)
function
vgm
(
t
,
a
)
...
@@ -541,19 +541,19 @@ e.slist=t;
...
@@ -541,19 +541,19 @@ e.slist=t;
e
.
code
=
a
;
e
.
code
=
a
;
return
e
;
return
e
;
end
end
function
vsyncprocess
(
a
,
t
,
o
)
function
vsyncprocess
(
o
,
a
,
t
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"syncprocess"
;
e
.
t
=
"syncprocess"
;
e
.
clk
=
a
;
e
.
clk
=
o
;
e
.
rst
=
t
;
e
.
rst
=
a
;
e
.
code
=
o
;
e
.
code
=
t
;
return
e
;
return
e
;
end
end
function
vreset
(
a
,
t
)
function
vreset
(
t
,
a
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"reset"
;
e
.
t
=
"reset"
;
e
.
level
=
a
;
e
.
level
=
t
;
e
.
code
=
t
;
e
.
code
=
a
;
return
e
;
return
e
;
end
end
function
vposedge
(
t
)
function
vposedge
(
t
)
...
@@ -570,6 +570,13 @@ e.code=a;
...
@@ -570,6 +570,13 @@ e.code=a;
e
.
code_else
=
o
;
e
.
code_else
=
o
;
return
e
;
return
e
;
end
end
function
vgenerate_if
(
a
,
t
)
local
e
=
{};
e
.
t
=
"generate_if"
;
e
.
cond
=
{
a
};
e
.
code
=
t
;
return
e
;
end
function
vequal
(
a
,
t
)
function
vequal
(
a
,
t
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"eq"
;
e
.
t
=
"eq"
;
...
@@ -597,18 +604,18 @@ e.t="not";
...
@@ -597,18 +604,18 @@ e.t="not";
e
.
a
=
t
;
e
.
a
=
t
;
return
e
;
return
e
;
end
end
function
vswitch
(
t
,
a
)
function
vswitch
(
a
,
t
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"switch"
;
e
.
t
=
"switch"
;
e
.
a
=
t
;
e
.
a
=
a
;
e
.
code
=
a
;
e
.
code
=
t
;
return
e
;
return
e
;
end
end
function
vcase
(
a
,
t
)
function
vcase
(
t
,
a
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"case"
;
e
.
t
=
"case"
;
e
.
a
=
a
;
e
.
a
=
t
;
e
.
code
=
t
;
e
.
code
=
a
;
return
e
;
return
e
;
end
end
function
vcasedefault
(
t
)
function
vcasedefault
(
t
)
...
@@ -623,11 +630,11 @@ e.t="comment";
...
@@ -623,11 +630,11 @@ e.t="comment";
e
.
str
=
t
;
e
.
str
=
t
;
return
e
;
return
e
;
end
end
function
vsub
(
t
,
a
)
function
vsub
(
a
,
t
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"sub"
;
e
.
t
=
"sub"
;
e
.
a
=
t
;
e
.
a
=
a
;
e
.
b
=
a
;
e
.
b
=
t
;
return
e
;
return
e
;
end
end
function
vothers
(
t
)
function
vothers
(
t
)
...
@@ -646,23 +653,23 @@ local e={}
...
@@ -646,23 +653,23 @@ local e={}
e
.
t
=
"undefined"
;
e
.
t
=
"undefined"
;
return
e
;
return
e
;
end
end
function
signal
(
t
,
o
,
a
,
i
)
function
signal
(
t
,
a
,
o
,
i
)
local
e
=
{}
local
e
=
{}
e
.
comment
=
i
;
e
.
comment
=
i
;
e
.
type
=
t
;
e
.
type
=
t
;
e
.
range
=
o
;
e
.
range
=
a
;
e
.
name
=
a
;
e
.
name
=
o
;
return
e
;
return
e
;
end
end
VPORT_WB
=
1
;
VPORT_WB
=
1
;
VPORT_REG
=
2
;
VPORT_REG
=
2
;
function
port
(
a
,
n
,
s
,
i
,
o
,
t
)
function
port
(
a
,
i
,
o
,
n
,
s
,
t
)
local
e
=
{}
local
e
=
{}
e
.
comment
=
o
;
e
.
comment
=
s
;
e
.
type
=
a
;
e
.
type
=
a
;
e
.
range
=
n
;
e
.
range
=
i
;
e
.
name
=
i
;
e
.
name
=
n
;
e
.
dir
=
s
;
e
.
dir
=
o
;
if
(
t
~=
nil
)
then
if
(
t
~=
nil
)
then
if
(
t
==
VPORT_WB
)
then
if
(
t
==
VPORT_WB
)
then
e
.
is_wb
=
true
;
e
.
is_wb
=
true
;
...
@@ -713,15 +720,35 @@ table_join(e,cgen_build_clock_list());
...
@@ -713,15 +720,35 @@ table_join(e,cgen_build_clock_list());
table_join
(
e
,
tree_2_table
(
"ports"
));
table_join
(
e
,
tree_2_table
(
"ports"
));
return
e
;
return
e
;
end
end
function
cgen_build_optional_list
()
local
a
=
{}
local
o
=
{}
local
e
=
1
for
i
,
t
in
pairs
(
tree_2_table
(
"optional"
))
do
if
a
[
t
]
==
nil
then
a
[
t
]
=
1
o
[
e
]
=
t
e
=
e
+
1
end
end
return
o
end
function
cgen_find_sigport
(
e
)
function
cgen_find_sigport
(
e
)
for
a
,
t
in
pairs
(
g_portlist
)
do
if
(
e
==
t
.
name
)
then
return
t
;
end
end
for
a
,
t
in
pairs
(
g_portlist
)
do
if
(
e
==
t
.
name
)
then
return
t
;
end
end
for
a
,
t
in
pairs
(
g_siglist
)
do
if
(
e
==
t
.
name
)
then
return
t
;
end
end
for
a
,
t
in
pairs
(
g_siglist
)
do
if
(
e
==
t
.
name
)
then
return
t
;
end
end
for
a
,
t
in
pairs
(
g_optlist
)
do
if
(
e
==
t
)
then
local
e
=
{}
e
.
type
=
INTEGER
;
e
.
name
=
t
;
return
e
;
end
end
die
(
"cgen internal error: undefined signal '"
..
e
..
"'"
);
die
(
"cgen internal error: undefined signal '"
..
e
..
"'"
);
return
nil
;
return
nil
;
end
end
function
cgen_build_signals_ports
()
function
cgen_build_signals_ports
()
g_portlist
=
cgen_build_portlist
();
g_portlist
=
cgen_build_portlist
();
g_siglist
=
cgen_build_siglist
();
g_siglist
=
cgen_build_siglist
();
g_optlist
=
cgen_build_optional_list
();
end
end
cur_indent
=
0
;
cur_indent
=
0
;
function
indent_zero
()
function
indent_zero
()
...
@@ -799,23 +826,23 @@ function gen_vhdl_bin_literal(i,a)
...
@@ -799,23 +826,23 @@ function gen_vhdl_bin_literal(i,a)
if
(
a
==
1
)
then
if
(
a
==
1
)
then
return
string.format
(
"'%d'"
,
csel
(
i
==
0
,
0
,
1
));
return
string.format
(
"'%d'"
,
csel
(
i
==
0
,
0
,
1
));
end
end
local
t
=
'
\"
'
;
local
e
=
'
\"
'
;
local
s
,
o
,
n
,
e
;
local
s
,
o
,
n
,
t
;
o
=
i
;
o
=
i
;
e
=
math.pow
(
2
,
a
-
1
);
t
=
math.pow
(
2
,
a
-
1
);
if
(
i
==
nil
)
then
if
(
i
==
nil
)
then
for
e
=
1
,
a
do
for
t
=
1
,
a
do
t
=
t
..
"X"
;
e
=
e
..
"X"
;
end
end
else
else
for
a
=
1
,
a
do
for
a
=
1
,
a
do
n
=
math.floor
(
o
/
e
);
n
=
math.floor
(
o
/
t
);
t
=
t
..
csel
(
n
>
0
,
"1"
,
"0"
);
e
=
e
..
csel
(
n
>
0
,
"1"
,
"0"
);
o
=
o
%
e
;
o
=
o
%
t
;
e
=
e
/
2
;
t
=
t
/
2
;
end
end
end
end
return
t
..
'
\"
'
;
return
e
..
'
\"
'
;
end
end
function
strip_periph_prefix
(
e
)
function
strip_periph_prefix
(
e
)
return
string.gsub
(
e
,
"^"
..
periph
.
hdl_prefix
..
"\_"
,
""
)
return
string.gsub
(
e
,
"^"
..
periph
.
hdl_prefix
..
"\_"
,
""
)
...
@@ -956,6 +983,23 @@ emit("\n");
...
@@ -956,6 +983,23 @@ emit("\n");
end
end
emit
(
"entity "
..
periph
.
hdl_entity
..
" is"
);
emit
(
"entity "
..
periph
.
hdl_entity
..
" is"
);
indent_right
();
indent_right
();
if
(
table
.
getn
(
g_optlist
)
~=
0
)
then
emit
(
"generic ("
);
indent_right
();
emiti
()
for
t
,
e
in
pairs
(
g_optlist
)
do
emiti
();
emitx
(
e
..
" : integer := 1"
);
if
(
t
~=
table
.
getn
(
g_optlist
))
then
emit
(
";"
)
else
emit
(
");"
)
end
end
indent_left
();
end
indent_left
();
indent_right
();
emit
(
"port ("
);
emit
(
"port ("
);
indent_right
();
indent_right
();
for
a
=
1
,
table
.
getn
(
g_portlist
)
do
for
a
=
1
,
table
.
getn
(
g_portlist
)
do
...
@@ -964,7 +1008,6 @@ if(options.hdl_reg_style=="signals"or not e.is_reg_port)then
...
@@ -964,7 +1008,6 @@ if(options.hdl_reg_style=="signals"or not e.is_reg_port)then
if
(
e
.
comment
~=
nil
and
e
.
comment
~=
""
)
then
if
(
e
.
comment
~=
nil
and
e
.
comment
~=
""
)
then
emitx
(
"-- "
..
e
.
comment
..
"
\n
"
);
emitx
(
"-- "
..
e
.
comment
..
"
\n
"
);
end
end
print
(
e
.
name
..
" "
..
e
.
type
)
local
t
=
string.format
(
"%-40s : %-6s %s"
,
e
.
name
,
e
.
dir
,
fieldtype_2_vhdl
[
e
.
type
]);
local
t
=
string.format
(
"%-40s : %-6s %s"
,
e
.
name
,
e
.
dir
,
fieldtype_2_vhdl
[
e
.
type
]);
if
(
e
.
range
>
1
or
e
.
type
==
SLV
)
then
if
(
e
.
range
>
1
or
e
.
type
==
SLV
)
then
t
=
t
..
"("
..
(
e
.
range
-
1
)
..
" downto 0)"
;
t
=
t
..
"("
..
(
e
.
range
-
1
)
..
" downto 0)"
;
...
@@ -1049,22 +1092,22 @@ emit("end process;");
...
@@ -1049,22 +1092,22 @@ emit("end process;");
emit
(
""
);
emit
(
""
);
emit
(
""
);
emit
(
""
);
end
end
function
cgen_vhdl_combprocess
(
e
)
function
cgen_vhdl_combprocess
(
t
)
local
t
=
true
;
local
e
=
true
;
emiti
();
emiti
();
emitx
(
"process ("
);
emitx
(
"process ("
);
for
a
,
e
in
pairs
(
e
.
slist
)
do
for
a
,
t
in
pairs
(
t
.
slist
)
do
if
(
t
)
then
if
(
e
)
then
t
=
false
;
e
=
false
;
else
else
emitx
(
", "
);
emitx
(
", "
);
end
end
emitx
(
e
);
emitx
(
t
);
end
end
emit
(
")"
);
emit
(
")"
);
emit
(
"begin"
);
emit
(
"begin"
);
indent_right
();
indent_right
();
recurse
(
e
.
code
);
recurse
(
t
.
code
);
indent_left
();
indent_left
();
emit
(
"end process;"
);
emit
(
"end process;"
);
emit
(
""
);
emit
(
""
);
...
@@ -1194,13 +1237,26 @@ indent_right();recurse(e.code);indent_left();
...
@@ -1194,13 +1237,26 @@ indent_right();recurse(e.code);indent_left();
emit
(
"end if;"
);
emit
(
"end if;"
);
end
end
end
end
function
cgen_vhdl_not
(
t
)
function
cgen_vhdl_generate_if
(
e
)
local
e
=
node_typesize
(
t
.
a
);
if
(
g_gen_block_count
==
nil
)
then
g_gen_block_count
=
0
else
g_gen_block_count
=
g_gen_block_count
+
1
end
gname
=
string.format
(
"genblock_%d"
,
g_gen_block_count
)
emiti
();
emitx
(
gname
..
": if ("
);
recurse
(
e
.
cond
);
emitx
(
") generate\n"
);
indent_right
();
recurse
(
e
.
code
);
indent_left
();
emit
(
"end generate "
..
gname
..
";"
);
end
function
cgen_vhdl_not
(
e
)
local
t
=
node_typesize
(
e
.
a
);
emitx
(
"not "
);
emitx
(
"not "
);
if
(
e
.
type
==
EXPRESSION
)
then
if
(
t
.
type
==
EXPRESSION
)
then
emitx
(
"("
);
recurse
({
t
.
a
});
emitx
(
")"
);
emitx
(
"("
);
recurse
({
e
.
a
});
emitx
(
")"
);
else
else
emitx
(
gen_subrange
(
e
));
emitx
(
gen_subrange
(
t
));
end
end
end
end
function
cgen_vhdl_binary_op
(
t
)
function
cgen_vhdl_binary_op
(
t
)
...
@@ -1253,25 +1309,25 @@ end
...
@@ -1253,25 +1309,25 @@ end
emit
(
"end case;"
);
emit
(
"end case;"
);
end
end
function
cgen_vhdl_instance
(
t
)
function
cgen_vhdl_instance
(
t
)
local
a
=
0
;
local
o
=
0
;
local
o
=
0
;
local
a
=
0
;
local
e
;
local
e
;
emit
(
t
.
name
..
" : "
..
t
.
component
);
emit
(
t
.
name
..
" : "
..
t
.
component
);
for
t
,
e
in
pairs
(
t
.
maps
)
do
for
t
,
e
in
pairs
(
t
.
maps
)
do
if
(
e
.
t
==
"genmap"
)
then
if
(
e
.
t
==
"genmap"
)
then
o
=
o
+
1
;
elseif
(
e
.
t
==
"portmap"
)
then
a
=
a
+
1
;
a
=
a
+
1
;
elseif
(
e
.
t
==
"portmap"
)
then
o
=
o
+
1
;
end
end
end
end
if
(
o
>
0
)
then
if
(
a
>
0
)
then
indent_right
();
indent_right
();
emit
(
"generic map ("
);
emit
(
"generic map ("
);
indent_right
();
indent_right
();
e
=
1
;
e
=
1
;
for
a
,
t
in
pairs
(
t
.
maps
)
do
for
o
,
t
in
pairs
(
t
.
maps
)
do
if
(
t
.
t
==
"genmap"
)
then
if
(
t
.
t
==
"genmap"
)
then
emit
(
string.format
(
"%-20s => %s"
,
t
.
to
,
t
.
from
)
..
csel
(
e
==
o
,
""
,
","
));
emit
(
string.format
(
"%-20s => %s"
,
t
.
to
,
t
.
from
)
..
csel
(
e
==
a
,
""
,
","
));
e
=
e
+
1
;
e
=
e
+
1
;
end
end
end
end
...
@@ -1279,15 +1335,15 @@ indent_left();
...
@@ -1279,15 +1335,15 @@ indent_left();
emit
(
")"
);
emit
(
")"
);
indent_left
();
indent_left
();
end
end
if
(
a
>
0
)
then
if
(
o
>
0
)
then
indent_right
();
indent_right
();
emit
(
"port map ("
);
emit
(
"port map ("
);
indent_right
();
indent_right
();
e
=
1
;
e
=
1
;
for
o
,
t
in
pairs
(
t
.
maps
)
do
for
a
,
t
in
pairs
(
t
.
maps
)
do
if
(
t
.
t
==
"portmap"
)
then
if
(
t
.
t
==
"portmap"
)
then
local
o
=
node_typesize
(
t
.
from
);
local
a
=
node_typesize
(
t
.
from
);
emit
(
string.format
(
"%-20s => %s"
,
t
.
to
,
gen_subrange
(
o
))
..
csel
(
e
==
a
,
""
,
","
));
emit
(
string.format
(
"%-20s => %s"
,
t
.
to
,
gen_subrange
(
a
))
..
csel
(
e
==
o
,
""
,
","
));
e
=
e
+
1
;
e
=
e
+
1
;
end
end
end
end
...
@@ -1310,6 +1366,7 @@ local t={
...
@@ -1310,6 +1366,7 @@ local t={
[
"combprocess"
]
=
cgen_vhdl_combprocess
;
[
"combprocess"
]
=
cgen_vhdl_combprocess
;
[
"assign"
]
=
cgen_vhdl_assign
;
[
"assign"
]
=
cgen_vhdl_assign
;
[
"if"
]
=
cgen_vhdl_if
;
[
"if"
]
=
cgen_vhdl_if
;
[
"generate_if"
]
=
cgen_vhdl_generate_if
;
[
"eq"
]
=
cgen_vhdl_binary_op
;
[
"eq"
]
=
cgen_vhdl_binary_op
;
[
"add"
]
=
cgen_vhdl_binary_op
;
[
"add"
]
=
cgen_vhdl_binary_op
;
[
"sub"
]
=
cgen_vhdl_binary_op
;
[
"sub"
]
=
cgen_vhdl_binary_op
;
...
@@ -1419,7 +1476,7 @@ function cgen_verilog_ending()
...
@@ -1419,7 +1476,7 @@ function cgen_verilog_ending()
indent_left
();
indent_left
();
emit
(
"endmodule"
);
emit
(
"endmodule"
);
end
end
function
cgen_generate_verilog_code
(
n
)
function
cgen_generate_verilog_code
(
i
)
local
a
=
false
;
local
a
=
false
;
function
find_code
(
e
,
t
)
function
find_code
(
e
,
t
)
for
a
,
e
in
ipairs
(
e
)
do
if
((
e
.
t
~=
nil
)
and
(
e
.
t
==
t
))
then
return
e
;
end
end
for
a
,
e
in
ipairs
(
e
)
do
if
((
e
.
t
~=
nil
)
and
(
e
.
t
==
t
))
then
return
e
;
end
end
...
@@ -1566,13 +1623,13 @@ indent_left();
...
@@ -1566,13 +1623,13 @@ indent_left();
emit
(
"end"
);
emit
(
"end"
);
end
end
end
end
function
cgen_verilog_not
(
t
)
function
cgen_verilog_not
(
e
)
local
e
=
node_typesize
(
t
.
a
);
local
t
=
node_typesize
(
e
.
a
);
emitx
(
"! "
);
emitx
(
"! "
);
if
(
e
.
type
==
EXPRESSION
)
then
if
(
t
.
type
==
EXPRESSION
)
then
emitx
(
"("
);
recurse
({
t
.
a
});
emitx
(
")"
);
emitx
(
"("
);
recurse
({
e
.
a
});
emitx
(
")"
);
else
else
emitx
(
gen_subrange
(
e
));
emitx
(
gen_subrange
(
t
));
end
end
end
end
function
cgen_verilog_binary_op
(
e
)
function
cgen_verilog_binary_op
(
e
)
...
@@ -1624,29 +1681,29 @@ end
...
@@ -1624,29 +1681,29 @@ end
end
end
emit
(
"endcase"
);
emit
(
"endcase"
);
end
end
function
cgen_verilog_instance
(
a
)
function
cgen_verilog_instance
(
t
)
local
a
=
0
;
local
o
=
0
;
local
o
=
0
;
local
i
=
0
;
local
e
;
local
e
;
emitx
(
a
.
component
..
" "
);
emitx
(
t
.
component
..
" "
);
for
t
,
e
in
pairs
(
a
.
maps
)
do
for
t
,
e
in
pairs
(
t
.
maps
)
do
if
(
e
.
t
==
"genmap"
)
then
if
(
e
.
t
==
"genmap"
)
then
i
=
i
+
1
;
elseif
(
e
.
t
==
"portmap"
)
then
o
=
o
+
1
;
o
=
o
+
1
;
elseif
(
e
.
t
==
"portmap"
)
then
a
=
a
+
1
;
end
end
end
end
if
(
i
>
0
)
then
if
(
o
>
0
)
then
indent_right
();
indent_right
();
emit
(
"# ("
);
emit
(
"# ("
);
indent_right
();
indent_right
();
e
=
1
;
e
=
1
;
for
t
,
a
in
pairs
(
a
.
maps
)
do
for
t
,
a
in
pairs
(
t
.
maps
)
do
if
(
a
.
t
==
"genmap"
)
then
if
(
a
.
t
==
"genmap"
)
then
local
t
=
a
.
from
;
local
t
=
a
.
from
;
if
(
t
==
"true"
)
then
t
=
1
;
if
(
t
==
"true"
)
then
t
=
1
;
elseif
(
t
==
"false"
)
then
t
=
0
;
end
elseif
(
t
==
"false"
)
then
t
=
0
;
end
emit
(
string.format
(
".%-20s(%s)"
,
a
.
to
,
t
)
..
csel
(
e
==
i
,
""
,
","
));
emit
(
string.format
(
".%-20s(%s)"
,
a
.
to
,
t
)
..
csel
(
e
==
o
,
""
,
","
));
e
=
e
+
1
;
e
=
e
+
1
;
end
end
end
end
...
@@ -1654,15 +1711,15 @@ indent_left();
...
@@ -1654,15 +1711,15 @@ indent_left();
emit
(
")"
);
emit
(
")"
);
indent_left
();
indent_left
();
end
end
if
(
o
>
0
)
then
if
(
a
>
0
)
then
indent_right
();
indent_right
();
emit
(
a
.
name
..
" ( "
);
emit
(
t
.
name
..
" ( "
);
indent_right
();
indent_right
();
e
=
1
;
e
=
1
;
for
a
,
t
in
pairs
(
a
.
maps
)
do
for
o
,
t
in
pairs
(
t
.
maps
)
do
if
(
t
.
t
==
"portmap"
)
then
if
(
t
.
t
==
"portmap"
)
then
local
a
=
node_typesize
(
t
.
from
);
local
o
=
node_typesize
(
t
.
from
);
emit
(
string.format
(
".%-20s(%s)"
,
t
.
to
,
gen_subrange
(
a
))
..
csel
(
e
==
o
,
""
,
","
));
emit
(
string.format
(
".%-20s(%s)"
,
t
.
to
,
gen_subrange
(
o
))
..
csel
(
e
==
a
,
""
,
","
));
e
=
e
+
1
;
e
=
e
+
1
;
end
end
end
end
...
@@ -1729,17 +1786,17 @@ end
...
@@ -1729,17 +1786,17 @@ end
end
end
cgen_new_snippet
();
cgen_new_snippet
();
cgen_verilog_header
();
cgen_verilog_header
();
local
a
=
cgen_get_snippet
();
local
e
=
cgen_get_snippet
();
cgen_new_snippet
();
cgen_new_snippet
();
recurse
(
n
);
recurse
(
i
);
cgen_verilog_ending
();
cgen_verilog_ending
();
local
t
=
cgen_get_snippet
();
local
a
=
cgen_get_snippet
();
cgen_new_snippet
();
cgen_new_snippet
();
cgen_verilog_module
();
cgen_verilog_module
();
local
e
=
cgen_get_snippet
();
local
t
=
cgen_get_snippet
();
cgen_write_snippet
(
a
);
cgen_write_snippet
(
e
);
cgen_write_snippet
(
e
);
cgen_write_snippet
(
t
);
cgen_write_snippet
(
t
);
cgen_write_snippet
(
a
);
end
end
function
cgen_c_field_define
(
e
,
a
)
function
cgen_c_field_define
(
e
,
a
)
local
t
;
local
t
;
...
@@ -1776,7 +1833,7 @@ dbg("DOCREG: ",e.name,e.num_fields);
...
@@ -1776,7 +1833,7 @@ dbg("DOCREG: ",e.name,e.num_fields);
if
(
e
.
num_fields
~=
nil
and
e
.
num_fields
>
0
)
then
if
(
e
.
num_fields
~=
nil
and
e
.
num_fields
>
0
)
then
emit
(
""
);
emit
(
""
);
emit
(
"/* definitions for register: "
..
e
.
name
..
" */"
);
emit
(
"/* definitions for register: "
..
e
.
name
..
" */"
);
foreach_subfield
(
e
,
function
(
e
,
t
)
cgen_c_field_define
(
e
,
t
)
end
);
foreach_subfield
(
e
,
function
(
t
,
e
)
cgen_c_field_define
(
t
,
e
)
end
);
end
end
end
);
end
);
foreach_reg
({
TYPE_RAM
},
function
(
e
)
foreach_reg
({
TYPE_RAM
},
function
(
e
)
...
@@ -1912,21 +1969,21 @@ end
...
@@ -1912,21 +1969,21 @@ end
end
end
return
e
;
return
e
;
end
end
function
htable_tdstyle
(
a
,
t
,
e
)
function
htable_tdstyle
(
e
,
a
,
t
)
tbl
.
data
[
a
][
t
].
style
=
e
;
tbl
.
data
[
e
][
a
].
style
=
t
;
end
end
function
htable_trstyle
(
e
,
a
,
t
)
function
htable_trstyle
(
t
,
a
,
e
)
tbl
.
data
[
e
].
style
=
t
;
tbl
.
data
[
t
].
style
=
e
;
end
end
function
htable_frame
(
e
,
t
,
o
,
a
)
function
htable_frame
(
a
,
o
,
t
,
e
)
if
(
a
==
nil
)
then
if
(
e
==
nil
)
then
e
.
data
[
t
][
o
].
extra
=
'style="border: solid 1px black;"'
;
a
.
data
[
o
][
t
].
extra
=
'style="border: solid 1px black;"'
;
else
else
e
.
data
[
t
][
o
].
extra
=
'style="border-left: solid 1px black; border-top: solid 1px black; border-bottom: solid 1px black;'
;
a
.
data
[
o
][
t
].
extra
=
'style="border-left: solid 1px black; border-top: solid 1px black; border-bottom: solid 1px black;'
;
e
.
data
[
t
][
a
].
extra
=
'style="border-right: solid 1px black; border-top: solid 1px black; border-bottom: solid 1px black;'
;
a
.
data
[
o
][
e
].
extra
=
'style="border-right: solid 1px black; border-top: solid 1px black; border-bottom: solid 1px black;'
;
if
(
a
>
o
+
1
)
then
if
(
e
>
t
+
1
)
then
for
a
=
o
+
1
,
a
-
1
do
for
e
=
t
+
1
,
e
-
1
do
e
.
data
[
t
][
a
].
extra
=
'border-top: solid 1px black; border-bottom: solid 1px black;'
;
a
.
data
[
o
][
e
].
extra
=
'border-top: solid 1px black; border-bottom: solid 1px black;'
;
end
end
end
end
end
end
...
@@ -1964,11 +2021,11 @@ emit("</tr>");
...
@@ -1964,11 +2021,11 @@ emit("</tr>");
end
end
emit
(
"</table>"
);
emit
(
"</table>"
);
end
end
function
has_any_ports
(
t
)
function
has_any_ports
(
e
)
local
e
=
false
;
local
t
=
false
;
if
(
t
.
ports
~=
nil
)
then
return
true
;
end
if
(
e
.
ports
~=
nil
)
then
return
true
;
end
foreach_subfield
(
t
,
function
(
t
)
if
(
t
.
ports
~=
nil
)
then
e
=
true
;
end
end
);
foreach_subfield
(
e
,
function
(
e
)
if
(
e
.
ports
~=
nil
)
then
t
=
true
;
end
end
);
return
e
;
return
t
;
end
end
function
htable_add_row
(
e
,
a
)
function
htable_add_row
(
e
,
a
)
if
(
a
>
e
.
rows
)
then
if
(
a
>
e
.
rows
)
then
...
@@ -1982,27 +2039,27 @@ end
...
@@ -1982,27 +2039,27 @@ end
e
.
rows
=
a
;
e
.
rows
=
a
;
end
end
end
end
function
hlink
(
t
,
e
)
function
hlink
(
e
,
t
)
return
'<A href="'
..
t
..
'">'
..
e
..
'</a>'
;
return
'<A href="'
..
e
..
'">'
..
t
..
'</a>'
;
end
end
function
hitem
(
e
)
function
hitem
(
e
)
return
'<li>'
..
e
..
'</li>'
;
return
'<li>'
..
e
..
'</li>'
;
end
end
function
hanchor
(
t
,
e
)
function
hanchor
(
e
,
t
)
return
'<a name="'
..
t
..
'">'
..
e
..
'</a>'
;
return
'<a name="'
..
e
..
'">'
..
t
..
'</a>'
;
end
end
doc_toc
=
{};
doc_toc
=
{};
function
hsection
(
t
,
a
,
o
)
function
hsection
(
a
,
t
,
o
)
local
e
=
{};
local
e
=
{};
local
i
=
0
;
local
i
=
0
;
e
.
id_mangled
=
"sect_"
..
t
..
"_"
..
a
;
e
.
id_mangled
=
"sect_"
..
a
..
"_"
..
t
;
e
.
key
=
t
*
1e3
+
a
;
e
.
key
=
a
*
1e3
+
t
;
if
(
a
~=
0
)
then
if
(
t
~=
0
)
then
e
.
level
=
2
;
e
.
level
=
2
;
e
.
id
=
t
..
"."
..
a
..
"."
;
e
.
id
=
a
..
"."
..
t
..
"."
;
else
else
e
.
level
=
1
;
e
.
level
=
1
;
e
.
id
=
t
..
"."
;
e
.
id
=
a
..
"."
;
end
end
e
.
name
=
o
;
e
.
name
=
o
;
table.insert
(
doc_toc
,
e
);
table.insert
(
doc_toc
,
e
);
...
@@ -2051,23 +2108,23 @@ end
...
@@ -2051,23 +2108,23 @@ end
end
);
end
);
cgen_doc_symbol
(
t
);
cgen_doc_symbol
(
t
);
end
end
function
cgen_doc_mem_symbol
(
a
)
function
cgen_doc_mem_symbol
(
t
)
local
t
=
{};
local
a
=
{};
for
e
,
a
in
pairs
(
a
.
ports
)
do
for
e
,
t
in
pairs
(
t
.
ports
)
do
local
e
=
a
;
local
e
=
t
;
if
(
string.find
(
a
.
name
,
"_i"
)
~=
nil
)
then
if
(
string.find
(
t
.
name
,
"_i"
)
~=
nil
)
then
e
.
is_wb
=
true
;
e
.
is_wb
=
true
;
else
else
e
.
is_wb
=
false
;
e
.
is_wb
=
false
;
end
end
table.insert
(
t
,
e
);
table.insert
(
a
,
e
);
end
end
if
(
a
.
clock
~=
nil
)
then
if
(
t
.
clock
~=
nil
)
then
local
e
=
port
(
BIT
,
0
,
"in"
,
a
.
clock
);
local
e
=
port
(
BIT
,
0
,
"in"
,
t
.
clock
);
e
.
is_wb
=
true
;
e
.
is_wb
=
true
;
table.insert
(
t
,
e
);
table.insert
(
a
,
e
);
end
end
cgen_doc_symbol
(
t
);
cgen_doc_symbol
(
a
);
end
end
function
cgen_doc_symbol
(
i
)
function
cgen_doc_symbol
(
i
)
local
t
=
htable_new
(
3
,
5
);
local
t
=
htable_new
(
3
,
5
);
...
@@ -2125,7 +2182,7 @@ local e=periph.description;
...
@@ -2125,7 +2182,7 @@ local e=periph.description;
if
(
e
==
nil
)
then
e
=
""
;
end
if
(
e
==
nil
)
then
e
=
""
;
end
emit
(
'<p>'
..
string.gsub
(
e
,
"
\n
"
,
"<br>"
)
..
'</p>'
);
emit
(
'<p>'
..
string.gsub
(
e
,
"
\n
"
,
"<br>"
)
..
'</p>'
);
emit
(
'<h3>Contents:</h3>'
);
emit
(
'<h3>Contents:</h3>'
);
table.sort
(
doc_toc
,
function
(
t
,
e
)
return
t
.
key
<
e
.
key
;
end
);
table.sort
(
doc_toc
,
function
(
e
,
t
)
return
e
.
key
<
t
.
key
;
end
);
for
t
,
e
in
ipairs
(
doc_toc
)
do
for
t
,
e
in
ipairs
(
doc_toc
)
do
emit
(
'<span style="margin-left: '
..
((
e
.
level
-
1
)
*
20
)
..
'px; ">'
..
e
.
id
..
" "
..
hlink
(
'#'
..
e
.
id_mangled
,
e
.
name
)
..
'</span><br/>'
);
emit
(
'<span style="margin-left: '
..
((
e
.
level
-
1
)
*
20
)
..
'px; ">'
..
e
.
id
..
" "
..
hlink
(
'#'
..
e
.
id_mangled
,
e
.
name
)
..
'</span><br/>'
);
end
end
...
@@ -2162,28 +2219,28 @@ e[5].text=string.upper(t.c_prefix);
...
@@ -2162,28 +2219,28 @@ e[5].text=string.upper(t.c_prefix);
i
=
not
i
;
i
=
not
i
;
end
end
end
);
end
);
foreach_reg
({
TYPE_RAM
},
function
(
e
)
foreach_reg
({
TYPE_RAM
},
function
(
t
)
if
(
e
.
full_hdl_prefix
~=
nil
)
then
if
(
t
.
full_hdl_prefix
~=
nil
)
then
htable_add_row
(
o
,
a
);
htable_add_row
(
o
,
a
);
local
t
=
o
.
data
[
a
];
a
=
a
+
1
;
local
e
=
o
.
data
[
a
];
a
=
a
+
1
;
t
.
style
=
csel
(
i
,
"tr_odd"
,
"tr_even"
);
e
.
style
=
csel
(
i
,
"tr_odd"
,
"tr_even"
);
t
[
1
].
style
=
"td_code"
;
e
[
1
].
style
=
"td_code"
;
t
[
1
].
text
=
string.format
(
"0x%x - 0x%x"
,
e
.
base
,
e
.
base
+
math.pow
(
2
,
e
.
wrap_bits
)
*
e
.
size
-
1
);
e
[
1
].
text
=
string.format
(
"0x%x - 0x%x"
,
t
.
base
,
t
.
base
+
math.pow
(
2
,
t
.
wrap_bits
)
*
t
.
size
-
1
);
t
[
2
].
text
=
"MEM"
;
e
[
2
].
text
=
"MEM"
;
t
[
3
].
text
=
hlink
(
"#"
..
string.upper
(
e
.
c_prefix
),
e
.
name
);
e
[
3
].
text
=
hlink
(
"#"
..
string.upper
(
t
.
c_prefix
),
t
.
name
);
t
[
4
].
style
=
"td_code"
;
e
[
4
].
style
=
"td_code"
;
t
[
4
].
text
=
e
.
full_hdl_prefix
;
e
[
4
].
text
=
t
.
full_hdl_prefix
;
t
[
5
].
style
=
"td_code"
;
e
[
5
].
style
=
"td_code"
;
t
[
5
].
text
=
string.upper
(
e
.
c_prefix
);
e
[
5
].
text
=
string.upper
(
t
.
c_prefix
);
i
=
not
i
;
i
=
not
i
;
end
end
end
);
end
);
htable_emit
(
o
);
htable_emit
(
o
);
end
end
function
find_field_by_offset
(
e
,
a
)
function
find_field_by_offset
(
e
,
t
)
local
t
=
nil
;
local
a
=
nil
;
foreach_subfield
(
e
,
function
(
e
)
if
(
a
>=
e
.
offset
and
a
<=
(
e
.
offset
+
e
.
size
-
1
))
then
t
=
e
;
end
end
);
foreach_subfield
(
e
,
function
(
e
)
if
(
t
>=
e
.
offset
and
t
<=
(
e
.
offset
+
e
.
size
-
1
))
then
a
=
e
;
end
end
);
return
t
;
return
a
;
end
end
function
cgen_doc_fieldtable
(
h
,
i
)
function
cgen_doc_fieldtable
(
h
,
i
)
local
e
=
70
;
local
e
=
70
;
...
@@ -2344,25 +2401,25 @@ if(t.description~=nil)then
...
@@ -2344,25 +2401,25 @@ if(t.description~=nil)then
emit
(
"<p>"
..
string.gsub
(
t
.
description
,
"
\n
"
,
"<br>"
)
..
"</p>"
);
emit
(
"<p>"
..
string.gsub
(
t
.
description
,
"
\n
"
,
"<br>"
)
..
"</p>"
);
end
end
end
end
function
cgen_generate_documentation
()
function
cgen_generate_
html_
documentation
()
cgen_new_snippet
();
cgen_doc_hdl_symbol
();
local
i
=
cgen_get_snippet
();
cgen_new_snippet
();
cgen_doc_hdl_symbol
();
local
i
=
cgen_get_snippet
();
cgen_new_snippet
();
cgen_new_snippet
();
emit
(
hsection
(
3
,
0
,
"Register description"
));
emit
(
hsection
(
3
,
0
,
"Register description"
));
foreach_reg
({
TYPE_REG
},
function
(
e
)
if
(
e
.
no_docu
==
nil
or
e
.
no_docu
==
false
)
then
cgen_doc_reg
(
e
);
end
end
);
foreach_reg
({
TYPE_REG
},
function
(
e
)
if
(
e
.
no_docu
==
nil
or
e
.
no_docu
==
false
)
then
cgen_doc_reg
(
e
);
end
end
);
local
o
=
cgen_get_snippet
();
local
o
=
cgen_get_snippet
();
local
t
=
""
;
local
a
=
""
;
if
(
periph
.
ramcount
>
0
)
then
if
(
periph
.
ramcount
>
0
)
then
emit
(
hsection
(
4
,
0
,
"Memory blocks"
));
emit
(
hsection
(
4
,
0
,
"Memory blocks"
));
cgen_new_snippet
();
cgen_new_snippet
();
foreach_reg
({
TYPE_RAM
},
function
(
e
)
if
(
e
.
no_docu
==
nil
or
e
.
no_docu
==
false
)
then
cgen_doc_ram
(
e
);
end
end
);
foreach_reg
({
TYPE_RAM
},
function
(
e
)
if
(
e
.
no_docu
==
nil
or
e
.
no_docu
==
false
)
then
cgen_doc_ram
(
e
);
end
end
);
t
=
cgen_get_snippet
();
a
=
cgen_get_snippet
();
end
end
local
a
=
""
;
local
t
=
""
;
if
(
periph
.
irqcount
>
0
)
then
if
(
periph
.
irqcount
>
0
)
then
cgen_new_snippet
();
cgen_new_snippet
();
emit
(
hsection
(
5
,
0
,
"Interrupts"
));
emit
(
hsection
(
5
,
0
,
"Interrupts"
));
foreach_reg
({
TYPE_IRQ
},
function
(
e
)
if
(
e
.
no_docu
==
nil
or
e
.
no_docu
==
false
)
then
cgen_doc_irq
(
e
);
end
end
);
foreach_reg
({
TYPE_IRQ
},
function
(
e
)
if
(
e
.
no_docu
==
nil
or
e
.
no_docu
==
false
)
then
cgen_doc_irq
(
e
);
end
end
);
a
=
cgen_get_snippet
();
t
=
cgen_get_snippet
();
end
end
cgen_new_snippet
();
cgen_new_snippet
();
cgen_doc_memmap
();
cgen_doc_memmap
();
...
@@ -2372,8 +2429,8 @@ cgen_doc_header_and_toc();
...
@@ -2372,8 +2429,8 @@ cgen_doc_header_and_toc();
emit
(
e
);
emit
(
e
);
emit
(
i
);
emit
(
i
);
emit
(
o
);
emit
(
o
);
emit
(
t
);
emit
(
a
);
emit
(
a
);
emit
(
t
);
emit
(
'</BODY>'
);
emit
(
'</BODY>'
);
emit
(
'</HTML>'
);
emit
(
'</HTML>'
);
cgen_write_current_snippet
();
cgen_write_current_snippet
();
...
@@ -3290,27 +3347,27 @@ e.ports={};
...
@@ -3290,27 +3347,27 @@ e.ports={};
e
.
acklen
=
1
;
e
.
acklen
=
1
;
e
.
read_code
=
{
va
(
vir
(
"rddata_reg"
,
e
),
e
.
value
);};
e
.
read_code
=
{
va
(
vir
(
"rddata_reg"
,
e
),
e
.
value
);};
end
end
function
fill_unused_bits
(
i
,
e
)
function
fill_unused_bits
(
o
,
e
)
local
a
=
{};
local
a
=
{};
local
t
=
{};
local
t
=
{};
local
o
=
true
;
local
i
=
true
;
foreach_subfield
(
e
,
function
(
e
,
t
)
foreach_subfield
(
e
,
function
(
e
,
t
)
if
(
e
.
type
==
SLV
or
e
.
type
==
SIGNED
or
e
.
type
==
UNSIGNED
or
e
.
type
==
CONSTANT
)
then
if
(
e
.
type
==
SLV
or
e
.
type
==
SIGNED
or
e
.
type
==
UNSIGNED
or
e
.
type
==
CONSTANT
)
then
for
e
=
e
.
offset
,(
e
.
offset
+
e
.
size
-
1
)
do
a
[
e
]
=
1
;
end
for
e
=
e
.
offset
,(
e
.
offset
+
e
.
size
-
1
)
do
a
[
e
]
=
1
;
end
elseif
(
e
.
type
==
BIT
or
e
.
type
==
MONOSTABLE
)
then
elseif
(
e
.
type
==
BIT
or
e
.
type
==
MONOSTABLE
)
then
a
[
e
.
offset
]
=
1
;
a
[
e
.
offset
]
=
1
;
end
end
if
(
e
.
access_bus
~=
WRITE_ONLY
)
then
o
=
false
;
end
if
(
e
.
access_bus
~=
WRITE_ONLY
)
then
i
=
false
;
end
end
);
end
);
if
(
o
)
then
if
(
i
)
then
for
e
=
0
,
DATA_BUS_WIDTH
-
1
do
for
e
=
0
,
DATA_BUS_WIDTH
-
1
do
table_join
(
t
,{
va
(
vi
(
i
,
e
),
vundefined
());});
table_join
(
t
,{
va
(
vi
(
o
,
e
),
vundefined
());});
end
end
return
t
;
return
t
;
end
end
for
e
=
0
,
DATA_BUS_WIDTH
-
1
do
for
e
=
0
,
DATA_BUS_WIDTH
-
1
do
if
(
a
[
e
]
==
nil
)
then
if
(
a
[
e
]
==
nil
)
then
table_join
(
t
,{
va
(
vi
(
i
,
e
),
vundefined
());});
table_join
(
t
,{
va
(
vi
(
o
,
e
),
vundefined
());});
end
end
end
end
return
t
;
return
t
;
...
@@ -3433,8 +3490,8 @@ end
...
@@ -3433,8 +3490,8 @@ end
function
wbgen_generate_eic
()
function
wbgen_generate_eic
()
if
(
periph
.
irqcount
==
0
)
then
return
;
end
if
(
periph
.
irqcount
==
0
)
then
return
;
end
local
t
=
0
;
local
t
=
0
;
local
s
=
{};
local
a
=
{};
local
i
=
{[
"__type"
]
=
TYPE_REG
;
local
o
=
{[
"__type"
]
=
TYPE_REG
;
[
"__blockindex"
]
=
1e6
;
[
"__blockindex"
]
=
1e6
;
[
"align"
]
=
8
;
[
"align"
]
=
8
;
[
"name"
]
=
"Interrupt disable register"
;
[
"name"
]
=
"Interrupt disable register"
;
...
@@ -3450,7 +3507,7 @@ signal(BIT,0,"eic_idr_write_int");};
...
@@ -3450,7 +3507,7 @@ signal(BIT,0,"eic_idr_write_int");};
[
"extra_code"
]
=
{
va
(
vi
(
"eic_idr_int"
,
periph
.
irqcount
-
1
,
0
),
vi
(
"wrdata_reg"
,
periph
.
irqcount
-
1
,
0
));};
[
"extra_code"
]
=
{
va
(
vi
(
"eic_idr_int"
,
periph
.
irqcount
-
1
,
0
),
vi
(
"wrdata_reg"
,
periph
.
irqcount
-
1
,
0
));};
[
"no_std_regbank"
]
=
true
;
[
"no_std_regbank"
]
=
true
;
};
};
local
a
=
{[
"__type"
]
=
TYPE_REG
;
local
i
=
{[
"__type"
]
=
TYPE_REG
;
[
"__blockindex"
]
=
1000001
;
[
"__blockindex"
]
=
1000001
;
[
"align"
]
=
1
;
[
"align"
]
=
1
;
[
"name"
]
=
"Interrupt enable register"
;
[
"name"
]
=
"Interrupt enable register"
;
...
@@ -3466,7 +3523,7 @@ signal(BIT,0,"eic_ier_write_int");};
...
@@ -3466,7 +3523,7 @@ signal(BIT,0,"eic_ier_write_int");};
[
"extra_code"
]
=
{
va
(
vi
(
"eic_ier_int"
,
periph
.
irqcount
-
1
,
0
),
vi
(
"wrdata_reg"
,
periph
.
irqcount
-
1
,
0
));};
[
"extra_code"
]
=
{
va
(
vi
(
"eic_ier_int"
,
periph
.
irqcount
-
1
,
0
),
vi
(
"wrdata_reg"
,
periph
.
irqcount
-
1
,
0
));};
[
"no_std_regbank"
]
=
true
;
[
"no_std_regbank"
]
=
true
;
};
};
local
o
=
{[
"__type"
]
=
TYPE_REG
;
local
n
=
{[
"__type"
]
=
TYPE_REG
;
[
"__blockindex"
]
=
1000002
;
[
"__blockindex"
]
=
1000002
;
[
"align"
]
=
1
;
[
"align"
]
=
1
;
[
"name"
]
=
"Interrupt status register"
;
[
"name"
]
=
"Interrupt status register"
;
...
@@ -3485,7 +3542,7 @@ signal(BIT,0,"eic_isr_write_int");};
...
@@ -3485,7 +3542,7 @@ signal(BIT,0,"eic_isr_write_int");};
[
"extra_code"
]
=
{
va
(
vi
(
"eic_isr_clear_int"
,
periph
.
irqcount
-
1
,
0
),
vi
(
"wrdata_reg"
,
periph
.
irqcount
-
1
,
0
));};
[
"extra_code"
]
=
{
va
(
vi
(
"eic_isr_clear_int"
,
periph
.
irqcount
-
1
,
0
),
vi
(
"wrdata_reg"
,
periph
.
irqcount
-
1
,
0
));};
[
"no_std_regbank"
]
=
true
;
[
"no_std_regbank"
]
=
true
;
};
};
local
n
=
{[
"__type"
]
=
TYPE_REG
;
local
s
=
{[
"__type"
]
=
TYPE_REG
;
[
"__blockindex"
]
=
1000003
;
[
"__blockindex"
]
=
1000003
;
[
"align"
]
=
1
;
[
"align"
]
=
1
;
[
"name"
]
=
"Interrupt mask register"
;
[
"name"
]
=
"Interrupt mask register"
;
...
@@ -3500,7 +3557,7 @@ local n={["__type"]=TYPE_REG;
...
@@ -3500,7 +3557,7 @@ local n={["__type"]=TYPE_REG;
foreach_reg
({
TYPE_IRQ
},
function
(
e
)
foreach_reg
({
TYPE_IRQ
},
function
(
e
)
e
.
index
=
t
;
e
.
index
=
t
;
t
=
t
+
1
;
t
=
t
+
1
;
table.insert
(
s
,{[
"index"
]
=
e
.
index
;[
"trigger"
]
=
e
.
trigger
;});
table.insert
(
a
,{[
"index"
]
=
e
.
index
;[
"trigger"
]
=
e
.
trigger
;});
fix_prefix
(
e
);
fix_prefix
(
e
);
local
t
=
{
local
t
=
{
[
"__blockindex"
]
=
e
.
index
;
[
"__blockindex"
]
=
e
.
index
;
...
@@ -3513,7 +3570,7 @@ local t={
...
@@ -3513,7 +3570,7 @@ local t={
[
"access_bus"
]
=
READ_WRITE
;
[
"access_bus"
]
=
READ_WRITE
;
[
"access_dev"
]
=
READ_WRITE
;
[
"access_dev"
]
=
READ_WRITE
;
};
};
local
s
=
{
local
a
=
{
[
"__blockindex"
]
=
e
.
index
;
[
"__blockindex"
]
=
e
.
index
;
[
"__type"
]
=
TYPE_FIELD
;
[
"__type"
]
=
TYPE_FIELD
;
[
"type"
]
=
BIT
;
[
"type"
]
=
BIT
;
...
@@ -3555,18 +3612,18 @@ end
...
@@ -3555,18 +3612,18 @@ end
if
(
e
.
mask_line
==
true
)
then
if
(
e
.
mask_line
==
true
)
then
table_join
(
e
.
ports
,{
port
(
BIT
,
0
,
"out"
,
e
.
full_prefix
..
"_mask_o"
);});
table_join
(
e
.
ports
,{
port
(
BIT
,
0
,
"out"
,
e
.
full_prefix
..
"_mask_o"
);});
end
end
table.insert
(
i
,
r
);
table.insert
(
o
,
r
);
table.insert
(
o
,
t
);
table.insert
(
n
,
t
);
table.insert
(
n
,
h
);
table.insert
(
s
,
h
);
table.insert
(
a
,
s
);
table.insert
(
i
,
a
);
end
);
end
);
add_global_signals
({
add_global_signals
({
signal
(
SLV
,
periph
.
irqcount
,
"irq_inputs_vector_int"
);
signal
(
SLV
,
periph
.
irqcount
,
"irq_inputs_vector_int"
);
});
});
table.insert
(
periph
,
o
);
table.insert
(
periph
,
i
);
table.insert
(
periph
,
i
);
table.insert
(
periph
,
a
);
table.insert
(
periph
,
s
);
table.insert
(
periph
,
n
);
table.insert
(
periph
,
n
);
table.insert
(
periph
,
o
);
local
e
=
{
vgm
(
"g_num_interrupts"
,
periph
.
irqcount
);
local
e
=
{
vgm
(
"g_num_interrupts"
,
periph
.
irqcount
);
vpm
(
"clk_i"
,
"clk_sys_i"
);
vpm
(
"clk_i"
,
"clk_sys_i"
);
vpm
(
"rst_n_i"
,
"rst_n_i"
);
vpm
(
"rst_n_i"
,
"rst_n_i"
);
...
@@ -3582,12 +3639,12 @@ vpm("reg_isr_i","eic_isr_clear_int");
...
@@ -3582,12 +3639,12 @@ vpm("reg_isr_i","eic_isr_clear_int");
vpm
(
"reg_isr_wr_stb_i"
,
"eic_isr_write_int"
);
vpm
(
"reg_isr_wr_stb_i"
,
"eic_isr_write_int"
);
vpm
(
"wb_irq_o"
,
"wb_int_o"
);
vpm
(
"wb_irq_o"
,
"wb_int_o"
);
};
};
local
a
;
local
o
;
for
o
,
t
in
ipairs
(
s
)
do
for
a
,
t
in
ipairs
(
a
)
do
table_join
(
e
,{
vgm
(
string.format
(
"g_irq%02x_mode"
,
t
.
index
),
t
.
trigger
)});
table_join
(
e
,{
vgm
(
string.format
(
"g_irq%02x_mode"
,
t
.
index
),
t
.
trigger
)});
a
=
o
;
o
=
a
;
end
end
for
t
=
a
,
31
do
for
t
=
o
,
31
do
table_join
(
e
,{
vgm
(
string.format
(
"g_irq%02x_mode"
,
t
),
0
)});
table_join
(
e
,{
vgm
(
string.format
(
"g_irq%02x_mode"
,
t
),
0
)});
end
end
local
t
=
{
vinstance
(
"eic_irq_controller_inst"
,
"wbgen2_eic"
,
e
);};
local
t
=
{
vinstance
(
"eic_irq_controller_inst"
,
"wbgen2_eic"
,
e
);};
...
@@ -3763,35 +3820,34 @@ local s={
...
@@ -3763,35 +3820,34 @@ local s={
[
"hdl_prefix"
]
=
e
.
hdl_prefix
..
"_CSR"
;
[
"hdl_prefix"
]
=
e
.
hdl_prefix
..
"_CSR"
;
[
"no_std_regbank"
]
=
true
;
[
"no_std_regbank"
]
=
true
;
};
};
function
gen_fifo_csr_field
(
d
,
n
,
t
,
a
,
h
,
o
,
r
,
i
)
function
gen_fifo_csr_field
(
a
,
i
,
t
,
r
,
h
,
o
,
d
,
n
)
print
(
"GenCSR Field "
..
t
);
if
(
e
.
flags_bus
==
nil
)
then
if
(
e
.
flags_bus
==
nil
)
then
return
;
return
;
end
end
if
inset
(
d
,
e
.
flags_bus
)
then
if
inset
(
a
,
e
.
flags_bus
)
then
local
t
=
{
local
t
=
{
[
"__type"
]
=
TYPE_FIELD
;
[
"__type"
]
=
TYPE_FIELD
;
[
"name"
]
=
t
;
[
"name"
]
=
t
;
[
"description"
]
=
a
;
[
"description"
]
=
r
;
[
"access_bus"
]
=
READ_ONLY
;
[
"access_bus"
]
=
READ_ONLY
;
[
"access_dev"
]
=
WRITE_ONLY
;
[
"access_dev"
]
=
WRITE_ONLY
;
[
"type"
]
=
o
;
[
"type"
]
=
o
;
[
"size"
]
=
h
;
[
"size"
]
=
h
;
[
"offset"
]
=
r
;
[
"offset"
]
=
d
;
[
"c_prefix"
]
=
n
;
[
"c_prefix"
]
=
i
;
[
"hdl_prefix"
]
=
n
;
[
"hdl_prefix"
]
=
i
;
[
"signals"
]
=
{};
[
"signals"
]
=
{};
[
"read_code"
]
=
{};
[
"read_code"
]
=
{};
[
"ack_len"
]
=
2
;
[
"ack_len"
]
=
2
;
};
};
local
a
=
e
.
full_prefix
..
"_"
..
n
..
"_int"
;
local
a
=
e
.
full_prefix
..
"_"
..
i
..
"_int"
;
if
(
i
==
nil
)
then
if
(
n
==
nil
)
then
i
=
true
n
=
true
else
else
i
=
false
n
=
false
end
end
if
(
i
)
then
if
(
n
)
then
table_join
(
e
.
maps
,{
vpm
(
e
.
nrdwr
..
"_"
..
n
..
"_o"
,
a
)});
table_join
(
e
.
maps
,{
vpm
(
e
.
nrdwr
..
"_"
..
i
..
"_o"
,
a
)});
end
end
table_join
(
t
.
signals
,{
signal
(
csel
(
o
==
MONOSTABLE
,
BIT
,
o
),
h
,
a
)});
table_join
(
t
.
signals
,{
signal
(
csel
(
o
==
MONOSTABLE
,
BIT
,
o
),
h
,
a
)});
if
(
o
==
BIT
)
then
if
(
o
==
BIT
)
then
...
@@ -3806,8 +3862,8 @@ t.write_code={vif(vequal(vi("rddata_reg",t.offset),1),{va(a,1)})};
...
@@ -3806,8 +3862,8 @@ t.write_code={vif(vequal(vi("rddata_reg",t.offset),1),{va(a,1)})};
t
.
ackgen_code
=
{
va
(
a
,
0
)}
t
.
ackgen_code
=
{
va
(
a
,
0
)}
end
end
table.insert
(
s
,
t
);
table.insert
(
s
,
t
);
elseif
(
i
)
then
elseif
(
n
)
then
table_join
(
e
.
maps
,{
vpm
(
e
.
nrdwr
..
"_"
..
n
..
"_o"
,
vopenpin
())});
table_join
(
e
.
maps
,{
vpm
(
e
.
nrdwr
..
"_"
..
i
..
"_o"
,
vopenpin
())});
end
end
end
end
gen_fifo_csr_field
(
FIFO_FULL
,
gen_fifo_csr_field
(
FIFO_FULL
,
...
@@ -3973,8 +4029,8 @@ foreach_reg(ALL_REG_TYPES,function(e)
...
@@ -3973,8 +4029,8 @@ foreach_reg(ALL_REG_TYPES,function(e)
gen_abstract_code
(
e
);
gen_abstract_code
(
e
);
end
);
end
);
local
n
=
{};
local
n
=
{};
local
i
=
{};
local
o
=
{};
local
o
=
{};
local
i
=
{};
foreach_field
(
function
(
e
,
t
)
foreach_field
(
function
(
e
,
t
)
table_join
(
n
,
e
.
reset_code_main
);
table_join
(
n
,
e
.
reset_code_main
);
end
);
end
);
...
@@ -3983,27 +4039,27 @@ table_join(n,e.reset_code_main);
...
@@ -3983,27 +4039,27 @@ table_join(n,e.reset_code_main);
end
);
end
);
foreach_reg
({
TYPE_REG
},
function
(
e
)
foreach_reg
({
TYPE_REG
},
function
(
e
)
foreach_subfield
(
e
,
function
(
e
,
t
)
foreach_subfield
(
e
,
function
(
e
,
t
)
table_join
(
i
,
e
.
ackgen_code
);
table_join
(
o
,
e
.
ackgen_code
);
table_join
(
o
,
e
.
ackgen_code_pre
);
table_join
(
i
,
e
.
ackgen_code_pre
);
end
);
end
);
table_join
(
i
,
e
.
ackgen_code
);
table_join
(
o
,
e
.
ackgen_code
);
table_join
(
o
,
e
.
ackgen_code_pre
);
table_join
(
i
,
e
.
ackgen_code_pre
);
end
);
end
);
local
e
=
{};
local
e
=
{};
foreach_reg
({
TYPE_REG
},
function
(
t
)
foreach_reg
({
TYPE_REG
},
function
(
t
)
local
i
=
find_max
(
t
,
"acklen"
);
local
i
=
find_max
(
t
,
"acklen"
);
local
o
=
{};
local
a
=
{};
local
a
=
{};
foreach_subfield
(
t
,
function
(
e
,
t
)
table_join
(
a
,
e
.
write_code
);
end
);
local
o
=
{};
foreach_subfield
(
t
,
function
(
e
,
t
)
table_join
(
o
,
e
.
read_code
);
end
);
foreach_subfield
(
t
,
function
(
e
,
t
)
table_join
(
o
,
e
.
write_code
);
end
);
foreach_subfield
(
t
,
function
(
e
,
t
)
table_join
(
a
,
e
.
read_code
);
end
);
local
n
=
fill_unused_bits
(
"rddata_reg"
,
t
);
local
n
=
fill_unused_bits
(
"rddata_reg"
,
t
);
table_join
(
a
,
t
.
write_code
);
table_join
(
o
,
t
.
write_code
);
table_join
(
o
,
t
.
read_code
);
table_join
(
a
,
t
.
read_code
);
local
a
=
{
local
a
=
{
vif
(
vequal
(
"wb_we_i"
,
1
),{
vif
(
vequal
(
"wb_we_i"
,
1
),{
a
,
});
o
,
o
,
});
a
,
n
n
};
};
if
(
not
(
t
.
dont_emit_ack_code
==
true
))
then
if
(
not
(
t
.
dont_emit_ack_code
==
true
))
then
...
@@ -4071,7 +4127,7 @@ vcomment("advance the ACK generator shift register");
...
@@ -4071,7 +4127,7 @@ vcomment("advance the ACK generator shift register");
va
(
vi
(
"ack_sreg"
,
MAX_ACK_LENGTH
-
2
,
0
),
vi
(
"ack_sreg"
,
MAX_ACK_LENGTH
-
1
,
1
));
va
(
vi
(
"ack_sreg"
,
MAX_ACK_LENGTH
-
2
,
0
),
vi
(
"ack_sreg"
,
MAX_ACK_LENGTH
-
1
,
1
));
va
(
vi
(
"ack_sreg"
,
MAX_ACK_LENGTH
-
1
),
0
);
va
(
vi
(
"ack_sreg"
,
MAX_ACK_LENGTH
-
1
),
0
);
vif
(
vequal
(
"ack_in_progress"
,
1
),{
vif
(
vequal
(
"ack_in_progress"
,
1
),{
vif
(
vequal
(
vi
(
"ack_sreg"
,
0
),
1
),{
i
;
va
(
"ack_in_progress"
,
0
);},
o
);
vif
(
vequal
(
vi
(
"ack_sreg"
,
0
),
1
),{
o
;
va
(
"ack_in_progress"
,
0
);},
i
);
},{
},{
e
e
});
});
...
@@ -4111,16 +4167,24 @@ table_join(e,{vcomment("Read & write lines decoder for RAMs");vcombprocess(a,t);
...
@@ -4111,16 +4167,24 @@ table_join(e,{vcomment("Read & write lines decoder for RAMs");vcombprocess(a,t);
else
else
table_join
(
e
,{
vcomment
(
"Drive the data output bus"
);
va
(
"wb_dat_o"
,
"rddata_reg"
)});
table_join
(
e
,{
vcomment
(
"Drive the data output bus"
);
va
(
"wb_dat_o"
,
"rddata_reg"
)});
end
end
foreach_reg
(
ALL_REG_TYPES
,
function
(
t
)
foreach_reg
(
ALL_REG_TYPES
,
function
(
t
)
ex_code
=
{}
if
(
t
.
extra_code
~=
nil
)
then
if
(
t
.
extra_code
~=
nil
)
then
table_join
(
e
,{
vcomment
(
"extra code for reg/fifo/mem: "
..
t
.
name
);});
table_join
(
e
x_code
,{
vcomment
(
"extra code for reg/fifo/mem: "
..
t
.
name
);});
table_join
(
e
,
t
.
extra_code
);
table_join
(
e
x_code
,
t
.
extra_code
);
end
end
foreach_subfield
(
t
,
function
(
t
,
a
)
foreach_subfield
(
t
,
if
(
t
.
extra_code
~=
nil
)
then
function
(
e
,
t
)
table_join
(
e
,{
vcomment
(
t
.
name
);
t
.
extra_code
});
if
(
e
.
extra_code
~=
nil
)
then
table_join
(
ex_code
,{
vcomment
(
e
.
name
);
e
.
extra_code
});
end
end
end
);
end
);
if
(
t
.
optional
==
nil
)
then
table_join
(
e
,
ex_code
)
else
table_join
(
e
,{
vgenerate_if
(
vnot
(
vequal
(
t
.
optional
,
0
)),
ex_code
)});
end
end
);
end
);
if
(
address_bus_width
>
0
)
then
if
(
address_bus_width
>
0
)
then
table_join
(
e
,{
va
(
"rwaddr_reg"
,
"wb_adr_i"
);});
table_join
(
e
,{
va
(
"rwaddr_reg"
,
"wb_adr_i"
);});
...
@@ -4171,7 +4235,7 @@ function usage_complete()
...
@@ -4171,7 +4235,7 @@ function usage_complete()
print
(
e
)
print
(
e
)
print
(
t
)
print
(
t
)
end
end
function
parse_args
(
a
)
function
parse_args
(
o
)
local
t
=
{
local
t
=
{
help
=
"h"
,
help
=
"h"
,
version
=
"v"
,
version
=
"v"
,
...
@@ -4186,8 +4250,8 @@ cstyle="s",
...
@@ -4186,8 +4250,8 @@ cstyle="s",
hstyle
=
"H"
hstyle
=
"H"
}
}
local
e
local
e
local
o
local
a
e
,
o
=
alt_getopt
.
get_opts
(
a
,
"hvC:D:K:l:V:s:f:H:p:"
,
t
)
e
,
a
=
alt_getopt
.
get_opts
(
o
,
"hvC:D:K:l:V:s:f:H:p:"
,
t
)
for
t
,
e
in
pairs
(
e
)
do
for
t
,
e
in
pairs
(
e
)
do
if
t
==
"h"
then
if
t
==
"h"
then
usage_complete
()
usage_complete
()
...
@@ -4224,11 +4288,11 @@ end
...
@@ -4224,11 +4288,11 @@ end
options
.
hdl_reg_style
=
e
options
.
hdl_reg_style
=
e
end
end
end
end
if
(
a
[
o
]
==
nil
)
then
if
(
o
[
a
]
==
nil
)
then
usage
()
usage
()
os.exit
(
0
)
os.exit
(
0
)
end
end
input_wb_file
=
a
[
o
];
input_wb_file
=
o
[
a
];
end
end
parse_args
(
arg
);
parse_args
(
arg
);
dofile
(
input_wb_file
);
dofile
(
input_wb_file
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment