









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The vhdl code implementation of 2x1 and 4x1 multiplexers (mux) using std_logic. The code includes entity declaration, architecture, and process statements. The 2x1 mux takes two input vectors and a select signal to produce an output vector. The 4x1 mux takes four input vectors and a two-bit select signal to produce an output vector.
Typology: Slides
1 / 16
This page cannot be seen from the preview
Don't miss anything!










8-line 2 x 1 MUX
library IEEE; use IEEE.std_logic_1164. all ; entity mux2 is port ( a: in STD_LOGIC_VECTOR(7 downto 0); b: in STD_LOGIC_VECTOR(7 downto 0); sel: in STD_LOGIC; y: out STD_LOGIC_VECTOR(7 downto 0) ); end mux2;
library IEEE; use IEEE.std_logic_1164. all ; entity mux2 is port ( a: in STD_LOGIC_VECTOR(7 downto 0); b: in STD_LOGIC_VECTOR(7 downto 0); sel: in STD_LOGIC; y: out STD_LOGIC_VECTOR(7 downto 0) ); end mux2;
STD_LOGIC_VECTOR(7 downto 0);
architecture mux2_arch of mux2 is begin mux2_1: process (a, b, sel) begin if sel = '0' then y <= a; else y <= b; end if ; end process mux2_1; end mux2_arch;
a(7:0) b(7:0) y(7:0) sel 8-line 2 x 1 MUX Note: <= is signal assignment
library IEEE; use IEEE.std_logic_1164. all ; entity mux4 is port ( a: in STD_LOGIC_VECTOR (7 downto 0); b: in STD_LOGIC_VECTOR (7 downto 0); c: in STD_LOGIC_VECTOR (7 downto 0); d: in STD_LOGIC_VECTOR (7 downto 0); sel: in STD_LOGIC_VECTOR (1 downto 0); y: out STD_LOGIC_VECTOR (7 downto 0) ); end mux4;
architecture mux4_arch of mux4 is begin process (sel, a, b, c, d) begin case sel is when "00" => y <= a; when "01" => y <= b; when "10" => y <= c; when others => y <= d; end case ; end process ; end mux4_arch; (^) Must include ALL posibilities in case statement Note implies operator => Sel y โ00โ a โ01โ b โ10โ c โ11โ d
VHDL Process P1: process (<sensitivity list)