logic.comp
来自「CNC 的开放码,EMC2 V2.2.8版」· COMP 代码 · 共 31 行
COMP
31 行
component logic;pin in bit in-##[16 : personality & 0xff];pin out bit and if personality & 0x100;pin out bit or if personality & 0x200;pin out bit xor 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'by adding:.IP \\(bu 4The number of input pins, usually from 2 to 16.IP \\(bu256 (0x100) if the `and' output is desired.IP \\(bu512 (0x200) if the `or' output is desired.IP \\(bu1024 (0x400) if the `xor' (exclusive or) output is desired""";license "GPL";;;FUNCTION(_) { int i, a=1, o=0, x=0; for(i=0; i < (personality & 0xff); i++) { 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;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?