google / pcbdl

PCB Design Language: A programming way to design schematics.
Other
155 stars 23 forks source link

Improve Consistent/Deterministic refdeses #4

Open amstan opened 5 years ago

amstan commented 5 years ago

I don't really want people to have to worry about refdeses inside the code. Part initializations should not be littered with refdes="Uwhatever".

Right now Context.autoname, beyond numbering parts automatically, also remembers what things were named (via the .refdes_mapping files). But it's hard to track parts via just the code, since there's nothing anchoring part instances across different runs to the place where they're defined.

Some traditional EDAs solve this problem by having an UUID for each part (which stays for the life of it, inside the source file), then layout tools don't even care if the refdeses change, as long as the UUID didn't. We don't have that luxury, unless we want things like R("100k", uuid="d4c1d842-705b-456d-9ee1-585463c11db2") everywhere.

The current implementation of Context.autoname uses the nearby lines contents around every part initialization to track a part. The problem with this is that a simple change to something maybe unrelated, or a simple change to the value of a part, causes the part's refdes to "pop" and get forgotten.

We need to track a few more things beyond just lines of code.

"Design doc" https://github.com/google/pcbdl/wiki/Consistent-refdeses

amstan commented 4 years ago

The current implementation is still pretty unusable. The extensive changes to the source code in c718fbc39266f9799fb85ae0d3084123da39a278 and issue #19 both show big weaknesses.

amstan commented 4 years ago

Perhaps https://en.wikipedia.org/wiki/Locality-sensitive_hashing as well?

amstan commented 4 years ago

So this got a lot better. There's still room for: