# Tried to make flip flop

**URL:** <https://forum.xod.io/t/tried-to-make-flip-flop/3427>\
**Category:** Uncategorized\
**Created:** [February 4, 2020, 10:11pm UTC](https://forum.xod.io/t/tried-to-make-flip-flop/3427 "2020-02-04T22:11:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidonowhattowrite](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@aidonowhattowrite](https://forum.xod.io/u/aidonowhattowrite)\
**Post date:** [February 4, 2020, 10:11pm UTC](https://forum.xod.io/t/tried-to-make-flip-flop/3427/1 "2020-02-04T22:11:00Z")

</div>

As the title, states I tried to make a Flip Flop gate, but for some reason I am getting a “False” statement in the watch.

I am using two NAND gates, and the pulse representing the CPU clock is false, therefore, if I am not wrong, both watches should display true?

Anyone got any idea as to why, it isn’t working?

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [February 4, 2020, 10:18pm UTC](https://forum.xod.io/t/tried-to-make-flip-flop/3427/2 "2020-02-04T22:18:27Z")

</div>

It would be a lot easier to help if you could include a copy of your xodball or a picture of your patch. (I find picture easier for small patches as I don’t have to download the xodball, but that is just personal preference.)

FYI: a flip-flop node already exists, but it is coded in C++

---

<div class="post-metadata">

**Author:** ![aidonowhattowrite](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@aidonowhattowrite](https://forum.xod.io/u/aidonowhattowrite)\
**Post date:** [February 4, 2020, 10:20pm UTC](https://forum.xod.io/t/tried-to-make-flip-flop/3427/3 "2020-02-04T22:20:19Z")

</div>

Whoops, thought I had already posted the screenshot.

Here you go 🙂

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/9/93630d9c09cf5de2356156bc5a8e3e3e14c171eb.png)

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [February 4, 2020, 10:37pm UTC](https://forum.xod.io/t/tried-to-make-flip-flop/3427/4 "2020-02-04T22:37:43Z")

</div>

That is not proper wiring for a NAND flip-flop.

If you add watch nodes to the top nand gates, you will see that they are both true (neither has both inputs true, so “and” is false, and nand negates that). Since 2nd row of nand gates has both inputs true, “and” is true, and nand negates it to false.

A true flip-flop built using gates is going to need wires looping back up to provide feedback on the current state. Any wires looping back will need to have a defer node added so XOD can figure out how to deal with the feedback loop.

Set-Reset flip-flop:  
 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/8/8287b052e7ef591e7c6612edf93ca18462f037b9.png)

Toggle flip-flop:

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/a/a070e35fa0558d0eab0e92293d3e9f7bb7118f73.png)

If you just need a flip-flop, the existing node is your best bet. If you are just experimenting, start with one of the above diagrams (or do an internet search…there are LOTS of options).

---

<div class="post-metadata">

**Author:** ![aidonowhattowrite](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@aidonowhattowrite](https://forum.xod.io/u/aidonowhattowrite)\
**Post date:** [February 4, 2020, 11:32pm UTC](https://forum.xod.io/t/tried-to-make-flip-flop/3427/5 "2020-02-04T23:32:23Z")

</div>

Thank you for the suggestion of nodes,

I did it like this

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/d/d594d71fdb2a29499ac65ddb20d7ea09e5151961.png)

But now I am getting “cloud compilation limits exceeded.”

Supposedly the cloud server should update every 10 minutes, but I have waited over 10 minutes between my attempts to simulate, so is there something wrong with my chain, or is it indeed the cloud that has to update?

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [February 5, 2020, 2:26am UTC](https://forum.xod.io/t/tried-to-make-flip-flop/3427/6 "2020-02-05T02:26:14Z")

</div>

Your patch still doesn’t match the toggle example I provided. The top nand gates should have 3 inputs with additional wires looping back.

If you are not logged into XOD, I think logging in will give you more compiles.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [February 7, 2020, 2:26am UTC](https://forum.xod.io/t/tried-to-make-flip-flop/3427/7 "2020-02-07T02:26:17Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
