48Hz still seems pretty fast to cycle through 10 values for a digit, but if that's what you want... (if you slowed it down, the problem might become more obvious, by the way)
The problem is a combination of your count process, how you're setting r_anode
, and your case statement to determine the value of segment
, possibly among other things.
Your count process goes from 1 to, well, a lot, and you only want to go to 20, as I understand it. You may want to consider adding a wraparound condition. That depends on how you do the following, though.
r_anode
is"1110"
for 10 clocks and then"1101"
for the rest of the 2^20 cycles. I don't think this is what you want. By the way, withnumeric_std
, you can just writeunsigned(counter) > 9
- I'm not sure what you have written should even compile (you were usingstd_logic_unsigned
before, I gather?).This is the main problem. You seem to want the values for both of your digits to depend on this one counter, but you are comparing the entire 20-bit
counter
value, so segments are only active for 10 clocks out of 2^20, and only on for the first digit, since you're explicitly checking only values 0 through 9. What you need is some sort of a modulus operation (or separate counters for each digit, or something).
You may also need to think about how you are driving the two displays, but that depends on how you fix the other issues.