Page 1 of 1

Multiplexer Race Condition

Posted: Sat Sep 30, 2023 3:50 pm
by SamuraiPDF
Hello! I will try to be as brief as possible, but in short, I have a condition where at random, my multiplexer is giving me both inputs combined.
I have a project where I have to do an endless runner, and I'm stuck with the player controls. The player is represented by a 10 bit register where only one bit is on at the time, indicating it's position. This is also so that the 10 column LED matrix can get the display properly.
So I made shift right and shift left circuits that hold the bit at the last position, so the player doesn't just disappear. It works properly.
Now I thought I could just put a 10 bit register, set it on 1, and when either left or right was triggered I would send a signal to the register to save the value from a MUX. The multiplexer has either the right or left shift (Right shift for left player movement, LeftSH for R player movement). However, sometimes, for a split of a second it sends both, and I end up with two bits turned on. I have tried a lot of things, I think if I remove the clock and make the player move once per push the problem dissappears. But I really wanted to make it possible to just hold the button. What should I do?

I asked in another place before, and told me there was nothing to do to the MUX, but insead I should properly time the register. HoweverI don't know how.
Here you can check the player circuit and mux, sorry for the mess. If is there any further information you need please tell me:
EndlessRunner.rar
Project
(70.86 KiB) Downloaded 734 times
Also, I'm trying to use the circuit at a speed of 15, but I think it's present on any speed

Re: Multiplexer Race Condition

Posted: Sat Sep 30, 2023 7:36 pm
by admin
Hi,
Your circuit is very big, and it is not clear where to look for the problem. From what I see there is a data register not the shift one. it can hosd more than one bit set. So, I am not sure how it supposed to work. Please share a simplified version to see the problem if you need help.

Re: Multiplexer Race Condition

Posted: Sat Sep 30, 2023 9:27 pm
by SamuraiPDF
Sorry, my bad. Here is a project with only the necessary circuits. I talked about what I thought was happening, but the only thing I'm 100% sure of is I'm getting duplicate bits.

Yes, the shift will shift any set of bits, but the register starts with one. I shouldn't be able to get 2 bits out of a shift. At least that's what I would think.

I am guessing that sometimes the multiplexer is giving both the Right Shift and Left Shift outputs to the register, thus saving 2 bits, separated by 1 as in the image in the post. But I don't know if this is something I can fix.

In main you have the LEDS, in the Player circuit you have what it's in the image

Re: Multiplexer Race Condition

Posted: Sun Oct 01, 2023 9:36 am
by admin
I think it is a real race condition on the circuit you've designed. Your clock signal is coming to the 10 bits register while the data on the D input is still changing. Try to change the design in a such way that this is not happening. I'd suggest having a shift register that can shift left and right depending on the direction input. Look for Bidirectional Shift Register for more information.