Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to implement 1 to 4 demultiplexer in VHDL

Status
Not open for further replies.

Rfboy

Member level 1
Joined
Apr 28, 2001
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
232
Hi guys,
I need to implement a simple 1 to 4 demultiplexer in vhdl...please help me ithis is the my first time in vhdl !!!!!
The input and output are a byte and the selector are a line with 2 bits...

Thak you
 

nand_gates

Advanced Member level 3
Joined
Jul 19, 2004
Messages
892
Helped
174
Reputation
348
Reaction score
51
Trophy points
1,308
Activity points
6,838
demultiplexer vhdl code

Its very simple...

Code:
library ieee;
use ieee.std_logic_1164.all;

entity demux is
  
  port (
    D0  : in  std_logic_vector(7 downto 0);
    D1  : in  std_logic_vector(7 downto 0);
    D2  : in  std_logic_vector(7 downto 0);
    D3  : in  std_logic_vector(7 downto 0);
    SEL : in  std_logic_vector(1 downto 0);
    Y   : out std_logic_vector(7 downto 0));

end demux;

architecture behave of demux is

begin  -- behave
with SEL select
  Y <= D0 when "00",
       D1 when "01",
       D2 when "10",
       D3 when "11",
       (others => 'X') when others;
end behave;
 

master.ro

Member level 1
Joined
Apr 18, 2006
Messages
38
Helped
4
Reputation
8
Reaction score
0
Trophy points
1,286
Location
Romania
Activity points
1,523
demux in vhdl

Hello !
I think that the code posted by nand_gates is a mux not a demux.
A demux has 1 input and 4 outputs and the input is connected to the output selected by selection.
 

    V

    Points: 2
    Helpful Answer Positive Rating

hamadeh

Member level 5
Joined
Dec 10, 2004
Messages
88
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,288
Location
Lebanon
Activity points
566
8 bit 1: 4 demultiplexer vhdl code

Hi guys, we are posting replys to this thread although it was created 3 years ago :D

any way I think one way of creating a 1 to 4 8bit demux is as follows :

Code:
entity demux is 
  
  port ( 
    D   : in  std_logic_vector(7 downto 0); 
    SEL : in  std_logic_vector(1 downto 0);
	 Y1  : out  std_logic_vector(7 downto 0); 
    Y2  : out  std_logic_vector(7 downto 0); 
    Y3  : out  std_logic_vector(7 downto 0); 
    Y4  : out std_logic_vector(7 downto 0)); 

end demux; 

architecture behave of demux is 

begin 
process(D,SEL)
begin
case SEL is				 
when "00" => 
	Y1 <= D;
	Y2 <=  (others => '0');
	Y3 <= (others => '0');
	Y4 <= (others => '0');

when "01" => 
	Y2 <= D;
	Y1 <= (others => '0');
	Y3 <= (others => '0');
	Y4 <= (others => '0');

when "10" => 
	Y3 <= D;
	Y2 <= (others => '0');
	Y1 <= (others => '0');
	Y4 <= (others => '0');

when "11" => 
	Y4 <= D;
	Y2 <= (others => '0');
	Y3 <= (others => '0');
	Y1 <= (others => '0');

when others => null;
end case;

end process;
end behave;

in this demux when an output is not selected it will provide a zero, if you need to preserve the last output just delete the Y# <= (others => '0'); , this of course will generate latches at the outputs.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top