Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HDL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
b5ff6fbe
Commit
b5ff6fbe
authored
2 years ago
by
Eric Kooistra
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of git.astron.nl:desp/hdl
parents
d194e64b
4279cc05
No related branches found
No related tags found
No related merge requests found
Pipeline
#50120
passed
2 years ago
Stage: linting
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tools/vhdl_style_fix.py
+126
-177
126 additions, 177 deletions
tools/vhdl_style_fix.py
tools/vhdl_style_fix.yaml
+240
-0
240 additions, 0 deletions
tools/vhdl_style_fix.yaml
tools/vhdl_style_fix_all_files.py
+37
-3
37 additions, 3 deletions
tools/vhdl_style_fix_all_files.py
with
403 additions
and
180 deletions
tools/vhdl_style_fix.py
+
126
−
177
View file @
b5ff6fbe
#!/usr/bin/python3
#!/usr/bin/python3
# ##########################################################################
# Copyright 2020
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ##########################################################################
# ##########################################################################
# Author: Pieter Donker
# Purpose: convert hdl code to fixed format
# Description:
# This script will handle one file.
# usage:
# vhdl_style_fix.py [filename]
#
# ##########################################################################
from
os
import
getenv
,
path
import
sys
import
sys
# from collections import OrderedDict
from
argparse
import
ArgumentParser
,
RawTextHelpFormatter
from
argparse
import
ArgumentParser
,
RawTextHelpFormatter
from
textwrap
import
dedent
from
textwrap
import
dedent
#
from
copy
import
copy
from
yaml
import
load
,
FullLoader
def
main
():
def
main
():
...
@@ -12,41 +41,53 @@ def main():
...
@@ -12,41 +41,53 @@ def main():
sdata
=
data_in
.
splitlines
()
sdata
=
data_in
.
splitlines
()
rts
=
RemoveTrailingSpaces
(
sdata
)
if
cnf
[
"
space
"
][
"
remove-trailing
"
]:
sdata
=
rts
.
get_data
()
func
=
RemoveTrailingSpaces
(
sdata
)
sdata
=
func
.
get_data
()
asao
=
AddSpacesAroundOperators
(
sdata
)
if
cnf
[
"
space
"
][
"
add-around-operators
"
]:
sdata
=
asao
.
get_data
()
func
=
AddSpacesAroundOperators
(
sdata
)
sdata
=
func
.
get_data
()
# asad = AddSpacesAroundDelimiters(sdata)
if
cnf
[
"
space
"
][
"
add-around-delimiters
"
]:
# sdata = asad.get_data()
func
=
AddSpacesAroundDelimiters
(
sdata
)
sdata
=
func
.
get_data
()
csl
=
CaseStandardLogic
(
sdata
)
if
cnf
[
"
case
"
][
"
standard-logic
"
]:
sdata
=
csl
.
get_data
()
func
=
CaseStandardLogic
(
sdata
)
sdata
=
func
.
get_data
()
cc
=
CaseConstants
(
sdata
)
if
cnf
[
"
case
"
][
"
constants
"
]:
sdata
=
cc
.
get_data
()
func
=
CaseConstants
(
sdata
)
sdata
=
func
.
get_data
()
ck
=
CaseKeywords
(
sdata
)
if
cnf
[
"
case
"
][
"
reserved-words
"
]:
sdata
=
ck
.
get_data
()
func
=
CaseReservedWords
(
sdata
)
sdata
=
func
.
get_data
()
ct
=
CaseTypes
(
sdata
)
if
cnf
[
"
case
"
][
"
types
"
]:
sdata
=
ct
.
get_data
()
func
=
CaseTypes
(
sdata
)
sdata
=
func
.
get_data
()
cc
=
CaseConversions
(
sdata
)
if
cnf
[
"
case
"
][
"
conversions
"
]:
sdata
=
cc
.
get_data
()
func
=
CaseConversions
(
sdata
)
sdata
=
func
.
get_data
()
cr
=
CaseResolutions
(
sdata
)
if
cnf
[
"
case
"
][
"
resolutions
"
]:
sdata
=
cr
.
get_data
()
func
=
CaseResolutions
(
sdata
)
sdata
=
func
.
get_data
()
ca
=
CaseAttributes
(
sdata
)
if
cnf
[
"
case
"
][
"
attributes
"
]:
sdata
=
ca
.
get_data
()
func
=
CaseAttributes
(
sdata
)
sdata
=
func
.
get_data
()
rsbb
=
RemoveSpaceBeforeBracket
(
sdata
)
if
cnf
[
"
space
"
][
"
remove-before-bracket
"
]:
sdata
=
rsbb
.
get_data
()
func
=
RemoveSpaceBeforeBracket
(
sdata
)
sdata
=
func
.
get_data
()
# sdata = apa.get_data()
if
cnf
[
"
align
"
][
"
procedure-args
"
]:
# apa = AlignProcedureArgs(sdata)
func
=
AlignProcedureArgs
(
sdata
)
sdata
=
func
.
get_data
()
data
=
'
\n
'
.
join
(
sdata
)
+
"
\n
"
data
=
'
\n
'
.
join
(
sdata
)
+
"
\n
"
...
@@ -60,6 +101,7 @@ def main():
...
@@ -60,6 +101,7 @@ def main():
class
BaseCheck
:
class
BaseCheck
:
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
self
.
splitchars
=
[]
self
.
splitchars
=
[]
self
.
tokens
=
None
self
.
data
=
data
self
.
data
=
data
self
.
n_data
=
len
(
self
.
data
)
self
.
n_data
=
len
(
self
.
data
)
...
@@ -110,7 +152,7 @@ class RemoveTrailingSpaces(BaseCheck):
...
@@ -110,7 +152,7 @@ class RemoveTrailingSpaces(BaseCheck):
class
AddSpacesAroundOperators
(
BaseCheck
):
class
AddSpacesAroundOperators
(
BaseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
)
self
.
tokens
=
O
perators
(
)
self
.
tokens
=
Tokens
(
cnf
[
"
tokens
"
][
"
o
perators
"
]
)
self
.
check
()
self
.
check
()
def
check
(
self
):
def
check
(
self
):
...
@@ -218,7 +260,7 @@ class AddSpacesAroundOperators(BaseCheck):
...
@@ -218,7 +260,7 @@ class AddSpacesAroundOperators(BaseCheck):
class
AddSpacesAroundDelimiters
(
BaseCheck
):
class
AddSpacesAroundDelimiters
(
BaseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
)
self
.
tokens
=
D
elimiters
(
)
self
.
tokens
=
Tokens
(
cnf
[
"
tokens
"
][
"
d
elimiters
"
]
)
self
.
check
()
self
.
check
()
def
check
(
self
):
def
check
(
self
):
...
@@ -267,79 +309,65 @@ class AddSpacesAroundDelimiters(BaseCheck):
...
@@ -267,79 +309,65 @@ class AddSpacesAroundDelimiters(BaseCheck):
self
.
data
[
i
]
=
''
.
join
(
new_line
)
self
.
data
[
i
]
=
''
.
join
(
new_line
)
class
Case
Keywords
(
BaseCheck
):
class
Case
Check
(
BaseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
,
case
,
splitchars
,
tokens
):
super
().
__init__
(
data
)
super
().
__init__
(
data
)
self
.
splitchars
=
[
"
"
,
"
.
"
,
"
;
"
,
"
(
"
,
"
)
"
]
self
.
case
=
str
.
lower
if
case
==
"
lower
"
else
str
.
upper
self
.
reserved_words
=
ReservedWords
()
self
.
splitchars
=
splitchars
self
.
check
(
)
self
.
tokens
=
Tokens
(
tokens
)
def
check
(
self
):
def
check
(
self
):
for
i
in
range
(
self
.
n_data
):
for
i
in
range
(
self
.
n_data
):
line
=
self
.
data
[
i
]
line
=
self
.
data
[
i
]
sline
=
self
.
splitline
(
line
)
sline
=
self
.
splitline
(
line
)
for
word
in
sline
:
for
word
in
sline
:
if
self
.
reserved_word
s
.
is_valid
(
word
):
if
self
.
token
s
.
is_valid
(
word
):
line
=
line
.
replace
(
word
,
word
.
lower
(
),
1
)
line
=
line
.
replace
(
word
,
self
.
case
(
word
),
1
)
self
.
data
[
i
]
=
line
self
.
data
[
i
]
=
line
class
Case
Types
(
B
aseCheck
):
class
Case
ReservedWords
(
C
aseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
,
self
.
splitchars
=
[
"
"
,
"
.
"
,
"
;
"
,
"
(
"
,
"
)
"
]
cnf
[
"
case
"
][
"
reserved-words
"
][
"
case
"
],
self
.
tokens
=
Types
()
cnf
[
"
case
"
][
"
reserved-words
"
][
"
splitchars
"
],
cnf
[
"
tokens
"
][
"
reserved-words
"
])
self
.
check
()
self
.
check
()
def
check
(
self
):
for
i
in
range
(
self
.
n_data
):
line
=
self
.
data
[
i
]
sline
=
self
.
splitline
(
line
)
for
word
in
sline
:
if
self
.
tokens
.
is_valid
(
word
):
line
=
line
.
replace
(
word
,
word
.
lower
(),
1
)
self
.
data
[
i
]
=
line
class
Case
Conversion
s
(
B
aseCheck
):
class
Case
Type
s
(
C
aseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
,
self
.
splitchars
=
[
"
"
,
"
.
"
,
"
;
"
,
"
(
"
,
"
)
"
]
cnf
[
"
case
"
][
"
types
"
][
"
case
"
],
self
.
tokens
=
Conversions
()
cnf
[
"
case
"
][
"
types
"
][
"
splitchars
"
],
cnf
[
"
tokens
"
][
"
types
"
])
self
.
check
()
self
.
check
()
def
check
(
self
):
for
i
in
range
(
self
.
n_data
):
line
=
self
.
data
[
i
]
sline
=
self
.
splitline
(
line
)
for
word
in
sline
:
if
self
.
tokens
.
is_valid
(
word
):
line
=
line
.
replace
(
word
,
word
.
lower
(),
1
)
self
.
data
[
i
]
=
line
class
Case
Resolut
ions
(
B
aseCheck
):
class
Case
Convers
ions
(
C
aseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
,
self
.
splitchars
=
[
"
"
,
"
.
"
,
"
;
"
,
"
(
"
,
"
)
"
]
cnf
[
"
case
"
][
"
conversions
"
][
"
case
"
],
self
.
tokens
=
Resolutions
()
cnf
[
"
case
"
][
"
conversions
"
][
"
splitchars
"
],
cnf
[
"
tokens
"
][
"
conversions
"
])
self
.
check
()
self
.
check
()
def
check
(
self
):
for
i
in
range
(
self
.
n_data
):
class
CaseResolutions
(
CaseCheck
):
line
=
self
.
data
[
i
]
def
__init__
(
self
,
data
):
sline
=
self
.
splitline
(
line
)
super
().
__init__
(
data
,
for
word
in
sline
:
cnf
[
"
case
"
][
"
resolutions
"
][
"
case
"
],
if
self
.
tokens
.
is_valid
(
word
):
cnf
[
"
case
"
][
"
resolutions
"
][
"
splitchars
"
],
line
=
line
.
replace
(
word
,
word
.
lower
(),
1
)
cnf
[
"
tokens
"
][
"
resolutions
"
]
)
self
.
data
[
i
]
=
line
self
.
check
()
class
CaseAttributes
(
B
aseCheck
):
class
CaseAttributes
(
C
aseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
,
self
.
splitchars
=
[
"
"
,
"
.
"
,
"
;
"
,
"
(
"
,
"
)
"
,
"'"
]
cnf
[
"
case
"
][
"
resolutions
"
][
"
case
"
],
self
.
tokens
=
Attributes
()
cnf
[
"
case
"
][
"
resolutions
"
][
"
splitchars
"
],
cnf
[
"
tokens
"
][
"
attributes
"
])
self
.
check
()
self
.
check
()
def
check
(
self
):
def
check
(
self
):
...
@@ -354,51 +382,33 @@ class CaseAttributes(BaseCheck):
...
@@ -354,51 +382,33 @@ class CaseAttributes(BaseCheck):
self
.
data
[
i
]
=
line
self
.
data
[
i
]
=
line
class
CaseConstants
(
B
aseCheck
):
class
CaseConstants
(
C
aseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
,
self
.
splitchars
=
[
"
"
,
"
.
"
,
"
;
"
,
"
(
"
,
"
)
"
,
"
,
"
]
cnf
[
"
case
"
][
"
constants
"
][
"
case
"
],
self
.
tokens
=
Constants
()
cnf
[
"
case
"
][
"
constants
"
][
"
splitchars
"
],
cnf
[
"
tokens
"
][
"
constants
"
])
self
.
check
()
self
.
check
()
def
check
(
self
):
for
i
in
range
(
self
.
n_data
):
line
=
self
.
data
[
i
]
sline
=
self
.
splitline
(
line
)
for
j
in
range
(
len
(
sline
)):
word
=
sline
[
j
]
if
self
.
tokens
.
is_valid
(
word
):
line
=
line
.
replace
(
word
,
word
.
lower
(),
1
)
self
.
data
[
i
]
=
line
class
CaseStandardLogic
(
B
aseCheck
):
class
CaseStandardLogic
(
C
aseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
,
self
.
splitchars
=
[
"
"
,
"
.
"
,
"
;
"
,
"
(
"
,
"
)
"
,
"
,
"
]
cnf
[
"
case
"
][
"
standard-logic
"
][
"
case
"
],
self
.
tokens
=
StandardLogic
()
cnf
[
"
case
"
][
"
standard-logic
"
][
"
splitchars
"
],
cnf
[
"
tokens
"
][
"
standard-logic
"
])
self
.
check
()
self
.
check
()
def
check
(
self
):
for
i
in
range
(
self
.
n_data
):
line
=
self
.
data
[
i
]
sline
=
self
.
splitline
(
line
)
for
j
in
range
(
len
(
sline
)):
word
=
sline
[
j
]
if
self
.
tokens
.
is_valid
(
word
):
line
=
line
.
replace
(
word
,
word
.
lower
(),
1
)
self
.
data
[
i
]
=
line
class
RemoveSpaceBeforeBracket
(
BaseCheck
):
class
RemoveSpaceBeforeBracket
(
BaseCheck
):
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
super
().
__init__
(
data
)
super
().
__init__
(
data
)
self
.
t
ype
s
=
Types
(
)
self
.
t
oken
s
=
T
okens
(
cnf
[
"
tokens
"
][
"
t
ypes
"
]
)
self
.
check
()
self
.
check
()
def
check
(
self
):
def
check
(
self
):
for
i
in
range
(
self
.
n_data
):
for
i
in
range
(
self
.
n_data
):
for
t
in
self
.
types
.
tokens
():
for
t
in
self
.
tokens
.
all
():
self
.
data
[
i
]
=
self
.
data
[
i
].
replace
(
f
"
{
t
}
(
"
,
f
"
{
t
}
(
"
)
self
.
data
[
i
]
=
self
.
data
[
i
].
replace
(
f
"
{
t
}
(
"
,
f
"
{
t
}
(
"
)
...
@@ -454,14 +464,14 @@ class AlignProcedureArgs(BaseCheck):
...
@@ -454,14 +464,14 @@ class AlignProcedureArgs(BaseCheck):
proc_span
=
[
0
,
0
]
proc_span
=
[
0
,
0
]
class
Token
:
class
Token
s
:
"""
"""
Base c
lass for tokens
C
lass for tokens
"""
"""
def
__init__
(
self
,
tokens
):
def
__init__
(
self
,
tokens
):
self
.
_tokens
=
tokens
self
.
_tokens
=
tokens
def
tokens
(
self
):
def
all
(
self
):
return
self
.
_tokens
return
self
.
_tokens
def
is_valid
(
self
,
val
):
def
is_valid
(
self
,
val
):
...
@@ -470,72 +480,11 @@ class Token:
...
@@ -470,72 +480,11 @@ class Token:
return
False
return
False
class
Types
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"
bit
"
,
"
bit_vector
"
,
"
integer
"
,
"
natural
"
,
"
positive
"
,
"
boolean
"
,
"
string
"
,
"
character
"
,
"
real
"
,
"
time
"
,
"
delay_length
"
,
"
std_ulogic
"
,
"
std_ulogic_vector
"
,
"
std_logic
"
,
"
std_logic_vector
"
])
class
Conversions
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"
signed
"
,
"
unsigned
"
,
"
to_signed
"
,
"
to_unsigned
"
,
"
to_integer
"
,
"
to_uint
"
,
"
to_sint
"
,
"
to_ureal
"
,
"
to_sreal
"
,
"
to_uvec
"
,
"
to_svec
"
])
class
Resolutions
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"'
u
'"
,
"'
x
'"
,
"'
0
'"
,
"'
1
'"
,
"'
z
'"
,
"'
w
'"
,
"'
l
'"
,
"'
h
'"
,
"'
-
'"
])
class
Constants
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"
true
"
,
"
false
"
])
class
StandardLogic
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"
ieee
"
,
"
std_logic_1164
"
,
"
numeric_std
"
,
"
math_real
"
,
"
std_logic_textio
"
,
"
resize
"
])
class
Attributes
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"
base
"
,
"
left
"
,
"
right
"
,
"
high
"
,
"
low
"
,
"
ascending
"
,
"
image
"
,
"
value
"
,
"
pos
"
,
"
val
"
,
"
succ
"
,
"
pred
"
,
"
leftof
"
,
"
rightof
"
,
"
left
"
,
"
left
"
,
"
right
"
,
"
right
"
,
"
high
"
,
"
high
"
,
"
low
"
,
"
low
"
,
"
range
"
,
"
range
"
,
"
reverse_range
"
,
"
reverse_range
"
,
"
length
"
,
"
length
"
,
"
ascending
"
,
"
ascending
"
,
"
delayed
"
,
"
stable
"
,
"
stable
"
,
"
quiet
"
,
"
quiet
"
,
"
transaction
"
,
"
event
"
,
"
active
"
,
"
last_event
"
,
"
last_active
"
,
"
last_value
"
,
"
driving
"
,
"
driving_value
"
,
"
simple_name
"
,
"
instance_name
"
,
"
path_name
"
])
class
Operators
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"
*
"
,
"
/
"
,
"
+
"
,
"
-
"
,
"
&
"
,
"
=
"
,
"
<
"
,
"
>
"
,
"
:
"
])
class
Delimiters
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"
:
"
])
class
ReservedWords
(
Token
):
def
__init__
(
self
):
super
().
__init__
([
"
abs
"
,
"
access
"
,
"
after
"
,
"
alias
"
,
"
all
"
,
"
and
"
,
"
architecture
"
,
"
array
"
,
"
assert
"
,
"
attribute
"
,
"
begin
"
,
"
block
"
,
"
body
"
,
"
buffer
"
,
"
bus
"
,
"
case
"
,
"
component
"
,
"
configuration
"
,
"
constant
"
,
"
disconnect
"
,
"
downto
"
,
"
else
"
,
"
elsif
"
,
"
end
"
,
"
entity
"
,
"
exit
"
,
"
file
"
,
"
for
"
,
"
function
"
,
"
generate
"
,
"
generic
"
,
"
group
"
,
"
guarded
"
,
"
if
"
,
"
impure
"
,
"
in
"
,
"
inertial
"
,
"
inout
"
,
"
is
"
,
"
label
"
,
"
library
"
,
"
linkage
"
,
"
literal
"
,
"
loop
"
,
"
map
"
,
"
mod
"
,
"
nand
"
,
"
new
"
,
"
next
"
,
"
nor
"
,
"
not
"
,
"
null
"
,
"
of
"
,
"
on
"
,
"
open
"
,
"
or
"
,
"
others
"
,
"
out
"
,
"
package
"
,
"
port
"
,
"
postponed
"
,
"
procedure
"
,
"
process
"
,
"
pure
"
,
"
range
"
,
"
record
"
,
"
register
"
,
"
reject
"
,
"
rem
"
,
"
report
"
,
"
return
"
,
"
rol
"
,
"
ror
"
,
"
select
"
,
"
severity
"
,
"
signal
"
,
"
shared
"
,
"
sla
"
,
"
sll
"
,
"
sra
"
,
"
srl
"
,
"
subtype
"
,
"
then
"
,
"
to
"
,
"
transport
"
,
"
type
"
,
"
unaffected
"
,
"
units
"
,
"
until
"
,
"
use
"
,
"
variable
"
,
"
wait
"
,
"
when
"
,
"
while
"
,
"
with
"
,
"
xnor
"
,
"
xor
"
])
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
# load config file
basedir
=
getenv
(
"
HDL_WORK
"
)
config_file
=
path
.
join
(
basedir
,
"
tools
"
,
"
vhdl_style_fix.yaml
"
)
cnf
=
load
(
open
(
config_file
,
'
r
'
),
Loader
=
FullLoader
)
# Parse command line arguments
# Parse command line arguments
parser
=
ArgumentParser
(
parser
=
ArgumentParser
(
description
=
""
.
join
(
dedent
(
"""
\
description
=
""
.
join
(
dedent
(
"""
\
...
...
This diff is collapsed.
Click to expand it.
tools/vhdl_style_fix.yaml
0 → 100644
+
240
−
0
View file @
b5ff6fbe
#
# config file for vhdl_style_fix.py
#
space
:
remove-trailing
:
True
add-around-operators
:
True
add-around-delimiters
:
False
remove-before-bracket
:
True
indend
:
apply
:
False
size
:
2
align
:
procedure-args
:
False
case
:
standard-logic
:
convert
:
True
case
:
"
lower"
splitchars
:
[
"
"
,
"
."
,
"
;"
,
"
("
,
"
)"
,
"
,"
]
constants
:
convert
:
True
case
:
"
lower"
splitchars
:
[
"
"
,
"
."
,
"
;"
,
"
("
,
"
)"
,
"
,"
]
reserved-words
:
convert
:
True
case
:
"
lower"
splitchars
:
[
"
"
,
"
."
,
"
;"
,
"
("
,
"
)"
]
types
:
convert
:
True
case
:
"
lower"
splitchars
:
[
"
"
,
"
."
,
"
;"
,
"
("
,
"
)"
]
conversions
:
convert
:
True
case
:
"
lower"
splitchars
:
[
"
"
,
"
."
,
"
;"
,
"
("
,
"
)"
]
resolutions
:
convert
:
True
case
:
"
lower"
splitchars
:
[
"
"
,
"
."
,
"
;"
,
"
("
,
"
)"
]
attributes
:
convert
:
True
case
:
"
lower"
splitchars
:
[
"
"
,
"
."
,
"
;"
,
"
("
,
"
)"
,
"
'"
]
# all tokens used
tokens
:
types
:
-
"
bit"
-
"
bit_vector"
-
"
integer"
-
"
natural"
-
"
positive"
-
"
boolean"
-
"
string"
-
"
character"
-
"
real"
-
"
time"
-
"
delay_length"
-
"
std_ulogic"
-
"
std_ulogic_vector"
-
"
std_logic"
-
"
std_logic_vector"
conversions
:
-
"
signed"
-
"
unsigned"
-
"
to_signed"
-
"
to_unsigned"
-
"
to_integer"
-
"
to_uint"
-
"
to_sint"
-
"
to_ureal"
-
"
to_sreal"
-
"
to_uvec"
-
"
to_svec"
resolutions
:
-
"
'u'"
-
"
'x'"
-
"
'0'"
-
"
'1'"
-
"
'z'"
-
"
'w'"
-
"
'l'"
-
"
'h'"
-
"
'-'"
constants
:
-
"
true"
-
"
false"
standard-logic
:
-
"
ieee"
-
"
std_logic_1164"
-
"
numeric_std"
-
"
math_real"
-
"
std_logic_textio"
-
"
resize"
operators
:
-
"
*"
-
"
/"
-
"
+"
-
"
-"
-
"
&"
-
"
="
-
"
<"
-
"
>"
-
"
:"
delimiters
:
-
"
:"
attributes
:
-
"
base"
-
"
left"
-
"
right"
-
"
high"
-
"
low"
-
"
ascending"
-
"
image"
-
"
value"
-
"
pos"
-
"
val"
-
"
succ"
-
"
pred"
-
"
leftof"
-
"
rightof"
-
"
range"
-
"
reverse_range"
-
"
length"
-
"
ascending"
-
"
delayed"
-
"
stable"
-
"
quiet"
-
"
transaction"
-
"
event"
-
"
active"
-
"
last_event"
-
"
last_active"
-
"
last_value"
-
"
driving"
-
"
driving_value"
-
"
simple_name"
-
"
instance_name"
-
"
path_name"
reserved-words
:
-
"
abs"
-
"
access"
-
"
after"
-
"
alias"
-
"
all"
-
"
and"
-
"
architecture"
-
"
array"
-
"
assert"
-
"
attribute"
-
"
begin"
-
"
block"
-
"
body"
-
"
buffer"
-
"
bus"
-
"
case"
-
"
component"
-
"
configuration"
-
"
constant"
-
"
disconnect"
-
"
downto"
-
"
else"
-
"
elsif"
-
"
end"
-
"
entity"
-
"
exit"
-
"
file"
-
"
for"
-
"
function"
-
"
generate"
-
"
generic"
-
"
group"
-
"
guarded"
-
"
if"
-
"
impure"
-
"
in"
-
"
inertial"
-
"
inout"
-
"
is"
-
"
label"
-
"
library"
-
"
linkage"
-
"
literal"
-
"
loop"
-
"
map"
-
"
mod"
-
"
nand"
-
"
new"
-
"
next"
-
"
nor"
-
"
not"
-
"
null"
-
"
of"
-
"
on"
-
"
open"
-
"
or"
-
"
others"
-
"
out"
-
"
package"
-
"
port"
-
"
postponed"
-
"
procedure"
-
"
process"
-
"
pure"
-
"
range"
-
"
record"
-
"
register"
-
"
reject"
-
"
rem"
-
"
report"
-
"
return"
-
"
rol"
-
"
ror"
-
"
select"
-
"
severity"
-
"
signal"
-
"
shared"
-
"
sla"
-
"
sll"
-
"
sra"
-
"
srl"
-
"
subtype"
-
"
then"
-
"
to"
-
"
transport"
-
"
type"
-
"
unaffected"
-
"
units"
-
"
until"
-
"
use"
-
"
variable"
-
"
wait"
-
"
when"
-
"
while"
-
"
with"
-
"
xnor"
-
"
xor"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tools/vhdl_style_fix_all_files.py
+
37
−
3
View file @
b5ff6fbe
#!/usr/bin/python3
#!/usr/bin/python3
from
os
import
getenv
# ##########################################################################
# Copyright 2020
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ##########################################################################
# ##########################################################################
# Author: Pieter Donker
# Purpose: run vhdl_style_fix.py on all files in the hdl dir using multiple
# workers
# Description:
# -p: number of workers to use
# -v: verbose
# usage:
# cd git/hdl/
# . ./init_hdl.sh
# vhdl_style_fix_all_files.py -p 4
#
# ##########################################################################
from
os
import
getenv
,
path
from
sys
import
exit
,
version_info
from
sys
import
exit
,
version_info
from
time
import
sleep
from
time
import
sleep
from
argparse
import
ArgumentParser
,
RawTextHelpFormatter
from
argparse
import
ArgumentParser
,
RawTextHelpFormatter
...
@@ -71,7 +103,9 @@ class Worker(Process):
...
@@ -71,7 +103,9 @@ class Worker(Process):
"""
"""
Use vhdl_style_fix.py to fix the file
Use vhdl_style_fix.py to fix the file
"""
"""
cmd
=
f
"
/home/donker/git/hdl/vhdl_style_fix.py
{
filename
}
"
basedir
=
getenv
(
"
HDL_WORK
"
)
fixtool
=
path
.
join
(
basedir
,
"
tools
"
,
"
vhdl_style_fix.py
"
)
cmd
=
f
"
{
fixtool
}
{
filename
}
"
if
self
.
verbose
:
if
self
.
verbose
:
cmd
+=
"
--verbose
"
cmd
+=
"
--verbose
"
response
=
run_cmd
(
cmd
)
response
=
run_cmd
(
cmd
)
...
@@ -84,7 +118,7 @@ class Worker(Process):
...
@@ -84,7 +118,7 @@ class Worker(Process):
control
=
self
.
control
.
get
()
control
=
self
.
control
.
get
()
if
control
==
"
stop
"
:
if
control
==
"
stop
"
:
self
.
stop
=
True
self
.
stop
=
True
print
(
f
"
stop
vsg
worker
{
self
.
id
}
"
)
print
(
f
"
stop worker
{
self
.
id
}
"
)
# get next vhd file to process
# get next vhd file to process
filename
=
self
.
in_data
.
get
(
block
=
False
)
filename
=
self
.
in_data
.
get
(
block
=
False
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment