Consider a 3-bit binary down counter initialized to "111" (decimal 7). It decrements by 1 on each clock cycle. What is the output value after 5 clock cycles?
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.NUMERIC_STD.ALL; entity down_counter is Port ( clk : in STD_LOGIC; reset : in STD_LOGIC; count : out STD_LOGIC_VECTOR (2 downto 0)); end down_counter; architecture Behavioral of down_counter is signal cnt : unsigned(2 downto 0) := "111"; begin process(clk, reset) begin if reset = '1' then cnt <= "111"; elsif rising_edge(clk) then cnt <= cnt - 1; end if; end process; count <= std_logic_vector(cnt); end Behavioral;
Count down from 7 by 1, five times: 7, 6, 5, 4, 3, 2...
The counter starts at 7 (binary 111). After 5 decrements, it reaches 2, which is binary "010".
In a binary down counter with a synchronous reset, what happens when the reset signal is asserted during a clock edge?
Think about what synchronous means: reset happens in sync with the clock.
A synchronous reset means the counter resets its value only at the clock edge when the reset signal is high.
What error will this VHDL code produce when synthesized or simulated?
process(clk, reset)
begin
if reset = '1' then
cnt <= "000";
elsif rising_edge(clk) then
cnt <= cnt - 1;
end if;
end process;Check the recommended way to detect clock edges in VHDL.
Using 'clk'event and clk = '1' is legal but discouraged; modern VHDL uses rising_edge(clk) for clarity and synthesis compatibility.
Which option contains the correct syntax for a process that decrements a 4-bit unsigned counter on the rising edge of clk with asynchronous reset?
Check for missing semicolons and proper end if statement.
Option C has all semicolons properly placed after every statement including after 'end if;'. Option C misses semicolon after 'end if'. Option C misses semicolon after the reset assignment. Option C misses semicolon after the decrement assignment 'cnt <= cnt - 1'.
A 5-bit binary down counter counts down from 31 to 0 and then wraps around back to 31. How many distinct states does this counter have before repeating?
Think about how many values a 5-bit binary number can represent.
A 5-bit binary number can represent 2^5 = 32 distinct values, from 0 to 31 inclusive.
