Complete the code to declare a generic parameter named WIDTH with a default value of 8.
entity my_module is
generic (
WIDTH : integer := [1]
);
port (
input : in std_logic_vector(WIDTH-1 downto 0);
output : out std_logic_vector(WIDTH-1 downto 0)
);
end my_module;The generic WIDTH is set to 8 by default, which defines the bit width of the input and output ports.
Complete the code to use the generic WIDTH to define the size of the signal 'data'.
architecture Behavioral of my_module is signal data : std_logic_vector([1]-1 downto 0); begin -- logic here end Behavioral;
The signal 'data' uses the generic WIDTH to set its size dynamically.
Fix the error in the generic map to set WIDTH to 16 when instantiating the module.
U1: entity work.my_module
generic map (
WIDTH => [1]
)
port map (
input => input_signal,
output => output_signal
);When instantiating, assign the generic WIDTH to 16 to override the default.
Fill both blanks to declare two generic parameters WIDTH and DEPTH with default values 8 and 16.
entity memory is
generic (
WIDTH : integer := [1];
DEPTH : integer := [2]
);
port (
addr : in std_logic_vector(DEPTH-1 downto 0);
data_in : in std_logic_vector(WIDTH-1 downto 0);
data_out : out std_logic_vector(WIDTH-1 downto 0)
);
end memory;WIDTH is set to 8 and DEPTH to 16 as default generic values.
Fill all three blanks to create a generic map that sets WIDTH to 16, DEPTH to 32, and MODE to 'FAST'.
U_mem: entity work.memory
generic map (
WIDTH => [1],
DEPTH => [2],
MODE => [3]
)
port map (
addr => addr_signal,
data_in => data_in_signal,
data_out => data_out_signal
);The generic map assigns WIDTH=16, DEPTH=32, and MODE='FAST' to configure the module.
