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:
Also, I'm trying to use the circuit at a speed of 15, but I think it's present on any speed
Multiplexer Race Condition
-
- Posts: 2
- Joined: Fri Sep 22, 2023 3:29 pm
Multiplexer Race Condition
- Attachments
-
- Duplicated bits
- imagen_2023-09-30_175008102.png (20.12 KiB) Viewed 42272 times
-
- Normal behaivor
- imagen_2023-09-30_174539179.png (18.78 KiB) Viewed 42272 times
Re: Multiplexer Race Condition
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.
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.
-
- Posts: 2
- Joined: Fri Sep 22, 2023 3:29 pm
Re: Multiplexer Race Condition
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
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
- Attachments
-
- imagen_2023-09-30_232313688.png (78.55 KiB) Viewed 42262 times
-
- PlayerMovement.rar
- (32.41 KiB) Downloaded 3559 times
Re: Multiplexer Race Condition
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.