Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDIF netlists are not reproducible #19

Open
gsmecher opened this issue Aug 18, 2022 · 1 comment
Open

EDIF netlists are not reproducible #19

gsmecher opened this issue Aug 18, 2022 · 1 comment

Comments

@gsmecher
Copy link

gsmecher commented Aug 18, 2022

SpyDrNet-TMR produces different EDIF netlists from run to run (Python 3.10.4). Repeatability is desirable for traceable builds and automated CAD flows.

For example:

netlist = sdn.load_example_netlist_by_name('fourBitCounter')
uniquify(netlist)

hinstances_to_replicate = list(netlist.get_hinstances(
    recursive=True,
    filter=lambda x: x.item.reference.is_leaf()))
instances_to_replicate = list(x.item for x in hinstances_to_replicate)

# Don't replicate any ports?
hports_to_replicate = []
ports_to_replicate = []

# Insertion points
insertion_points = find_after_ff_voter_points(netlist, [*hinstances_to_replicate, *hports_to_replicate], XILINX)

replicas = tmr.apply_nmr([*instances_to_replicate, *ports_to_replicate], 3, name_suffix='TMR', rename_original=True)
voters = tmr.insert_organs(replicas, insertion_points, XilinxTMRVoter(), 'VOTER')

sdn.compose(netlist, "fourBitCounter_tmr.edif")

If I run this command repeatedly, the generated EDIF is equivalent but permuted. Speculating, but the underlying cause is probably the appearance of memory addresses in the __hash__ exported by SpyDrNet IR classes like OuterPin. As a result, dictionary order is different from run to run, even though iterating through dictionary keys is determinstic in Python from 3.6 onwards and is considered a language feature from 3.7 onwards.

The __hash__ should identify instances using source location from the input netlist, if possible. (The ability to trace an IR instance back to source netlist is presumably useful on its own.)

Easy to complain, harder to implement - I am leaving this here in the hopes it's helpful, and with no expectation that anyone is going to rush out and implement it for me. Thanks for all your hard work on SpyDrNet and SpyDrNet-TMR.

best,
Graeme

@jacobdbrown4
Copy link
Collaborator

Thanks for submitting this issue. I used your script and was able to replicate the issue you're talking about. Determinism is definitely one of our goals so we will look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants