Files
srdl2sv/srdl2sv/main.py
Dennis cecb73f07a Fundamental changes to the architecture of component classes
All components (e.g., fields, registers, addrmaps) are now children
of a common class Component. This common class has certain common
methods such as get_ports(), get_rtl(), or create_logger().

The AddrMap is now prepared to support alias registers by saving the
registers in a dictionary. That way, registers can easily be accessed
once an alias to a register is found. Furthermore, the addrmap template
is now also loaded from a YAML file. Lastly, the first preparements to
insert ports into the addrmap module are made.

For templates, the indents do not need to be added anymore to the
template. Now, a seperate method will automatically indent the RTL
based on simple rules (e.g., increment indent if `begin` is found).
The CLI also supports settings for the tabs (i.e., real tabs or spaces
and the tab width).

A lot of functionality from the __init__() method of the field class
got reorganized. More logic will be reorganized in the future.
2021-05-15 00:29:59 +02:00

68 lines
1.8 KiB
Python
Executable File

#!/usr/bin/env python3
# Standard modules
import sys
import time
import os
# Imported modules
from systemrdl import RDLCompiler, RDLCompileError
# Local modules
from components.addrmap import AddrMap
from cli.cli import CliArguments
from log.log import create_logger
if __name__ == "__main__":
# Take start timestamp
start = time.time()
# Construct command line arguments
cli_arguments = CliArguments()
config = cli_arguments.get_config()
# Create logger
logger = create_logger(
__name__,
stream_log_level=config['stream_log_level'],
file_log_level=config['file_log_level'],
file_name=config['file_log_location'])
# Compile and elaborate files provided from the command line
rdlc = RDLCompiler()
try:
for input_file in config['input_file']:
rdlc.compile_file(
input_file, incl_search_paths=config['search_paths'])
root = rdlc.elaborate()
except RDLCompileError:
sys.exit(1)
addrmap = AddrMap(root.top, config)
# Create output directory
try:
os.makedirs(config['output_dir'])
logger.info('Succesfully created directory "{}"'.format(
config['output_dir']))
except FileExistsError:
logger.info('Directory "{}" does already exist'.format(
config['output_dir']))
# Save RTL to file
out_file_name = "{}/{}.sv".format(config['output_dir'], addrmap.name)
with open(out_file_name, 'w') as file:
file.write(
addrmap.get_rtl(
tab_width=config['tab_width'],
real_tabs=config['real_tabs']
)
)
logger.info('Succesfully created "{}"'.format(out_file_name))
logger.info("Elapsed time: %f seconds", time.time() - start)