SR Latches

Today I am going to explain how the SR Latch block works. This is how it looks like:

SR Latch

SR Latch in the game is an electronic device that can be used as memory, storing one bit of information. By applying different signals to its 3 inputs, you can manipulate the value of the bit in various ways.

In reality, an SR latch is a very simple device, but in the game I made it universal by combining functions of two different “real” latches. This is because I want to save block IDs by not having to add all of these latches as separate devices.

The value of the bit stored by the latch is available on the output, which in the picture is on the top of the latch. Apart from the output, this latch also has 3 inputs. On the left is the S input, which stands for “set”. On the right is the R input, which stands for “reset”. The third input on the bottom (marked with a little half-circle) I will talk about later. For now let’s assume that it is disconnected.

When the SR latch detects a rising edge on S input, it will set its state to 1, and this will immediately show on the output. The latch will now remember that its state is 1. You can walk away, or exit and reload the game, the latch’s state will still be 1. This is how memory works.

To clear the latch you have to send it a signal on the R input. As soon as a rising edge is detected there, the latch will reset its state to 0. And it will remember it until you again send it a signal on the S input.

Here’s the truth table of the SR latch when the bottom input is disconnected. S and R inputs are activated by a rising edge of the signal, so 1 means rising edge, 0 means anything else:

S R State
0 0 No change
1 0 1
0 1 0

Both rising edges at exactly the same time are impossible, one will always come first. Simple.

Now about the function of the bottom input, the one marked with a half-circle (in reality it should be a little triangle, but I can’t make it look like triangle without shifting it off-center). When anything is connected to this input, the function of the SR latch changes. It becomes what is known as a synchronous latch. The signal on the bottom input is the “clock” signal. Its function is that the latch will only react to S and R inputs during a rising edge of a signal on the clock input. When there is no clock signal, you can put anything on S and R inputs, the latch will ignore it (i.e. remain in its current state, whatever it is). In other words, it will only “read” the S and R inputs in the instant clock input goes from 0 to 1.

Another difference from the simple mode is that having both S and R at 1 during a clock signal will toggle the current state. I.e. when it was 0 it will become 1 and vice versa.

Here’s the truth table of the SR latch when the clock input is connected:

S R Clock State
0 0 Rising edge No change
1 0 Rising edge 1
0 1 Rising edge 0
1 1 Rising edge Toggle
Any Any Anything else No change

If you had anything to do with logic gates in real life, you should be quite comfortable with that. Otherwise, you’ll have to learn. There is a lot of resources and tutorials on the web that will teach you all there is to know about it. Incidentally, this knowledge may turn quite useful in the real life if you intend to study anything related to computers or electronics. After all, real computers are made of logic gates.

Here’s a little device made out of 4 synchronous SR latches (clock input is connected). Can anyone guess what it is doing when one presses the button? Btw. the disconnected NOT gates serve as sources of a constant “1” signal.


I am waiting for answers in the comments. Those of you familiar with logic circuits should have no problems guessing :-)

One more thing remains to be said. The SR latch is nothing magical. You can build it out of other logic gates, for example from AND and NOT gates. I included it as a separate block because it’s a common thing to use, and making it out of gates is unwieldy. One SR latch made from gates would be several times bigger than the mystery circuit above.

And there is another crucial reason. The state of the latch made out of gates would not be saved when you leave the area or exit the game. In general, internal state of electric circuits is lost when they go out of visibility range. Only the state of the built-in SR latch is persistent.


  1. jriot10
    Posted December 11, 2012 at 23:16 | Permalink | Reply

    Even though that was confusing the table tells you that when you press the button the lights will toggle on and off.

  2. Callum James Yates (Calgen)
    Posted December 11, 2012 at 23:20 | Permalink | Reply

    Wow you have been busy, could you explain the semi circle part again but in a less complicated way, I am a GCSE student studying computing so I understand the other gates, just not that one it is new to me, thanks. :)

    • Posted December 12, 2012 at 00:10 | Permalink | Reply

      The semicircle input is the clock. The latch will only make changes to its state when the clock goes from 0 to 1 (i.e. rising edge). At all other times the S and R inputs are ignored.

  3. brian t
    Posted December 11, 2012 at 23:48 | Permalink | Reply

    I’ve chosen just to guess the second light eluminates and the other three go off. But it is a Guess. No Ive not had time to realy understand the complete logic yet.

    • Posted December 12, 2012 at 00:12 | Permalink | Reply

      That’s wrong unfortunately :-) I’m more after what this device is supposed to do rather than what exactly happens when you click the button. Although this can of course be inferred once you know what the device is for.

      • brian t
        Posted December 12, 2012 at 00:45 | Permalink | Reply

        Christmas light’s is my second guess, and they all chain react off and on in sequence. sorry. but looking at it and not ever using circuits, they all appear the same so I gueesing now each unit alters the next. sorry.

        • brian t
          Posted December 12, 2012 at 00:52 | Permalink

          My third guess is that you are trying to work out, out of all of us has a clue about logic circuits so count me as a complete guesser lol.

        • brian t
          Posted December 12, 2012 at 01:19 | Permalink

          Fourth and final guess simimilar to 2nd guess. the 2nd light iluminates and the 3rd goes off. the other two stay iliminated until the “clock” in the next unit alters the following one(i think) causing the unilumited light to move left to right (i think)

  4. Electric Jack
    Posted December 12, 2012 at 00:29 | Permalink | Reply

    This is a guess because I have a limited understanding of binary still but it looks like a 4 bit binary counter? Is it counting the amount of times the button is pressed? If so, it says it has been pushed 13 times. That is just my wild guess.

    • Posted December 12, 2012 at 01:40 | Permalink | Reply

      That’s right! Awesome! Yes, it is a binary counter. And it shows number 13. Now bonus question. What will be the next number shown after the button is clicked? Hint: remember that synchronous latch toggles its state when both S and R are 1.

      • Electric Jack
        Posted December 12, 2012 at 02:35 | Permalink | Reply

        Wow, I guess I haven’t completely lost what I learned about binary. XD Ok, this is where my dyslexia comes in lol. But, on an ascending counter, it would read from right to left 1110 which is decimal 14 as bit 3 toggles. Is that close? It has been a while since I have studied binary.

        • Electric Jack
          Posted December 12, 2012 at 02:53 | Permalink

          oops, I mean as bit 2 and bit 3 toggles. Well, one thing is for sure Kaalus. This update has definitely got me interested it hitting the books again and studying up. This is going to be a lot of fun to see what we can all make. :D

      • Posted December 12, 2012 at 11:08 | Permalink | Reply

        14 each button press will add one to the count until it reaches 15. then the next button press will make the system overflow and will reset everything back to 0. Im so going to make a 4 bit binary adder :)

        • Posted December 12, 2012 at 14:57 | Permalink

          That’s the obvious answer but it’s not correct. When you click the button, there will a a clock signal coming to the first SR latch, and both S and R inputs are hardwired to one, so it will toggle. Because it’s on now it will switch off. When it switches off, there is no rising edge signal to the next ST latch (it’ll be a falling edge), so the next latch will not change. So the next number will not be 14…

        • Posted December 12, 2012 at 15:44 | Permalink

          Ah missed that :) The latch only changing on a change of signal from 0 to 1, so its counting down not up 12 – 11 – 10 – etc

        • Electric Jack
          Posted December 13, 2012 at 03:10 | Permalink

          Ya, I missed that one too. I made the mistake of assuming and had a feeling I got that wrong. Ahh well, just like with all forms of logic and mathematics, once you get it down in your head how it works and what it is doing, you will wonder why you weren’t able to see it before. ;)

  5. max samuels
    Posted December 12, 2012 at 00:38 | Permalink | Reply

    Does it cycle through the lights on a predetermined pattern.

    • max samuels
      Posted December 12, 2012 at 00:40 | Permalink | Reply

      Meaning that this device is a very basic computer?

      • Posted December 12, 2012 at 01:41 | Permalink | Reply

        It’s not a computer, it’s something much simpler.

  6. max samuels
    Posted December 12, 2012 at 00:42 | Permalink | Reply

    Who wants to help me make the first survivalcraft computer

  7. chase reynolds
    Posted December 12, 2012 at 01:05 | Permalink | Reply

    This was helpful awsom game :)

  8. joel
    Posted December 12, 2012 at 01:51 | Permalink | Reply

    When will be out for android

  9. chrism81
    Posted December 12, 2012 at 01:54 | Permalink | Reply

    Its 4 bits of memory.

    • chrism81
      Posted December 12, 2012 at 01:56 | Permalink | Reply

      I wonder if somebody could actually recreate an old computer, like a altair8800.

  10. jriot10
    Posted December 12, 2012 at 02:27 | Permalink | Reply

    Lol Kaalus. When you click the picture it says it is a binary counter.

  11. Aj Nineht
    Posted December 12, 2012 at 02:49 | Permalink | Reply

    I do believe that because of the ‘n9t’ pieces, they will produce power, causing the switch to switch, making it appear the there is an unlit pane travelling across the wall in series, which simulates a four-bit binary counter.

  12. Shan e
    Posted December 12, 2012 at 03:02 | Permalink | Reply

    So, guess I better learn binary…

  13. jesusice
    Posted December 12, 2012 at 03:49 | Permalink | Reply

    Oh, great! I barely got tine enough to play SC and now not only do I have to learn circuits… I got to learn binary!?


  14. blob10
    Posted December 12, 2012 at 05:18 | Permalink | Reply

    Your awesome kaalus

  15. victorlourme
    Posted December 12, 2012 at 06:24 | Permalink | Reply

    when 1.19 will be released? I have a big problem on my tablet, I do not see animals, but just a shadow!! kaalus help me!

  16. Posted December 12, 2012 at 10:54 | Permalink | Reply

    Sweet, One thing I have noticed is that all the circuits you have posted have no power supply. In one of the photos/videos I noticed a battery, how/will this be implemented?

    I have had SC since day 1 and the work you are doing is amazing, I just upgraded to the HTC 8X and the game runs so smooth and looks amazing in high res!

    • Posted December 12, 2012 at 15:00 | Permalink | Reply

      The battery is the remnant from my original plan where I wanted to have separate power and logic circuits. I abandoned this idea because it would introduce a lot more complexity for no good purpose. So the battery is now a simple generator of a “constant on” signal. Because it looks cool, I want to keep it. Electrically, a disconnected not gate does the same thing. And a switch with lever pushed up. And a pressure plate when you’re pushing against it. No need to use battery unless you like the looks or you have to put it on the floor.

  17. Kostya
    Posted December 12, 2012 at 12:08 | Permalink | Reply

    Cool.Please do multiplayer, really want:-D.Those elements that burn, and turn off the one that turns off:-D

  18. jack
    Posted December 12, 2012 at 14:51 | Permalink | Reply

    I dont know wat u all talking about .. Plzz dont make the game too complicated .. im not smart like u guys. :(

    • Alex McCulloch
      Posted December 12, 2012 at 16:14 | Permalink | Reply

      Nothing is impossible to learn Jack you just have to google or either mess around with it until you understand it. A complicated game will make your brain grow. You learn from mistakes- which most of us will make when he comes out with the update.

  19. Alex McCulloch
    Posted December 12, 2012 at 16:14 | Permalink | Reply

    This is a good thing though as you will learn how to learn

  20. Artyom
    Posted December 12, 2012 at 16:22 | Permalink | Reply

    Excuse me, but when it will be armor?

  21. Cooperdan
    Posted December 12, 2012 at 18:28 | Permalink | Reply

    I hope you make the new recipedia description on electrical logical circuits a heck lot more simpler than this description on this SR latches :P haha :)

  22. craftw4
    Posted December 12, 2012 at 18:40 | Permalink | Reply


    Pistons maybe? This is my last time when i ask this if you answer :-D

  23. Posted December 12, 2012 at 19:12 | Permalink | Reply

    Just a guess but, it lights up the lights one after the other in sequence?

  24. Cody White
    Posted December 12, 2012 at 22:09 | Permalink | Reply

    Please add something relevant to pistons

  25. Posted December 13, 2012 at 00:39 | Permalink | Reply

    OHHH This is a toggling the Lights on and off repeatedly!!!!

  26. rhancandia
    Posted December 13, 2012 at 00:56 | Permalink | Reply

    its a running light. we used to make those last semester on my Digital Electronics class.


  27. mut
    Posted December 13, 2012 at 12:27 | Permalink | Reply

    Light on=1,off=0
    Every time one presses the button, from the left light,
    1011→0011→1101→0101→1001→0001→1110→0110→1010→0010→1100→0100→1000→0000→1111→0111→1011(initial state)

    • Posted December 13, 2012 at 12:46 | Permalink | Reply

      This is correct. It’s a binary counter counting backwards.

      • Alex McCulloch
        Posted December 13, 2012 at 20:05 | Permalink | Reply

        Mut awesome job. I was having a hell of a time remembering how to do it but now I remember. lol

      • Hilda
        Posted December 15, 2012 at 15:19 | Permalink | Reply

        I like thy upvrade

  28. Hilda
    Posted December 15, 2012 at 15:19 | Permalink | Reply

    I need that up date now wen will it come out it looks cool

  29. Tatyana
    Posted December 15, 2012 at 19:32 | Permalink | Reply

    On one side, I’m excited, but this update sounds like it’s about to make things a whole lot more complicated. Are we even going to be able to use this electricity if we don’t understand these things? Because I don’t really feel like taking a Google class on this circuit stuff.

    • Posted December 15, 2012 at 19:47 | Permalink | Reply

      Placing a button next to a door is not rocket science and will work :-)
      If you want to build e.g. a combination lock or something more complicated like that, then yes, you’ll need to understand how this stuff works.

      • Tatyana
        Posted December 16, 2012 at 05:07 | Permalink | Reply

        Alright then. I’ll try to see this as a challenge then. It’ll be nice I guess, to not know everything about a game before I start. And it’ll be even sweeter to explain all of it to my friends when they can’t figure it out xD.

  30. yo motha
    Posted December 20, 2012 at 03:39 | Permalink | Reply

    How many updates are there going to be for survival craft in total:]

  31. yo motha
    Posted December 20, 2012 at 03:49 | Permalink | Reply

    Do you have any more games kaalus ?:)

  32. yo motha
    Posted December 20, 2012 at 04:03 | Permalink | Reply

    What new blocks or things are there going to be in 1.19:]

  33. Posted December 31, 2012 at 04:33 | Permalink | Reply

    I have one issue, can please take off the trial on the free version so we can play as much as we want.

  34. Zeriya
    Posted January 3, 2013 at 23:36 | Permalink | Reply

    My Brain >.<

  35. Shankar
    Posted May 23, 2013 at 05:36 | Permalink | Reply

    For the better understanding of the SR Latch, I would recommend to watch this video, which describes the SR Latch in detail. It talks about the basic operation, the concept of present state, next state. And explains in detail how latch behaves for different inputs like 00,01,10 and 11.

  36. Chloe
    Posted June 9, 2013 at 18:37 | Permalink | Reply

    Wait where does it say 13? And what would you use one generally for in the game? Yeah I’m a total noob

  37. Posted August 5, 2013 at 07:49 | Permalink | Reply

    Hi to every body, it’s my first go to see of this webpage; this blog consists of amazing and actually fine information designed for visitors.|

  38. Clayton
    Posted August 17, 2013 at 23:12 | Permalink | Reply

    Could someone nicely explain what these latches are used for? I’m playing around with them, and all I’ve discovered is that they are a complex button. I don’t know anything about binary anything, so I’m thinking I’m missing the point of them. Any helps appreciated.

  39. Andy
    Posted August 20, 2013 at 02:51 | Permalink | Reply

    The first light will turn off, as the button push will result in a toggle of the gate –> no signal to the light.

    I was confused at first because you said the gate responds to rising edges, and the n gates provide a constant signal.

  40. sam
    Posted August 22, 2013 at 16:35 | Permalink | Reply

    Is it some sort of random generator, so when you press the button, another set of light aluminate?

  41. Posted September 7, 2013 at 10:57 | Permalink | Reply

    kate spade ケース

Leave a Reply. No swearing please.

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s