// Auto-generated by gencfuncs.lua enum GateFuncs { GateFunc_None, GateFunc_Diode, GateFunc_Not, GateFunc_Enabler1, GateFunc_Enabler2, GateFunc_Enabler3, GateFunc_Enabler4, GateFunc_Enabler5, GateFunc_Enabler6, GateFunc_Enabler7, GateFunc_Enabler8, GateFunc_Enabler9, GateFunc_Enabler10, GateFunc_Enabler11, GateFunc_Enabler12, GateFunc_Enabler13, GateFunc_Enabler14, GateFunc_Enabler15, GateFunc_Enabler16, GateFunc_Enabler24, GateFunc_Enabler32, GateFunc_Enabler48, GateFunc_Enabler64, GateFunc_Buffer1, GateFunc_Buffer2, GateFunc_Buffer3, GateFunc_Buffer4, GateFunc_Buffer5, GateFunc_Buffer6, GateFunc_Buffer7, GateFunc_Buffer8, GateFunc_Buffer9, GateFunc_Buffer10, GateFunc_Buffer11, GateFunc_Buffer12, GateFunc_Buffer13, GateFunc_Buffer14, GateFunc_Buffer15, GateFunc_Buffer16, GateFunc_Buffer24, GateFunc_Buffer32, GateFunc_Buffer48, GateFunc_Buffer64, GateFunc_DFF1, GateFunc_DFF2, GateFunc_DFF3, GateFunc_DFF4, GateFunc_DFF5, GateFunc_DFF6, GateFunc_DFF7, GateFunc_DFF8, GateFunc_DFF9, GateFunc_DFF10, GateFunc_DFF11, GateFunc_DFF12, GateFunc_DFF13, GateFunc_DFF14, GateFunc_DFF15, GateFunc_DFF16, GateFunc_DFF24, GateFunc_DFF32, GateFunc_DFF48, GateFunc_DFF64, GateFunc_Mux1, GateFunc_Mux2, GateFunc_Mux3, GateFunc_Mux4, GateFunc_Mux5, GateFunc_Mux6, GateFunc_Mux7, GateFunc_Mux8, GateFunc_Demux1, GateFunc_Demux2, GateFunc_Demux3, GateFunc_Demux4, GateFunc_Demux5, GateFunc_Demux6, GateFunc_Demux7, GateFunc_Demux8, GateFunc_Adder2, GateFunc_Adder4, GateFunc_Adder8, GateFunc_Adder16, GateFunc_Adder32, GateFunc_Incrementer2, GateFunc_Incrementer4, GateFunc_Incrementer8, GateFunc_Incrementer16, GateFunc_Incrementer32, GateFunc_Multiplier2, GateFunc_Multiplier4, GateFunc_Multiplier8, GateFunc_Multiplier16, GateFunc_Multiplier32, GateFunc_Divider2, GateFunc_Divider4, GateFunc_Divider8, GateFunc_Divider16, GateFunc_Divider32, GateFunc_ShifterLeft2, GateFunc_ShifterLeft4, GateFunc_ShifterLeft8, GateFunc_ShifterLeft16, GateFunc_ShifterLeft32, GateFunc_ShifterRight2, GateFunc_ShifterRight4, GateFunc_ShifterRight8, GateFunc_ShifterRight16, GateFunc_ShifterRight32, GateFunc_And2, GateFunc_And3, GateFunc_And4, GateFunc_And5, GateFunc_And6, GateFunc_And7, GateFunc_And8, GateFunc_Or2, GateFunc_Or3, GateFunc_Or4, GateFunc_Or5, GateFunc_Or6, GateFunc_Or7, GateFunc_Or8, GateFunc_Xor2, GateFunc_Xor3, GateFunc_Xor4, GateFunc_Xor5, GateFunc_Xor6, GateFunc_Xor7, GateFunc_Xor8, GateFunc_Nand2, GateFunc_Nand3, GateFunc_Nand4, GateFunc_Nand5, GateFunc_Nand6, GateFunc_Nand7, GateFunc_Nand8, GateFunc_Nor2, GateFunc_Nor3, GateFunc_Nor4, GateFunc_Nor5, GateFunc_Nor6, GateFunc_Nor7, GateFunc_Nor8, GateFunc_Xnor2, GateFunc_Xnor3, GateFunc_Xnor4, GateFunc_Xnor5, GateFunc_Xnor6, GateFunc_Xnor7, GateFunc_Xnor8, GateFunc_Rom4x1, GateFunc_Rom4x4, GateFunc_Rom4x8, GateFunc_Rom6x1, GateFunc_Rom6x4, GateFunc_Rom6x8, GateFunc_Rom6x16, GateFunc_Rom6x32, GateFunc_Rom6x48, GateFunc_Rom6x64, GateFunc_Rom8x1, GateFunc_Rom8x4, GateFunc_Rom8x8, GateFunc_Rom8x16, GateFunc_Rom8x32, GateFunc_Rom8x48, GateFunc_Rom8x64, GateFunc_Rom9x1, GateFunc_Rom9x4, GateFunc_Rom9x8, GateFunc_Rom9x16, GateFunc_Rom9x32, GateFunc_Rom9x48, GateFunc_Rom9x64, GateFunc_Rom10x8, GateFunc_Rom10x16, GateFunc_Rom10x32, GateFunc_Rom10x48, GateFunc_Rom10x64, GateFunc_Rom11x8, GateFunc_Rom11x16, GateFunc_Rom11x32, GateFunc_Rom11x48, GateFunc_Rom11x64, GateFunc_Rom12x8, GateFunc_Rom12x16, GateFunc_Rom12x32, GateFunc_Rom12x48, GateFunc_Rom12x64, GateFunc_Ram8x8, GateFunc_Ram8x12, }; GATEFUNC(Diode) { setport(2, getport(1)); } GATEFUNC(Not) { setport(2, !getport(1)); } GATEFUNC(Enabler1) { if(getport(3)) { copyword(1, 1, 2); } else { clearword(1, 2); } } GATEFUNC(Enabler2) { if(getport(5)) { copyword(2, 1, 3); } else { clearword(2, 3); } } GATEFUNC(Enabler3) { if(getport(7)) { copyword(3, 1, 4); } else { clearword(3, 4); } } GATEFUNC(Enabler4) { if(getport(9)) { copyword(4, 1, 5); } else { clearword(4, 5); } } GATEFUNC(Enabler5) { if(getport(11)) { copyword(5, 1, 6); } else { clearword(5, 6); } } GATEFUNC(Enabler6) { if(getport(13)) { copyword(6, 1, 7); } else { clearword(6, 7); } } GATEFUNC(Enabler7) { if(getport(15)) { copyword(7, 1, 8); } else { clearword(7, 8); } } GATEFUNC(Enabler8) { if(getport(17)) { copyword(8, 1, 9); } else { clearword(8, 9); } } GATEFUNC(Enabler9) { if(getport(19)) { copyword(9, 1, 10); } else { clearword(9, 10); } } GATEFUNC(Enabler10) { if(getport(21)) { copyword(10, 1, 11); } else { clearword(10, 11); } } GATEFUNC(Enabler11) { if(getport(23)) { copyword(11, 1, 12); } else { clearword(11, 12); } } GATEFUNC(Enabler12) { if(getport(25)) { copyword(12, 1, 13); } else { clearword(12, 13); } } GATEFUNC(Enabler13) { if(getport(27)) { copyword(13, 1, 14); } else { clearword(13, 14); } } GATEFUNC(Enabler14) { if(getport(29)) { copyword(14, 1, 15); } else { clearword(14, 15); } } GATEFUNC(Enabler15) { if(getport(31)) { copyword(15, 1, 16); } else { clearword(15, 16); } } GATEFUNC(Enabler16) { if(getport(33)) { copyword(16, 1, 17); } else { clearword(16, 17); } } GATEFUNC(Enabler24) { if(getport(49)) { copyword(24, 1, 25); } else { clearword(24, 25); } } GATEFUNC(Enabler32) { if(getport(65)) { copyword(32, 1, 33); } else { clearword(32, 33); } } GATEFUNC(Enabler48) { if(getport(97)) { copyword(48, 1, 49); } else { clearword(48, 49); } } GATEFUNC(Enabler64) { if(getport(129)) { copyword(64, 1, 65); } else { clearword(64, 65); } } GATEFUNC(Buffer1) { if(getport(3)) { copyword(1, 1, 2); } else { clearword(1, 2); } } GATEFUNC(Buffer2) { if(getport(5)) { copyword(2, 1, 3); } else { clearword(2, 3); } } GATEFUNC(Buffer3) { if(getport(7)) { copyword(3, 1, 4); } else { clearword(3, 4); } } GATEFUNC(Buffer4) { if(getport(9)) { copyword(4, 1, 5); } else { clearword(4, 5); } } GATEFUNC(Buffer5) { if(getport(11)) { copyword(5, 1, 6); } else { clearword(5, 6); } } GATEFUNC(Buffer6) { if(getport(13)) { copyword(6, 1, 7); } else { clearword(6, 7); } } GATEFUNC(Buffer7) { if(getport(15)) { copyword(7, 1, 8); } else { clearword(7, 8); } } GATEFUNC(Buffer8) { if(getport(17)) { copyword(8, 1, 9); } else { clearword(8, 9); } } GATEFUNC(Buffer9) { if(getport(19)) { copyword(9, 1, 10); } else { clearword(9, 10); } } GATEFUNC(Buffer10) { if(getport(21)) { copyword(10, 1, 11); } else { clearword(10, 11); } } GATEFUNC(Buffer11) { if(getport(23)) { copyword(11, 1, 12); } else { clearword(11, 12); } } GATEFUNC(Buffer12) { if(getport(25)) { copyword(12, 1, 13); } else { clearword(12, 13); } } GATEFUNC(Buffer13) { if(getport(27)) { copyword(13, 1, 14); } else { clearword(13, 14); } } GATEFUNC(Buffer14) { if(getport(29)) { copyword(14, 1, 15); } else { clearword(14, 15); } } GATEFUNC(Buffer15) { if(getport(31)) { copyword(15, 1, 16); } else { clearword(15, 16); } } GATEFUNC(Buffer16) { if(getport(33)) { copyword(16, 1, 17); } else { clearword(16, 17); } } GATEFUNC(Buffer24) { if(getport(49)) { copyword(24, 1, 25); } else { clearword(24, 25); } } GATEFUNC(Buffer32) { if(getport(65)) { copyword(32, 1, 33); } else { clearword(32, 33); } } GATEFUNC(Buffer48) { if(getport(97)) { copyword(48, 1, 49); } else { clearword(48, 49); } } GATEFUNC(Buffer64) { if(getport(129)) { copyword(64, 1, 65); } else { clearword(64, 65); } } GATEFUNC(DFF1) { if(getport(3)) { copyword(1, 1, 2); } } GATEFUNC(DFF2) { if(getport(5)) { copyword(2, 1, 3); } } GATEFUNC(DFF3) { if(getport(7)) { copyword(3, 1, 4); } } GATEFUNC(DFF4) { if(getport(9)) { copyword(4, 1, 5); } } GATEFUNC(DFF5) { if(getport(11)) { copyword(5, 1, 6); } } GATEFUNC(DFF6) { if(getport(13)) { copyword(6, 1, 7); } } GATEFUNC(DFF7) { if(getport(15)) { copyword(7, 1, 8); } } GATEFUNC(DFF8) { if(getport(17)) { copyword(8, 1, 9); } } GATEFUNC(DFF9) { if(getport(19)) { copyword(9, 1, 10); } } GATEFUNC(DFF10) { if(getport(21)) { copyword(10, 1, 11); } } GATEFUNC(DFF11) { if(getport(23)) { copyword(11, 1, 12); } } GATEFUNC(DFF12) { if(getport(25)) { copyword(12, 1, 13); } } GATEFUNC(DFF13) { if(getport(27)) { copyword(13, 1, 14); } } GATEFUNC(DFF14) { if(getport(29)) { copyword(14, 1, 15); } } GATEFUNC(DFF15) { if(getport(31)) { copyword(15, 1, 16); } } GATEFUNC(DFF16) { if(getport(33)) { copyword(16, 1, 17); } } GATEFUNC(DFF24) { if(getport(49)) { copyword(24, 1, 25); } } GATEFUNC(DFF32) { if(getport(65)) { copyword(32, 1, 33); } } GATEFUNC(DFF48) { if(getport(97)) { copyword(48, 1, 49); } } GATEFUNC(DFF64) { if(getport(129)) { copyword(64, 1, 65); } } GATEFUNC(Mux1) { if(getport(4)) { setport(5, getport(getword(1, 1)+2)); } else { setport(5, 0); } } GATEFUNC(Mux2) { if(getport(7)) { setport(8, getport(getword(2, 1)+3)); } else { setport(8, 0); } } GATEFUNC(Mux3) { if(getport(12)) { setport(13, getport(getword(3, 1)+4)); } else { setport(13, 0); } } GATEFUNC(Mux4) { if(getport(21)) { setport(22, getport(getword(4, 1)+5)); } else { setport(22, 0); } } GATEFUNC(Mux5) { if(getport(38)) { setport(39, getport(getword(5, 1)+6)); } else { setport(39, 0); } } GATEFUNC(Mux6) { if(getport(71)) { setport(72, getport(getword(6, 1)+7)); } else { setport(72, 0); } } GATEFUNC(Mux7) { if(getport(136)) { setport(137, getport(getword(7, 1)+8)); } else { setport(137, 0); } } GATEFUNC(Mux8) { if(getport(265)) { setport(266, getport(getword(8, 1)+9)); } else { setport(266, 0); } } GATEFUNC(Demux1) { int pa = getdata(0); if(getport(4)) { int a = getword(1, 1) + 2; if(pa != a) { if(pa) { setport(pa, 0); } setport(a, 1); setdata(0, a); } } else { if(pa) { setport(pa, 0); setdata(0, 0); } } } GATEFUNC(Demux2) { int pa = getdata(0); if(getport(7)) { int a = getword(2, 1) + 3; if(pa != a) { if(pa) { setport(pa, 0); } setport(a, 1); setdata(0, a); } } else { if(pa) { setport(pa, 0); setdata(0, 0); } } } GATEFUNC(Demux3) { int pa = getdata(0); if(getport(12)) { int a = getword(3, 1) + 4; if(pa != a) { if(pa) { setport(pa, 0); } setport(a, 1); setdata(0, a); } } else { if(pa) { setport(pa, 0); setdata(0, 0); } } } GATEFUNC(Demux4) { int pa = getdata(0); if(getport(21)) { int a = getword(4, 1) + 5; if(pa != a) { if(pa) { setport(pa, 0); } setport(a, 1); setdata(0, a); } } else { if(pa) { setport(pa, 0); setdata(0, 0); } } } GATEFUNC(Demux5) { int pa = getdata(0); if(getport(38)) { int a = getword(5, 1) + 6; if(pa != a) { if(pa) { setport(pa, 0); } setport(a, 1); setdata(0, a); } } else { if(pa) { setport(pa, 0); setdata(0, 0); } } } GATEFUNC(Demux6) { int pa = getdata(0); if(getport(71)) { int a = getword(6, 1) + 7; if(pa != a) { if(pa) { setport(pa, 0); } setport(a, 1); setdata(0, a); } } else { if(pa) { setport(pa, 0); setdata(0, 0); } } } GATEFUNC(Demux7) { int pa = getdata(0); if(getport(136)) { int a = getword(7, 1) + 8; if(pa != a) { if(pa) { setport(pa, 0); } setport(a, 1); setdata(0, a); } } else { if(pa) { setport(pa, 0); setdata(0, 0); } } } GATEFUNC(Demux8) { int pa = getdata(0); if(getport(265)) { int a = getword(8, 1) + 9; if(pa != a) { if(pa) { setport(pa, 0); } setport(a, 1); setdata(0, a); } } else { if(pa) { setport(pa, 0); setdata(0, 0); } } } GATEFUNC(Adder2) { unsigned int v = getword(2, 1) + (getword(2, 3)^(getport(9)*3)) + getport(7); setword(2, 5, v); setport(8, (v>>2) & 1); } GATEFUNC(Adder4) { unsigned int v = getword(4, 1) + (getword(4, 5)^(getport(15)*15)) + getport(13); setword(4, 9, v); setport(14, (v>>4) & 1); } GATEFUNC(Adder8) { unsigned int v = getword(8, 1) + (getword(8, 9)^(getport(27)*255)) + getport(25); setword(8, 17, v); setport(26, (v>>8) & 1); } GATEFUNC(Adder16) { unsigned int v = getword(16, 1) + (getword(16, 17)^(getport(51)*65535)) + getport(49); setword(16, 33, v); setport(50, (v>>16) & 1); } GATEFUNC(Adder32) { unsigned long long v = (unsigned long long)getword(32, 1) + (unsigned long long)(getword(32, 33)^(getport(99)*4294967295)) + (unsigned long long)getport(97); setword(32, 65, v); setport(98, (v>>32ull) & 1); } GATEFUNC(Incrementer2) { unsigned int a = (getword(2, 1)^(getport(8)*3)) + getport(5) + (getport(6)*3); setword(2, 3, a); setport(7, (a>>2) & 1); } GATEFUNC(Incrementer4) { unsigned int a = (getword(4, 1)^(getport(12)*15)) + getport(9) + (getport(10)*15); setword(4, 5, a); setport(11, (a>>4) & 1); } GATEFUNC(Incrementer8) { unsigned int a = (getword(8, 1)^(getport(20)*255)) + getport(17) + (getport(18)*255); setword(8, 9, a); setport(19, (a>>8) & 1); } GATEFUNC(Incrementer16) { unsigned int a = (getword(16, 1)^(getport(36)*65535)) + getport(33) + (getport(34)*65535); setword(16, 17, a); setport(35, (a>>16) & 1); } GATEFUNC(Incrementer32) { unsigned long long a = (unsigned long long)(getword(32, 1)^(getport(68)*4294967295)) + (unsigned long long)getport(65) + (unsigned long long)(getport(66)*4294967295); setword(32, 33, a); setport(67, (a>>32ull) & 1); } GATEFUNC(Multiplier2) { setword(4, 5, getword(2, 1) * getword(2, 3)); } GATEFUNC(Multiplier4) { setword(8, 9, getword(4, 1) * getword(4, 5)); } GATEFUNC(Multiplier8) { setword(16, 17, getword(8, 1) * getword(8, 9)); } GATEFUNC(Multiplier16) { setword(32, 33, getword(16, 1) * getword(16, 17)); } GATEFUNC(Multiplier32) { setword64(64, 65, (unsigned long long)getword(32, 1) * (unsigned long long)getword(32, 33)); } GATEFUNC(Divider2) { unsigned int a = getword(2, 1); unsigned int b = getword(2, 3); setword(2, 5, b!=0 ? a/b : 0); setword(2, 7, b!=0 ? a%b : 0); } GATEFUNC(Divider4) { unsigned int a = getword(4, 1); unsigned int b = getword(4, 5); setword(4, 9, b!=0 ? a/b : 0); setword(4, 13, b!=0 ? a%b : 0); } GATEFUNC(Divider8) { unsigned int a = getword(8, 1); unsigned int b = getword(8, 9); setword(8, 17, b!=0 ? a/b : 0); setword(8, 25, b!=0 ? a%b : 0); } GATEFUNC(Divider16) { unsigned int a = getword(16, 1); unsigned int b = getword(16, 17); setword(16, 33, b!=0 ? a/b : 0); setword(16, 49, b!=0 ? a%b : 0); } GATEFUNC(Divider32) { unsigned int a = getword(32, 1); unsigned int b = getword(32, 33); setword(32, 65, b!=0 ? a/b : 0); setword(32, 97, b!=0 ? a%b : 0); } GATEFUNC(ShifterLeft2) { int dist = getword(1, 7); setword(4, 3, ((getword(2, 1))<>(2-dist)) : 0)); } GATEFUNC(ShifterLeft4) { int dist = getword(2, 13); setword(8, 5, ((getword(4, 1))<>(4-dist)) : 0)); } GATEFUNC(ShifterLeft8) { int dist = getword(3, 25); setword(16, 9, ((getword(8, 1))<>(8-dist)) : 0)); } GATEFUNC(ShifterLeft16) { int dist = getword(4, 49); setword(32, 17, ((getword(16, 1))<>(16-dist)) : 0)); } GATEFUNC(ShifterLeft32) { int dist = getword(5, 97); setword64(64, 33, (((unsigned long long)getword(32, 1))<>(32-dist)) : 0ull)); } GATEFUNC(ShifterRight2) { int dist = getword(1, 7); setword(4, 3, ((getword(2, 1))<<(2-dist)) | (getport(8) ? (3<<(4-dist)) : 0)); } GATEFUNC(ShifterRight4) { int dist = getword(2, 13); setword(8, 5, ((getword(4, 1))<<(4-dist)) | (getport(15) ? (15<<(8-dist)) : 0)); } GATEFUNC(ShifterRight8) { int dist = getword(3, 25); setword(16, 9, ((getword(8, 1))<<(8-dist)) | (getport(28) ? (255<<(16-dist)) : 0)); } GATEFUNC(ShifterRight16) { int dist = getword(4, 49); setword(32, 17, ((getword(16, 1))<<(16-dist)) | (dist!=0 && getport(53) ? (65535<<(32-dist)) : 0)); } GATEFUNC(ShifterRight32) { int dist = getword(5, 97); setword64(64, 33, (((unsigned long long)getword(32, 1))<<(32-dist)) | (dist!=0 && getport(102) ? (4294967295ull<<(64-dist)) : 0ull)); } GATEFUNC(And2) { setport(3, (getport(1) && getport(2))); } GATEFUNC(And3) { setport(4, (getport(1) && getport(2) && getport(3))); } GATEFUNC(And4) { setport(5, (getport(1) && getport(2) && getport(3) && getport(4))); } GATEFUNC(And5) { setport(6, (getport(1) && getport(2) && getport(3) && getport(4) && getport(5))); } GATEFUNC(And6) { setport(7, (getport(1) && getport(2) && getport(3) && getport(4) && getport(5) && getport(6))); } GATEFUNC(And7) { setport(8, (getport(1) && getport(2) && getport(3) && getport(4) && getport(5) && getport(6) && getport(7))); } GATEFUNC(And8) { setport(9, (getport(1) && getport(2) && getport(3) && getport(4) && getport(5) && getport(6) && getport(7) && getport(8))); } GATEFUNC(Or2) { setport(3, (getport(1) || getport(2))); } GATEFUNC(Or3) { setport(4, (getport(1) || getport(2) || getport(3))); } GATEFUNC(Or4) { setport(5, (getport(1) || getport(2) || getport(3) || getport(4))); } GATEFUNC(Or5) { setport(6, (getport(1) || getport(2) || getport(3) || getport(4) || getport(5))); } GATEFUNC(Or6) { setport(7, (getport(1) || getport(2) || getport(3) || getport(4) || getport(5) || getport(6))); } GATEFUNC(Or7) { setport(8, (getport(1) || getport(2) || getport(3) || getport(4) || getport(5) || getport(6) || getport(7))); } GATEFUNC(Or8) { setport(9, (getport(1) || getport(2) || getport(3) || getport(4) || getport(5) || getport(6) || getport(7) || getport(8))); } GATEFUNC(Xor2) { setport(3, (getport(1) ^ getport(2))); } GATEFUNC(Xor3) { setport(4, (getport(1) ^ getport(2) ^ getport(3))); } GATEFUNC(Xor4) { setport(5, (getport(1) ^ getport(2) ^ getport(3) ^ getport(4))); } GATEFUNC(Xor5) { setport(6, (getport(1) ^ getport(2) ^ getport(3) ^ getport(4) ^ getport(5))); } GATEFUNC(Xor6) { setport(7, (getport(1) ^ getport(2) ^ getport(3) ^ getport(4) ^ getport(5) ^ getport(6))); } GATEFUNC(Xor7) { setport(8, (getport(1) ^ getport(2) ^ getport(3) ^ getport(4) ^ getport(5) ^ getport(6) ^ getport(7))); } GATEFUNC(Xor8) { setport(9, (getport(1) ^ getport(2) ^ getport(3) ^ getport(4) ^ getport(5) ^ getport(6) ^ getport(7) ^ getport(8))); } GATEFUNC(Nand2) { setport(3, !(getport(1) && getport(2))); } GATEFUNC(Nand3) { setport(4, !(getport(1) && getport(2) && getport(3))); } GATEFUNC(Nand4) { setport(5, !(getport(1) && getport(2) && getport(3) && getport(4))); } GATEFUNC(Nand5) { setport(6, !(getport(1) && getport(2) && getport(3) && getport(4) && getport(5))); } GATEFUNC(Nand6) { setport(7, !(getport(1) && getport(2) && getport(3) && getport(4) && getport(5) && getport(6))); } GATEFUNC(Nand7) { setport(8, !(getport(1) && getport(2) && getport(3) && getport(4) && getport(5) && getport(6) && getport(7))); } GATEFUNC(Nand8) { setport(9, !(getport(1) && getport(2) && getport(3) && getport(4) && getport(5) && getport(6) && getport(7) && getport(8))); } GATEFUNC(Nor2) { setport(3, !(getport(1) || getport(2))); } GATEFUNC(Nor3) { setport(4, !(getport(1) || getport(2) || getport(3))); } GATEFUNC(Nor4) { setport(5, !(getport(1) || getport(2) || getport(3) || getport(4))); } GATEFUNC(Nor5) { setport(6, !(getport(1) || getport(2) || getport(3) || getport(4) || getport(5))); } GATEFUNC(Nor6) { setport(7, !(getport(1) || getport(2) || getport(3) || getport(4) || getport(5) || getport(6))); } GATEFUNC(Nor7) { setport(8, !(getport(1) || getport(2) || getport(3) || getport(4) || getport(5) || getport(6) || getport(7))); } GATEFUNC(Nor8) { setport(9, !(getport(1) || getport(2) || getport(3) || getport(4) || getport(5) || getport(6) || getport(7) || getport(8))); } GATEFUNC(Xnor2) { setport(3, !(getport(1) ^ getport(2))); } GATEFUNC(Xnor3) { setport(4, !(getport(1) ^ getport(2) ^ getport(3))); } GATEFUNC(Xnor4) { setport(5, !(getport(1) ^ getport(2) ^ getport(3) ^ getport(4))); } GATEFUNC(Xnor5) { setport(6, !(getport(1) ^ getport(2) ^ getport(3) ^ getport(4) ^ getport(5))); } GATEFUNC(Xnor6) { setport(7, !(getport(1) ^ getport(2) ^ getport(3) ^ getport(4) ^ getport(5) ^ getport(6))); } GATEFUNC(Xnor7) { setport(8, !(getport(1) ^ getport(2) ^ getport(3) ^ getport(4) ^ getport(5) ^ getport(6) ^ getport(7))); } GATEFUNC(Xnor8) { setport(9, !(getport(1) ^ getport(2) ^ getport(3) ^ getport(4) ^ getport(5) ^ getport(6) ^ getport(7) ^ getport(8))); } GATEFUNC(Rom4x1) { if(getport(6)) { int a = getword(4, 1); for(int i=0; i<1; i++) { setport(5+i, getdata(a + i*16)); } } else { clearword(1, 5); } } GATEFUNC(Rom4x4) { if(getport(9)) { int a = getword(4, 1); for(int i=0; i<4; i++) { setport(5+i, getdata(a + i*16)); } } else { clearword(4, 5); } } GATEFUNC(Rom4x8) { if(getport(13)) { int a = getword(4, 1); for(int i=0; i<8; i++) { setport(5+i, getdata(a + i*16)); } } else { clearword(8, 5); } } GATEFUNC(Rom6x1) { if(getport(8)) { int a = getword(6, 1); for(int i=0; i<1; i++) { setport(7+i, getdata(a + i*64)); } } else { clearword(1, 7); } } GATEFUNC(Rom6x4) { if(getport(11)) { int a = getword(6, 1); for(int i=0; i<4; i++) { setport(7+i, getdata(a + i*64)); } } else { clearword(4, 7); } } GATEFUNC(Rom6x8) { if(getport(15)) { int a = getword(6, 1); for(int i=0; i<8; i++) { setport(7+i, getdata(a + i*64)); } } else { clearword(8, 7); } } GATEFUNC(Rom6x16) { if(getport(23)) { int a = getword(6, 1); for(int i=0; i<16; i++) { setport(7+i, getdata(a + i*64)); } } else { clearword(16, 7); } } GATEFUNC(Rom6x32) { if(getport(39)) { int a = getword(6, 1); for(int i=0; i<32; i++) { setport(7+i, getdata(a + i*64)); } } else { clearword(32, 7); } } GATEFUNC(Rom6x48) { if(getport(55)) { int a = getword(6, 1); for(int i=0; i<48; i++) { setport(7+i, getdata(a + i*64)); } } else { clearword(48, 7); } } GATEFUNC(Rom6x64) { if(getport(71)) { int a = getword(6, 1); for(int i=0; i<64; i++) { setport(7+i, getdata(a + i*64)); } } else { clearword(64, 7); } } GATEFUNC(Rom8x1) { if(getport(10)) { int a = getword(8, 1); for(int i=0; i<1; i++) { setport(9+i, getdata(a + i*256)); } } else { clearword(1, 9); } } GATEFUNC(Rom8x4) { if(getport(13)) { int a = getword(8, 1); for(int i=0; i<4; i++) { setport(9+i, getdata(a + i*256)); } } else { clearword(4, 9); } } GATEFUNC(Rom8x8) { if(getport(17)) { int a = getword(8, 1); for(int i=0; i<8; i++) { setport(9+i, getdata(a + i*256)); } } else { clearword(8, 9); } } GATEFUNC(Rom8x16) { if(getport(25)) { int a = getword(8, 1); for(int i=0; i<16; i++) { setport(9+i, getdata(a + i*256)); } } else { clearword(16, 9); } } GATEFUNC(Rom8x32) { if(getport(41)) { int a = getword(8, 1); for(int i=0; i<32; i++) { setport(9+i, getdata(a + i*256)); } } else { clearword(32, 9); } } GATEFUNC(Rom8x48) { if(getport(57)) { int a = getword(8, 1); for(int i=0; i<48; i++) { setport(9+i, getdata(a + i*256)); } } else { clearword(48, 9); } } GATEFUNC(Rom8x64) { if(getport(73)) { int a = getword(8, 1); for(int i=0; i<64; i++) { setport(9+i, getdata(a + i*256)); } } else { clearword(64, 9); } } GATEFUNC(Rom9x1) { if(getport(11)) { int a = getword(9, 1); for(int i=0; i<1; i++) { setport(10+i, getdata(a + i*512)); } } else { clearword(1, 10); } } GATEFUNC(Rom9x4) { if(getport(14)) { int a = getword(9, 1); for(int i=0; i<4; i++) { setport(10+i, getdata(a + i*512)); } } else { clearword(4, 10); } } GATEFUNC(Rom9x8) { if(getport(18)) { int a = getword(9, 1); for(int i=0; i<8; i++) { setport(10+i, getdata(a + i*512)); } } else { clearword(8, 10); } } GATEFUNC(Rom9x16) { if(getport(26)) { int a = getword(9, 1); for(int i=0; i<16; i++) { setport(10+i, getdata(a + i*512)); } } else { clearword(16, 10); } } GATEFUNC(Rom9x32) { if(getport(42)) { int a = getword(9, 1); for(int i=0; i<32; i++) { setport(10+i, getdata(a + i*512)); } } else { clearword(32, 10); } } GATEFUNC(Rom9x48) { if(getport(58)) { int a = getword(9, 1); for(int i=0; i<48; i++) { setport(10+i, getdata(a + i*512)); } } else { clearword(48, 10); } } GATEFUNC(Rom9x64) { if(getport(74)) { int a = getword(9, 1); for(int i=0; i<64; i++) { setport(10+i, getdata(a + i*512)); } } else { clearword(64, 10); } } GATEFUNC(Rom10x8) { if(getport(19)) { int a = getword(10, 1); for(int i=0; i<8; i++) { setport(11+i, getdata(a + i*1024)); } } else { clearword(8, 11); } } GATEFUNC(Rom10x16) { if(getport(27)) { int a = getword(10, 1); for(int i=0; i<16; i++) { setport(11+i, getdata(a + i*1024)); } } else { clearword(16, 11); } } GATEFUNC(Rom10x32) { if(getport(43)) { int a = getword(10, 1); for(int i=0; i<32; i++) { setport(11+i, getdata(a + i*1024)); } } else { clearword(32, 11); } } GATEFUNC(Rom10x48) { if(getport(59)) { int a = getword(10, 1); for(int i=0; i<48; i++) { setport(11+i, getdata(a + i*1024)); } } else { clearword(48, 11); } } GATEFUNC(Rom10x64) { if(getport(75)) { int a = getword(10, 1); for(int i=0; i<64; i++) { setport(11+i, getdata(a + i*1024)); } } else { clearword(64, 11); } } GATEFUNC(Rom11x8) { if(getport(20)) { int a = getword(11, 1); for(int i=0; i<8; i++) { setport(12+i, getdata(a + i*2048)); } } else { clearword(8, 12); } } GATEFUNC(Rom11x16) { if(getport(28)) { int a = getword(11, 1); for(int i=0; i<16; i++) { setport(12+i, getdata(a + i*2048)); } } else { clearword(16, 12); } } GATEFUNC(Rom11x32) { if(getport(44)) { int a = getword(11, 1); for(int i=0; i<32; i++) { setport(12+i, getdata(a + i*2048)); } } else { clearword(32, 12); } } GATEFUNC(Rom11x48) { if(getport(60)) { int a = getword(11, 1); for(int i=0; i<48; i++) { setport(12+i, getdata(a + i*2048)); } } else { clearword(48, 12); } } GATEFUNC(Rom11x64) { if(getport(76)) { int a = getword(11, 1); for(int i=0; i<64; i++) { setport(12+i, getdata(a + i*2048)); } } else { clearword(64, 12); } } GATEFUNC(Rom12x8) { if(getport(21)) { int a = getword(12, 1); for(int i=0; i<8; i++) { setport(13+i, getdata(a + i*4096)); } } else { clearword(8, 13); } } GATEFUNC(Rom12x16) { if(getport(29)) { int a = getword(12, 1); for(int i=0; i<16; i++) { setport(13+i, getdata(a + i*4096)); } } else { clearword(16, 13); } } GATEFUNC(Rom12x32) { if(getport(45)) { int a = getword(12, 1); for(int i=0; i<32; i++) { setport(13+i, getdata(a + i*4096)); } } else { clearword(32, 13); } } GATEFUNC(Rom12x48) { if(getport(61)) { int a = getword(12, 1); for(int i=0; i<48; i++) { setport(13+i, getdata(a + i*4096)); } } else { clearword(48, 13); } } GATEFUNC(Rom12x64) { if(getport(77)) { int a = getword(12, 1); for(int i=0; i<64; i++) { setport(13+i, getdata(a + i*4096)); } } else { clearword(64, 13); } } GATEFUNC(Ram8x8) { if(getport(25)) { setword(8, 9, getdata(getword(8, 17))); } else { clearword(8, 9); } if(getport(26)) { setdata(getword(8, 17), getword(8, 1)); } } GATEFUNC(Ram8x12) { if(getport(29)) { setword(8, 9, getdata(getword(12, 17))); } else { clearword(8, 9); } if(getport(30)) { setdata(getword(12, 17), getword(8, 1)); } } GateFunc sim_logic_functions[] = { 0, GATEFUNCID(Diode), GATEFUNCID(Not), GATEFUNCID(Enabler1), GATEFUNCID(Enabler2), GATEFUNCID(Enabler3), GATEFUNCID(Enabler4), GATEFUNCID(Enabler5), GATEFUNCID(Enabler6), GATEFUNCID(Enabler7), GATEFUNCID(Enabler8), GATEFUNCID(Enabler9), GATEFUNCID(Enabler10), GATEFUNCID(Enabler11), GATEFUNCID(Enabler12), GATEFUNCID(Enabler13), GATEFUNCID(Enabler14), GATEFUNCID(Enabler15), GATEFUNCID(Enabler16), GATEFUNCID(Enabler24), GATEFUNCID(Enabler32), GATEFUNCID(Enabler48), GATEFUNCID(Enabler64), GATEFUNCID(Buffer1), GATEFUNCID(Buffer2), GATEFUNCID(Buffer3), GATEFUNCID(Buffer4), GATEFUNCID(Buffer5), GATEFUNCID(Buffer6), GATEFUNCID(Buffer7), GATEFUNCID(Buffer8), GATEFUNCID(Buffer9), GATEFUNCID(Buffer10), GATEFUNCID(Buffer11), GATEFUNCID(Buffer12), GATEFUNCID(Buffer13), GATEFUNCID(Buffer14), GATEFUNCID(Buffer15), GATEFUNCID(Buffer16), GATEFUNCID(Buffer24), GATEFUNCID(Buffer32), GATEFUNCID(Buffer48), GATEFUNCID(Buffer64), GATEFUNCID(DFF1), GATEFUNCID(DFF2), GATEFUNCID(DFF3), GATEFUNCID(DFF4), GATEFUNCID(DFF5), GATEFUNCID(DFF6), GATEFUNCID(DFF7), GATEFUNCID(DFF8), GATEFUNCID(DFF9), GATEFUNCID(DFF10), GATEFUNCID(DFF11), GATEFUNCID(DFF12), GATEFUNCID(DFF13), GATEFUNCID(DFF14), GATEFUNCID(DFF15), GATEFUNCID(DFF16), GATEFUNCID(DFF24), GATEFUNCID(DFF32), GATEFUNCID(DFF48), GATEFUNCID(DFF64), GATEFUNCID(Mux1), GATEFUNCID(Mux2), GATEFUNCID(Mux3), GATEFUNCID(Mux4), GATEFUNCID(Mux5), GATEFUNCID(Mux6), GATEFUNCID(Mux7), GATEFUNCID(Mux8), GATEFUNCID(Demux1), GATEFUNCID(Demux2), GATEFUNCID(Demux3), GATEFUNCID(Demux4), GATEFUNCID(Demux5), GATEFUNCID(Demux6), GATEFUNCID(Demux7), GATEFUNCID(Demux8), GATEFUNCID(Adder2), GATEFUNCID(Adder4), GATEFUNCID(Adder8), GATEFUNCID(Adder16), GATEFUNCID(Adder32), GATEFUNCID(Incrementer2), GATEFUNCID(Incrementer4), GATEFUNCID(Incrementer8), GATEFUNCID(Incrementer16), GATEFUNCID(Incrementer32), GATEFUNCID(Multiplier2), GATEFUNCID(Multiplier4), GATEFUNCID(Multiplier8), GATEFUNCID(Multiplier16), GATEFUNCID(Multiplier32), GATEFUNCID(Divider2), GATEFUNCID(Divider4), GATEFUNCID(Divider8), GATEFUNCID(Divider16), GATEFUNCID(Divider32), GATEFUNCID(ShifterLeft2), GATEFUNCID(ShifterLeft4), GATEFUNCID(ShifterLeft8), GATEFUNCID(ShifterLeft16), GATEFUNCID(ShifterLeft32), GATEFUNCID(ShifterRight2), GATEFUNCID(ShifterRight4), GATEFUNCID(ShifterRight8), GATEFUNCID(ShifterRight16), GATEFUNCID(ShifterRight32), GATEFUNCID(And2), GATEFUNCID(And3), GATEFUNCID(And4), GATEFUNCID(And5), GATEFUNCID(And6), GATEFUNCID(And7), GATEFUNCID(And8), GATEFUNCID(Or2), GATEFUNCID(Or3), GATEFUNCID(Or4), GATEFUNCID(Or5), GATEFUNCID(Or6), GATEFUNCID(Or7), GATEFUNCID(Or8), GATEFUNCID(Xor2), GATEFUNCID(Xor3), GATEFUNCID(Xor4), GATEFUNCID(Xor5), GATEFUNCID(Xor6), GATEFUNCID(Xor7), GATEFUNCID(Xor8), GATEFUNCID(Nand2), GATEFUNCID(Nand3), GATEFUNCID(Nand4), GATEFUNCID(Nand5), GATEFUNCID(Nand6), GATEFUNCID(Nand7), GATEFUNCID(Nand8), GATEFUNCID(Nor2), GATEFUNCID(Nor3), GATEFUNCID(Nor4), GATEFUNCID(Nor5), GATEFUNCID(Nor6), GATEFUNCID(Nor7), GATEFUNCID(Nor8), GATEFUNCID(Xnor2), GATEFUNCID(Xnor3), GATEFUNCID(Xnor4), GATEFUNCID(Xnor5), GATEFUNCID(Xnor6), GATEFUNCID(Xnor7), GATEFUNCID(Xnor8), GATEFUNCID(Rom4x1), GATEFUNCID(Rom4x4), GATEFUNCID(Rom4x8), GATEFUNCID(Rom6x1), GATEFUNCID(Rom6x4), GATEFUNCID(Rom6x8), GATEFUNCID(Rom6x16), GATEFUNCID(Rom6x32), GATEFUNCID(Rom6x48), GATEFUNCID(Rom6x64), GATEFUNCID(Rom8x1), GATEFUNCID(Rom8x4), GATEFUNCID(Rom8x8), GATEFUNCID(Rom8x16), GATEFUNCID(Rom8x32), GATEFUNCID(Rom8x48), GATEFUNCID(Rom8x64), GATEFUNCID(Rom9x1), GATEFUNCID(Rom9x4), GATEFUNCID(Rom9x8), GATEFUNCID(Rom9x16), GATEFUNCID(Rom9x32), GATEFUNCID(Rom9x48), GATEFUNCID(Rom9x64), GATEFUNCID(Rom10x8), GATEFUNCID(Rom10x16), GATEFUNCID(Rom10x32), GATEFUNCID(Rom10x48), GATEFUNCID(Rom10x64), GATEFUNCID(Rom11x8), GATEFUNCID(Rom11x16), GATEFUNCID(Rom11x32), GATEFUNCID(Rom11x48), GATEFUNCID(Rom11x64), GATEFUNCID(Rom12x8), GATEFUNCID(Rom12x16), GATEFUNCID(Rom12x32), GATEFUNCID(Rom12x48), GATEFUNCID(Rom12x64), GATEFUNCID(Ram8x8), GATEFUNCID(Ram8x12), };