// 74xx238 emulation component for the LogicSimulator // Copyright (C) 2022 Sascha Nitsch // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . // eslint-disable-next-line @typescript-eslint/no-unused-vars function IC74xx238Init() { class IC74xx238 extends DILBase { private val = 0; private enable = false; constructor(simulator: Simulator, id: string, param: BaseComponentParam) { super(simulator, id, 16, param); } setup(canvas: SVGElement) { super.DILBASEsetup('ic16', canvas, '74xx238'); } update(): boolean { if (this.startdelay) { --this.startdelay; return false; } if (this.getStateWire('p16') !== WireState.high || this.getStateWire('p8') !== WireState.low) return false; // no power // enable = !E1 AND !E2 AND E3 const enable = this.binary(this.getStateWire('p4'), true) === false && this.binary(this.getStateWire('p5'), true) === false && this.binary(this.getStateWire('p6'), true) === true; const val = this.asint(this.binary(this.getStateWire('p3'), true), 4) + this.asint(this.binary(this.getStateWire('p2'), true), 2) + this.asint(this.binary(this.getStateWire('p1'), true), 1); const mod = this.val !== val || this.enable !== enable; this.val = val; this.enable = enable; this.getPin('p15').setBool(enable && val === 0); this.getPin('p14').setBool(enable && val === 1); this.getPin('p13').setBool(enable && val === 2); this.getPin('p12').setBool(enable && val === 3); this.getPin('p11').setBool(enable && val === 4); this.getPin('p10').setBool(enable && val === 5); this.getPin('p9').setBool(enable && val === 6); this.getPin('p7').setBool(enable && val === 7); return mod; } } window.IC74xx238 = IC74xx238; } // eslint-disable-next-line @typescript-eslint/no-unused-vars function IC74xx238Depends() { return 'dilbase'; }