slot machine

Thread Starter

matt03

Joined Aug 21, 2013
20
hi, i'm fairly new to this, so please forgive me with anything i'm doing wrong.

i'm working on a school project. i'm designing a digital slot machine on multisim12.

for the slot machine, i'm using a 0-9 up counter designed with 4 JK flipflops. (3 counters all in all)
the outputs of each flip flop are fed into the input of a BCD to 7-segment decoder then to a 7 segment display.

i wanted my pay out to be the following:

numbers that are not equal = $0
000 - 666 = $20
777 = $999
888 and 999 = $200

however, i am having problems comparing the 3 numbers. right now, i am using nand gates to compare the BCDs of each displayed digit, then the outputs of the nand gates are the inputs of a 2 input nor gate with the other connected to ground. the outputs of the nor gate are then the A inputs of a 4 bit magnitude comparator with the B inputs set at 0111.

it works at 777, however regardless of whether the numbers are 1-1-1 or 1-2-3, the A less than B output is always $20.
 

WBahn

Joined Mar 31, 2012
29,979
It would help if you had a schematic or some logic expressions instead of just a verbal description, but I definitely want to thank you for making an attempt first and then posting that attempt to start the ball rolling.

I'm not following how you are comparing the numbers. When you say using NAND gates to compare the BCDs of each displayed digit, what do you mean? You have three four-bit values:

D0[3:0]
D1[3:0]
D2{3:0]

where D0, D1 and D2 are three digits and Dn[0] is the lsb of the Dn digit whle Dn[3] is the msb of that digit.

So you have twelve signals that are your inputs.

How many outputs do you have? How many possibly outcomes do you have? How do you want to encode them?

What are your constraints? Can you only use two-input NAND and NOR gates? I'm inferring this from your description -- but it would be better if you stated what your restrictions are.

Now break down your requirements into chucks:

Q1) Irrespective of how much the payout is, what has to be true regarding the three digits in order to be any kind of a winner?

Q2) Given that you know that the result is a winner, do you need to know all three digits to determine the payout, or just one of them?

Q3) Given the answer to Q2, are there any outcomes that you can assert knowing just one of the bits in the digits?

Q4) Given that you know that the result is a winner and that it does not fall into the outcome(s) captured by Q3, can you easily detect any of the other outcomes?

Q5) At some point, you are left with just one outcome that hasn't been detected, meaning that if you got to this point, it has to be that outcome.
 

Thread Starter

matt03

Joined Aug 21, 2013
20
first, thanks for replying!

i attached a picture of my current circuit. i hope it helps. i can post more if needed.

my restrictions are only the use of flip flops, logic gates, decoders, multiplexers, encoders and magnitude comparators.

from my circuit, the LSB from the counter to the BCD to 7 segment decoder is A and D is the MSB, so my input is DCBA = Q1Q2Q3Q4 from the flipflop.

the use of the NAND and NOR gates was something i just came up with that might help with the comparison of numbers. (feel free to change this if you have better ideas)

i have 4 NAND gates in total. 1 NAND gate has 3 inputs. Each input is taken from the respective outputs of the 3 different counters. So the first NAND gate has inputs D1 D2 D3.

answers for the breakdown:

Q1) Irrespective of how much the payout is, what has to be true regarding the three digits in order to be any kind of a winner?

for the player to win, the 3 digits generated from the counter must be the same (111, 777, etc)

Q2) Given that you know that the result is a winner, do you need to know all three digits to determine the payout, or just one of them?

this was one of my initial problems. what i thought of first was to compare all 3 numbers and make sure they are all equal, once they are equal, i wanted to compare them to 7 to determine the payout. i'm not completely sure if i used to correct set of gates to compare the numbers or if i should even use gates.

Q3) Given the answer to Q2, are there any outcomes that you can assert knowing just one of the bits in the digits?

no, i don't believe there are.

Q4) Given that you know that the result is a winner and that it does not fall into the outcome(s) captured by Q3, can you easily detect any of the other outcomes?

no, i do not think so.
 

Attachments

WBahn

Joined Mar 31, 2012
29,979
Okay, so that gives me a pretty good idea for some points to start with.

Q5) If your problem was limited to determining if (the 4-bit number) D0 is equal to (the 4-bit number) D1, how would you do that? Can you sketch a circuit?

Q6) If you know that D0 is equal to D1 and you also know that D1 is equal to D2, what do you know?

Q7) Using the information from Q5 and Q6, can you sketch a circuit that takes D0, D1, and D2 as inputs and gives a single output that tells you the information refered to in Q6?

Let's shift gears slightly and just focus on D0 (or one of the others, but let's pick D0).

Write out all the possible values of the four Q bits and indicated what value they represent. Then add three columns to the right of that. In the first column, put T if the payout should be $20 if all three numbers are that value and put F otherwise. Similarly, in the second and third columns, put T if the payout should be $999 or $200 respectively.

For any rows that do not correspond to values between 0 and 9, inclusive, but and X in each column, indicating that you don't care what happens in that case because that case should never happen.

Let's get you to that point and then push to the finish line from there.
 

Thread Starter

matt03

Joined Aug 21, 2013
20
Q5) If your problem was limited to determining if (the 4-bit number) D0 is equal to (the 4-bit number) D1, how would you do that? Can you sketch a circuit?

initially i thought of the NAND and NOR gates. now, i reconsider and think maybe 2 magnitude comparators and an AND gate would be ok. i attached a picture of how i think it could work.

Q6) If you know that D0 is equal to D1 and you also know that D1 is equal to D2, what do you know?

if D0 equals D1 and D1 equals D2, we know D0 equals D2 as well and that the given combination is a winning one.

Q7) Using the information from Q5 and Q6, can you sketch a circuit that takes D0, D1, and D2 as inputs and gives a single output that tells you the information refered to in Q6?

so i did consider the 2 magnitude comparators and the AND gate. for comparator1: inputA = D0, input B=D1
comparator2: inputA = D1, input B=D2

then the "A equals B" outputs of both comparators are connected to a 2 input AND gate, only functioning when D0=D1=D2.
 

Attachments

WBahn

Joined Mar 31, 2012
29,979
Q5) If your problem was limited to determining if (the 4-bit number) D0 is equal to (the 4-bit number) D1, how would you do that? Can you sketch a circuit?

initially i thought of the NAND and NOR gates. now, i reconsider and think maybe 2 magnitude comparators and an AND gate would be ok. i attached a picture of how i think it could work.
Yep. That's got it. Well almost.

Look at the data sheet and you will find that the output is LO when the two values are equal. This is why the name of the pin on the part ends with a "B", which is common shorthand for "BAR" or a "active-LO signal".

So you don't want a gate that requires both to be HI in order to generate a HI, you want a gate that requires both inputs to be LO to generate a HI. What gate would that be?

Having finished up that last little bit, you have a logic signal that is T if it's a winner and F if it's a loser. So we can set that on a shelf and come back to it later. For the next phase, let's assume that we have a winner and we just need to figure out the specific payout.
 
Last edited:

WBahn

Joined Mar 31, 2012
29,979
here's the table you asked for as well.
Very good.

Now, look at your three output columns and your four input columns and take another shot at Q3 and, if you get that, Q4. Remember, the idea is to ask if there is a way to tell the value in one of the output columns by just looking at one of the input columns.
 

Thread Starter

matt03

Joined Aug 21, 2013
20
Yep. That's got it. Well almost.

Look at the data sheet and you will find that the output is LO when the two values are equal. This is why the name of the pin on the part ends with a "B", which is common shorthand for "BAR" or a "active-LO signal".

So you don't want a gate that requires both to be HI in order to generate a HI, you want a gate that requires both inputs to be LO to generate a HI. What gate would that be?
we're talking about the "B" on the comparator, right? i thought it stood for B as in the input B. and the bubbles on pins mean "active-LO"

anyway, for a gate that functions only when both signals are LO would be a NOR gate.
 

Thread Starter

matt03

Joined Aug 21, 2013
20
Very good.

Now, look at your three output columns and your four input columns and take another shot at Q3 and, if you get that, Q4. Remember, the idea is to ask if there is a way to tell the value in one of the output columns by just looking at one of the input columns.
well what i noticed for $20 is that Q1 is always 0. and for $200 functions only when Q1 = 1. i'm not sure i'm analyzing it right, so i tried karnaugh mapping the outputs and see if that could help. it's in the attached picture.
 

Attachments

WBahn

Joined Mar 31, 2012
29,979
we're talking about the "B" on the comparator, right? i thought it stood for B as in the input B. and the bubbles on pins mean "active-LO"

anyway, for a gate that functions only when both signals are LO would be a NOR gate.
Actually, you are correct. That B does mean the input B. I just looked a bit more closely at the datasheet and see (now that I, to some degree, CAN see) that I misinterpreted the last row of the truth table. So the outputs ARE active HI and your use of the AND gate is correct.

Also, you can actually avoid the AND gate by cascading the two 7485s as though you were comparing two 8-bit words. You simply treat one word as being two of the 4-bit values glued together and the other as being the remaining 4-bit value just repeated and glued to itself.
 

WBahn

Joined Mar 31, 2012
29,979
well what i noticed for $20 is that Q1 is always 0. and for $200 functions only when Q1 = 1. i'm not sure i'm analyzing it right, so i tried karnaugh mapping the outputs and see if that could help. it's in the attached picture.
Ah, so you do already know about K-maps. Good. Yes, you can use Q1 as your $200 flag. While it's true that the $20 requires that Q1 be LO, that is not sufficient. So that's not immediately useful. What does the K-map tell you about the logic for the $999 flag?

Now, instead of generating the $20 flag by looking at the four Q outputs, what if you generate it by looking at the other two flags? What would that logic look like?

Think of it in story problem terms. If you know that it IS a winner AND it's NOT a $999 winner AND it's NOT a $200 winner, then what do you know?
 

Thread Starter

matt03

Joined Aug 21, 2013
20
Ah, so you do already know about K-maps. Good. Yes, you can use Q1 as your $200 flag. While it's true that the $20 requires that Q1 be LO, that is not sufficient. So that's not immediately useful. What does the K-map tell you about the logic for the $999 flag?

Now, instead of generating the $20 flag by looking at the four Q outputs, what if you generate it by looking at the other two flags? What would that logic look like?

Think of it in story problem terms. If you know that it IS a winner AND it's NOT a $999 winner AND it's NOT a $200 winner, then what do you know?
For $999, it only works when Q2Q3Q4 are all high.
If its a winner and neither a $999 or $200 winner, it is a $20 winner.
 

WBahn

Joined Mar 31, 2012
29,979
Very good. So now you have an understanding of the logic you are trying to implement. All that is left is to convert each of those statements into a logic equation (or make a truth table or a K-map, which are all equivalent).

Take your best shot and post the results. You are almost there.
 

Thread Starter

matt03

Joined Aug 21, 2013
20
Are the logic equations the same as the ones I derived from the kmap?

Also, if I use the cascaded comparators to compare the 3 generated digits, assuming they are winning combinations, where do I go from there?
 

WBahn

Joined Mar 31, 2012
29,979
I'm not seeing the cascaded comparators you are referring to.

You can use the K-maps you did, those they do not necessarily represent the easiest way to implement the logic (but "easiest" is a subjective term, so don't put too much stock in that).

But you need to show your work. Go from the K-maps you presently have, if you like. But show some work towards the solution.
 

Thread Starter

matt03

Joined Aug 21, 2013
20
one picture is for the cascaded comparators. the other is for the logic equations derived from the karnaugh maps for all 3 counters and the different results. however, i have a problem with the $20. even if its not equal, it still functions, so the $20 still shows even if its 1-7-3 or other combinations.
 

Attachments

WBahn

Joined Mar 31, 2012
29,979
one picture is for the cascaded comparators. the other is for the logic equations derived from the karnaugh maps for all 3 counters and the different results. however, i have a problem with the $20. even if its not equal, it still functions, so the $20 still shows even if its 1-7-3 or other combinations.
I haven't looked at your schematics -- will do that later once I get to a place where I can download files at other than a snail's pace. But the problem you are having suggests exactly where to look. Determining what the payout should be, for ALL payouts, was contingent upon the independent determination, via the comparator circuit, that there was to be ANY payout. So if your logic is saying that there should be a payout when there shouldn't be, look to how you are folding the output from the comparator logic into your final payout signals, since the lack of a winner should FORCE all three outputs to zero.
 

WBahn

Joined Mar 31, 2012
29,979
I can't make heads or tails of your schematics. First, they are all different. Second, they are of so low resolution that there is no way to read the signal or pin names.

But I can tell that you are leaving numerous inputs unconnected. Never do this. If you don't need to every change a particular input, then hard tie it to a state that is consistent with how you want it to behave. If it doesn't matter, then flip a coin and tie it to whichever state wins. Do NOT leave them unconnected.

Your cascaded comparator portion is almost correct. I think you will have it if you address the unconnected inputs issue appropriately.
 
Top