Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
ORS Hardware
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yoji Takeuchi
ORS Hardware
Commits
4e2f9f63
Commit
4e2f9f63
authored
Dec 01, 2022
by
Thomas Gambier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add netlist comparator
parent
fb3dc63f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
0 deletions
+108
-0
README.md
README.md
+1
-0
tools/compare_netlist.py
tools/compare_netlist.py
+107
-0
No files found.
README.md
View file @
4e2f9f63
...
@@ -38,6 +38,7 @@ In order to do a full functional product, you will need all those components:
...
@@ -38,6 +38,7 @@ In order to do a full functional product, you will need all those components:
*
`NC Drill`
: text file for drilling
*
`NC Drill`
: text file for drilling
*
`Pick Place`
: text files for pick and place
*
`Pick Place`
: text files for pick and place
*
`Schematic Print`
: PDF version of the schematic
*
`Schematic Print`
: PDF version of the schematic
*
`tools`
: directory containing useful tools
## FAQ
## FAQ
...
...
tools/compare_netlist.py
0 → 100644
View file @
4e2f9f63
#! /usr/bin/env python3
import
argparse
import
pprint
parser
=
argparse
.
ArgumentParser
(
description
=
"Compare 2 netlists dumped by Altium"
)
parser
.
add_argument
(
'ref_netlist'
,
type
=
argparse
.
FileType
(
'r'
,
encoding
=
"ISO-8859-1"
))
parser
.
add_argument
(
'new_netlist'
,
type
=
argparse
.
FileType
(
'r'
,
encoding
=
"ISO-8859-1"
))
args
=
parser
.
parse_args
()
pp
=
pprint
.
PrettyPrinter
(
indent
=
4
)
def
read_line_eof
(
f
):
l
=
f
.
readline
()
if
len
(
l
)
==
0
:
raise
EOFError
return
l
.
strip
()
def
read_netlist
(
f
):
component_dict
=
{}
connection_dict
=
{}
line
=
read_line_eof
(
f
)
try
:
while
True
:
if
line
==
"["
:
component
=
read_line_eof
(
f
)
component_dict
[
component
]
=
[]
line
=
read_line_eof
(
f
)
while
line
!=
"]"
:
component_dict
[
component
].
append
(
line
)
line
=
read_line_eof
(
f
)
elif
line
==
"("
:
connection
=
read_line_eof
(
f
)
connection_dict
[
connection
]
=
[]
line
=
read_line_eof
(
f
)
while
line
!=
")"
:
connection_dict
[
connection
].
append
(
line
)
line
=
read_line_eof
(
f
)
connection_dict
[
connection
].
sort
()
else
:
line
=
read_line_eof
(
f
)
except
EOFError
:
return
(
component_dict
,
connection_dict
)
return
(
component_dict
,
connection_dict
)
def
dict_compare
(
d1
,
d2
):
d1_keys
=
set
(
d1
.
keys
())
d2_keys
=
set
(
d2
.
keys
())
shared_keys
=
d1_keys
.
intersection
(
d2_keys
)
added
=
d1_keys
-
d2_keys
removed
=
d2_keys
-
d1_keys
modified
=
{
o
:
(
d1
[
o
],
d2
[
o
])
for
o
in
shared_keys
if
d1
[
o
]
!=
d2
[
o
]}
same
=
set
(
o
for
o
in
shared_keys
if
d1
[
o
]
==
d2
[
o
])
return
added
,
removed
,
modified
,
same
def
pprint
(
o
):
if
len
(
o
)
>
0
:
pp
.
pprint
(
o
)
else
:
print
(
None
)
def
compare_netlist
(
netlist1
,
netlist2
):
comp1
,
con1
=
netlist1
comp2
,
con2
=
netlist2
comp_added
,
comp_removed
,
comp_modified
,
comp_same
=
dict_compare
(
comp2
,
comp1
)
con_added
,
con_removed
,
con_modified
,
con_same
=
dict_compare
(
con2
,
con1
)
print
(
"******************************************************"
)
print
(
"******************** COMPONENTS **********************"
)
print
(
"******************************************************"
)
print
(
"Added in netlist:"
)
pprint
(
comp_added
)
print
(
"Removed in netlist:"
)
pprint
(
comp_removed
)
print
(
"Modified in netlist:"
)
pprint
(
comp_modified
)
print
(
"
\
n
\
n
"
)
print
(
"******************************************************"
)
print
(
"*********************** NETS *************************"
)
print
(
"******************************************************"
)
print
(
"Added in netlist:"
)
pprint
(
con_added
)
print
(
"Removed in netlist:"
)
pprint
(
con_removed
)
print
(
"Modified in netlist:"
)
for
c
in
con_modified
:
l1
,
l2
=
con_modified
[
c
]
print
(
""
)
print
(
"NET: {}"
.
format
(
c
))
print
(
"Wires added:"
,
end
=
''
)
s
=
set
(
l1
)
-
set
(
l2
)
if
len
(
s
)
>
0
:
print
(
s
)
else
:
print
(
"None"
)
print
(
"Wires removed:"
,
end
=
''
)
s
=
set
(
l2
)
-
set
(
l1
)
if
len
(
s
)
>
0
:
print
(
s
)
else
:
print
(
"None"
)
compare_netlist
(
read_netlist
(
args
.
ref_netlist
),
read_netlist
(
args
.
new_netlist
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment