Forum Discussion
design a BCD Counter
Hi,
Click(Highlight) "Q" in Simulation Waveform Editor.
"Edit"->"Radix"-"Unsigned Decimal"
It is counting (0-15) since your design(logic) consist of 4 flops, just modify the design as per requirement.
let me know, if this has helped to resolve your issue or if you have any different concern
Regards,
Vicky
i found what was wrong. as @RRomano001 suggested. i had my most and lest significant bits switched, that's why it wasn't right. But now i'm trying to expand it into a digit counter by adding wires from Not Q[0], Q[1], Not Q[2] and Q[3] connected to AND4 logic gate so that when we get 1010 it will feed into the next counter and give us the next digit which is not doing so. i'm thinking it's the wire placement that is wrong. do you have any idea where to add them
thank you
- RRomano0017 years ago
Contributor
Hi Gabra, sorry say this but I fear you need grasp digital design in deep as i usually told my pupils, error come from everywhere.
A BCD counter never count to 1010 that is ten decimal but remain in BCD domain {0..9} .
You can apply this method to ripple carry asyncronous reset but not to a syncronous counter as your appear to be.
This case require an enable count that happen on last digit value, when counter is 9 then load 0 as next state, at same time enable count on next digit. Your design miss this feature.
I suggest you start learning an HDL language and do this in a more simple fashion using state machine. I am proficient on VHDL and just read and understand Verilog I don't like so much, in HDL your design can be:
signal BCD : Std_Logic_Vector(3 downto 0); signal enable : Std_Logic := '1'; -- enable count signal sreset : std logic := '0'; -- reset to 0 clock gated BCD_counter: process (clock, reset_n) var count : integer range 0 to 9 := 0; if reset_n = '0' then count := 0; -- async reset else If rising_edge(clock, reset_n) then BCD <= Std_Logic_Vector(to_unsigned(count, 4)); if enable = '1' then if count = 9 or sreset = '1' then Count := 0; else count := count +1; end if; -- counter end if; -- enable end if; -- edge end if; -- reset end process;Regards
- gabra47 years ago
New Contributor
hello again.
i know i'm not that knowledgeable when it comes too the digital systems part, but i'm doing my best with my limited time. and i end up getting to what i was looking for. but my problem is that we have this week off and i can't gt in contact with the lab assistants, plus the lecturer doesn't provide enough explanations to everything and with my limited knowledge, it takes some time to grasp it. but if only i can get you to help me for the last time. i'm at the last part of my circuit and i have all my parts ready. a part with bcd counter and a part with a digit shifter where it changes the locations of the digits on my fpga. but the thing is, i'm trying to connect them so that i can switch them with one button push, it worked but i have to hold the button to keep the shifter not just press it. i'm not quite sure what we need to use here, i'm thinking of a 2 to 1 multiplexer but then i'm not sure how to connect it.
i have attached all my project for you to check it and have more freedom working around it. if you could help me i appreciate it, if not, i understand.
thank you