Showing posts with label encoder. Show all posts
Showing posts with label encoder. Show all posts

Thursday, 31 May 2018

Half Subtractor design using VHDL



PROGRAM:

library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity half_subtractor is
     port(
         a : in STD_LOGIC;
         b : in STD_LOGIC;
         diff : out STD_LOGIC;
         borrow : out STD_LOGIC
         );
end half_subtractor;

architecture half_subtractor_arc of half_subtractor is
begin

    diff <= a xor b;
    borrow <= (not a) and b;

end half_subtractor_arc;

4 to 2 encoder using VHDL programming language |



PROGRAM:

library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity encoder4_2 is
     port(
         a : in STD_LOGIC;
         b : in STD_LOGIC;
         c : in STD_LOGIC;
         d : in STD_LOGIC;
         x : out STD_LOGIC;
         y : out STD_LOGIC
         );
end encoder4_2;
                                            
architecture encoder4_2_arc of encoder4_2 is
begin

    x <= b or d;
    y <= c or d;

end encoder4_2_arc;