mirror of
https://github.com/Silicon1602/srdl2sv.git
synced 2024-11-14 03:03:35 +00:00
Add <<INDENT>> and <<UNINDENT>> helpers to template
This allows a designer to add markers to the template to indicate where a new level of indentation should start or end. This is apart fromt he auto-indents caused by "case", "begin", or "{".
This commit is contained in:
parent
01a696c2b3
commit
695de2d330
@ -126,7 +126,12 @@ class Component():
|
||||
|
||||
# Define triggers for which the indentation level will increment or
|
||||
# decrement on the next line
|
||||
trigger_re = re.compile(r'.*?((?:\bbegin\b|\{|\bcase\b)|(?:\bend\b|}|\bendcase\b))([^$]*)')
|
||||
trigger_re = re.compile(r"""
|
||||
.*?(
|
||||
(?:\bbegin\b|\{|\bcase\b|<<INDENT>>)|
|
||||
(?:\bend\b|}|\bendcase\b|<<UNINDENT>>)
|
||||
)([^$]*)
|
||||
""", flags=re.VERBOSE)
|
||||
|
||||
rtl_indented = []
|
||||
|
||||
@ -145,7 +150,7 @@ class Component():
|
||||
matchObj = trigger_re.match(line_split)
|
||||
|
||||
if matchObj:
|
||||
if matchObj.group(1) in ('begin', '{', 'case'):
|
||||
if matchObj.group(1) in ('begin', '{', 'case', '<<INDENT>>'):
|
||||
indent_lvl_next += 1
|
||||
else:
|
||||
indent_lvl = indent_lvl_next - 1
|
||||
@ -159,7 +164,9 @@ class Component():
|
||||
break
|
||||
|
||||
# Add tabs
|
||||
rtl_indented.append("{}{}".format(tab*indent_lvl, line))
|
||||
if line.strip() not in ('<<INDENT>>', '<<UNINDENT>>'):
|
||||
rtl_indented.append("{}{}".format(tab*indent_lvl, line))
|
||||
|
||||
|
||||
|
||||
return '\n'.join(rtl_indented)
|
||||
|
@ -2,8 +2,11 @@
|
||||
module_declaration:
|
||||
rtl: |-
|
||||
module {name}
|
||||
<<INDENT>>
|
||||
{import_package_list}
|
||||
<<UNINDENT>>
|
||||
(
|
||||
<<INDENT>>
|
||||
// Clock & Resets
|
||||
input reg_clk,
|
||||
input bus_clk,
|
||||
@ -18,6 +21,7 @@ module_declaration:
|
||||
|
||||
// Outputs
|
||||
{outputs}
|
||||
<<UNINDENT>>
|
||||
);
|
||||
import_package:
|
||||
rtl: |-
|
||||
|
Loading…
Reference in New Issue
Block a user