Skip to main content

VHDL Behavioral Description of all Logic Gates

AND Gate



library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity and_gate is
port(
   a,b : in std_logic;
   s : out std_logic
);
end and_gate;
architecture Behavioral of and_gate is
begin
s<=a and b;
end Behavioral;

OR Gate


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity or_gate is
port(
   a,b : in std_logic;
   s : out std_logic
);
end or_gate;
architecture Behavioral of or_gate is
begin
s<=a or b;
end Behavioral;

NOT Gate


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity not_gate is
port(
   a : in std_logic;
   s : out std_logic
);
end not_gate;
architecture Behavioral of not_gate is
begin
s<=not(a);
end Behavioral;

NAND Gate


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity nand_gate is
port(
   a,b : in std_logic;
   s : out std_logic
);
end nand_gate;
architecture Behavioral of nand_gate is
begin
s<=a nand b;
end Behavioral;

NOR Gate


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity nor_gate is
port(
   a,b : in std_logic;
   s : out std_logic
);
end nor_gate;
architecture Behavioral of nor_gate is
begin
s<=a nor b;
end Behavioral;

XOR Gate


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity xor_gate is
port(
   a,b : in std_logic;
   s : out std_logic
);
end xor_gate;
architecture Behavioral of xor_gate is
begin
s<=a xor b;
end Behavioral;

XNOR Gate


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity xnor_gate is
port(
   a,b : in std_logic;
   s : out std_logic
);
end xnor_gate;
architecture Behavioral of xnor_gate is
begin
s<=a xnor b;
end Behavioral;


Comments

Popular posts from this blog

8051 Simple Programs

Sum of 8-bit Numbers Stored in Memory Here  we will discuss about 8051 programs but we can't discuss about all of the 8051 instructions. For programming 8051 we should know about assembler directives as well as instruction set. Click  here to download Atmel c51 user guide that will discuss about 8051(c51 family microcontroller) instruction set, assembler directives, c51 cross assembler from Atmel.  Program ORG 00H MOV R0,#50H   ; get memory location in memory pointer R0 MOV R1,#51H   ; get memory location on memory pointer register R1 MOV A,@R0       ; get content of memory location 50H to accumulator ADD A,@R1        ; add content of A with content of memory location 51H and store result in A MOV R0,#52H    ; get 52H to memory pointer R0 MOV@R0,A         ; copy content of A to memory location 52H END Add 16-bit Numbers ...

Even and Odd Memory Banks

The 8086 microprocessor uses a 20-bit address to access memory. With 20-bit address the processor can generate 2 20 = 1 Mega address. The basic memory word size of the memories used in the 8086 system is 8-bit or 1-byte (i.e., in one memory location an 8-bit binary information can be stored). Hence, the physical memory space of the 8086 is 1Mb (1 Mega-byte). For the programmer, the 8086 memory address space is a sequence of one mega-byte in which one location stores an 8-bit binary code/data and two consecutive locations store 16-bit binary code/data. But physically (i.e., in the hardware), the 1Mb memory space is divided into two banks of 512kb (512kb + 512kb = 1Mb). The two memory banks are called Even (or Lower) bank and Odd (or Upper) bank. The organization of even and odd memory banks in the 8086-based system is shown in Figure. The 8086-based system will have two sets of memory IC's. One set for even bank and another set for odd bank. The data lines D 0 -D 7 are conne...

8051 Keyboard Interfacing

Keyboards are organized in a matrix of rows and columns. The CPU accesses both rows and columns through ports. Therefore, with two 8-bit ports, an 8 x 8 matrix of keys can be connected to a microprocessor. When a key is pressed, a row and a column make a contact. Otherwise, there is no connection between rows and columns. In IBM PC keyboards, a single microcontroller takes care of hardware and software interfacing. A 4x4 matrix connected to two ports. The rows are connected to an output port and the columns are connected to an input port. Grounding Rows and reading Columns:- 8051 keyboard interfacing It is the function of the microcontroller to scan the keyboard continuously to detect and identify the key pressed. To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, then it reads the columns. If the data read from columns is D3 – D0 =1111, no key has been pressed and the process continues till key press is detected. If one of t...