0.3.7: Added 4 bit hex display as well as fixed flip flop connection bugs
This commit is contained in:
parent
bd8a903aec
commit
edb836be75
@ -12,6 +12,11 @@ To be decided, but at this moment this code is open source and free to use for n
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### 0.3.7
|
||||||
|
|
||||||
|
* Added 4 bit display! Currently shows hex format
|
||||||
|
* Fixed a bug with flip flop save states for connections
|
||||||
|
|
||||||
### 0.3.6
|
### 0.3.6
|
||||||
|
|
||||||
* Fixed a bug where flip flops weren't firing output changes when only !Q changed.
|
* Fixed a bug where flip flops weren't firing output changes when only !Q changed.
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
let ElementReferenceTable = new Array();
|
let ElementReferenceTable = new Array();
|
||||||
|
|
||||||
let ElementCategory_Inputs = new ElementCatalog_Category("Inputs","");
|
let ElementCategory_Inputs = new ElementCatalog_Category("Inputs","");
|
||||||
|
let ElementCategory_Outputs = new ElementCatalog_Category("Outputs","");
|
||||||
let ElementCategory_LOGIC = new ElementCatalog_Category("Logic" ,"");
|
let ElementCategory_LOGIC = new ElementCatalog_Category("Logic" ,"");
|
||||||
let ElementCategory_FlipFlop = new ElementCatalog_Category("Flip-Flops" ,"");
|
let ElementCategory_FlipFlop = new ElementCatalog_Category("Flip-Flops" ,"");
|
||||||
let ElementCategory_Timing = new ElementCatalog_Category("Timing" ,"");
|
let ElementCategory_Timing = new ElementCatalog_Category("Timing" ,"");
|
||||||
let ElementCategory_ICs = new ElementCatalog_Category("ICs" ,"");
|
let ElementCategory_ICs = new ElementCatalog_Category("ICs" ,"");
|
||||||
let elementCatalog = new ElementCatalog([ElementCategory_Inputs,
|
let elementCatalog = new ElementCatalog([ElementCategory_Inputs,
|
||||||
|
ElementCategory_Outputs,
|
||||||
ElementCategory_LOGIC,
|
ElementCategory_LOGIC,
|
||||||
ElementCategory_FlipFlop,
|
ElementCategory_FlipFlop,
|
||||||
ElementCategory_Timing,
|
ElementCategory_Timing,
|
||||||
@ -1067,6 +1069,59 @@ let ElementCatalog_DELAY = new ElementCatalog_Element("Delay","The delay element
|
|||||||
ElementReferenceTable.push(ElementCatalog_DELAY);
|
ElementReferenceTable.push(ElementCatalog_DELAY);
|
||||||
ElementCategory_Timing.addElement(ElementCatalog_DELAY);
|
ElementCategory_Timing.addElement(ElementCatalog_DELAY);
|
||||||
|
|
||||||
|
class output4bitDisplay extends Element {
|
||||||
|
constructor(RestoreData = null,logicengine) {
|
||||||
|
super(RestoreData,logicengine,4);
|
||||||
|
this.Name = "4B Display";
|
||||||
|
this.Output = false;
|
||||||
|
this.OutputChar = "0";
|
||||||
|
this.NoOutput = true;
|
||||||
|
this.Width = 100;
|
||||||
|
this.Height = 100;
|
||||||
|
this.Inputs = [0,0,0,0];
|
||||||
|
this.removeProperty("Inputs");
|
||||||
|
}
|
||||||
|
|
||||||
|
setInput(Input, Value) {
|
||||||
|
this.Inputs[Input] = (Value) ? 1 : 0;
|
||||||
|
let outchar = (this.Inputs[0] << 3) + (this.Inputs[1] << 2) + (this.Inputs[2] << 1) + (this.Inputs[3]);
|
||||||
|
|
||||||
|
this.OutputChar = (outchar);
|
||||||
|
switch (outchar) {
|
||||||
|
case 10:
|
||||||
|
this.OutputChar = 'A';
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
this.OutputChar = 'B';
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
this.OutputChar = 'C';
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
this.OutputChar = 'D';
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
this.OutputChar = 'E';
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
this.OutputChar = 'F';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
drawElement(x, y, ctx) {
|
||||||
|
this.drawBorderBox(ctx, x+20,y,this.Width-40,this.Height);
|
||||||
|
this.drawTextCentered(ctx,x,y,this.Width,this.Height,this.OutputChar,"72px Console");
|
||||||
|
this.drawInputs(ctx,x,y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let ElementCatalog_Output_4BDisplay = new ElementCatalog_Element("4B Display","A display! Takes a 4 bit input and shows hex value of the input.","[8]",output4bitDisplay,[]);
|
||||||
|
ElementReferenceTable.push(ElementCatalog_Output_4BDisplay);
|
||||||
|
ElementCategory_Outputs.addElement(ElementCatalog_Output_4BDisplay);
|
||||||
|
|
||||||
|
|
||||||
class inputElement extends Element {
|
class inputElement extends Element {
|
||||||
constructor(RestoreData = null,logicengine) {
|
constructor(RestoreData = null,logicengine) {
|
||||||
super(RestoreData,logicengine,0);
|
super(RestoreData,logicengine,0);
|
||||||
@ -1179,14 +1234,14 @@ class FlipFlopJK extends Element {
|
|||||||
this.Height = 80;
|
this.Height = 80;
|
||||||
|
|
||||||
if (RestoreData) {
|
if (RestoreData) {
|
||||||
this.Outputs = RestoreData.Outputs;
|
this.Outputs = RestoreData.OutputStates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON(key) {
|
toJSON(key) {
|
||||||
let $superjson = super.toJSON(key);
|
let $superjson = super.toJSON(key);
|
||||||
|
|
||||||
$superjson.Outputs = this.Outputs;
|
$superjson.OutputStates = this.Outputs;
|
||||||
return $superjson;
|
return $superjson;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1241,14 +1296,14 @@ class FlipFlopSR extends Element {
|
|||||||
this.Height = 80;
|
this.Height = 80;
|
||||||
|
|
||||||
if (RestoreData) {
|
if (RestoreData) {
|
||||||
this.Outputs = RestoreData.Outputs;
|
this.Outputs = RestoreData.OutputStates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON(key) {
|
toJSON(key) {
|
||||||
let $superjson = super.toJSON(key);
|
let $superjson = super.toJSON(key);
|
||||||
|
|
||||||
$superjson.Outputs = this.Outputs;
|
$superjson.OutputStates = this.Outputs;
|
||||||
return $superjson;
|
return $superjson;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1299,14 +1354,14 @@ class FlipFlopT extends Element {
|
|||||||
this.Height = 80;
|
this.Height = 80;
|
||||||
|
|
||||||
if (RestoreData) {
|
if (RestoreData) {
|
||||||
this.Outputs = RestoreData.Outputs;
|
this.Outputs = RestoreData.OutputStates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON(key) {
|
toJSON(key) {
|
||||||
let $superjson = super.toJSON(key);
|
let $superjson = super.toJSON(key);
|
||||||
|
|
||||||
$superjson.Outputs = this.Outputs;
|
$superjson.OutputStates = this.Outputs;
|
||||||
return $superjson;
|
return $superjson;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1350,14 +1405,14 @@ class FlipFlopD extends Element {
|
|||||||
this.Height = 80;
|
this.Height = 80;
|
||||||
|
|
||||||
if (RestoreData) {
|
if (RestoreData) {
|
||||||
this.Outputs = RestoreData.Outputs;
|
this.Outputs = RestoreData.OutputStates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON(key) {
|
toJSON(key) {
|
||||||
let $superjson = super.toJSON(key);
|
let $superjson = super.toJSON(key);
|
||||||
|
|
||||||
$superjson.Outputs = this.Outputs;
|
$superjson.OutputStates = this.Outputs;
|
||||||
return $superjson;
|
return $superjson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
MatCat BrowserLogic Simulator
|
MatCat BrowserLogic Simulator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let Version = "0.3.6";
|
let Version = "0.3.7";
|
||||||
let spanVersion = document.getElementById("version");
|
let spanVersion = document.getElementById("version");
|
||||||
spanVersion.innerText = Version;
|
spanVersion.innerText = Version;
|
||||||
// get the canvas and get the engine object going
|
// get the canvas and get the engine object going
|
||||||
|
Loading…
Reference in New Issue
Block a user