Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20704 Discussions

Design a BCD counter with a asynchronous master reset. Display the values 0 to 9 on

Altera_Forum
Honored Contributor II
1,227 Views

Design a BCD counter with a asynchronous master reset. Display the values 0 to 9 on the 7-segment display and whenever the count is 1, 3 or 5, a Led will turn on. 

 

HI,i have a problem with the program with regards to the led_on.Can any kind soul provides some advice on this? 

 

This is so far what i've done, 

 

-- a BCD coubter with asynchronous reset 

library ieee; 

use ieee.std_logic_1164.all; 

use ieee.numeric_std.all; 

 

entity bcd_counter is 

port ( clk, reset_bar,led_on: in std_logic; 

q : out std_logic_vector (9 downto 0)); 

 

end bcd_counter; 

 

architecture flow of bcd_counter is 

 

signal count_sig: unsigned (9 downto 0); 

 

begin 

process (clk, reset_bar,led_on) 

begin 

if (reset_bar = '1' and led_on = '1') then 

count_sig <= "0000000000"; 

 

elsif falling_edge (clk) then 

if (count_sig = 9) then 

count_sig <= "0000000000"; 

else 

count_sig <= count_sig +1; 

if(led_on = '1') then 

count_sig <="0000000000"; 

else 

count_sig<= count_sig +1; 

 

end if; 

end if; 

end if; 

end process; 

 

q <= std_logic_vector (count_sig); 

 

end flow;
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
465 Views

What does LED_ON do ? Is it like : counter_enable?  

Or do u whant to turn the led (make is light'n up)?
0 Kudos
Altera_Forum
Honored Contributor II
465 Views

counter_enable which triggers the 9 output. I tried compiling the graph, the only thing that doesn't toggles is the led_on ): Is it because theres a problem with my if, else? Or do i have to include the led_on, on a separate if,else statement? I really need help on this ):

0 Kudos
Altera_Forum
Honored Contributor II
465 Views

From the looks of it led_on is your reset signal, and reset_bar specifies if its an async or sync reset. 

 

What does your testbench code look like?
0 Kudos
Altera_Forum
Honored Contributor II
465 Views

the resetbar is a master reset. Even with the compilation, the led_on was still unable to on. How do i use the if else, particularly on the led_on? So far what i've came out, is for the reset_bar. :

0 Kudos
Altera_Forum
Honored Contributor II
465 Views

hope that image answer ur question tricky

0 Kudos
Altera_Forum
Honored Contributor II
465 Views

Plz describe your needs for the programm. 

Also describe what every input has to do.  

 

We can't figure out what the code has to do (or what u whant LED_ON has to do).
0 Kudos
Altera_Forum
Honored Contributor II
465 Views

A testbench is a peice of VHDL code used to drive your unit under test in a simulator, not the board you're going to run your design on.

0 Kudos
Reply