diff --git a/app/index.html b/app/index.html index 4872408a..3b3bac75 100755 --- a/app/index.html +++ b/app/index.html @@ -248,6 +248,7 @@

Tutorial

  • TimerStart
  • TimerEnd
  • ROM
  • +
  • D Latch
  • diff --git a/app/js/components.js b/app/js/components.js index 87fdd8c9..4ba37f73 100644 --- a/app/js/components.js +++ b/app/js/components.js @@ -3493,4 +3493,29 @@ class Wire { } } +class DLatch extends Component { + constructor(name,pos, properties) { + super(name,pos,2,2,{ type: "value" }); + this.value = this.properties.value || 0; + + this.DATA = 0; + this.ENABLE = 1; + this.VAL = 0; + this.NOT_VAL = 1; + this.addInputPort({ side: 3, pos: 0 }, 'D'); + this.addInputPort({ side: 3, pos: 1 }, 'E'); + this.addOutputPort({ side: 1, pos: 0 }, 'Q'); + this.addOutputPort({ side: 1, pos: 1 }, '~Q'); + } + + function() { + if (this.input[this.ENABLE].value) { + this.value = this.input[this.DATA].value || 0; + } + this.properties.value = this.value; + this.output[this.VAL].value = +this.value; + this.output[this.NOT_VAL].value = 1 - this.value; + } +} + let Selected = Input; diff --git a/app/js/localStorage2.js b/app/js/localStorage2.js index d3f4550c..ded6615a 100644 --- a/app/js/localStorage2.js +++ b/app/js/localStorage2.js @@ -98,7 +98,7 @@ const constructors = { Button,Constant,Delay,Clock,Debug, Beep,Counter,LED,Display, Custom, TimerStart, TimerEnd, - ROM + ROM, DLatch }; /*