64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
// 74xx21 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 IC74xx21Init() {
|
|
class IC74xx21 extends DILBase {
|
|
constructor(simulator: Simulator, id: string, param: BaseComponentParam) {
|
|
super(simulator, id, 14, param);
|
|
}
|
|
|
|
setup(canvas: SVGElement) {
|
|
super.DILBASEsetup('ic14', canvas, '74xx21');
|
|
}
|
|
|
|
update(): boolean {
|
|
if (this.startdelay) {
|
|
--this.startdelay;
|
|
return false;
|
|
}
|
|
if (this.getStateWire('p14') !== WireState.up || this.getStateWire('p7') !== WireState.down) return false; // no power
|
|
let oldstate;
|
|
let mod = false;
|
|
let state;
|
|
oldstate = this.binary(this.getStateWire('p6'), true);
|
|
state =
|
|
this.binary(this.getStateWire('p1'), true) !== false &&
|
|
this.binary(this.getStateWire('p2'), true) !== false &&
|
|
this.binary(this.getStateWire('p4'), true) !== false &&
|
|
this.binary(this.getStateWire('p5'), true) !== false;
|
|
this.getPin('p6').setBool(state);
|
|
mod ||= state !== oldstate;
|
|
|
|
oldstate = this.binary(this.getStateWire('p8'), true);
|
|
state =
|
|
this.binary(this.getStateWire('p9'), true) !== false &&
|
|
this.binary(this.getStateWire('p10'), true) !== false &&
|
|
this.binary(this.getStateWire('p12'), true) !== false &&
|
|
this.binary(this.getStateWire('p13'), true) !== false;
|
|
mod ||= state !== oldstate;
|
|
this.getPin('p8').setBool(state);
|
|
return mod;
|
|
}
|
|
}
|
|
window.IC74xx21 = IC74xx21;
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
function IC74xx21Depends() {
|
|
return 'dilbase';
|
|
}
|