Consider the following VHDL testbench code that instantiates a component. What will be the output on the signal out_signal after 10 ns?
library ieee; use ieee.std_logic_1164.all; entity tb is end tb; architecture behavior of tb is signal in_signal : std_logic := '0'; signal out_signal : std_logic; component inverter is port( a : in std_logic; y : out std_logic ); end component; begin uut: inverter port map(a => in_signal, y => out_signal); process begin in_signal <= '0'; wait for 5 ns; in_signal <= '1'; wait for 5 ns; wait; end process; end behavior;
Think about what an inverter does to the input signal.
The component inverter outputs the logical NOT of the input a. At 10 ns, in_signal is '1', so out_signal will be NOT '1', which is '0'.
Given the following testbench snippet, what is the value of out_signal at 15 ns?
library ieee; use ieee.std_logic_1164.all; entity tb is end tb; architecture behavior of tb is signal in_signal : std_logic := '0'; signal out_signal : std_logic; component buffer is port( a : in std_logic; y : out std_logic ); end component; begin uut: buffer port map(a => in_signal, y => out_signal); process begin in_signal <= '0'; wait for 10 ns; in_signal <= '1'; wait for 10 ns; wait; end process; end behavior;
Remember that signal assignments take effect after the delta cycle or delay.
At 10 ns, in_signal is assigned '1'. The buffer outputs the input value directly (after delta cycle), so by 15 ns, out_signal is '1'.
Examine the following testbench code snippet. What error will occur when compiling or simulating?
library ieee; use ieee.std_logic_1164.all; entity tb is end tb; architecture behavior of tb is signal in_signal : std_logic := '0'; signal out_signal : std_logic; component and_gate is port( a : in std_logic; b : in std_logic; y : out std_logic ); end component; begin uut: and_gate port map(a => in_signal, y => out_signal); process begin in_signal <= '1'; wait; end process; end behavior;
Check if all ports of the component are connected in the port map.
The component and_gate has three ports: a, b, and y. The port map only connects a and y. Missing b causes a compilation error.
Which option contains a syntax error in the component instantiation within a testbench?
library ieee; use ieee.std_logic_1164.all; entity tb is end tb; architecture behavior of tb is signal in_signal : std_logic := '0'; signal out_signal : std_logic; component not_gate is port( a : in std_logic; y : out std_logic ); end component; begin -- component instantiation here end behavior;
Look carefully at the punctuation between port mappings.
Option A is missing a comma between a => in_signal and y => out_signal, causing a syntax error.
In the following testbench code, how many instances of the component flip_flop are created?
library ieee; use ieee.std_logic_1164.all; entity tb is end tb; architecture behavior of tb is signal d, clk, q1, q2 : std_logic := '0'; component flip_flop is port( d : in std_logic; clk : in std_logic; q : out std_logic ); end component; begin ff1: flip_flop port map(d => d, clk => clk, q => q1); ff2: flip_flop port map(d => q1, clk => clk, q => q2); ff3: flip_flop port map(d => q2, clk => clk, q => open); end behavior;
Count each unique label that instantiates the component.
There are three component instances: ff1, ff2, and ff3. Each is a separate instantiation of flip_flop.