Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a dual-port RAM signal.
VHDL
signal ram : array (0 to 15) of std_logic_vector([1] downto 0);
Attempts:
3 left
💡 Hint
Common Mistakes
Using 15 instead of 7 for the vector width.
✗ Incorrect
The RAM has 8-bit wide data, so the vector goes from 7 downto 0.
2fill in blank
mediumComplete the code to read data from port B of the RAM.
VHDL
process(clk) begin if rising_edge(clk) then data_b <= ram([1]); end if; end process;
Attempts:
3 left
💡 Hint
Common Mistakes
Using addr_a instead of addr_b for port B read.
✗ Incorrect
Port B reads data from the RAM at address addr_b.
3fill in blank
hardFix the error in the write process for port A.
VHDL
process(clk) begin if rising_edge(clk) then if we_a = '1' then ram([1]) <= data_a; end if; end if; end process;
Attempts:
3 left
💡 Hint
Common Mistakes
Using addr_b instead of addr_a in port A write.
✗ Incorrect
Writing to RAM at port A uses the address addr_a.
4fill in blank
hardFill both blanks to complete the dual-port RAM read and write logic.
VHDL
process(clk) begin if rising_edge(clk) then if we_a = '1' then ram([1]) <= data_a; end if; data_b <= ram([2]); end if; end process;
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping addr_a and addr_b in write/read.
✗ Incorrect
Port A writes to ram at addr_a, port B reads from ram at addr_b.
5fill in blank
hardFill all three blanks to complete the dual-port RAM entity port declaration.
VHDL
entity dual_port_ram is
port (
clk : in std_logic;
addr_a : in std_logic_vector([1] downto 0);
data_a : in std_logic_vector([2] downto 0);
we_a : in std_logic;
addr_b : in std_logic_vector([3] downto 0);
data_b : out std_logic_vector(7 downto 0)
);
end dual_port_ram;Attempts:
3 left
💡 Hint
Common Mistakes
Using 15 for address width instead of 3.
✗ Incorrect
Address width is 4 bits (3 downto 0), data width is 8 bits (7 downto 0).
