Challenge - 5 Problems
ROM Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of ROM read with constant array
What is the output on the data bus when the address input is 3 in this ROM implementation using a constant array?
VHDL
library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity rom_const is port( addr : in std_logic_vector(2 downto 0); data : out std_logic_vector(7 downto 0) ); end rom_const; architecture rtl of rom_const is type rom_array is array (0 to 7) of std_logic_vector(7 downto 0); constant rom_content : rom_array := ( x"0A", x"1B", x"2C", x"3D", x"4E", x"5F", x"6A", x"7B" ); begin process(addr) begin data <= rom_content(to_integer(unsigned(addr))); end process; end rtl;
Attempts:
2 left
💡 Hint
Remember that the address is converted from std_logic_vector to integer to index the array.
✗ Incorrect
The address 3 corresponds to the fourth element in the constant array (indexing from 0). The value at index 3 is x"3D".
❓ Predict Output
intermediateValue of data after address change
Given the ROM constant array below, what will be the value of 'data' when 'addr' is "101"?
VHDL
architecture rtl of rom_const is use ieee.numeric_std.all; type rom_array is array (0 to 7) of std_logic_vector(7 downto 0); constant rom_content : rom_array := ( x"AA", x"BB", x"CC", x"DD", x"EE", x"FF", x"11", x"22" ); begin process(addr) begin data <= rom_content(to_integer(unsigned(addr))); end process; end rtl;
Attempts:
2 left
💡 Hint
Convert the binary address "101" to decimal to find the index.
✗ Incorrect
The binary "101" is decimal 5. The value at index 5 in rom_content is x"FF".
🔧 Debug
advancedIdentify the error in ROM constant array declaration
What error will this VHDL code produce when compiling?
VHDL
architecture rtl of rom_const is type rom_array is array (0 to 7) of std_logic_vector(7 downto 0); constant rom_content : rom_array := ( x"0A", x"1B", x"2C", x"3D", x"4E", x"5F", x"6A" ); begin process(addr) begin data <= rom_content(to_integer(unsigned(addr))); end process; end rtl;
Attempts:
2 left
💡 Hint
Check the number of elements in the constant array compared to its declared size.
✗ Incorrect
The constant array is declared with 8 elements (0 to 7) but only 7 values are provided, causing a size mismatch error.
📝 Syntax
advancedCorrect syntax for ROM constant array initialization
Which option correctly initializes a constant ROM array of 4 elements with 8-bit values in VHDL?
Attempts:
2 left
💡 Hint
VHDL uses parentheses with index associations for array initialization.
✗ Incorrect
Option B uses the correct VHDL syntax with index associations. Option B misses index associations, C and D use invalid brackets.
🚀 Application
expertNumber of elements in ROM constant array
How many elements are in this ROM constant array?
VHDL
type rom_array is array (0 to 15) of std_logic_vector(7 downto 0); constant rom_content : rom_array := ( 0 => x"00", 1 => x"11", 2 => x"22", 3 => x"33", 4 => x"44", 5 => x"55", 6 => x"66", 7 => x"77", 8 => x"88", 9 => x"99", 10 => x"AA", 11 => x"BB", 12 => x"CC", 13 => x"DD", 14 => x"EE", 15 => x"FF" );
Attempts:
2 left
💡 Hint
Count from 0 to 15 inclusive.
✗ Incorrect
The array is declared from 0 to 15, which means it contains 16 elements in total.
