tuura / plato

A DSL for asynchronous circuits specification
Other
12 stars 2 forks source link

Implemented OR-causality. #48

Closed jrbeaumont closed 7 years ago

jrbeaumont commented 7 years ago

The algorithm for this I will display in a blog post. For now, here is some testing information. The test files are here: Or-causality testing.zip

OR-gate C = A+B: Works as expected. Synthesis produces this circuit: circuit_or_gate.pdf

AND-gate C = AB: Also works as expected. Synthesis produces this circuit: circuit_and_gate.pdf

Two OR-gates - C = (A+B)(D+E): Synthesis produces a predictably complex circuit, but simulation of the STG reveals it to work as expected. To set C high (minimum): A+ and D+. A+ and E+. B+ and D+. B+ and E+. To set C low: All signals low

AND and OR gate - C = (A+B)DE: Again, synthesis produces something unrecognizable. Simulation reveals correctness: To set C high (minimum): A+, D+ and E+. B+, D+ and E+. To set C low (minimum): A-, B- and E-. A-, B- and D-.

A 2-input OR and a 3-input OR - C = (A+B)(D+E+F): Synthesis doesn't produce much, but simulation is good: To set C high (minimum): A+ and D+. A+ and E+. A+ and F+. B+ and D+. B+ and E+. B+ and F+. To set C low: All signals low

Let me know if you have any other test cases you wish me to try.

snowleopard commented 7 years ago

I think we should combine arcs and ors into arcs:

arcs :: [([a], a)]

arcConcept from to = mempty { arcs = [([from], to)] }

In other words, usual causality is a special case of OR-causality with a singleton list of causes. Pretty sure this will simplify the rest of the code too.

jrbeaumont commented 7 years ago

Can be done. Something like: When it comes to handling OR causality in the translation, filter for lists of >1 size and those are OR causality?

snowleopard commented 7 years ago

Yes, but I don't think you will ever need to do the filtering. Think of singletons as brackets with single variables when doing expansion.

In fact I think all you need is standard Haskell function sequence which will magically compute all terms for you :-)

See answers here: http://stackoverflow.com/questions/4119730/cartesian-product

snowleopard commented 7 years ago

For example, try sequence [[1], [2, 3], [4, 5]].

jrbeaumont commented 7 years ago

Yeah that would work great. I'll replace this part in my implementation and see how it goes.

jrbeaumont commented 7 years ago

@snowleopard: I have used your suggestions and re-tested. All works well :)

jrbeaumont commented 7 years ago

@snowleopard: Fixes made. Still working correctly.

jrbeaumont commented 7 years ago

@snowleopard: Hold off for 2 minutes, I forgot to include AND and OR gate concepts

jrbeaumont commented 7 years ago

@snowleopard: OK i'm done, unless you have any further suggestions :)

jrbeaumont commented 7 years ago

This should close #34

snowleopard commented 7 years ago

Great, thanks!