Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Created August 15, 2012 09:26
Show Gist options
  • Save Idorobots/3358061 to your computer and use it in GitHub Desktop.
Save Idorobots/3358061 to your computer and use it in GitHub Desktop.
More fun with SICP
(var bus-size 16)
(var A (make-bus bus-size))
(var B (make-bus bus-size))
(var c (make-wire))
(probe 'Carry c)
(var S (make-bus bus-size))
(ripple-carry-adder A B S c)
(set-bus-value! A '(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1))
(set-bus-value! B '(1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))
(write "A: " (bus-value A) "\n")
(write "B: " (bus-value B) "\n")
(write "S: " (bus-value S) "\n")
(propagate)
(write "S: " (bus-value S) "\n")
; 0 ns - Carry: new value = 0
; A: (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
; B: (1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
; S: (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
; Simulation started!
; 192 ns - Carry: new value = 1
; S: (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment