0.3.6: Fixed bug with ~Q outputs on flip flops

This commit is contained in:
MatCat 2021-03-03 19:04:47 -08:00
parent ace0fd20d1
commit bd8a903aec
3 changed files with 13 additions and 5 deletions

View File

@ -12,6 +12,10 @@ To be decided, but at this moment this code is open source and free to use for n
## Changelog
### 0.3.6
* Fixed a bug where flip flops weren't firing output changes when only !Q changed.
### 0.3.5
* Fixed a bug where newly linked objects weren't being polled to the proper output

View File

@ -1193,6 +1193,7 @@ class FlipFlopJK extends Element {
setInput(Input, Value) {
if (Input >= this.Inputs.length) return false;
let oldOutput = this.Outputs[0];
let oldOutput2 = this.Outputs[1];
this.Inputs[Input] = Value;
if (this.Inputs[1]) {
if (!this.Inputs[0] && this.Inputs[2]) {
@ -1209,7 +1210,7 @@ class FlipFlopJK extends Element {
this.Outputs[1] = !this.Outputs[0];
}
}
if (oldOutput != this.getOutput(0)) {
if (oldOutput != this.getOutput(0) || oldOutput2 != this.getOutput(1)) {
this.setConnections();
}
}
@ -1254,6 +1255,7 @@ class FlipFlopSR extends Element {
setInput(Input, Value) {
if (Input >= this.Inputs.length) return false;
let oldOutput = this.Outputs[0];
let oldOutput2 = this.Outputs[1];
this.Inputs[Input] = Value;
if (this.Inputs[1]) {
if (!this.Inputs[0] && this.Inputs[2]) {
@ -1266,7 +1268,7 @@ class FlipFlopSR extends Element {
this.Outputs[1] = false;
}
}
if (oldOutput != this.getOutput(0)) {
if (oldOutput != this.getOutput(0) || oldOutput2 != this.getOutput(1)) {
this.setConnections();
}
}
@ -1311,12 +1313,13 @@ class FlipFlopT extends Element {
setInput(Input, Value) {
if (Input >= this.Inputs.length) return false;
let oldOutput = this.Outputs[0];
let oldOutput2 = this.Outputs[1];
this.Inputs[Input] = Value;
if (this.Inputs[0] && this.Inputs[1]) {
this.Outputs[0] = !this.Outputs[0];
this.Outputs[1] = !this.Outputs[0];
}
if (oldOutput != this.getOutput(0)) {
if (oldOutput != this.getOutput(0) || oldOutput2 != this.getOutput(1)) {
this.setConnections();
}
}
@ -1361,13 +1364,14 @@ class FlipFlopD extends Element {
setInput(Input, Value) {
if (Input >= this.Inputs.length) return false;
let oldOutput = this.Outputs[0];
let oldOutput2 = this.Outputs[1];
let oldInput = this.Inputs[1];
this.Inputs[Input] = Value;
if (this.Inputs[1] && !oldInput) {
this.Outputs[0] = this.Inputs[0];
this.Outputs[1] = !this.Outputs[0];
}
if (oldOutput != this.getOutput(0)) {
if (oldOutput != this.getOutput(0) || oldOutput2 != this.getOutput(1)) {
this.setConnections();
}
}

View File

@ -2,7 +2,7 @@
MatCat BrowserLogic Simulator
*/
let Version = "0.3.5";
let Version = "0.3.6";
let spanVersion = document.getElementById("version");
spanVersion.innerText = Version;
// get the canvas and get the engine object going