VHDL Implementation of Multiplexers: 2x1 and 4x1 MUX, Slides of Computer Science

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

2012/2013

Uploaded on 03/23/2013

dhruv
dhruv ๐Ÿ‡ฎ๐Ÿ‡ณ

4.3

(12)

194 documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Multiplexers
Combinational logic circuit
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download VHDL Implementation of Multiplexers: 2x1 and 4x1 MUX and more Slides Computer Science in PDF only on Docsity!

Multiplexers

Combinational logic circuit

Combinational Circuit Example

8-line 2-to-1 Multiplexer

8-line 2 x 1 MUX

a(7:0)

b(7:0)

y(7:0)

sel

sel y

0 a

1 b

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;

Entity

Each entity must

begin with these

library and use

statements

port statement defines

inputs and outputs

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;

Entity

Mode: in or out

Data type: STD_LOGIC,

STD_LOGIC_VECTOR(7 downto 0);

Standard Logic

Type std_ulogic is unresolved.

Resolved signals provide a mechanism

for handling the problem of multiple

output signals connected to one signal.

subtype std_logic is resolved

std_ulogic;

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;

Architecture

a(7:0) b(7:0) y(7:0) sel 8-line 2 x 1 MUX Note: <= is signal assignment

An 8-line 4 x 1 multiplexer

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;

Example of case statement

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) begin < sequential statements > end process P1 ; Optional process label Within a process: Variables are assigned using := and are updated immediately. Signals are assigned using <= and are updated at the end of the process.