Advertisement
Guest User

Untitled

a guest
May 8th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns chipper.gates
  2.   (:use chipper.core))
  3.  
  4. (defprimitive nand* [a b] => [out]
  5.   (if (= 2 (+ a b)) [0] [1]))
  6.  
  7. (defgate not* [in] => [out]
  8.   (nand* [in in] => [out]))
  9.  
  10. (defgate and* [a b] => [out]
  11.   (nand* [a b] => [w])
  12.   (not* [w] => [out]))
  13.  
  14. (defgate or* [a b] => [out]
  15.    (not* [a] => [na])
  16.    (not* [b] => [nb])
  17.    (and* [na nb] => [w])
  18.    (not* [w] => [out]))
  19.  
  20. (defgate xor* [a b] => [out]
  21.   (not* [a] =>[na])
  22.   (not* [b] => [nb])
  23.   (and* [a nb] => [anb])
  24.   (and* [b na] => [bna])
  25.   (or* [anb bna] => [out]))
  26.  
  27. (defgate mux* [a b sel] => [out]
  28.   (not* [sel] => [nsel])
  29.   (and* [a nsel] => [w1])
  30.   (and* [b sel] => [w2])
  31.   (or* [w1 w2] => [out]))
  32.  
  33. (defgate dmux* [in sel] => [a b]
  34.   (not* [sel] => [nsel])
  35.   (and* [in nsel] => [a])
  36.   (and* [in sel] => [b]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement