Digital Logic Circuit Problem

Thread Starter

Jaust

Joined Oct 18, 2018
2
Problem:
Given three inputs, design a combinational digital circuit that corresponds to three mutually exclusive outputs. You may only use T flip-flops to store outputs.

Example:
User presses button A to turn light A on, then presses button C to turn light C on and turn light A off. If the user presses button C again, then light C will turn off.

...

I've been stuck on this problem for a while now and so far I've only been able to come up with a sequential logic solution.



However, it's asking for a combinational solution and I'm not certain how to find one without being able to use the states of each T flip-flop.

I keep running into two issues: determining when to toggle a flip-flop without knowing its state and finding a way to modify other input without creating a feedback loop.

It looks like I could solve both issues by using the asynchronous 'reset' function that is found on integrated circuit chips, specifically by OR'ing non-corresponding inputs to a T flip-flop's 'reset'.



Unfortunately, I doubt this is the solution my instructor is looking for because I've lost points in the past for using similar solutions.

Without using asynchronous 'set' or 'reset' functions, my other idea was to encode all the output into four states using a 2-bit counter: all off (00), light A on (01), light B on (11), and light C on (10). However, I haven't found a way to consistently iterate the counter so that each input lands on the correct state.

Thus, I've come here. I'm uncertain how to proceed on this problem. Any advice or hints would be very much appreciated, thank you. :)
 

WBahn

Joined Mar 31, 2012
24,854
The problem statement is pretty ambiguous.

For instance, what does and does not constitute "mutually exclusive" for three outputs? Normally, two things are mutually exclusive if they cannot be the same. But if you have three binary outputs, at least two of them must always be the same.

So does it mean that exactly one of them is ON while the other two are OFF? That would seem reasonable, except that it contradicts their example.

So does it mean at most one of them is ON (but they can all be off)?

What does it mean for the three outputs to "correspond" to the three inputs?

Are these buttons momentary contacts or are they latched contacts?

It would seem that, based on what they've set up (assuming you are telling us everything), that it would be legal to simply have your three outputs all three outputs toggle one of the outputs and keep the other two always LO. That's almost certainly not what they wanted, but if they don't want a particular behavior, then they should write their specs so as to preclude it.

As written, it could be strongly argued that the restriction of using TFFs is intended only to mean that you can't use any other kind of FF to store the outputs (such as a DFF). Strictly speaking it doesn't preclude the use of FFs elsewhere in the circuit or the use of the FF outputs as inputs back into the circuit. However, the stipulation that you are designing a combinatorial circuit could be interpreted as precluding both (certainly it would prohibit the former). But if you draw a black box around the gate logic and it has six inputs, then you can clearly argue that the circuit you designed and that is located within that box is purely combinatorial.

Finally, try at nearly all costs to avoid using the asynchronous inputs. As soon as you go there you have entered the world of asynchronous logic design and that is not a jungle to go stumbling through lightly.
 

Thread Starter

Jaust

Joined Oct 18, 2018
2
I apologize for the ambiguity, a lot of my assignment questions are like this from my instructor. My impression was that one and only one output may be high/active at a time or all of them must be low/off. She's used the term 'mutually exclusive' before to generally mean that two or more things can't happen at the same time. She's also used the term "corresponding" to refer to something having a direct relationship with the next thing, in the case I assume the first input has a direct impact on the first output and so on. Unrelated to the nature of the question, she's also been strict on securing input and I originally considered adding a 3-input XOR gate to modify each input, which based on the example are likely meant to be physical buttons that emit a signal for as long as it's pressed.

Thanks for the advice about asynchronous logic. I'm taking a beginner's course currently and I learned more about it in my lab assignments than my textbook or lectures, so it's a possible cause of some of my missing marks. It could be due to the simplicity of the circuits I was working with, but the simulations always worked. Nevertheless, I find it interesting that integrated circuits have all these functions to experiment with.

Circling back to the memory elements, we've been allowed to use flip-flops as discrete elements in our combinational circuits before, although I didn't consider using other ones in this problem. That's a good observation that only the output memory is restricted to T flip-flops. I'm definitely going to explore that, but I've yet to find an obvious solution.

Thanks for the answer!
 

ebp

Joined Feb 8, 2018
2,332
Overall, the machine is sequential. It is impossible to describe its behavior with only a truth table, as can be done for combinatorial logic.. A state diagram is required. However, with a synchronous state machine you can partition the machine into the next-state transform logic which is strictly combinatorial and a state register - but the outputs of the state register must be fed back to the comb logic.I sort of think that is what is intended, but the problem really is badly posed.

Your last circuit only has means for clearing the flip flops. You can't change the state by changing the state of a T FF without using a clock - but you are very close and I suspect were just suffering from frustration leading to an error (error if what I think you want to do actually is what you want to do). Just have another look and I think you'll see what to do. Apart from that issue, I like your last circuit. It is simple and does the required task - but of course you're out of luck if your T FFs don't have async clear. While I agree with WBahn that async sequential circuits can be problematic, this one is actually very readily done with an async circuit. Any time you have asynchronous external inputs in a sync machine there is a risk of metastability. Provided your three inputs are mutually exclusive and the switches are debounced, the async machine eliminates the risk of metastability.

Here's a little something to consider: If you have three flip flops, you have 8 possible states but you only want to use 3 of them. What happens if the flip flops power up in one of the unwanted states?

On problems: Way back when Darwin was still available to do guest lectures, my second year invertebrate zoology prof said that exam questions that took a lot of words were usually easier to answer than questions posed with just a few words. I've always remembered that. It is actually often nearly as difficult to pose a good assignment or exam question as it is to answer one. You can make a marking nightmare for yourself by being sloppy in posing the question. I think your instructor will not and should not sleep easy. Regrettably, introductory courses seem to be given to relatively green instructors and I think those are the courses that should have experienced teachers.
 

danadak

Joined Mar 10, 2018
3,612
Probably not appropriate but one way to tackle this, for expediency, is to
describe this in Verilog and let a compiler produce the logic. Can be
very effective, as long as the coding is accurate.

By coding you are creating the state machine needed, and its like
a flow chart, easier to see and understand where change is needed.
For us visual learners.....:). Even some tools these days are GUI and
really nice to use to create state machines. And test results quickly
either in a sim or actual hardware.

Regards, Dana.
 
Top