Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- design.vhd
- library IEEE;
- use IEEE.std_logic_1164.all;
- entity mux_4to1 is
- port(A : in bit_vector(3 downto 0);
- Sel : in bit_vector(1 downto 0);
- F : out bit);
- end entity mux_4to1;
- architecture mux_4to1_arch of mux_4to1 is
- begin
- process(A, Sel)
- begin
- if(Sel = "00") then
- F <= A(0);
- elsif(Sel = "01") then
- F <= A(1);
- elsif(Sel = "10") then
- F <= A(2);
- elsif(Sel = "11") then
- F <= A(3);
- else
- F <= '0';
- end if;
- end process;
- end architecture mux_4to1_arch;
- -- testbench.vhd
- library IEEE;
- use IEEE.std_logic_1164.all;
- entity mux_4to1_tb is
- end entity mux_4to1_tb;
- architecture mux_4to1_tb_arch of mux_4to1_tb is
- signal A : bit_vector(3 downto 0);
- signal Sel : bit_vector(1 downto 0);
- signal F : bit;
- begin
- DUT1 : entity work.mux_4to1(mux_4to1_arch)
- port map(A, Sel, F);
- STIMULUS : process
- begin
- A <= "0101"; wait for 10ns;
- Sel <= "00"; wait for 10ns;
- Sel <= "01"; wait for 10ns;
- Sel <= "10"; wait for 10ns;
- Sel <= "11"; wait for 10ns;
- Sel <= "XX"; wait for 10ns;
- end process STIMULUS;
- end architecture mux_4to1_tb_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement