More topics in VLSI and VHDL course

VHDL code for demultiplexer using behavioral method – full code & explanation

In this post, we will take a look at implementing the VHDL code for demultiplexer using behavioral architecture. First, we will take a look at the logic circuit of the 1:4 demultiplexer. Then we will understand its behavior using its truth table. And then we will understand the syntax. For the full code, scroll down.

Explanation of the VHDL code for demultiplexer using behavioral architecture method. How does the code work?

A demultiplexer is a data distributor. It takes in a single data line and connects it with one of the several output lines it has. It does this depending on the value of the select inputs.

1_4 demultiplexer _ 1_4 demux using gates
1:4 demux using gates

Truth table of 1:4 demux

I0S0S1Y0Y1Y2Y3
I00I000
I010I00
I1000I0
I11000I

The entity declaration will declare all the ports of the demultiplexer. The architecture declaration will be followed by a begin statement, then a process statement and then finally one more begin statement. The first begin statement is for the architecture and the second one is for the process.

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity DEMUX_SOURCE is

Port ( I : in  STD_LOGIC;

S : in STD_LOGIC_VECTOR (1 downto 0);

Y : out STD_LOGIC_VECTOR (3 downto 0));

end DEMUX_SOURCE;

architecture Behavioral of DEMUX_SOURCE is

begin

The process statement is unique to the behavioral modeling style. This is because a process by its definition defines the functionality using sequential statements like if, elsif, case, and loops. If you not familiar with these sequential statements you should consider refreshing your knowledge with this C programming course. The signals mentioned in parenthesis next to the process statement are part of what’s known as the sensitivity list. The signals mentioned here are important to the process. Any time any event occurs concerning these signals, the process jumps into action and executes the sequential statements.

process (I, S)

begin

Here we will be using if-elsif command that is possible with VHDL. This is similar to the if-else commands we saw in C. These commands put forth a condition and then allow us to define the output for that particular condition. It’s a nifty programming tool that you should familiarize with. It finds uses in the behavioral modeling style extensively. Let’s see it in action. Peer carefully over the syntax. Students generally forget the then part of the if-elsif statements. Moreover, keep the truth table close. We are essentially coding in the functionality of each case in the truth table.

if (S <= "00") then

Y(0) <= I ;

elsif (S <= "01") then

Y(1) <= I ;

elsif (S <= "10") then

Y(2) <= I ;

else

Y(3) <= I ;

Remember that the if-elsif sequential commands need a closing statement. Additionally, so does the process statement and architecture as a whole. Mind you, however, that the process statement never really ends. It remains in a state of perpetual suspension until the sensitivity list is triggered again.

end if;

end process;

end Behavioral;

Full VHDL code for a demultiplexer using the behavioral modeling method


1:4 DEMUX BEHAVIORAL

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity DEMUX_SOURCE is

Port ( I : in  STD_LOGIC;

S : in STD_LOGIC_VECTOR (1 downto 0);

Y : out STD_LOGIC_VECTOR (3 downto 0));

end DEMUX_SOURCE;

architecture Behavioral of DEMUX_SOURCE is

begin

process (I, S)

begin

if (S <= "00") then

Y(0) <= I ;

elsif (S <= "01") then

Y(1) <= I ;

elsif (S <= "10") then

Y(2) <= I ;

else

Y(3) <= I ;

end if;

end process;

end Behavioral;

Testbench waveform for 1:4 Demultiplexer

1 4 demultiplexer vhdl testbench waveform
f is the input signal, s0 and s1 are the select lines and a, b, c, and d are the four outputs.



About The Writer

X More topics in VLSI and VHDL course
What is VLSI? And what are the job opportunities for a VLSI student?
VHDL code for full subtractor & half subtractor using dataflow method – full code & explanation
VHDL code for full adder using behavioral method – full code & explanation
VHDL code for all logic gates using dataflow method – full code and explanation
VHDL code for full subtractor using behavioral method – full code & explanation
VHDL code for half adder & full adder using dataflow method – full code & explanation
VHDL code for demultiplexer using dataflow method – full code & explanation
VHDL code for multiplexer using dataflow method – full code and explanation
VHDL code for an encoder using dataflow method – full code and explanation
VHDL code for half subtractor using behavioral method – full code & explanation
VHDL code for multiplexer using behavioral method – full code and explanation
VHDL code for comparator using behavioral method – full code and explanation
VHDL code for decoder using dataflow method – full code and explanation
VHDL code for full adder using structural method – full code and explanation
VHDL code for EXOR using NAND & structural method – full code & explanation
VHDL code for ALU (1-bit) using structural method – full code and explanation
VHDL code for demultiplexer using behavioral method – full code & explanation
VHDL code for decoder using behavioral method – full code and explanation
VHDL code for an encoder using behavioral method – full code and explanation
VHDL code for flip-flops using behavioral method – full code of all flip-flops
VHDL code for synchronous counters using behavioral method
CLOSE

Leave a Reply

Your email address will not be published. Required fields are marked *