76 lines
2.8 KiB
TypeScript
76 lines
2.8 KiB
TypeScript
// Logic simulation for the 74xx244 IC 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
|
|
class Logic74xx244 extends BaseComponent {
|
|
private oe = false;
|
|
private i0 = false;
|
|
private i1 = false;
|
|
private i2 = false;
|
|
private i3 = false;
|
|
private o0 = false;
|
|
private o1 = false;
|
|
private o2 = false;
|
|
private o3 = false;
|
|
constructor(simulator: Simulator, id: string, param: BaseComponentParam) {
|
|
super(simulator, id, param);
|
|
this.pins.set('oe', new TriState(this, -40, -45));
|
|
this.pins.set('i0', new TriState(this, -40, -15));
|
|
this.pins.set('i1', new TriState(this, -40, 0));
|
|
this.pins.set('i2', new TriState(this, -40, 15));
|
|
this.pins.set('i3', new TriState(this, -40, 30));
|
|
this.pins.set('o0', new TriState(this, 40, -15));
|
|
this.pins.set('o1', new TriState(this, 40, 0));
|
|
this.pins.set('o2', new TriState(this, 40, 15));
|
|
this.pins.set('o3', new TriState(this, 40, 30));
|
|
}
|
|
|
|
setup(canvas: SVGElement) {
|
|
super.doSetup('logic74xx244', canvas);
|
|
}
|
|
|
|
io() {
|
|
this.oe = this.binary(this.getPin('oe').getAndReset(), true);
|
|
this.i0 = this.binary(this.getPin('i0').getAndReset(), true);
|
|
this.i1 = this.binary(this.getPin('i1').getAndReset(), true);
|
|
this.i2 = this.binary(this.getPin('i2').getAndReset(), true);
|
|
this.i3 = this.binary(this.getPin('i3').getAndReset(), true);
|
|
this.o0 = this.binary(this.getPin('o0').getAndReset(), true);
|
|
this.o1 = this.binary(this.getPin('o1').getAndReset(), true);
|
|
this.o2 = this.binary(this.getPin('o2').getAndReset(), true);
|
|
this.o3 = this.binary(this.getPin('o3').getAndReset(), true);
|
|
}
|
|
|
|
update(): boolean {
|
|
if (this.startdelay) {
|
|
--this.startdelay;
|
|
return false;
|
|
}
|
|
let mod = false;
|
|
if (this.oe === false) {
|
|
mod ||= this.i0 !== this.o0;
|
|
this.getPin('o0').setBool(this.i0);
|
|
mod ||= this.i1 !== this.o1;
|
|
this.getPin('o1').setBool(this.i1);
|
|
mod ||= this.i2 !== this.o2;
|
|
this.getPin('o2').setBool(this.i2);
|
|
mod ||= this.i3 !== this.o3;
|
|
this.getPin('o3').setBool(this.i3);
|
|
}
|
|
return mod;
|
|
}
|
|
}
|