From 6fa4359a66cb74411f3e9a61ba7b92ee24db069a Mon Sep 17 00:00:00 2001
From: Woodfold <woodfold@woodfold-thermwood.(none)>
Date: Wed, 9 Dec 2009 16:32:38 -0800
Subject: added nand, nor, xnor

---
 src/hal/components/logic.comp |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/hal/components/logic.comp b/src/hal/components/logic.comp
index 378dd18..d50929e 100644
--- a/src/hal/components/logic.comp
+++ b/src/hal/components/logic.comp
@@ -1,21 +1,24 @@
 component logic;
 pin in bit in-##[16 : personality & 0xff];
 pin out bit and if personality & 0x100;
+pin out bit nand if personality & 0x100;
 pin out bit or if personality & 0x200;
+pin out bit nor if personality & 0x200;
 pin out bit xor if personality & 0x400;
+pin out bit xnor if personality & 0x400;
 function _ nofp;
 description """
-Experimental general `logic function' component.  Can perform `and', `or'
-and `xor' of up to 16 inputs.  Determine the proper value for `personality'
+Experimental general `logic function' component.  Can perform `and', `nand', `or', `nor',
+`xor' and `xnor'  of up to 16 inputs.  Determine the proper value for `personality'
 by adding:
 .IP \\(bu 4
 The number of input pins, usually from 2 to 16
 .IP \\(bu
-256 (0x100)  if the `and' output is desired
+256 (0x100)  if the `and' / `nand' output is desired
 .IP \\(bu
-512 (0x200)  if the `or' output is desired
+512 (0x200)  if the `or' / `nor' output is desired
 .IP \\(bu
-1024 (0x400)  if the `xor' (exclusive or) output is desired""";
+1024 (0x400)  if the `xor' / `xnor' (exclusive or/exclusive nor) output is desired""";
 license "GPL";
 ;;
 FUNCTION(_) {
@@ -24,7 +27,16 @@ FUNCTION(_) {
         if(in(i)) { o = 1; x = !x; }
         else { a = 0; }
     }
-    if(personality & 0x100) and = a;
-    if(personality & 0x200) or = o;
-    if(personality & 0x400) xor = x;
+    if(personality & 0x100) {
+        and = a;
+        nand = !a;
+    }
+    if(personality & 0x200) {
+        or = o;
+        nor = !o;
+    }
+    if(personality & 0x400) {
+        xor = x;
+        xnor = !x;
+    }
 }
-- 
1.5.4.3

