Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jonnatan Mendoza Escobar
svhd_lib_modules_make
Commits
d096cab1
Commit
d096cab1
authored
Jun 09, 2022
by
Jonnatan Mendoza Escobar
Browse files
🎨
Impruve enviorment variables handling to work with makefiles
parent
2be0c4d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
d096cab1
# This makefle specs that the following variables are predefined previously
# VTREE
# DOC_FOLDER
# HLIB_MODULES_PATH
#
ifndef
VTREE
$(error
VTREE
is
not
set)
endif
MODULES_LIST
=
$(
shell
$(VTREE)
get_modules .
)
RTL_FILES_PATHS
=
$(
foreach
TOP_MODULE,
$(MODULES_LIST)
,
$(
dir
$(
shell
find
.
-type
f
-iname
$(TOP_MODULE)
.sv
-o
-iname
$(TOP_MODULE)
.v
)))
# Verilator Lint Flags
VERILATOR_WNO_OPTS
?=
VERILATOR_LINT_FLAGS
=
--lint-only
+1800-2017ext+sv
-sv
-Wall
$(VERILATOR_WNO_OPTS)
-Wno-fatal
define
mtree_func
$(VTREE)
mtree
$(LIB_
ROOT
_PATH)
$(1)
-v
1;
$(VTREE)
mtree
$(
H
LIB_
MODULES
_PATH)
$(1)
-v
1;
endef
define
minsts_func
$(VTREE)
minsts
$(LIB_
ROOT
_PATH)
$(1)
-v
1;
$(VTREE)
minsts
$(
H
LIB_
MODULES
_PATH)
$(1)
-v
1;
endef
define
print_sr
c
echo
" [+] $(1)"
;
define
mtree_fun
c
$(VTREE)
mtree
$(HLIB_MODULES_PATH)
$(1)
-v
1
;
endef
define
docs_all_func_html
$(call print_src,Generating HTML docs for
:
$(1))
\
teroshdl-hdl-documenter -i $(1) --outpath $(DOC_FOLDER)/html --symbol_verilog "!" --self_contained
endef
VERILATOR_WNO_OPTS
?=
VERILATOR_LINT_FLAGS
=
--lint-only
+1800-2017ext+sv
-sv
-Wall
$(VERILATOR_WNO_OPTS)
-Wno-fatal
define
docs_all_func_md
$(call print_src,Generating Markdown docs for
:
$(1))
\
teroshdl-hdl-documenter -i $(1) --outpath $(DOC_FOLDER)/markdown --symbol_verilog "!" --self_contained --out markdown
endef
define
docs_func
$(call
docs_all_func_html,$(1))
\
$(call
docs_all_func_md,$(1))
endef
# define docs_func
# teroshdl-hdl-documenter -i $(1) --outpath doc --symbol_verilog "!" --self_contained;
# endef
define
print_src
echo
" [+] $(1)"
;
endef
define
verilator_lint_func
verilator
$(shell
cat
$(1).dep)
--top-module
$(1)
$(VERILATOR_LINT_FLAGS)
2>&1
|
tee
linting/$(1).verilator.lint;
endef
docs
:
teroshdl-hdl-documenter
-i
src
--outpath
doc
--symbol_verilog
"!"
--self_contained
mtree
:
@
(
$(
call
print_src,
"LIB_PATH: "
$(LIB_
ROOT
_PATH)
)
)
@
(
$(
call
print_src,
"LIB_PATH: "
$(
H
LIB_
MODULES
_PATH)
)
)
@
(
$(
foreach
TOP_MODULE,
$(MODULES_LIST)
,
$(
call
mtree_func,
$(TOP_MODULE)
))
)
.PHONY
:
mtree
$(addsuffix .dep,$(MODULES_LIST))
:
%.dep:
@
(
$(
call
print_src,
"LIB_PATH: "
$(LIB_
ROOT
_PATH)
)
)
@
(
$(
call
print_src,
"LIB_PATH: "
$(
H
LIB_
MODULES
_PATH)
)
)
@
(
$(
foreach
TOP_MODULE,
$(MODULES_LIST)
,
$(
call
mtree_func,
$(TOP_MODULE)
))
)
# Parallel lint Rule.
# $(addprefix linting/, $(addsuffix .lint,$(MODULES_LIST))): %.lint: $(addsuffix .dep,$(MODULES_LIST))
# verilator $(shell cat $(notdir $*).dep) --top-module $(notdir $*) $(VERILATOR_LINT_FLAGS) > $*.lint
# mlintv: $(addprefix linting/, $(addsuffix .lint,$(MODULES_LIST)))
# .PHONY: mlintv
#@($(foreach TOP_MODULE,$(MODULES_LIST), $(call docs_func,$(dir $(shell cat $(TOP_MODULE).dep)),$(TOP_MODULE))))
minsts
:
@
(
$(
call
print_src,
"LIB_PATH: "
$(LIB_
ROOT
_PATH)
)
)
@
(
$(
call
print_src,
"LIB_PATH: "
$(
H
LIB_
MODULES
_PATH)
)
)
@
(
$(
foreach
TOP_MODULE,
$(MODULES_LIST)
,
$(
call
minsts_func,
$(TOP_MODULE)
))
)
# A Requirement of the library to be able to automatically generate the documentation is that module name in code is equal to filename
docs
:
$(addsuffix .dep
,
$(MODULES_LIST))
@
if
[
-z
$(RTL_FILES_PATHS)
]
;
then
\
echo
"Error: Not valid RTL files fouded, this could be because the names of the modules in code do not match the filename in source files."
;
\
echo
$(RTL_FILES_PATHS)
;
\
fi
echo
$RTL_FILES_PATHS
@
(
$(
foreach
TOP_MODULE,
$(MODULES_LIST)
,
$(
call
docs_func,
$(
dir
$(
shell
find
.
-type
f
-iname
$(TOP_MODULE)
.sv
-o
-iname
$(TOP_MODULE)
.v
)))
)
)
mlint
:
$(addsuffix .dep
,
$(MODULES_LIST))
mkdir
-p
linting
@
(
$(
call
print_src,
"LIB_PATH: "
$(LIB_
ROOT
_PATH)
)
)
@
(
$(
call
print_src,
"LIB_PATH: "
$(
H
LIB_
MODULES
_PATH)
)
)
@
(
$(
foreach
TOP_MODULE,
$(MODULES_LIST)
,
$(
call
verilator_lint_func,
$(TOP_MODULE)
))
)
clean
:
rm
-f
$(DOC_FOLDER)
/
*
.html
rm
-rf
$(DOC_FOLDER)
/html
rm
-rf
$(DOC_FOLDER)
/markdown
rm
-f
*
.insts
rm
-f
*
.dep
rm
-f
linting/
*
.lint
...
...
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