logicsimulator/components/ic74xx244.ts

64 lines
3.1 KiB
TypeScript

// 74xx244 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 IC74xx244Init() {
class IC74xx244 extends DILBase {
constructor(simulator: Simulator, id: string, param: BaseComponentParam) {
super(simulator, id, 20, param);
}
setup(canvas: SVGElement) {
super.DILBASEsetup('ic20', canvas, '74xx244');
}
updatefunction() {
if (this.startdelay) {
--this.startdelay;
return false;
}
if (this.getStateWire('p20') !== WireState.high || this.getStateWire('p10') !== WireState.low) return false; // no power
let mod = false;
if (this.binary(this.getStateWire('p1'), true) === false) {
mod ||= this.binary(this.getStateWire('p18'), true) !== this.binary(this.getStateWire('p2'), true);
this.getPin('p18').setBool(this.binary(this.getStateWire('p2'), true));
mod ||= this.binary(this.getStateWire('p16'), true) !== this.binary(this.getStateWire('p4'), true);
this.getPin('p16').setBool(this.binary(this.getStateWire('p4'), true));
mod ||= this.binary(this.getStateWire('p14'), true) !== this.binary(this.getStateWire('p6'), true);
this.getPin('p14').setBool(this.binary(this.getStateWire('p6'), true));
mod ||= this.binary(this.getStateWire('p12'), true) !== this.binary(this.getStateWire('p8'), true);
this.getPin('p12').setBool(this.binary(this.getStateWire('p8'), true));
}
if (this.binary(this.getStateWire('p19'), true) === false) {
mod ||= this.binary(this.getStateWire('p9'), true) !== this.binary(this.getStateWire('p11'), true);
this.getPin('p9').setBool(this.binary(this.getStateWire('p11'), true));
mod ||= this.binary(this.getStateWire('p7'), true) !== this.binary(this.getStateWire('p13'), true);
this.getPin('p7').setBool(this.binary(this.getStateWire('p13'), true));
mod ||= this.binary(this.getStateWire('p5'), true) !== this.binary(this.getStateWire('p15'), true);
this.getPin('p5').setBool(this.binary(this.getStateWire('p15'), true));
mod ||= this.binary(this.getStateWire('p3'), true) !== this.binary(this.getStateWire('p17'), true);
this.getPin('p3').setBool(this.binary(this.getStateWire('p17'), true));
}
return mod;
}
}
window.IC74xx244 = IC74xx244;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function IC74xx244Depends() {
return 'dilbase';
}