Talk:Four bit adder: Difference between revisions

(→‎Clojure solution: new section)
(→‎I made a latch!: new section)
 
Line 269:
 
The choice of big endian or little endian is arbitrary, but I think big endian is easier to read. That requires a little extra fiddling with how the bits are fed to the reduce function, but also shows off the '''rseq''' function, which is constant-time reverse for vectors.
 
== I made a latch! ==
 
It wasn't my original goal. Instead my first step was a concurrent implementation a little more robust than MizardX's. That method probably would be sufficient to build a latch, but I wanted something more resistant to blocking and deadlocking. Anyway,
<pre>
=== RUN Test-4
--- PASS: Test-4 (0.01 seconds)
logic_test.go:17: power up
logic_test.go:20: S: 0 R: 0 Q: 1 NQ: 0
logic_test.go:22: pulling R = 1
logic_test.go:25: S: 0 R: 1 Q: 0 NQ: 1
logic_test.go:27: pulling R = 0
logic_test.go:30: S: 0 R: 0 Q: 0 NQ: 1
logic_test.go:32: pulling S = 1
logic_test.go:35: S: 1 R: 0 Q: 1 NQ: 0
logic_test.go:37: pulling S = 0
logic_test.go:40: S: 0 R: 0 Q: 1 NQ: 0
</pre>
The concurrency isn't very exotic, and could probably be coded pretty easily in most languages with any kind of concurrency support, but I'm not sure it's quite ready for another task. It still runs asyncronously, with no concept of simulation time, so you have to do the hokey thing of just sleeping for a bit to let it run. I have a vague idea of using a priority queue for simulation time. Maybe that will be next. &mdash;[[User:Sonia|Sonia]] 01:05, 9 July 2012 (UTC)
1,707

edits