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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ default: $(ALL_COCOTB_TESTS)
@echo "##############################################################################" @echo "##############################################################################"
build_dirs/%/compile.f: systemrdl/%.rdl 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)/*_if.sv > $@
ls $(PWD)/$(@D)/*amba*.sv >> $@ ls $(PWD)/$(@D)/*amba*.sv >> $@