mirror of
https://github.com/Silicon1602/srdl2sv.git
synced 2024-11-14 11:03:36 +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
|
# Define triggers for which the indentation level will increment or
|
||||||
# decrement on the next line
|
# 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 = []
|
rtl_indented = []
|
||||||
|
|
||||||
@ -145,7 +150,7 @@ class Component():
|
|||||||
matchObj = trigger_re.match(line_split)
|
matchObj = trigger_re.match(line_split)
|
||||||
|
|
||||||
if matchObj:
|
if matchObj:
|
||||||
if matchObj.group(1) in ('begin', '{', 'case'):
|
if matchObj.group(1) in ('begin', '{', 'case', '<<INDENT>>'):
|
||||||
indent_lvl_next += 1
|
indent_lvl_next += 1
|
||||||
else:
|
else:
|
||||||
indent_lvl = indent_lvl_next - 1
|
indent_lvl = indent_lvl_next - 1
|
||||||
@ -159,7 +164,9 @@ class Component():
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Add tabs
|
# 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)
|
return '\n'.join(rtl_indented)
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
module_declaration:
|
module_declaration:
|
||||||
rtl: |-
|
rtl: |-
|
||||||
module {name}
|
module {name}
|
||||||
|
<<INDENT>>
|
||||||
{import_package_list}
|
{import_package_list}
|
||||||
|
<<UNINDENT>>
|
||||||
(
|
(
|
||||||
|
<<INDENT>>
|
||||||
// Clock & Resets
|
// Clock & Resets
|
||||||
input reg_clk,
|
input reg_clk,
|
||||||
input bus_clk,
|
input bus_clk,
|
||||||
@ -18,6 +21,7 @@ module_declaration:
|
|||||||
|
|
||||||
// Outputs
|
// Outputs
|
||||||
{outputs}
|
{outputs}
|
||||||
|
<<UNINDENT>>
|
||||||
);
|
);
|
||||||
import_package:
|
import_package:
|
||||||
rtl: |-
|
rtl: |-
|
||||||
|
Loading…
Reference in New Issue
Block a user