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
6b6a3b7e
Commit
6b6a3b7e
authored
May 04, 2018
by
Dimitris Lampridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new option to drive unsused register bits to zero instead of X
parent
9acf1cd6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
122 additions
and
102 deletions
+122
-102
target_pipelined_wb.lua
target_pipelined_wb.lua
+1
-1
target_wishbone.lua
target_wishbone.lua
+1
-1
wbgen2
wbgen2
+106
-96
wbgen_main.lua
wbgen_main.lua
+6
-1
wbgen_regbank.lua
wbgen_regbank.lua
+8
-3
No files found.
target_pipelined_wb.lua
View file @
6b6a3b7e
...
@@ -105,7 +105,7 @@ function gen_bus_logic_pipelined_wb(mode)
...
@@ -105,7 +105,7 @@ function gen_bus_logic_pipelined_wb(mode)
foreach_subfield
(
reg
,
function
(
field
,
reg
)
table_join
(
wcode
,
field
.
write_code
);
end
);
foreach_subfield
(
reg
,
function
(
field
,
reg
)
table_join
(
wcode
,
field
.
write_code
);
end
);
foreach_subfield
(
reg
,
function
(
field
,
reg
)
table_join
(
rcode
,
field
.
read_code
);
end
);
foreach_subfield
(
reg
,
function
(
field
,
reg
)
table_join
(
rcode
,
field
.
read_code
);
end
);
local
padcode
=
fill_unused_bits
(
"rddata_reg"
,
reg
);
local
padcode
=
fill_unused_bits
(
"rddata_reg"
,
reg
,
options
.
unused_zeroes
);
table_join
(
wcode
,
reg
.
write_code
);
table_join
(
wcode
,
reg
.
write_code
);
...
...
target_wishbone.lua
View file @
6b6a3b7e
...
@@ -98,7 +98,7 @@ function gen_bus_logic_wishbone()
...
@@ -98,7 +98,7 @@ function gen_bus_logic_wishbone()
foreach_subfield
(
reg
,
function
(
field
,
reg
)
table_join
(
wcode
,
field
.
write_code
);
end
);
foreach_subfield
(
reg
,
function
(
field
,
reg
)
table_join
(
wcode
,
field
.
write_code
);
end
);
foreach_subfield
(
reg
,
function
(
field
,
reg
)
table_join
(
rcode
,
field
.
read_code
);
end
);
foreach_subfield
(
reg
,
function
(
field
,
reg
)
table_join
(
rcode
,
field
.
read_code
);
end
);
local
padcode
=
fill_unused_bits
(
"rddata_reg"
,
reg
);
local
padcode
=
fill_unused_bits
(
"rddata_reg"
,
reg
,
options
.
unused_zeroes
);
table_join
(
wcode
,
reg
.
write_code
);
table_join
(
wcode
,
reg
.
write_code
);
...
...
wbgen2
View file @
6b6a3b7e
...
@@ -104,12 +104,12 @@ return i,t,h
...
@@ -104,12 +104,12 @@ return i,t,h
end
end
function
get_opts
(
a
,
t
,
o
)
function
get_opts
(
a
,
t
,
o
)
local
e
=
{}
local
e
=
{}
local
t
,
i
,
o
=
get_ordered_opts
(
a
,
t
,
o
)
local
a
,
i
,
t
=
get_ordered_opts
(
a
,
t
,
o
)
for
a
,
t
in
u
(
t
)
do
for
a
,
o
in
u
(
a
)
do
if
o
[
a
]
then
if
t
[
a
]
then
e
[
t
]
=
o
[
a
]
e
[
o
]
=
t
[
a
]
else
else
e
[
t
]
=
1
e
[
o
]
=
1
end
end
end
end
return
e
,
i
return
e
,
i
...
@@ -191,7 +191,7 @@ e=e+1;
...
@@ -191,7 +191,7 @@ e=e+1;
end
end
return
e
;
return
e
;
end
end
function
calc_size
(
e
,
t
)
function
calc_size
(
e
,
a
)
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
t
.
total_size
=
t
.
total_size
+
e
.
size
;
a
.
total_size
=
a
.
total_size
+
e
.
size
;
end
end
function
foreach_reg
(
a
,
t
,
e
)
function
foreach_reg
(
a
,
t
,
e
)
if
(
e
==
nil
)
then
if
(
e
==
nil
)
then
...
@@ -292,15 +292,15 @@ if(t==e)then return true;end
...
@@ -292,15 +292,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
,
t
,
e
)
function
csel
(
t
,
e
,
a
)
if
(
a
)
then
if
(
t
)
then
return
t
;
else
return
e
;
return
e
;
else
return
a
;
end
end
end
end
function
check_field_types
(
e
)
function
check_field_types
(
e
)
...
@@ -324,13 +324,13 @@ return e;
...
@@ -324,13 +324,13 @@ return e;
end
end
return
e
;
return
e
;
end
end
function
default_access
(
e
,
t
,
o
,
a
)
function
default_access
(
e
,
t
,
a
,
o
)
if
(
e
.
type
==
t
)
then
if
(
e
.
type
==
t
)
then
if
(
e
.
access_bus
==
nil
)
then
if
(
e
.
access_bus
==
nil
)
then
e
.
access_bus
=
o
;
e
.
access_bus
=
a
;
end
end
if
(
e
.
access_dev
==
nil
)
then
if
(
e
.
access_dev
==
nil
)
then
e
.
access_dev
=
a
;
e
.
access_dev
=
o
;
end
end
end
end
end
end
...
@@ -404,19 +404,19 @@ end
...
@@ -404,19 +404,19 @@ end
function
assign_addresses
()
function
assign_addresses
()
local
o
=
math.max
(
max_ram_addr_bits
,
log2up
(
all_regs_size
));
local
o
=
math.max
(
max_ram_addr_bits
,
log2up
(
all_regs_size
));
local
e
=
num_rams
;
local
e
=
num_rams
;
local
a
=
0
;
local
t
=
0
;
if
(
all_regs_size
>
0
)
then
if
(
all_regs_size
>
0
)
then
e
=
e
+
1
;
e
=
e
+
1
;
end
end
local
t
=
log2up
(
e
);
local
a
=
log2up
(
e
);
foreach_reg
({
TYPE_REG
,
TYPE_FIFO
},
function
(
e
)
foreach_reg
({
TYPE_REG
,
TYPE_FIFO
},
function
(
e
)
if
(
e
.
__type
==
TYPE_REG
)
then
if
(
e
.
__type
==
TYPE_REG
)
then
e
.
base
=
align
(
e
,
a
);
e
.
base
=
align
(
e
,
t
);
a
=
e
.
base
+
1
;
t
=
e
.
base
+
1
;
end
end
end
);
end
);
address_bus_width
=
o
+
t
;
address_bus_width
=
o
+
a
;
address_bus_select_bits
=
t
;
address_bus_select_bits
=
a
;
end
end
function
find_max
(
e
,
a
)
function
find_max
(
e
,
a
)
local
t
=
0
;
local
t
=
0
;
...
@@ -453,15 +453,15 @@ end);
...
@@ -453,15 +453,15 @@ end);
end
);
end
);
return
t
;
return
t
;
end
end
function
remove_duplicates
(
a
)
function
remove_duplicates
(
o
)
function
count_entries
(
t
,
a
)
function
count_entries
(
a
,
t
)
local
o
,
o
,
e
;
local
o
,
o
,
e
;
e
=
0
;
e
=
0
;
for
o
,
t
in
ipairs
(
t
)
do
if
(
t
==
a
)
then
e
=
e
+
1
;
end
end
for
o
,
a
in
ipairs
(
a
)
do
if
(
a
==
t
)
then
e
=
e
+
1
;
end
end
return
e
;
return
e
;
end
end
local
e
=
{};
local
e
=
{};
for
a
,
t
in
ipairs
(
a
)
do
for
a
,
t
in
ipairs
(
o
)
do
local
a
=
count_entries
(
e
,
t
);
local
a
=
count_entries
(
e
,
t
);
if
(
a
==
0
)
then
if
(
a
==
0
)
then
table.insert
(
e
,
t
);
table.insert
(
e
,
t
);
...
@@ -488,20 +488,20 @@ end
...
@@ -488,20 +488,20 @@ end
end
end
function
deepcopy
(
i
)
function
deepcopy
(
i
)
local
o
=
{}
local
o
=
{}
local
function
t
(
e
)
local
function
a
(
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
a
=
{}
local
t
=
{}
o
[
e
]
=
a
o
[
e
]
=
t
for
e
,
o
in
pairs
(
e
)
do
for
e
,
o
in
pairs
(
e
)
do
a
[
t
(
e
)]
=
t
(
o
)
t
[
a
(
e
)]
=
a
(
o
)
end
end
return
setmetatable
(
a
,
getmetatable
(
e
))
return
setmetatable
(
t
,
getmetatable
(
e
))
end
end
return
t
(
i
)
return
a
(
i
)
end
end
function
va
(
a
,
t
)
function
va
(
a
,
t
)
local
e
=
{};
local
e
=
{};
...
@@ -510,20 +510,20 @@ e.dst=a;
...
@@ -510,20 +510,20 @@ e.dst=a;
e
.
src
=
t
;
e
.
src
=
t
;
return
e
;
return
e
;
end
end
function
vi
(
a
,
t
,
o
)
function
vi
(
a
,
o
,
t
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"index"
;
e
.
t
=
"index"
;
e
.
name
=
a
;
e
.
name
=
a
;
e
.
h
=
t
;
e
.
h
=
o
;
e
.
l
=
o
;
e
.
l
=
t
;
return
e
;
return
e
;
end
end
function
vinstance
(
t
,
o
,
a
)
function
vinstance
(
a
,
t
,
o
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"instance"
;
e
.
t
=
"instance"
;
e
.
name
=
t
;
e
.
name
=
a
;
e
.
component
=
o
;
e
.
component
=
t
;
e
.
maps
=
a
;
e
.
maps
=
o
;
return
e
;
return
e
;
end
end
function
vpm
(
t
,
a
)
function
vpm
(
t
,
a
)
...
@@ -533,11 +533,11 @@ e.to=t;
...
@@ -533,11 +533,11 @@ e.to=t;
e
.
from
=
a
;
e
.
from
=
a
;
return
e
;
return
e
;
end
end
function
vgm
(
a
,
t
)
function
vgm
(
t
,
a
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"genmap"
;
e
.
t
=
"genmap"
;
e
.
to
=
a
;
e
.
to
=
t
;
e
.
from
=
t
;
e
.
from
=
a
;
return
e
;
return
e
;
end
end
function
vcombprocess
(
a
,
t
)
function
vcombprocess
(
a
,
t
)
...
@@ -590,11 +590,11 @@ e.a=a;
...
@@ -590,11 +590,11 @@ e.a=a;
e
.
b
=
t
;
e
.
b
=
t
;
return
e
;
return
e
;
end
end
function
vand
(
t
,
a
)
function
vand
(
a
,
t
)
local
e
=
{};
local
e
=
{};
e
.
t
=
"and"
;
e
.
t
=
"and"
;
e
.
a
=
t
;
e
.
a
=
a
;
e
.
b
=
a
;
e
.
b
=
t
;
return
e
;
return
e
;
end
end
function
vor
(
a
,
t
)
function
vor
(
a
,
t
)
...
@@ -955,15 +955,15 @@ indent_left();
...
@@ -955,15 +955,15 @@ indent_left();
emit
(
""
);
emit
(
""
);
emit
(
"constant c_"
..
periph
.
hdl_prefix
..
"_"
..
o
..
"_registers_init_value: t_"
..
periph
.
hdl_prefix
..
"_"
..
o
..
"_registers := ("
);
emit
(
"constant c_"
..
periph
.
hdl_prefix
..
"_"
..
o
..
"_registers_init_value: t_"
..
periph
.
hdl_prefix
..
"_"
..
o
..
"_registers := ("
);
indent_right
();
indent_right
();
for
e
=
1
,
table
.
getn
(
a
)
do
for
t
=
1
,
table
.
getn
(
a
)
do
local
t
=
a
[
e
];
local
e
=
a
[
t
];
line
=
strip_periph_prefix
(
t
.
name
)
..
" => "
;
line
=
strip_periph_prefix
(
e
.
name
)
..
" => "
;
if
(
t
.
range
>
1
)
then
if
(
e
.
range
>
1
)
then
line
=
line
..
"(others => '0')"
line
=
line
..
"(others => '0')"
else
else
line
=
line
..
"'0'"
line
=
line
..
"'0'"
end
end
if
(
e
~=
table
.
getn
(
a
))
then
if
(
t
~=
table
.
getn
(
a
))
then
line
=
line
..
","
;
line
=
line
..
","
;
end
end
emit
(
line
);
emit
(
line
);
...
@@ -1269,13 +1269,13 @@ emitx(") generate\n");
...
@@ -1269,13 +1269,13 @@ emitx(") generate\n");
indent_right
();
recurse
(
e
.
code
);
indent_left
();
indent_right
();
recurse
(
e
.
code
);
indent_left
();
emit
(
"end generate "
..
gname
..
";"
);
emit
(
"end generate "
..
gname
..
";"
);
end
end
function
cgen_vhdl_not
(
e
)
function
cgen_vhdl_not
(
t
)
local
t
=
node_typesize
(
e
.
a
);
local
e
=
node_typesize
(
t
.
a
);
emitx
(
"not "
);
emitx
(
"not "
);
if
(
t
.
type
==
EXPRESSION
)
then
if
(
e
.
type
==
EXPRESSION
)
then
emitx
(
"("
);
recurse
({
e
.
a
});
emitx
(
")"
);
emitx
(
"("
);
recurse
({
t
.
a
});
emitx
(
")"
);
else
else
emitx
(
gen_subrange
(
t
));
emitx
(
gen_subrange
(
e
));
end
end
end
end
function
cgen_vhdl_binary_op
(
t
)
function
cgen_vhdl_binary_op
(
t
)
...
@@ -1655,23 +1655,23 @@ emitx(gen_subrange(t));
...
@@ -1655,23 +1655,23 @@ emitx(gen_subrange(t));
end
end
end
end
function
cgen_verilog_binary_op
(
e
)
function
cgen_verilog_binary_op
(
e
)
local
o
=
node_typesize
(
e
.
a
);
local
a
=
node_typesize
(
e
.
a
);
local
a
=
node_typesize
(
e
.
b
);
local
o
=
node_typesize
(
e
.
b
);
local
t
=
e
.
t
;
local
t
=
e
.
t
;
if
(
o
.
type
==
EXPRESSION
)
then
if
(
a
.
type
==
EXPRESSION
)
then
emitx
(
"("
);
recurse
({
e
.
a
});
emitx
(
")"
);
emitx
(
"("
);
recurse
({
e
.
a
});
emitx
(
")"
);
else
else
emitx
(
gen_subrange
(
o
));
emitx
(
gen_subrange
(
a
));
end
end
if
(
t
==
"eq"
)
then
emitx
(
" == "
);
end
if
(
t
==
"eq"
)
then
emitx
(
" == "
);
end
if
(
t
==
"and"
)
then
emitx
(
" && "
);
end
if
(
t
==
"and"
)
then
emitx
(
" && "
);
end
if
(
t
==
"or"
)
then
emitx
(
" || "
);
end
if
(
t
==
"or"
)
then
emitx
(
" || "
);
end
if
(
t
==
"sub"
)
then
emitx
(
" - "
);
end
if
(
t
==
"sub"
)
then
emitx
(
" - "
);
end
if
(
t
==
"add"
)
then
emitx
(
" + "
);
end
if
(
t
==
"add"
)
then
emitx
(
" + "
);
end
if
(
a
.
type
==
EXPRESSION
)
then
if
(
o
.
type
==
EXPRESSION
)
then
emitx
(
"("
);
recurse
({
e
.
b
});
emitx
(
")"
);
emitx
(
"("
);
recurse
({
e
.
b
});
emitx
(
")"
);
else
else
emitx
(
gen_subrange
(
a
));
emitx
(
gen_subrange
(
o
));
end
end
end
end
function
cgen_verilog_comment
(
e
)
function
cgen_verilog_comment
(
e
)
...
@@ -2055,11 +2055,11 @@ emit("</tr>");
...
@@ -2055,11 +2055,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
,
t
)
function
htable_add_row
(
e
,
t
)
if
(
t
>
e
.
rows
)
then
if
(
t
>
e
.
rows
)
then
...
@@ -2219,7 +2219,7 @@ local e=periph.description;
...
@@ -2219,7 +2219,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
(
e
,
t
)
return
e
.
key
<
t
.
key
;
end
);
table.sort
(
doc_toc
,
function
(
t
,
e
)
return
t
.
key
<
e
.
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
...
@@ -2274,10 +2274,10 @@ end
...
@@ -2274,10 +2274,10 @@ 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
;
...
@@ -2439,11 +2439,11 @@ emit("<p>"..string.gsub(t.description,"\n","<br>").."</p>");
...
@@ -2439,11 +2439,11 @@ emit("<p>"..string.gsub(t.description,"\n","<br>").."</p>");
end
end
end
end
function
cgen_generate_html_documentation
()
function
cgen_generate_html_documentation
()
cgen_new_snippet
();
cgen_doc_hdl_symbol
();
local
o
=
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
i
=
cgen_get_snippet
();
local
o
=
cgen_get_snippet
();
local
t
=
""
;
local
t
=
""
;
if
(
periph
.
ramcount
>
0
)
then
if
(
periph
.
ramcount
>
0
)
then
emit
(
hsection
(
4
,
0
,
"Memory blocks"
));
emit
(
hsection
(
4
,
0
,
"Memory blocks"
));
...
@@ -2464,8 +2464,8 @@ local e=cgen_get_snippet();
...
@@ -2464,8 +2464,8 @@ local e=cgen_get_snippet();
cgen_new_snippet
();
cgen_new_snippet
();
cgen_doc_header_and_toc
();
cgen_doc_header_and_toc
();
emit
(
e
);
emit
(
e
);
emit
(
o
);
emit
(
i
);
emit
(
i
);
emit
(
o
);
emit
(
t
);
emit
(
t
);
emit
(
a
);
emit
(
a
);
emit
(
'</BODY>'
);
emit
(
'</BODY>'
);
...
@@ -3402,7 +3402,7 @@ e.ports={};
...
@@ -3402,7 +3402,7 @@ 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
(
i
,
e
,
n
)
local
a
=
{};
local
a
=
{};
local
t
=
{};
local
t
=
{};
local
o
=
true
;
local
o
=
true
;
...
@@ -3414,15 +3414,20 @@ a[e.offset]=1;
...
@@ -3414,15 +3414,20 @@ a[e.offset]=1;
end
end
if
(
e
.
access_bus
~=
WRITE_ONLY
)
then
o
=
false
;
end
if
(
e
.
access_bus
~=
WRITE_ONLY
)
then
o
=
false
;
end
end
);
end
);
if
(
n
)
then
unused
=
0
;
else
unused
=
vundefined
();
end
if
(
o
)
then
if
(
o
)
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
(
i
,
e
),
unused
);});
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
(
i
,
e
),
unused
);});
end
end
end
end
return
t
;
return
t
;
...
@@ -3545,8 +3550,8 @@ end
...
@@ -3545,8 +3550,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
n
=
{[
"__type"
]
=
TYPE_REG
;
local
i
=
{[
"__type"
]
=
TYPE_REG
;
[
"__blockindex"
]
=
1e6
;
[
"__blockindex"
]
=
1e6
;
[
"align"
]
=
8
;
[
"align"
]
=
8
;
[
"name"
]
=
"Interrupt disable register"
;
[
"name"
]
=
"Interrupt disable register"
;
...
@@ -3578,7 +3583,7 @@ signal(BIT,0,"eic_ier_write_int");};
...
@@ -3578,7 +3583,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
a
=
{[
"__type"
]
=
TYPE_REG
;
local
n
=
{[
"__type"
]
=
TYPE_REG
;
[
"__blockindex"
]
=
1000002
;
[
"__blockindex"
]
=
1000002
;
[
"align"
]
=
1
;
[
"align"
]
=
1
;
[
"name"
]
=
"Interrupt status register"
;
[
"name"
]
=
"Interrupt status register"
;
...
@@ -3597,7 +3602,7 @@ signal(BIT,0,"eic_isr_write_int");};
...
@@ -3597,7 +3602,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
i
=
{[
"__type"
]
=
TYPE_REG
;
local
s
=
{[
"__type"
]
=
TYPE_REG
;
[
"__blockindex"
]
=
1000003
;
[
"__blockindex"
]
=
1000003
;
[
"align"
]
=
1
;
[
"align"
]
=
1
;
[
"name"
]
=
"Interrupt mask register"
;
[
"name"
]
=
"Interrupt mask register"
;
...
@@ -3612,7 +3617,7 @@ local i={["__type"]=TYPE_REG;
...
@@ -3612,7 +3617,7 @@ local i={["__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
;
...
@@ -3625,7 +3630,7 @@ local t={
...
@@ -3625,7 +3630,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
;
...
@@ -3667,18 +3672,18 @@ end
...
@@ -3667,18 +3672,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
(
n
,
h
);
table.insert
(
i
,
h
);
table.insert
(
a
,
t
);
table.insert
(
n
,
t
);
table.insert
(
i
,
r
);
table.insert
(
s
,
r
);
table.insert
(
o
,
s
);
table.insert
(
o
,
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
,
n
);
table.insert
(
periph
,
o
);
table.insert
(
periph
,
i
);
table.insert
(
periph
,
i
);
table.insert
(
periph
,
a
);
table.insert
(
periph
,
o
);
table.insert
(
periph
,
s
);
table.insert
(
periph
,
n
);
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"
);
...
@@ -3694,12 +3699,12 @@ vpm("reg_isr_i","eic_isr_clear_int");
...
@@ -3694,12 +3699,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
);};
...
@@ -4110,7 +4115,7 @@ local a={};
...
@@ -4110,7 +4115,7 @@ local a={};
local
o
=
{};
local
o
=
{};
foreach_subfield
(
t
,
function
(
e
,
t
)
table_join
(
o
,
e
.
write_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
);
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
,
options
.
unused_zeroes
);
table_join
(
o
,
t
.
write_code
);
table_join
(
o
,
t
.
write_code
);
table_join
(
a
,
t
.
read_code
);
table_join
(
a
,
t
.
read_code
);
local
a
=
{
local
a
=
{
...
@@ -4283,6 +4288,7 @@ options.lang="vhdl";
...
@@ -4283,6 +4288,7 @@ options.lang="vhdl";
options
.
c_reg_style
=
"struct"
;
options
.
c_reg_style
=
"struct"
;
options
.
hdl_reg_style
=
"signals"
;
options
.
hdl_reg_style
=
"signals"
;
options
.
doc_format
=
"html"
options
.
doc_format
=
"html"
options
.
unused_zeroes
=
false
require
"alt_getopt"
require
"alt_getopt"
local
e
=
[[slave Wishbone generator
local
e
=
[[slave Wishbone generator
wbgen2 [options] input_file.wb]]
wbgen2 [options] input_file.wb]]
...
@@ -4302,6 +4308,7 @@ local t=[[options:
...
@@ -4302,6 +4308,7 @@ local t=[[options:
-V, --vo=FILE Write the slave's generated HDL code to FILE
-V, --vo=FILE Write the slave's generated HDL code to FILE
-p, --vpo=FILE Generate a VHDL package for slave's generated VHDL
-p, --vpo=FILE Generate a VHDL package for slave's generated VHDL
(necessary with --hstyle=record)
(necessary with --hstyle=record)
-Z, --zeroes Drive unused register bits to '0' instead of 'X'
wbgen2 (c) Tomasz Wlostowski/CERN BE-CO-HT 2010-2012]]
wbgen2 (c) Tomasz Wlostowski/CERN BE-CO-HT 2010-2012]]
function
usage
()
function
usage
()
...
@@ -4324,11 +4331,12 @@ lang="l",
...
@@ -4324,11 +4331,12 @@ lang="l",
vo
=
"V"
,
vo
=
"V"
,
vpo
=
"p"
,
vpo
=
"p"
,
cstyle
=
"s"
,
cstyle
=
"s"
,
zeroes
=
"Z"
,
hstyle
=
"H"
hstyle
=
"H"
}
}
local
e
local
e
local
a
local
a
e
,
a
=
alt_getopt
.
get_opts
(
o
,
"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:
Z
"
,
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
()
...
@@ -4358,6 +4366,8 @@ elseif t=="V"then
...
@@ -4358,6 +4366,8 @@ elseif t=="V"then
options
.
output_hdl_file
=
e
options
.
output_hdl_file
=
e
elseif
t
==
"p"
then
elseif
t
==
"p"
then
options
.
output_package_file
=
e
options
.
output_package_file
=
e
elseif
t
==
"Z"
then
options
.
unused_zeroes
=
true
elseif
t
==
"H"
then
elseif
t
==
"H"
then
if
(
e
~=
"signals"
and
e
~=
"record"
and
e
~=
"record_full"
)
then
if
(
e
~=
"signals"
and
e
~=
"record"
and
e
~=
"record_full"
)
then
die
(
"Unknown register style: "
..
e
);
die
(
"Unknown register style: "
..
e
);
...
...
wbgen_main.lua
View file @
6b6a3b7e
...
@@ -28,6 +28,7 @@ options.lang = "vhdl";
...
@@ -28,6 +28,7 @@ options.lang = "vhdl";
options
.
c_reg_style
=
"struct"
;
options
.
c_reg_style
=
"struct"
;
options
.
hdl_reg_style
=
"signals"
;
options
.
hdl_reg_style
=
"signals"
;
options
.
doc_format
=
"html"
options
.
doc_format
=
"html"
options
.
unused_zeroes
=
false
require
"alt_getopt"
require
"alt_getopt"
...
@@ -50,6 +51,7 @@ local commands_string = [[options:
...
@@ -50,6 +51,7 @@ local commands_string = [[options:
-V, --vo=FILE Write the slave's generated HDL code to FILE
-V, --vo=FILE Write the slave's generated HDL code to FILE
-p, --vpo=FILE Generate a VHDL package for slave's generated VHDL
-p, --vpo=FILE Generate a VHDL package for slave's generated VHDL
(necessary with --hstyle=record)
(necessary with --hstyle=record)
-Z, --zeroes Drive unused register bits to '0' instead of 'X'
wbgen2 (c) Tomasz Wlostowski/CERN BE-CO-HT 2010-2012]]
wbgen2 (c) Tomasz Wlostowski/CERN BE-CO-HT 2010-2012]]
...
@@ -75,13 +77,14 @@ function parse_args(arg)
...
@@ -75,13 +77,14 @@ function parse_args(arg)
vo
=
"V"
,
vo
=
"V"
,
vpo
=
"p"
,
vpo
=
"p"
,
cstyle
=
"s"
,
cstyle
=
"s"
,
zeroes
=
"Z"
,
hstyle
=
"H"
hstyle
=
"H"
}
}
local
optarg
local
optarg
local
optind
local
optind
optarg
,
optind
=
alt_getopt
.
get_opts
(
arg
,
"hvC:D:K:l:V:s:f:H:p:"
,
long_opts
)
optarg
,
optind
=
alt_getopt
.
get_opts
(
arg
,
"hvC:D:K:l:V:s:f:H:p:
Z
"
,
long_opts
)
for
key
,
value
in
pairs
(
optarg
)
do
for
key
,
value
in
pairs
(
optarg
)
do
if
key
==
"h"
then
if
key
==
"h"
then
usage_complete
()
usage_complete
()
...
@@ -119,6 +122,8 @@ function parse_args(arg)
...
@@ -119,6 +122,8 @@ function parse_args(arg)
options
.
output_hdl_file
=
value
options
.
output_hdl_file
=
value
elseif
key
==
"p"
then
elseif
key
==
"p"
then
options
.
output_package_file
=
value
options
.
output_package_file
=
value
elseif
key
==
"Z"
then
options
.
unused_zeroes
=
true
elseif
key
==
"H"
then
elseif
key
==
"H"
then
if
(
value
~=
"signals"
and
value
~=
"record"
and
value
~=
"record_full"
)
then
if
(
value
~=
"signals"
and
value
~=
"record"
and
value
~=
"record_full"
)
then
die
(
"Unknown register style: "
..
value
);
die
(
"Unknown register style: "
..
value
);
...
...
wbgen_regbank.lua
View file @
6b6a3b7e
...
@@ -653,7 +653,7 @@ function gen_hdl_code_constant(field, reg)
...
@@ -653,7 +653,7 @@ function gen_hdl_code_constant(field, reg)
end
end
-- generates code which loads data unused bits of data output register with Xs
-- generates code which loads data unused bits of data output register with Xs
function
fill_unused_bits
(
target
,
reg
)
function
fill_unused_bits
(
target
,
reg
,
unused_zeroes
)
local
t
=
{};
local
t
=
{};
local
code
=
{};
local
code
=
{};
local
all_wo
=
true
;
local
all_wo
=
true
;
...
@@ -668,16 +668,21 @@ function fill_unused_bits(target, reg)
...
@@ -668,16 +668,21 @@ function fill_unused_bits(target, reg)
if
(
field
.
access_bus
~=
WRITE_ONLY
)
then
all_wo
=
false
;
end
if
(
field
.
access_bus
~=
WRITE_ONLY
)
then
all_wo
=
false
;
end
end
);
end
);
if
(
unused_zeroes
)
then
unused
=
0
;
else
unused
=
vundefined
();
end
if
(
all_wo
)
then
if
(
all_wo
)
then
for
i
=
0
,
DATA_BUS_WIDTH
-
1
do
for
i
=
0
,
DATA_BUS_WIDTH
-
1
do
table_join
(
code
,
{
va
(
vi
(
target
,
i
),
vundefined
()
);
});
table_join
(
code
,
{
va
(
vi
(
target
,
i
),
unused
);
});
end
end
return
code
;
return
code
;
end
end
for
i
=
0
,
DATA_BUS_WIDTH
-
1
do
for
i
=
0
,
DATA_BUS_WIDTH
-
1
do
if
(
t
[
i
]
==
nil
)
then
if
(
t
[
i
]
==
nil
)
then
table_join
(
code
,
{
va
(
vi
(
target
,
i
),
vundefined
()
);
});
table_join
(
code
,
{
va
(
vi
(
target
,
i
),
unused
);
});
end
end
end
end
...
...
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