CC Zone - Chip's Challenge Forum
How to use logic gates? - Printable Version

+- CC Zone - Chip's Challenge Forum (https://forum.bitbusters.club)
+-- Forum: Chip's Challenge (https://forum.bitbusters.club/forum-4.html)
+--- Forum: Chip's Challenge 2 (https://forum.bitbusters.club/forum-18.html)
+--- Thread: How to use logic gates? (/thread-1390.html)

Pages: 1 2


How to use logic gates? - Flareon350 - 23-May-2016

So I'm not gonna hide it. Yes I do not know how any of the logic gates work, with the exception of the AND gate. The main CC2 game really didn't teach it well in all honesty (either that or I really just don't understand them).

Since I don't know how to use them, I won't be using them much in my CC2 levels unless I learn how. But due to the fact I can't learn anything through watching videos and reading up on stuff like that, I need some help learning. So could someone who does know what they all do teach me and maybe provide examples for me to understand? I really could use some guidance with these tiles.

The reason for this thread is because I may not be alone in not understanding how they work so anyone else in the future who doesn't know how to use logic gates can view this thread and maybe learn as well.

I'd appreciate it if someone could help me learn how to use these so I can maybe build a crazy logic level one day. Slight smile


How to use logic gates? - _H_ - 23-May-2016

I'll try to give you a short overview over the elements and their mechanics Slight smile

The logic gates are AND, NAND (not and), OR and XOR (exclusive or) will give you based on their inputs on the side (in the following table x and y) the result (marked as r) at the top - T stands for true or a high signal F for false or a low one:

Code:
r: AND (*)
x y r
(T,T,T)
(T,F,F)
(F,T,F)
(F,F,F)

r: NAND
x y r
(T,T,F)
(T,F,T)
(F,T,T)
(F,F,T)

r: OR (+)
x y r
(T,T,T)
(T,F,T)
(F,T,T)
(F,F,F)

r: XOR
x y r
(T,T,F)
(T,F,T)
(F,T,T)
(F,F,F)

Except for the exclusive or there are no surprises as the words are used the same manner in everyday language. For XOR remember, that if both inputs are the same, the output will be false and if they are different, the result will be true.

The not element negates a signal, this means False will give you True as a result, and vice versa.

Each of the gates has a delay of 1 tick to it, this means, the output will not be instant. If you e.g. realize a diode by putting two not gates after each other, there will be a delay of two ticks compared to the reference signal.

The latch gates are a bit trickier - they are essentially what is more well known as D-latches (compared to a D-flip-flop which is edge-sensitive it is level-sensitive, sometimes called transparent D-flip-flop), this means they will change their state according to the data (D) input as long as the enable (E) input is high. You can use them to store the input state.

Code:
D E Q
(F,T,F)
(T,T,T)
(x,F,Q previous)

To get more detailed information about all the logic gates, I recommend using the internet and a search engine of your choice. If you search for the electronic real world counterparts you will find a lot of detailed explanation (much more than I or anyone else could ever write here) and examples of using them B) (Keep as well in mind, wikipedia is never the worst starting point...)

If you have any specific questions about their behavior especially their mechanics within CC2 I and I guess a lot of other members are glad to help...


How to use logic gates? - mobius - 23-May-2016

This is an excellent topic. I too, would appreciate help on the subject. Unfortunately, I think it’s kind of one of those things that really takes a while to learn cause it’s sort of like a type of math. Just explaining it won’t be as simple as having a single post or even a video. And it’s pretty important imo, considering you can build a mini-computer in a level Smiley [see the UART level in the downloads]

What I’m doing for myself, is I’m experimenting on my own and learning as I go. That’s a really slow way of doing it, but I plan to upload levels, possibly a pack of demos and explanations on the subject as I learn. And in my regular levelpack I have currently two tutorial levels demonstrating logic gates in *slightly* more detail than CC2’s game.



A quick tip I can say off the top of my head: if you put a inverter in a wire loop [just make a wire rectangle and pun an inverter in it somewhere]. The wire will cycle on and off rapidly. With this you can make things happen like a cloner clone rapidly with no buttons being pressed at all; or have a timer go up or down without button presses as well. This is sort of where I started and will probably have demos of first. I started getting fascinated by this when I saw it first in "Crazy 1 and 2".


How to use logic gates? - Joshua Bone - 23-May-2016

http://imgur.com/a/6nO1x

Album showing all the combinations for the 4 basic gates (AND, OR, XOR, NAND).


How to use logic gates? - FelixNemis - 23-May-2016

This seems like something that a lot of people have trouble with, so I decided to go ahead and make a basic set of lessons showing how each wiring element in CC2 works.
http://cczone.invisionzone.com/index.php?/files/file/570-introduction-to-wiring/
It doesn't go into how to wire up multiple gates together to make complex circuits, but it covers all the elements individually.


How to use logic gates? - Flareon350 - 23-May-2016

Thank you everyone, especially Felix! I think a tutorial for logic stuff was highly needed, just no one spoke up about it Tongue

I think I get how latches work now but I'm still playing the tutorial (solved all of them, just playing around with stuff). I'll have to test some stuff out on my own to make sure I know how to use them.


How to use logic gates? - mobius - 24-May-2016

is it possible to set up "IF statements" with wires?

Let's say I want the following:

You clone a monster to randomly press one of three buttons, each connects to a latch or otherwise connects to another button which you press, to open the door to the exit. [six buttons total]

Now if you clone another monster, and it presses a different button, it turns off the first latch and turns on the other one it went to. So now, chip can only pressed the latest button triggered to open the door.

Is this possible?


How to use logic gates? - _H_ - 24-May-2016

Quote:is it possible to set up "IF statements" with wires?
Almost all useful logic circuits are conditional on their input, so yes as you can see most circuit as a conditional expression. Slight smile

Quote:You clone a monster to randomly press one of three buttons, each connects to a latch or otherwise connects to another button which you press, to open the door to the exit. [six buttons total]
I'm not quite sure what you mean with otherwise connects to another button.

Quote:Now if you clone another monster, and it presses a different button, it turns off the first latch and turns on the other one it went to.
You cannot turn on or of logic gates, however you can set their output to a high signal or a low one.

Quote:So now, chip can only pressed the latest button triggered to open the door.
Not a hundred percent sure what you are describing here.

But if I guess correctly, you either want three outputs, where two are set at random and Chip has to set the third signal to high to get to the exit, or you want one of three outputs set, if Chip triggers the corresponding event to a certain output, another one is chosen at random and Chip has to set a corresponding signal again to finish the level.

In the first case just connect both inputs of each of the latches to get a one time use too set a signal and connect their outputs with two and gates to have the condition all three have to be high.

If you tried to describe the second behavior, it's a bit trickier, since you have to reset the states (or duplicate the circuit). To do this, connect the inputs of the latches via or gates to get essentially a SR-latch. Now you have one input to set a state and one to reset it (as e.g. in the level SET AND RESET). The set connection has to be connected to your random events, the reset one should be triggered from an and gate which gets its signal from the corresponding output of the latch and the circuit Chip is triggering (e.g. a button). The same connection can trigger future events, as e.g. a second random set. To determine what should occur, use a counter, in case of just a few events, you can use the counter tile, otherwise to make the circuit more generally applicable, build a binary counter out of the gates... B)


How to use logic gates? - FelixNemis - 24-May-2016

Quote:is it possible to set up "IF statements" with wires?

Let's say I want the following:

You clone a monster to randomly press one of three buttons, each connects to a latch or otherwise connects to another button which you press, to open the door to the exit. [six buttons total]

Now if you clone another monster, and it presses a different button, it turns off the first latch and turns on the other one it went to. So now, chip can only pressed the latest button triggered to open the door.

Is this possible?
If I understand correctly you want something like this


[Click to Show Content]


Where the monster pushes one button, and chip must push a corresponding button to exit, and if the monster pushes another button, the first one wont work and the new button's corresponding button needs to be pushed.


How to use logic gates? - Eric119 - 24-May-2016

I think this does what you're looking for. Assuming at most one of the buttons is ever held down at a time, only the output of the later one's latch will be on. If you want to control whether a button opens a door, you can (for instance) feed the latch output into an AND gate and have the button connected to the other input of the AND gate. All this is easily extended to any number of latches.



[Image: logic.png]