Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare the clock divider process sensitivity list.
VHDL
process([1]) begin if rising_edge(clk) then -- clock divider logic end if; end process;
Attempts:
3 left
💡 Hint
Common Mistakes
Including 'enable' in the sensitivity list causes incorrect behavior.
Forgetting to include 'clk' in the sensitivity list.
✗ Incorrect
The process must be sensitive to the clock signal 'clk' to detect rising edges.
2fill in blank
mediumComplete the if statement to check if the enable signal is active.
VHDL
if rising_edge(clk) then if [1] = '1' then -- divide clock end if; end if;
Attempts:
3 left
💡 Hint
Common Mistakes
Checking 'reset' instead of 'enable'.
Using 'clk' inside the if condition incorrectly.
✗ Incorrect
The enable signal controls whether the clock divider logic runs.
3fill in blank
hardFix the error in the clock divider counter increment line.
VHDL
if rising_edge(clk) then if enable = '1' then counter <= counter [1] 1; end if; end if;
Attempts:
3 left
💡 Hint
Common Mistakes
Using C-style operators like '+=' or '++' which are invalid in VHDL.
Using '-' instead of '+' causing decrement.
✗ Incorrect
In VHDL, use '+' to add values; '+=' and '++' are not valid operators.
4fill in blank
hardFill both blanks to complete the clock divider output assignment and reset condition.
VHDL
process(clk) begin if rising_edge(clk) then if [1] = '1' then counter <= 0; else counter <= counter + 1; end if; if counter = [2] then div_clk <= not div_clk; counter <= 0; end if; end if; end process;
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'enable' instead of 'reset' for clearing the counter.
Using wrong counter comparison value.
✗ Incorrect
Reset clears the counter; the counter compares to 10 to toggle div_clk.
5fill in blank
hardFill all three blanks to complete the clock divider with enable and reset signals.
VHDL
entity clk_divider is
port(
clk : in std_logic;
reset : in std_logic;
[1] : in std_logic;
div_clk : out std_logic
);
end entity;
architecture Behavioral of clk_divider is
signal counter : integer := 0;
begin
process(clk)
begin
if rising_edge(clk) then
if [2] = '1' then
counter <= 0;
elsif [3] = '1' then
if counter = 4 then
div_clk <= not div_clk;
counter <= 0;
else
counter <= counter + 1;
end if;
end if;
end if;
end process;
end Behavioral;Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'reset' and 'enable' signals.
Missing 'enable' port in entity.
✗ Incorrect
The entity has 'enable' input; inside process reset clears counter; enable controls counting.
