Long CLI arguments now use dashes rather than underscores

This commit is contained in:
Dennis Potter 2021-10-31 13:53:11 -07:00
parent ed167c05de
commit 0371bef439
Signed by: Dennis
GPG Key ID: 186A8AD440942BAF
6 changed files with 66 additions and 74 deletions

View File

@ -122,63 +122,54 @@ The following bus protocols are planned at this point:
# Help function
A comprehensive help function of the tool can be invoked by running `srdl2sv --help`.
```
usage: srdl2sv [-h] [-a ADDRESS_WIDTH] [-b {simple,amba3ahblite}]
[-c DESCRIPTIONS] [-d SEARCH_PATHS [SEARCH_PATHS ...]] [-e]
[--file_log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL,NONE}]
[--stream_log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL,NONE}]
[--no_byte_enable] [-o OUT_DIR] [-r] [--real_tabs]
[--tab_width TAB_WIDTH]
IN_RDL [IN_RDL ...]
usage: srdl2sv [-h] [-a ADDRESS_WIDTH] [-b {simple,amba3ahblite}] [-c DESCRIPTIONS]
[-d SEARCH_PATHS [SEARCH_PATHS ...]] [-e]
[--file-logging {DEBUG,INFO,WARNING,ERROR,CRITICAL,NONE}]
[--stdout-logging {DEBUG,INFO,WARNING,ERROR,CRITICAL,NONE}] [--no-byte-enable]
[-o OUT_DIR] [-r] [--real-tabs] [--tab-width TAB_WIDTH]
RDL [RDL ...]
SystemRDL 2 SystemVerilog compiler
A SystemRDL 2.0 to (synthesizable) SystemVerilog compiler
positional arguments:
IN_RDL Location of RDL file(s) with root addrmap.
RDL Location of RDL file(s) with root addrmap.
optional arguments:
-h, --help show this help message and exit
-a ADDRESS_WIDTH, --address_width ADDRESS_WIDTH
Set the address width of the register space. For some
protocols, the default as described in the
specification is used. (default: 32)
-a ADDRESS_WIDTH, --address-width ADDRESS_WIDTH
Set the address width of the register space. For some protocols, the default
as described in the specification is used. (default: 32)
-b {simple,amba3ahblite}, --bus {simple,amba3ahblite}
Set the bus protocol that shall be used by software to
communicate with the registers. If just a simple
interface to the registers is needed, use the 'simple'
protocol. (default: amba3ahblite)
Set the bus protocol that shall be used by software to communicate with the
registers. If just a simple interface to the registers is needed, use the
'simple' protocol. (default: amba3ahblite)
-c DESCRIPTIONS, --descriptions DESCRIPTIONS
Include descriptions of addrmaps (+16), regfiles (+8),
memories (+4) registers (+2), and fields (+1) in RTL.
This is a bitfield.
-d SEARCH_PATHS [SEARCH_PATHS ...], --search_paths SEARCH_PATHS [SEARCH_PATHS ...]
Point to one (or more) directories that will be
searched for RDL files.
-e, --disable_enums Disable enumeration generation. This will prevent the
compiler from generating packages and it will prevent
it from using enums in the port list.
--file_log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL,NONE}
Set verbosity level of output to log-file. When set to
'NONE', nothing will be printed to the shell.
(default: NONE)
--stream_log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL,NONE}
Set verbosity level of output to shell. When set to
'NONE', nothing will be printed to the shell.
(default: INFO)
--no_byte_enable If this flag gets set, byte-enables get disabled. At
that point, it is only possible to address whole
registers, not single bytes within these registers
Include descriptions of addrmaps (+16), regfiles (+8), memories (+4) registers
(+2), and fields (+1) in RTL. This is a bitfield.
-d SEARCH_PATHS [SEARCH_PATHS ...], --search-paths SEARCH_PATHS [SEARCH_PATHS ...]
Point to one (or more) directories that will be searched for RDL files.
-e, --no-enums Disable enumeration generation. This will prevent the compiler from generating
packages and it will prevent it from using enums in the port list.
--file-logging {DEBUG,INFO,WARNING,ERROR,CRITICAL,NONE}
Set verbosity level of output to log-file. When set to 'NONE', nothing will be
printed to the shell. (default: NONE)
--stdout-logging {DEBUG,INFO,WARNING,ERROR,CRITICAL,NONE}
Set verbosity level of output to shell. When set to 'NONE', nothing will be
printed to the shell. (default: INFO)
--no-byte-enable If this flag gets set, byte-enables get disabled. At that point, it is only
possible to address whole registers, not single bytes within these registers
anymore.
-o OUT_DIR, --out_dir OUT_DIR
Define output directory to dump files. If directory is
non-existent, it will be created. (default:
./srdl2sv_out)
-r, --recursive_search
If set, the dependency directories will be searched
recursively.
--real_tabs Use tabs, rather than spaces, for tabs
--tab_width TAB_WIDTH
Define how many tabs or spaces will be contained in
one level of indentation. (default: 4)
-o OUT_DIR, --out-dir OUT_DIR
Define output directory to dump files. If directory is non-existent, it will
be created. (default: ./srdl2sv_out)
-r, --recursive-search
If set, the dependency directories will be searched recursively.
--real-tabs Use tabs, rather than spaces, for tabs
--tab-width TAB_WIDTH
Define how many tabs or spaces will be contained in one level of indentation.
(default: 4)
Report bugs via https://github.com/Silicon1602/srdl2sv/issues
```
# Contributing
# License

View File

@ -18,11 +18,12 @@ class CliArguments():
def __init__(self):
self.parser = argparse.ArgumentParser(
description="SystemRDL 2 SystemVerilog compiler")
description="A SystemRDL 2.0 to (synthesizable) SystemVerilog compiler",
epilog="Report bugs via https://github.com/Silicon1602/srdl2sv/issues")
self.parser.add_argument(
"-a",
"--address_width",
"--address-width",
default=32,
type=int,
help="Set the address width of the register space. For some \
@ -49,7 +50,7 @@ class CliArguments():
self.parser.add_argument(
"-d",
"--search_paths",
"--search-paths",
type=str,
nargs="+",
help="Point to one (or more) directories that will\
@ -57,28 +58,28 @@ class CliArguments():
self.parser.add_argument(
"-e",
"--disable_enums",
"--no-enums",
action="store_true",
help="Disable enumeration generation. This will prevent the\
compiler from generating packages and it will prevent\
it from using enums in the port list.")
self.parser.add_argument(
"--file_log_level",
"--file-logging",
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'NONE'],
default='NONE',
help="Set verbosity level of output to log-file. When set to 'NONE',\
nothing will be printed to the shell. (default: %(default)s)")
self.parser.add_argument(
"--stream_log_level",
"--stdout-logging",
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'NONE'],
default='INFO',
help="Set verbosity level of output to shell. When set to 'NONE',\
nothing will be printed to the shell. (default: %(default)s)")
self.parser.add_argument(
"--no_byte_enable",
"--no-byte-enable",
action="store_true",
help="If this flag gets set, byte-enables get disabled. At that point, it \
is only possible to address whole registers, not single bytes within \
@ -86,7 +87,7 @@ class CliArguments():
self.parser.add_argument(
"-o",
"--out_dir",
"--out-dir",
type=str,
default="./srdl2sv_out",
help="Define output directory to dump files.\
@ -95,25 +96,25 @@ class CliArguments():
self.parser.add_argument(
"-r",
"--recursive_search",
"--recursive-search",
action="store_true",
help="If set, the dependency directories will be\
searched recursively.")
self.parser.add_argument(
"--real_tabs",
"--real-tabs",
action="store_true",
help="Use tabs, rather than spaces, for tabs")
self.parser.add_argument(
"--tab_width",
"--tab-width",
type=int,
default=4,
help="Define how many tabs or spaces will be contained\
in one level of indentation. (default: %(default)s)")
self.parser.add_argument(
"IN_RDL",
"RDL",
type=str,
nargs="+",
help="Location of RDL file(s) with root addrmap.")
@ -126,7 +127,7 @@ class CliArguments():
config['list_args'] = []
# Save input file and output directory to dump everything in
config['input_file'] = args.IN_RDL
config['input_file'] = args.RDL
config['output_dir'] = args.out_dir
config['list_args'].append(f"Ouput Directory : {config['output_dir']}")
@ -137,10 +138,10 @@ class CliArguments():
pass
# Map logging level string to integers
config['stream_log_level'] = logging_map[args.stream_log_level]
config['file_log_level'] = logging_map[args.file_log_level]
config['list_args'].append(f"Stream Log Level : {args.stream_log_level}")
config['list_args'].append(f"File Log Level : {args.file_log_level}")
config['stdout_log_level'] = logging_map[args.stdout_logging]
config['file_log_level'] = logging_map[args.file_logging]
config['list_args'].append(f"Stream Log Level : {args.stdout_logging}")
config['list_args'].append(f"File Log Level : {args.file_logging}")
# Determine paths to be passed to systemrdl-compiler to search
# for include files.
@ -167,7 +168,7 @@ class CliArguments():
config['list_args'].append(f"Tab Width : {config['tab_width']}")
# Set enums
config['enums'] = not args.disable_enums
config['enums'] = not args.no_enums
config['list_args'].append(f"Enums Enabled : {config['enums']}")
# Set bus

View File

@ -89,7 +89,7 @@ class Component():
def __create_logger(self, name: str, config: dict):
self.logger = create_logger(
name,
stream_log_level=config['stream_log_level'],
stdout_log_level=config['stdout_log_level'],
file_log_level=config['file_log_level'],
file_name=config['file_log_location'])
self.logger.propagate = False

View File

@ -31,7 +31,7 @@ class CustomFormatter(logging.Formatter):
def create_logger (
mod_name,
stream_log_level: int = logging.WARNING,
stdout_log_level: int = logging.WARNING,
file_log_level: int = logging.INFO,
file_name: Optional[str] = None):
@ -40,10 +40,10 @@ def create_logger (
# Set log level. If the minimum log level of one of the
# two loggers is 0, the maximum of both values must be taken.
# Otherwise, the complete logger gets deactivated.
min_log_level = min(stream_log_level, file_log_level)
min_log_level = min(stdout_log_level, file_log_level)
if min_log_level == 0:
log.setLevel(max(stream_log_level, file_log_level))
log.setLevel(max(stdout_log_level, file_log_level))
else:
log.setLevel(min_log_level)
@ -57,9 +57,9 @@ def create_logger (
file_handler.setFormatter(file_formatter)
log.addHandler(file_handler)
if stream_log_level > 0:
if stdout_log_level > 0:
stream_handler = logging.StreamHandler()
stream_handler.setLevel(stream_log_level)
stream_handler.setLevel(stdout_log_level)
stream_formatter = CustomFormatter(
"[%(levelname)s][%(name)s] %(message)s")

View File

@ -25,7 +25,7 @@ def main():
# Create logger
logger = create_logger(
__name__,
stream_log_level=config['stream_log_level'],
stdout_log_level=config['stdout_log_level'],
file_log_level=config['file_log_level'],
file_name=config['file_log_location'])

View File

@ -35,7 +35,7 @@ default: $(ALL_COCOTB_TESTS)
@echo "##############################################################################"
build_dirs/%/compile.f: systemrdl/%.rdl
srdl2sv $? --out_dir $(shell dirname $@) --file_log_level DEBUG --stream_log_level DEBUG
srdl2sv $? --out-dir $(shell dirname $@) --file-logging DEBUG --stdout-logging DEBUG
ls $(PWD)/$(@D)/*_if.sv > $@
ls $(PWD)/$(@D)/*amba*.sv >> $@