DECODER's
![]() |
Coding the decoder blocks |
I enlight these:
What are decoder's?
2to4 decoder
3to8 decoder
4to16 decoder
Applications of decoder unit
- What are decoder's?
A decoder is a circuit that changes a code into a set of signals. In general a decoder has N-inputs and 2^N (power(2,N))outputs. Decoders are simply a collection of logic gates which are arranged in a specific way so as to breakdown any combination of inputs to a set of terms that are all set to '0' apart from one term.
Internal Circuit of 2 to 4 decoder
![]() |
logic's for 2 to 4 decoder |
Truth table of 2 to 4 decoder
![]() |
functionality |
VHDL Coding
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity decoding is
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity decoding is
Port ( a : in STD_LOGIC_VECTOR (1 downto 0);
en : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (3 downto 0));
end decoding;
architecture Behavioral of decoding is
begin
process (a,en)
begin
if(en ='1') then
case a is
when "00" => y <= "0001";
when "01" => y <= "0010";
when "10" => y <= "0100";
when "11" => y <= "1000";
when others => y <= "0000";
end case;
else
y<= "0000";
end if;
end process;
end Behavioral;
Simulation Results
![]() |
verification |
Verilog Coding
module decoding_2_4(
output reg [3:0] y,
input en,
input [1:0] a
);
always @(en or a)
begin
if(en==1'b1)
begin
case(a)
2'b00: y <= 4'b0001;
2'b01: y <= 4'b0010;
2'b10: y <= 4'b0100;
2'b11: y <= 4'b1000;
default: y <= 4'b0000;
endcase
end
else
y <= 4'b0000;
end
endmodule
Simulation Results
![]() |
verification |
Truth table of 3 to 8 decoder
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb2rsfPD5F3Wwmjx-ipIwpu4Hu6VkwcV4_kt8H-E0mCZwWhw1KUXLY2tUXtOHyfFjTsGbE16NcTDO6DDYbyDFVQtEJeFN84sPwxE4t7HbAaUy6lUUjOJOl25edP1PpTYjn_1NxlCI80N8/s640/02__3-to-8_Decoder_TruthTable.jpg)
functionality
Verilog Coding
module decode_3to8(
output reg [7:0]y,
input [2:0]x,
input en
);
always @(x or en)
begin
if(en==1'b1)
begin
case(x)
3'b000: y <= 8'b00000001;
3'b001: y <= 8'b00000010;
3'b010: y <= 8'b00000100;
3'b011: y <= 8'b00001000;
3'b100: y <= 8'b00010000;
3'b101: y <= 8'b00100000;
3'b110: y <= 8'b01000000;
3'b111: y <= 8'b10000000;
default: y <= 8'b00000000;
endcase
end
else
begin
y <= 8'bz;
end
end
endmodule
Simulation Results
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVKq5vWm42_gXwW7UiopUJhUwhMFCjRp6Gt7gCOW-6uxZ9qV5Xb19z3jNvTOnyVT8aUnPKScej0GLtEMNTM9quC1LB4M7GK9BMXJvZMjAKDf2IrMmGv09g0tGF_4UAAvTlMK8P6TZh6mA/s640/03.png)
verification phase
VHDL Coding
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dec_3_8 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
en : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (7 downto 0));
end dec_3_8;
architecture Behavioral of dec_3_8 is
begin
process (a,en)
begin
if(en ='1') then
case a is
when "000" => y <= "00000001";
when "001" => y <= "00000010";
when "010" => y <= "00000100";
when "011" => y <= "00001000";
when "100" => y <= "00010000";
when "101" => y <= "00100000";
when "110" => y <= "01000000";
when "111" => y <= "10000000";
when others => y <= "00000000";
end case;
else
y<= "00000000";
end if;
end process;
end Behavioral;
Simulation Results
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgClw0u4VqTDonraOp7reFfwEKu5VeW-SnrD3UlSuo5FdIE6kKI_JPCmxOTO1xFcAv5P8vcd9Ia7h4Cu-7iYsOTjXLy8FSjgsGiwFY1I9Kya7GG8IaXG8g0YSp7gTPJ7Yu72vEekSmv7Bg/s640/05.png)
verification phase
- 4 to 16 decoder
IC block for 4 to 16 decoder from two 3 to 8 decoder's
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDitxELAIMEC0fLw3MzrDyMXHouNdEY3WcZ1sane-ikSrsQbTKGrKGex-az4h2UrSv_V5-0AAZD5H52Rko-2iE-xN9-4xt-IBbw6FN_YMt6pAEse4zONSYVwrCcEn3NFEzRar2Xmq9Vro/s640/dc23_clip_image004.gif)
using two 3 to 8 decoder blocks
Truth table of 4 to 16 decoder
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijGgE-iunq2bTj-oOERjL9i2ygd72FvXhvzjU9qNCQbm-wc0JC2W9J2nhmDcRMNPdLv5XdEY8rl6k-sguLpan2vvSM2dZaBEiF0VM_ij2fTHHLjqHQ1HMs2_4mLgrqDQLQgkO2vwuCs-4/s640/TRUTH+TABLE+OF+4-TO-16+LINE+DECODER+BY+USING+FOUR+2-TO-4+LINE+DECODER.PNG)
functionality
VERILOG coding
module decode_4to16(
output [15:0] y,
input [3:0] x
);
decode_3to8 d1(.x(x[2:0]),.en(~x[3]),.y(y[7:0]));
decode_3to8 d2(.x(x[2:0]),.en(x[3]),.y(y[15:8]));
endmodule
/*
module decode_3to8(
output reg [7:0]y,
input [2:0]x,
input en
);
always @(x or en)
begin
if(en==1'b1)
begin
case(x)
3'b000: y <= 8'b00000001;
3'b001: y <= 8'b00000010;
3'b010: y <= 8'b00000100;
3'b011: y <= 8'b00001000;
3'b100: y <= 8'b00010000;
3'b101: y <= 8'b00100000;
3'b110: y <= 8'b01000000;
3'b111: y <= 8'b10000000;
default: y <= 8'b00000000;
endcase
end
else
begin
y <= 8'b00000000;
end
end
endmodule */
Simulation Results
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVTtTNoXC1bwZD_bmlX_69OL24RQMMVOKRuPtOFh6iOw9Lt1XWoebLSYyIUt9GlQPawtQmHq-2K_Kkj2oH9CfTbEVmA1SrfX_ihRCtNumUJs7bCLCAMV3wkVYOYGes2OGicxGO03cOlf8/s640/Screenshot+%252842%2529.png)
verification
VHDL coding
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity for_4_16 is
Port ( y : out STD_LOGIC_VECTOR (15 downto 0);
x : in STD_LOGIC_VECTOR (3 downto 0));
end for_4_16;
--component is same as in the above 3 to 8 decoder program vhdl
architecture Behavioral of for_4_16 is
component dec_3_8
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
en : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (7 downto 0));
end component;
begin
l1: dec_3_8 PORT MAP(x(2 downto 0),not x(3),y(7 downto 0));
l2: dec_3_8 PORT MAP(x(2 downto 0),x(3),y(15 downto 8));
end Behavioral;
Simulation Results
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRbBnw3nP2KomTwlenlWIuc5zZLD4pl_fP9VYRMjw2yRZ2awxk4Dg1U8CsGIQ7QpkZBDNOx9nW1nK26M5mMQpSrn2aEWp1tmbpk3BQbt1ft1itKxEAWftrPvrFBAnse_pifs5KjUbQn5o/s640/06.png)
verification
- Applications of decoder unit
Used in ROM's(memory)Used in digital communications(demodulation)
Used in TV remotes
Used in computer keyboard
Used in Traffic lights control systems.
Used in LED array(display units). etc.,
![]() |
functionality |
Verilog Coding
module decode_3to8(
output reg [7:0]y,
input [2:0]x,
input en
);
always @(x or en)
begin
if(en==1'b1)
begin
case(x)
3'b000: y <= 8'b00000001;
3'b001: y <= 8'b00000010;
3'b010: y <= 8'b00000100;
3'b011: y <= 8'b00001000;
3'b100: y <= 8'b00010000;
3'b101: y <= 8'b00100000;
3'b110: y <= 8'b01000000;
3'b111: y <= 8'b10000000;
default: y <= 8'b00000000;
endcase
end
else
begin
y <= 8'bz;
end
end
endmodule
Simulation Results
![]() |
verification phase |
VHDL Coding
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dec_3_8 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
en : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (7 downto 0));
end dec_3_8;
architecture Behavioral of dec_3_8 is
begin
process (a,en)
begin
if(en ='1') then
case a is
when "000" => y <= "00000001";
when "001" => y <= "00000010";
when "010" => y <= "00000100";
when "011" => y <= "00001000";
when "100" => y <= "00010000";
when "101" => y <= "00100000";
when "110" => y <= "01000000";
when "111" => y <= "10000000";
when others => y <= "00000000";
end case;
else
y<= "00000000";
end if;
end process;
end Behavioral;
Simulation Results
![]() |
verification phase |
- 4 to 16 decoder
IC block for 4 to 16 decoder from two 3 to 8 decoder's
Truth table of 4 to 16 decoder
![]() |
using two 3 to 8 decoder blocks |
Truth table of 4 to 16 decoder
functionality |
VERILOG coding
module decode_4to16(
output [15:0] y,
input [3:0] x
);
decode_3to8 d1(.x(x[2:0]),.en(~x[3]),.y(y[7:0]));
decode_3to8 d2(.x(x[2:0]),.en(x[3]),.y(y[15:8]));
endmodule
/*
module decode_3to8(
output reg [7:0]y,
input [2:0]x,
input en
);
always @(x or en)
begin
if(en==1'b1)
begin
case(x)
3'b000: y <= 8'b00000001;
3'b001: y <= 8'b00000010;
3'b010: y <= 8'b00000100;
3'b011: y <= 8'b00001000;
3'b100: y <= 8'b00010000;
3'b101: y <= 8'b00100000;
3'b110: y <= 8'b01000000;
3'b111: y <= 8'b10000000;
default: y <= 8'b00000000;
endcase
end
else
begin
y <= 8'b00000000;
end
end
endmodule */
Simulation Results![]() |
verification |
VHDL coding
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity for_4_16 is
Port ( y : out STD_LOGIC_VECTOR (15 downto 0);
x : in STD_LOGIC_VECTOR (3 downto 0));
end for_4_16;
--component is same as in the above 3 to 8 decoder program vhdl
architecture Behavioral of for_4_16 is
component dec_3_8
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
en : in STD_LOGIC;
y : out STD_LOGIC_VECTOR (7 downto 0));
end component;
begin
l1: dec_3_8 PORT MAP(x(2 downto 0),not x(3),y(7 downto 0));
l2: dec_3_8 PORT MAP(x(2 downto 0),x(3),y(15 downto 8));
end Behavioral;
Simulation Results
![]() |
verification |
- Applications of decoder unit
Used in TV remotes
Used in computer keyboard
Used in Traffic lights control systems.
Used in LED array(display units). etc.,
0 comments:
Post a Comment