Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
wishbone-gen
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
hdl-core-lib
wishbone-gen
Commits
e9d14fb8
Commit
e9d14fb8
authored
Sep 29, 2014
by
Benoit Rat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
epics: Add files to generate epics db
parent
45e99e8f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
163 additions
and
3 deletions
+163
-3
Makefile
Makefile
+1
-1
cgen_epics_db.lua
cgen_epics_db.lua
+145
-0
Makefile
examples/Makefile
+4
-1
squishy
squishy
+1
-0
wbgen_main.lua
wbgen_main.lua
+12
-1
No files found.
Makefile
View file @
e9d14fb8
SOURCES
=
cgen_c_headers.lua cgen_common.lua cgen_verilog.lua cgen_vhdl.lua target_wishbone.lua wbgen_common.lua wbgen_main.lua wbgen_rams.lua wbgen_regbank.lua wbgen_eic.lua
SOURCES
=
cgen_c_headers.lua cgen_common.lua cgen_verilog.lua cgen_vhdl.lua target_wishbone.lua wbgen_common.lua wbgen_main.lua wbgen_rams.lua wbgen_regbank.lua wbgen_eic.lua
cgen_epics_db.lua
OUTPUT
=
wbgen2
VHDL_LIBRARY
=
lib/wbgen2_dpssram.vhd lib/wbgen2_eic.vhd
...
...
cgen_epics_db.lua
0 → 100644
View file @
e9d14fb8
#!/usr/bin/lua
-- wbgen2, (c) 2013 Benoit Rat/Seven Solutions
-- LICENSED UNDER GPL v2
-- File: cgen_epicsdb.lua
--
-- The EPICS db code generator.
--
-- generates records for each field in the wishbone
--
function
cgen_db_field_records
(
field
,
reg
,
index
)
local
prefix
;
-- anonymous field?
if
(
field
.
c_prefix
==
nil
)
then
return
;
else
if
(
reg
.
c_prefix
==
field
.
c_prefix
or
(
field
.
c_prefix
==
"value"
and
reg
.
num_fields
==
1
))
then
prefix_c
=
reg
.
c_prefix
;
else
prefix_c
=
reg
.
c_prefix
..
"_"
..
field
.
c_prefix
;
end
prefix_records
=
prefix_c
:
gsub
(
"_(%a)"
,
string.upper
):
gsub
(
"^%l"
,
string.upper
);
end
emit
(
"##---------------- '"
..
field
.
name
..
"' in '"
..
reg
.
name
..
"'"
);
if
(
field
.
access_bus
==
WRITE_ONLY
or
field
.
access_bus
==
READ_WRITE
)
then
emit
(
""
);
if
(
field
.
type
==
BIT
or
field
.
type
==
MONOSTABLE
)
then
emit
(
string.format
(
"record(bo, \"
$
(
user
):
%
s
%
s
\
")"
,
prefix_records
,
"Cmd"
));
emit
(
"{"
);
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"DTYP"
,
"asynInt32"
));
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
%
s
\
")"
,
"OUT"
,
"@asyn($(PORT),$(ADDR),$(TIMEOUT))"
,
prefix_c
));
else
emit
(
string.format
(
"record(ao, \"
$
(
user
):
%
s
%
s
\
")"
,
prefix_records
,
"Set"
));
emit
(
"{"
);
if
(
field
.
nbfp
~=
nil
and
field
.
nbfp
>
0
)
then
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"DTYP"
,
"asynFloat64"
));
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"PREC"
,
"3"
));
else
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"DTYP"
,
"asynInt32"
));
end
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
%
s
\
")"
,
"OUT"
,
"@asyn($(PORT),$(ADDR),$(TIMEOUT))"
,
prefix_c
));
end
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"DESC"
,
field
.
name
));
emit
(
"}"
);
end
if
(
field
.
access_bus
==
READ_ONLY
or
field
.
access_bus
==
READ_WRITE
)
then
emit
(
""
);
if
(
field
.
type
==
BIT
or
field
.
type
==
MONOSTABLE
)
then
emit
(
string.format
(
"record(bi, \"
$
(
user
):
%
s
%
s
\
")"
,
prefix_records
,
"Stat"
));
emit
(
"{"
);
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"DTYP"
,
"asynInt32"
));
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
%
s
\
")"
,
"INP"
,
"@asyn($(PORT),$(ADDR),$(TIMEOUT))"
,
prefix_c
));
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"SCAN"
,
"I/O Intr"
));
else
emit
(
string.format
(
"record(ai, \"
$
(
user
):
%
s
%
s
\
")"
,
prefix_records
,
"Rdbk"
));
emit
(
"{"
);
if
(
field
.
nbfp
~=
nil
and
field
.
nbfp
>
0
)
then
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"DTYP"
,
"asynFloat64"
));
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"PREC"
,
"3"
));
else
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"DTYP"
,
"asynInt32"
));
end
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
%
s
\
")"
,
"INP"
,
"@asyn($(PORT),$(ADDR),$(TIMEOUT))"
,
prefix_c
));
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"SCAN"
,
"I/O Intr"
));
end
emit
(
string.format
(
"
\t
field(%-5s,\"
%
s
\
")"
,
"DESC"
,
field
.
name
));
emit
(
"}"
);
end
emit
(
""
);
end
-- iterates all regs and rams and generates appropriate #define-s
function
cgen_db_fields
()
local
index
;
foreach_reg
({
TYPE_REG
},
function
(
reg
)
dbg
(
"DOCREG: "
,
reg
.
name
,
reg
.
num_fields
);
if
(
reg
.
num_fields
~=
nil
and
reg
.
num_fields
>
0
)
then
emit
(
"##================ "
..
reg
.
name
..
" "
);
emit
(
""
);
index
=
0
;
foreach_subfield
(
reg
,
function
(
field
,
reg
)
cgen_db_field_records
(
field
,
reg
,
index
);
index
=
index
+
1
;
end
);
emit
(
""
);
end
end
);
foreach_reg
({
TYPE_RAM
},
function
(
ram
)
cgen_db_ramdefs
(
ram
);
end
);
end
-- generates C file header
function
cgen_db_fileheader
()
emit
(
"################################################################################"
);
emit
(
"# "
);
emit
(
"# * File : "
..
options
.
output_epics_db_file
);
emit
(
"# * Author : auto-generated by wbgen2 from "
..
input_wb_file
);
emit
(
"# * Generated : "
..
os.date
());
emit
(
"# "
);
emit
(
"# THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE "
..
input_wb_file
);
emit
(
"# "
);
emit
(
"#"
);
emit
(
"# The $(user) is a MACRO that need to be defined in the st.cmd script"
);
emit
(
"# This file hes been generated to be used with the AsynWBPortDriver class "
);
emit
(
"#"
);
emit
(
"# Then the list of prefix are:"
);
emit
(
"# "
);
emit
(
"# The list of sufix are: "
);
emit
(
"# Cmd (command), Rdbk (readback), Set (Setting), Stat (Status)"
);
emit
(
"#"
);
emit
(
"################################################################################"
);
emit
(
""
);
emit
(
""
);
emit
(
"## Records definitions for slave peripheral: "
..
periph
.
name
);
emit
(
"## ============================================================================="
);
emit
(
""
);
emit
(
""
);
end
-- main C code generator function. Takes the peripheral definition and generates C code.
function
cgen_generate_epics_db_code
()
cgen_new_snippet
();
cgen_db_fileheader
();
cgen_db_fields
();
emit
(
""
);
emit
(
"## End of auto-generated: "
..
input_wb_file
);
emit
(
"## ============================================================================="
);
emit
(
""
);
emit
(
"# User can fill its own records here"
);
cgen_write_current_snippet
();
end
examples/Makefile
View file @
e9d14fb8
...
...
@@ -42,9 +42,12 @@ pkg: $(WBINPUT:.wb=_pkg.vhd)
%.html
:
%.wb
wbgen2
--docformat
=
html
--doco
=
$@
$<
%.db
:
%.wb
wbgen2
--epicsdb
=
$@
$<
%.tex
:
%.wb
wbgen2
--docformat
=
latex
--docu
=
$@
$<
%_pkg.vhd
:
%.wb
wbgen2
--vo
=
$*
.vhdl
--vpo
=
$@
--hstyle
=
record
$<
...
...
squishy
View file @
e9d14fb8
...
...
@@ -12,6 +12,7 @@ Main "cgen_common.lua"
Main "cgen_vhdl.lua"
Main "cgen_verilog.lua"
Main "cgen_c_headers.lua"
Main "cgen_epics_db.lua"
Main "cgen_doc.lua"
Main "cgen_doc_texinfo.lua"
Main "cgen_doc_latex.lua"
...
...
wbgen_main.lua
View file @
e9d14fb8
...
...
@@ -38,6 +38,7 @@ local commands_string = [[options:
-C, --co=FILE Write the slave's generated C header file to FILE
-f, --docformat=FORMAT Write documentation for latex, texinfo or HTML (defaults to HTML)
-D, --doco=FILE Write the slave's generated documentation to FILE
-E, --epicsdb=FILE Write the slave's generated epics db FILE
-h, --help Show this help text
-l, --lang=LANG Set the output Hardware Description Language (HDL) to LANG
Valid values for LANG: {vhdl,verilog}
...
...
@@ -70,6 +71,7 @@ function parse_args(arg)
co
=
"C"
,
docformat
=
"f"
,
doco
=
"D"
,
epicsdb
=
"E"
,
constco
=
"K"
,
lang
=
"l"
,
vo
=
"V"
,
...
...
@@ -81,7 +83,7 @@ function parse_args(arg)
local
optarg
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:
E:
K:l:V:s:f:H:p:"
,
long_opts
)
for
key
,
value
in
pairs
(
optarg
)
do
if
key
==
"h"
then
usage_complete
()
...
...
@@ -97,6 +99,9 @@ function parse_args(arg)
elseif
key
==
"D"
then
options
.
output_doc_file
=
value
elseif
key
==
"E"
then
options
.
output_epics_db_file
=
value
elseif
key
==
"K"
then
options
.
output_vlog_constants_file
=
value
...
...
@@ -201,6 +206,12 @@ if(options.output_c_header_file ~= nil) then
cgen_generate_done
();
end
if
(
options
.
output_epics_db_file
~=
nil
)
then
cgen_generate_init
(
options
.
output_epics_db_file
)
cgen_generate_epics_db_code
();
cgen_generate_done
();
end
if
(
options
.
output_vlog_constants_file
~=
nil
)
then
cgen_gen_vlog_constants
(
options
.
output_vlog_constants_file
);
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