logicsimulator/components/ic74xx86.ts

56 lines
2.3 KiB
TypeScript

// 74xx86 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 <https://www.gnu.org/licenses/>.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function IC74xx86Init() {
class IC74xx86 extends DILBase {
constructor(simulator: Simulator, id: string, param: BaseComponentParam) {
super(simulator, id, 14, param);
}
setup(canvas: SVGElement) {
super.DILBASEsetup('ic14', canvas, '74xx86');
}
update(): boolean {
if (this.startdelay) {
--this.startdelay;
return false;
}
if (this.getStateWire('p14') !== WireState.high || this.getStateWire('p7') !== WireState.low) return false; // no power
let mod = false;
let state;
state = this.binary(this.getStateWire('p1'), true) !== this.binary(this.getStateWire('p2'), true);
mod ||= this.binary(this.getStateWire('p3'), true) !== state;
this.getPin('p3').setBool(state);
state = this.binary(this.getStateWire('p4'), true) !== this.binary(this.getStateWire('p5'), true);
mod ||= this.binary(this.getStateWire('p6'), true) !== state;
this.getPin('p6').setBool(state);
state = this.binary(this.getStateWire('p9'), true) !== this.binary(this.getStateWire('p10'), true);
mod ||= this.binary(this.getStateWire('p8'), true) !== state;
this.getPin('p8').setBool(state);
state = this.binary(this.getStateWire('p12'), true) !== this.binary(this.getStateWire('p13'), true);
mod ||= this.binary(this.getStateWire('p11'), true) !== state;
this.getPin('p11').setBool(state);
return mod;
}
}
window.IC74xx86 = IC74xx86;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function IC74xx86Depends() {
return 'dilbase';
}