Friday, 28 February 2014

VHDL Code for All Logic Gates

VHDL Code for All Logic Gates

1. AND Gate:

TRUTH TABLE: 
 x     y     z 
 0     0     0 
 0     1     0 
 1     0     0 
 1     1     1 
  
VHDL CODE:


Library IEEE; 
use IEEE.std_logic_1164.all; 
entity AND2 is 
 port( x : in STD_LOGIC; 
         y : in STD_LOGIC; 
         z : out STD_LOGIC ); 
end AND2;

--Dataflow model 
architecture behav1 of AND2 is 
begin 
 Z<= x and y; --Signal Assignment Statement 
end behav1; 
-- Behavioral model 
architecture behav2 of AND2 is 
begin 
 process (x, y) 
 begin 
 if (x='1' and y='1') then -- Compare with truth table 
 Z <= '1'; 
 else 
 Z <= '0'; 
 end if; 
 end process; 
end behav2; 

2. OR Gate

TRUTH TABLE: 
 x     y     z 
 0     0     0 
 0     1     1 
 1     0     1 
 1     1     1 
VHDL CODE: 
Library IEEE; 
use IEEE.std_logic_1164.all; 
entity OR2 is 
 port(x : in STD_LOGIC; 
       y : in STD_LOGIC; 
       z : out STD_LOGIC); 
end OR2; 
--Dataflow model 

architecture behav1 of OR2 is 
 begin 
 Z <= x or y; --Signal Assignment Statement 
end behav1;


-- Behavioral model 
architecture behav2 of OR2 is 
 begin 
 process (x, y) 
 begin 
 if (x='0' and y='0') then -- Compare with truth table 
 Z <= '0'; 
 else 
 Z<= '1'; 
 end if; 
 end process; 
 end behav2;

3. NOT Gate:

TRUTH TABLE: 

 x   z 
 0   1 
 1   0 
VHDL CODE: 
Library IEEE; 
use IEEE.std_logic_1164.all; 
entity not1 is 
 port(X: in STD_LOGIC; 
       Z: out STD_LOGIC); 
 end not1; 
  
--Dataflow model 

 architecture behav1 of not1 is 
 begin 
 Z<= not X; --Signal Assignment Statement 
end behav1; 
-- Behavioral model 

architecture behav2 of not1 is 
 begin 
 process (X) 
 begin 
 if (x='0') then -- Compare with truth table 
 Z <= '1'; 
 else 
 Z<= '0';
 end if; 
 end process; 
 end behav2; 

4. NAND Gate

TRUTH TABLE: 

 x   y   z 
 0   0   1 
 0   1   1 
 1   0   1 
 1   1   0 

VHDL CODE: 
Library IEEE; 
use IEEE.std_logic_1164.all; 
entity nand2 is 
 port(x : in STD_LOGIC; 
        y : in STD_LOGIC; 
        z : out STD_LOGIC); 
end nand2; 
--Dataflow model 
architecture behav1 of nand2 is 
begin 
 z<= x nand y;       --Signal Assignment Statement 
end behav1; 
 -- Behavioral model 
architecture behav2 of nand2 is 
begin 
 Process (x, y) 
 Begin 
 If (x='1' and y='1') then     -- Compare with truth table 
 Z <= '0'; 
 else 
 Z <= '1'; 
 end if; 
 end process; 
 end behav2;

5. NOR Gate:

TRUTH TABLE: 
x   y   z 
0   0   1 
0   1   0 
1   0   0 
1   1   0 
VHDL CODE: 

Library IEEE; 
use IEEE.std_logic_1164.all; 
entity nor2 is 
 Port (X: in STD_LOGIC; 
        Y: in STD_LOGIC; 
        Z: out STD_LOGIC); 
end nor2; 

--Dataflow model 
architecture behav1 of nor2 is 
begin 
 Z<= x nor y;     --Signal Assignment Statement 
end behav1; 
-- Behavioral model 
architecture behav2 of nor2 is 
begin 
 process (x, y) 
 begin 
 If (x='0' and y='0') then -- Compare with truth table 
 Z <= '1'; 
 else 
 Z <= '0'; 
 end if; 
 end process; 
 end behav2; 

6. EX-OR Gate:

TRUTH TABLE: 
 x   y   z 
 0   0   0 
 0   1   1 
 1   0   1 
 1   1   0 
VHDL CODE: 
Library IEEE; 
use IEEE.std_logic_1164.all; 
entity xor2 is 
 Port (X: in STD_LOGIC; 
         Y: in STD_LOGIC; 
         Z: out STD_LOGIC); 
end xor2; 
--Dataflow model 
architecture behav1 of xor2 is 
begin 
 Z<= x xor y;    --Signal Assignment Statement 
end behav1; 

-- Behavioral model 
architecture behav2 of xor2 is 
begin 
 process (x, y) 
 begin 
 If (x/=y) then    -- Compare with truth table 
 Z <= '1'; 
 else 
 Z<= '0'; 
 end if; 
 end process; 
 end behav2; 

7. EX-NOR Gate:

TRUTH TABLE: 

 x   y   z 
 0   0   1 
 0   1   0 
 1   0   0 
 1   1   1 
VHDL CODE: 
Library IEEE; 
use IEEE.std_logic_1164.all; 
entity xnor2 is 
 Port (X: in STD_LOGIC; 
         Y: in STD_LOGIC; 
         Z: out STD_LOGIC); 
end xnor2; 
--Dataflow model 
architecture behav1 of xnor2 is 
begin 
 Z<= x xnor y; --Signal Assignment Statement 
end behav1; 
-- Behavioral model 
architecture behav2 of xnor2 is 
begin 
 process (x, y) 
 begin 
If (x=y) then -- Compare with truth table 
 Z <= '1'; 
 else 
 Z<= '0'; 
 end if; 
 end process; 
 end behav2;

Sunday, 23 February 2014

Microprocessor 8085 Question Bank - 02



Architecture and operation:


1.  Give a general block diagram of a microprocessor based system. Explain     
     briefly the various blocks of the system. Give some examples of the types of 
     devices used for each block.
2.  What is a microprocessor? Sketch and explain the various pins of 8085.
3.  Sketch and explain the signal diagram of 8085.
4.  Explain the operation of 8085 signals: READY, S1 & S0, HOLD & HLDA and  
     ALE.
5.  Explain the architecture of 8085 with the help of its internal block schematic.
6.  Write the flag register and explain each of the flags with an example.
7.  Mention the list of registers of 8085 that are accessible to the programmer. 
8.  Explain what each of these registers is generally used for.
9.  What should be the starting address of ROM for an 8085 microcomputer? 
     Substantiate your answer.
10. Explain the purpose of the following signals of 8085: AD0-AD7, /RESET IN, 
      RESET OUT, and RST 7.5.
11. Explain with schematic diagram how separate address, data signals can be 
      generated from 8085 common address-data lines.
12. List the control and status signals in 8085. Explain their functions.
13. What are RAM’s and ROM’s? Why should both of these be used in an 8085 
      system? 
14. Explain the functions of following 8085 registers in Intel 8085: HL, STACK 
      POINTER, and FLAG REGISTER.  
15. Specify the contents of the registers and the flag status as the following   
      instructions are executed.
            MVI A, 00H
            MVI B, F8H
            MOV C, A
            MOV D, B
            HLT
16. Write instructions to load the hexadecimal number 65H in register C and    
     92H in accumulator A, Display the number 65H at PORT0 and 92H at PORT1.
17. Draw and explain the block diagram of a microprocessor 8085.  
18. Why the lower order address bus is multiplexed with data bus? How they 
      will be de-multiplexed?
19. Differentiate between maskable and non-maskable interrupts. 
20. Mention the functions of the following pins of 8085: ALE, CLK OUT, RESET 
     OUT, RESET IN
21. Explain in detail the following instructions:-  
       (i) ADC    (ii) LHLD     (iii) RLC    (iv) DI
22. What are the various addressing modes available in 8085? Explain with   
      examples.
23. Compare the memory mapped I/O with peripheral mapped I/O.
24. Explain data transfer techniques.
25. Mention the functions of RIM and SIM.
 

 

Thursday, 20 February 2014

Microprocessor - 01


Introduction of Microprocessor:  


The first question comes in a mind "What is a microprocessor?”.

Let us start with a more familiar term computer. A digital computer is an electronic machine capable of quickly performing a wide variety of tasks. They can be used to compile, correlate, sort, merge and store data as well as perform calculations.

A digital computer is different from a general purpose calculator in that it is capable of operating according to the instructions that are stored within the computer whereas a calculator must be given instructions on a step by step basis. By the definition a programmable calculator is a computer.

Historically, digital computers have been categorized according to the size using the words large, medium, minicomputer and microcomputer. In the early years of development, the emphasis was on large and more powerful computers. Large and medium sized computers were designed to store complex scientific and engineering problems. These computers were accessible and affordable only to large corporations, big universities and government agencies. In late 1960s, minicomputers were available for use in a office, small collage, medium size business organization, small factory etc. As the technology has advanced from SSI to VLSI & SLSI (Very Large Scale Integration & Super Large Scale Integration) the face of the computer has changed. It has now become possible to build the control processing unit (CPU) with its related timing functions on a single chip known as microprocessor. A microprocessor combined with memory and input/output devices forms a microcomputer. As for as the computing power is concerned the 32- bit microcomputers are as powerful as traditional mainframe computers. The microcomputer is making an impact on every activity of mankind. It is being used in almost all control applications. For example analytical and scientific instruments, data communication, character recognition, musical instruments, household items, defense equipments, medical equipments etc.

Computers communicate and operate in binary numbers 0 and 1 also known as bits. It is the abbreviation for the term binary digit. The bit size of a microprocessor refers to the number of bit which can be processed simultaneously by the arithmetic circuit of the microprocessor. A number of bits taken as a group are this manner is called word. For example, the first commercial microprocessor the Intel 4004 which was introduced in 1971 is a 4-bit machine and is said to process a 4-bit word. A 4-bit word is commonly known as nibble and an 8-bit word is commonly known as byte. Intel 8085 is an 8-bit microprocessor. It should be noted that a processor can perform calculations involving more than its bit size but takes more time to complete the operation. The short word length requires few circuitry and interconnection in the CPU.

Microcomputers:

In a very general a microcomputer is best regard as a system incorporating a CPU and assisted hardware whose purpose is to manipulate data in same fashion. This is exactly what any digital circuit designed using SSI’s and MSI’s will also do therefore, microcomputer should be regard as a general purpose logic device. In contrast to standard SSI’s and MSI’s where the manufacturer decides what the device will do, with microcomputer it is the user who decides what the device should do by asking it to execute a proper set of instructions. A microcomputer, from this point of view is merely an assembly of devices whose sole task is to ensure that the instruction desire are indeed carried out properly and to allow the microprocessor to communicate with the real world, i.e. the user environment. The power of the microcomputer lies in the fact that if the application change, the same system can still used by appropriately modifying the instruction to be executed and if necessary some changes in the hardware. In contrast, a digit circuit designed using SSI’s and MSI’s for same application will need to be completely redesigned if the application changes significantly. The objective of a microcomputer is to manipulate data in a certain fashion specified by the system designer. A typical microcomputer achieves their objective by getting its CPU (microprocessor) to execute a number of instructions in the proper sequence. This sequence of instruction comprises the program that is executed by the micro computer.

Microcontrollers:

A microprocessor does not have enough memory for program and data storage, neither does it has any input and output devices. Thus when a microprocessor is used to design a system, several other chips are also used to make up a complete system. For many applications, these extra chips imply additional cost and increased size of the product. For example, when used inside a toy, a designer would like to minimize the size and cost of the electronic equipment inside the toy. Therefore, in such applications a microcontroller is used more often than a microprocessor. A microcontroller is a chip consisting of a microprocessor, memory and an input/output device. There are 4 bit as well as 32 bit microcontrollers.

Evolution of the Microprocessors:

4-bit Microprocessors:
The first microprocessor was introduced in 1971 by Intel Corp. It was named Intel 4004 as it was a 4 bit processor. It was a processor on a single chip. It could perform simple arithmetic and logic operations such as addition, subtraction, Boolean AND and Boolean OR. It had a control unit capable of performing control functions like fetching an instruction from memory, decoding it, and generating control pulses to execute it. It was able to operate on 4 bits of data at a time.This first microprocessor was quite a success in industry. Soon other microprocessors were also introduced. Intel introduced the enhanced version of 4004, the 4040. Some other 4 bit processors are International’s PPS4 and Thoshiba’s T3472.
8-bit Microprocessors:
The first 8 bit microprocessor which could perform arithmetic and logic operations on 8 bit words was introduced in 1973 again by Intel. This was Intel 8008 and was later followed by an improved version, Intel 8088. Some other 8 bit processors are Zilog-80 and Motorola M6800.
16-bit Microprocessors:
The 8-bit processors were followed by 16 bit processors. They are Intel 8086 and 80286.
32-bit Microprocessors:
The 32 bit microprocessors were introduced by several companies but the most popular one is Intel 80386.
Pentium Series:
Instead of 80586, Intel came out with a new processor namely Pentium processor. Its performance is closer to RISC performance. Pentium was followed by Pentium Pro CPU. Pentium Pro allows allow multiple CPUs in a single system in order to achieve multiprocessing. The MMX extension was added to Pentium Pro and the result was Pentium II. The low cost version of Pentium II is celeron.

The Pentium III provided high performance floating point operations for certain types of computations by using the SIMD extensions to the instruction set. These new instructions makes the Pentium III faster than high-end RISC CPUs.

Interestingly Pentium IV could not execute code faster than the Pentium III when running at the same clock frequency. So Pentium IV had to speed up by executing at a much higher clock frequency.

Microcomputer Organization:

 The basic components of a microcomputer are:

  • CPU
  • Program memory
  • Data memory
  • Output ports
  • Input ports
  • Clock generator

CPU(Central Processing Unit):

The CPU consists of ALU (Arithmetic and Logic Unit), Register unit and Control unit. The CPU retrieves stored instructions and data word from memory; it also deposits processed data in memory.

ALU(Arithmetic and Logic Unit):


Arithmetic and Logic Unit performs computing functions on data. These functions are arithmetic operations such as additions, subtraction and logical operation such as AND, OR, Rotate etc. Result are stored either in registers or in memory or sent to output devices.


Register Unit:


Register Unit contains various register. The registers are used primarily to store data temporarily during the execution of a program. Some of the registers are accessible to the uses through instructions. 


Control Unit:


Control Unit provides necessary timing & control signals necessary to all the operations in the microcomputer. It controls the flow of data between the microprocessor and peripherals (input, output & memory). The control unit gets a clock which determines the speed of the microprocessor. 

The CPU has three basic functions:

  1. It fetches an instructions word stored in memory.
  2. It determines what the instruction is telling it to do.(decodes the instruction)
  3. It executes the instruction. Executing the instruction may include same of the following major tasks.
  1. Transfer of data from reg. to reg. in the CPU itself.
  2. Transfer of data between a CPU reg. & specified memory location.
  3.  Performing arithmetic and logical operations on data from a specific memory       location or a designated CPU register.
  4.   Directing the CPU to change a sequence of fetching instruction, if processing       the data created a specific condition.
  5.  Performing housekeeping function within the CPU itself in order to establish     desired condition at certain registers.
It looks for control signal such as interrupts and provides appropriate responses.
It provides states, control, and timing signals that the memory and input/output section can use.

Program Memory:


The basic task of a microcomputer system is to ensure that its CPU executes the desired instruction sequence in the program properly. The instruction sequence is stared in the program memory on initialization- usually a power up and manual reset the processor starts by executing the instruction in a predetermined location in program memory. The first instruction of the program should therefore be in this location in typical microprocessor basic system, the program to be executed is fixed one which does not change. Therefore microprocessor program are store on ROM, or PROM, EPROM, EEPROM. 


Data Memory:

A microcomputer manipulates data according to the algorithm given by the instruction in the program in the program memory. These instruction may require intermediate results to be stored, the functional block in microcontroller have same internal register which can also be used if available for such storage external data memory is needed if the storage requirements is more. Apart from intermediate storage, the data memory may also be used to provide data needed by the program, to store some of the results of the program. Data memory is used for all storage purposes other than storage of program. Therefore, they must have head write capability RWM or RAM. It stores both the instructions to be executed (i.e. program) and the data involved. It usually contains ROM (Read memory). The ROM can only read and cannot be written into and is non volatile that is, it retains its contents when the power is turned off. A ROM is typically used to store instructions and data that do not change. For example, it stores the monitor program if a microcomputer. One can either read from or write into a RWM. The RWM is volatile, that is it does not retain its contents when the power is turned off. It is used to store user programmes & data which are temporary might change during the course of executing a program. Both ROM & RWM are RAM (Random access memory). RWM is respectively. During a memory read operation, the content of the addressed location is not destroyed. During a unit operation, the original content of the addressed location is destroyed.

Input/Output Ports:

The input & output ports provide the microcomputer the capability to communicate with the outside world. The input ports allow data to pass from the outside world to the microcomputer, data which will be used in the data manipulation being done by the microcomputer, to send data to output devices. The user can enter instruction (i.e. program) and data in memory through input devices such as keyboard, or simple switches, CRT, disk devices, tape or card readers. Computers are also used to measure and control physical quantities like temperature, pressure, speed etc. For these purposes, transducers are used to convent physical quantities into proportional electrical signals A/D computers are used to convert electrical signals into digital signals which are sent to the compute. The computer sends the results of the computation to the output devices e.g. LED, CRT, D/A converters, printers etc.. These I/O devices allow the computer to communicate with the outside world I/O devices are called peripherals.

Clock Generation:

Operations inside the microprocessor as well as in other parts of the microcontroller, are usually synchronous by nature. The clock generator generates the appropriate clock periods during which instruction executions are carried out by the microprocessor. This condition ensures that events in different path of the systems can proceed in a systematic fashion. Some of the microprocessors have an internal clock generator circuit to generate a clock signal. These microprocessors require an external crystal or RC network to be connected at the appropriate pins for deciding the operating frequency (e.g. 8085). Some microprocessors require an external clock generator (e.g. 8086). These microprocessors also provides an output clock signal which can be used by other devices in the microcomputer system for their can timing and synchronizing.