You are on page 1of 29

COMPUTER ORGANIZATION AND ARCHITECTURE

LABORATORY MANUAL

S No. Name of the Experiment Page


No
1 Identification of different components of a pc.
2 Assembling and disassembling of a pc.
3 Study of smps with single output under line regulation
4 Study of different troubleshooting of a dot matrix printer using LX 1050+ printer
trainer module
5 Write a C/C++ program for IEEE 754 floating point representation and perform
addition and subtraction
6 Write a C/C++ program to perform signed bit multiplication using Booth's algorithm

7 To study of Half Adder


8 To study of Full Adder
9
Design of digital circuits (MUX, DEMUX &ALU) in VHDL using Active VHDl.

10 Study of assembly language program in pc using 8086 architecture

EXPERIMENT-1

AIM: Identification of different components of a pc

1.Input Unit
2.Output Unit
3.Storage Unit
4.Central Processing Unit (CPU)
5.Arithmetic and Logic Unit (ALU)
6.Control Unit
Input Unit
Data and instructions must enter the computer system before any computation can be performed on the
supplied data. The input unit that links the external environment with the computer system performs this
task. Data and instructions enter input units in forms that depend upon the particular device used. For
example, data is entered from a keyboard in a manner similar to typing, and this differs from the way in
which data is entered through a mouse, which is another type of input device. However, regardless of the
form in which they receive their inputs, all input devices must provide a computer with data that are
transformed into the binary codes that the primary memory of the computer is designed to accept. This
transformation is accomplished by units that called input interfaces. Input interfaces are designed to
match the unique physical or electrical characteristics of input devices to the requirements of the
computer system.

An input unit performs the following functions.

1. It accepts (or reads) the list of instructions and data from the outside world.
2. It converts these instructions and data in computer acceptable format.
3. It supplies the converted instructions and data to the computer system for further processing.

Output Unit
The job of an output unit is just the reverse of that of an input unit. It supplied information and results of
computation to the outside world. Thus it links the computer with the external environment. As computers
work with binary code, the results produced are also in the binary form. Hence, before supplying the
results to the outside world, it must be converted to human acceptable (readable) form. This task is
accomplished by units called output interfaces.

Following functions are performed by an output unit.

1. It accepts the results produced by the computer which are in coded form and hence cannot be easily
understood by us.
2. It converts these coded results to human acceptable (readable) form.
3. It supplied the converted results to the outside world.

Storage Unit
The data and instructions that are entered into the computer system through input units have to be stored
inside the computer before the actual processing starts. Similarly, the results produced by the computer
after processing must also be kept somewhere inside the computer system before being passed on to the
output units. Moreover, the intermediate results produced by the computer must also be preserved for
ongoing processing. The Storage Unit or the primary / main storage of a computer system is designed
to do all these things. It provides space for storing data and instructions, space for intermediate results and
also space for the final results.
The specific functions of the storage unit are to store:

1. All the data to be processed and the instruction required for processing (received from input devices).
2. Intermediate results of processing.
3. Final results of processing before these results are released to an output device.

Central Processing Unit (CPU)

The main unit inside the computer is the CPU. This unit is responsible for all events inside the computer.
It controls all internal and external devices, performs “Arithmetic and Logical operations”. The
operations a Microprocessor performs are called “instruction set” of this processor. The instruction set is
“hard wired” in the CPU and determines the machine language for the CPU.

The more complicated the instruction set is, the slower the CPU works. Processors differed from one
another by the instruction set. If the same program can run on two different computer brands they are said
to be compatible. Programs written for IBM compatible computers will not run on Apple computers
because these two architectures are not compatible.

The control Unit and the Arithmetic and Logic unit of a computer system are jointly known as the Central
Processing Unit (CPU). The CPU is the brain of any computer system. In a human body, all major
decisions are taken by the brain and the other parts of the body function as directed by the brain.
Similarly, in a computer system, all major calculations and comparisons are made inside the CPU and the
CPU is also responsible for activating and controlling the operations of other units of a computer system.

Arithmetic And Logic Unit (ALU)

The arithmetic and logic unit (ALU) of a computer system is the place where the actual execution of the
instructions take place during the processing operations. All calculations are performed and all
comparisons (decisions) are made in the ALU. The data and instructions, stored in the primary storage
prior to processing are transferred as and when needed to the ALU where processing takes place. No
processing is done in the primary storage unit. Intermediate results generated in the ALU are temporarily
transferred back to the primary storage until needed at a later time. Data may thus move from primary
storage to ALU and back again as storage many times before the processing is over. After the completion
of processing, the final results which are stored in the storage unit are released to an output device.
The arithmetic and logic unit (ALU) is the part where actual computations take place. It consists of
circuits that perform arithmetic operations (e.g. addition, subtraction, multiplication, division over data
received from memory and capable to compare numbers (less than, equal to, or greater than).

All activities in the computer system are composed of thousands of individual steps. These steps should
follow in some order in fixed intervals of time. These intervals are generated by the Clock Unit. Every
operation within the CPU takes place at the clock pulse.. The clock rate is measured in megahertz (Mhz)
or Gigahertz (Ghz). Larger systems are even faster.
Control Unit

By selecting, interpreting, and seeing to the execution of the program instructions, the control unit is able
to maintain order and directs the operation of the entire system. Although, it does not perform any actual
processing on the data, the control unit acts as a central nervous system for the other components of the
computer. It manages and coordinates the entire computer system. It obtains instructions from the
program stored in main memory, interprets the instructions, and issues signals that cause other units of the
system to execute them.
The control unit directs and controls the activities of the internal and external devices. It interprets the
instructions fetched into the computer, determines what data, if any, are needed, where it is stored, where
to store the results of the operation, and sends the control signals to the devices involved in the execution
of the instructions.

EXPERIMENT-2

AIM: Assembling and disassembling a pc of a pc.

Procedure:

Follow the steps below to properly assemble a computer system.

Step 1:

1. Take Inventory: Before start, take inventory of parts. Make sure we have the following
components and tools.
o Motherboard
o CPU
o Heat Sink and CPU Fan
o SMPS
o Hard disk drive
o CD/ DVD drive
o RAM
o CMOS Battery
o Case/ Tower/Cabinet
o A good screwdriver sets

2. Make Space, Make Time: Building a PC take space – about a dining room table worth. So, make sure
you have plenty of working room and a few hours to proceed with minimal interruption.
3. Have the Drivers Ready: Motherboard comes bundled with a CD containing all the drivers. Make sure
that CD is available before start assembling. In case the CD is missing and assuming we have another
PC with internet connection, download the latest drivers from the vendors’ websites for each
component installing.

Step 2: INSTALL THE MOTHERBOARD

1. Great care should be taken when installing the motherboard. First, take the board out of its packaging
and put it on top of the antistatic bag it came in. Before you secure the motherboard onto the PC
case/chassis, inspect it carefully for any visible defects.
2. Next, review the motherboard manual, to make sure we should familiar with the motherboard layout
and understand which socket is which. Manuals are extremely helpful, usually easy to read, and
include illustrations instructions.

Step 3: PLACE THE MOTHERBOARD INTO THE CASE

1. Some PC cases have a removable motherboard tray. If yours does, remove the screws holding it in
place and pull it out of the case.
2. Note the pattern of the holes in your motherboard, and screw brass standoffs into the motherboard tray
or into the PC case in the correct locations (ALWAYS check the manual and follow their instructions
to the letter).
3. Check the layout of the sockets on the motherboard, and confirm that the ports on the motherboard’s
back panel match the holes on the case’s Input/output (I/O) shield that is installed in your case. If
necessary, remove the old I/O shield by tapping it firmly a few times with the butt-end of a
screwdriver, and then replace it with the shield that came with the new motherboard.
4. Carefully position the motherboard on top of the brass standoffs, line up all the holes, and use the
screws that accompanied the case to fasten down the motherboard

Step 4: INSTALL THE PROCESSOR (CPU)


1. Use the unlocking mechanism to open the CPU socket which is usually a lever.
2. Carefully line up the pins and place the chip in its socket; it will fit only when oriented in the proper
way. An arrow or a missing pin on one corner of the chip will show how to line things up.
3. Align Triangular CPU and socket key marks.
4. Lower the lever to lock the CPU into place.

Step 5: INSTALL THE CPU HEAT SINK


1. Follow the manufacturer’s directions to install the heat sink and the fan that will cool the processor.
2. Attach the clip that holds the heat sink in place keeping in mind that it may require a fair amount of
force. Again, follow the instructions that came with the heat sink. They will show you how to fit it
correctly. Plug the CPU fan’s power connector into the proper connector on the motherboard.
Step 6: INSTALL THE MEMORY MODULES (RAM MEMORY)

1. In order to install the memory modules, insert them into the proper sockets and push down firmly but
evenly until the clips on both sides of the socket pop into place. If the motherboard supports dual-
channel memory, consult the user manual to determine which pairs of RAM sockets should use.

Step 7: CONNECT THE POWER SUPPLY

1. First, plug the large ATX power connector from power supply into the matching port on the
motherboard.
2. Locate the smaller, square processor power connector and attach it to the motherboard.
3. Attach each of the tiny leads from the power and reset switches, the hard-disk activity lights, the PC
speaker, and any front-panel USB and FireWire ports to the corresponding pin on the motherboard.

Step 8: CONNECT THE KEYBOARD, MOUSE, AND MONITOR

1. Connect a keyboard, mouse, monitor, and power cable to the computer and turn it on.
2. If the internal fans begin to whir, the system beeps, and see the machine starting to boot, power down
by holding the power button for 5 seconds and continue building.
3. If nothing happens, back up a step and recheck all the connections. Make sure that both the processor
and the memory are properly seated, and recheck those minuscule leads connecting the motherboard to
the power and reset switches.
4. If it performs as expected, shut down the PC, unplug it, and open the case.

Step 9: INSTALL THE DRIVES

1. Use the included screws to attach the drives to the rails or cage, and slide them into the case. For
externally accessible drives such as a DVD recorder, save time by installing one drive rail and sliding
the drive in for a test fitting to make sure that its front is even with the case.
2. When the drives are installed, connect power and data cables to each one. Parallel ATA drives use
wide, flat data cables that can be installed only in the correct way. SATA drives use a thin, 1cm ¬wide
data cable. SATA drives use a new type of power connector that many power supplies don’t come
with.

Step 10: INSTALL THE ADD-IN CARDS


1. For each add-in card, choose a free PCI slot.
2. Remove its backplane cover to allow access from the rear of the case.
3. Carefully position the card above the slot, and press down firmly to seat the card.
4. Secure the card with a screw.
Step 11: TURN THE COMPUTER ON

It is time to turn on your system and check the PC set up\.


Make sure the keyboard, mouse, and monitor are all plugged into the appropriate ports on the back of the
PC. Plug the power cord back in, and turn the machine on.

General steps for disassembling a PC


 Unplugged the AC power supply to the PC from the wall socket
 Remove the Cover or chassis or case.
 Unplugged bus cables and ATX power cables
 Remove Adapter Cards if any
 Remove the processor and the heat sink and fan
 Remove hard disk and CD/ DVD drives
 Remove the Memory Modules
 Remove the Power Supply
 Remove the Motherboard

EXPERIMENT-3

AIM: Study of smps with single output under line regulation.

Switched Mode Power Supplies.

The working of SMPS is simply understood by knowing that the transistor used in LPS is used to control
the voltage drop while the transistor in SMPS is used as a controlled switch.

Working
The working of SMPS can be understood by the following figure.
Input Stage
The AC input supply signal 50 Hz is given directly to the rectifier and filter circuit combination without
using any transformer. This output will have many variations and the capacitance value of the capacitor
should be higher to handle the input fluctuations. This unregulated dc is given to the central switching
section of SMPS.

Switching Section
A fast switching device such as a Power transistor or a MOSFET is employed in this section, which
switches ON and OFF according to the variations and this output is given to the primary of the
transformer present in this section. The transformer used here are much smaller and lighter ones unlike
the ones used for 60 Hz supply. These are much efficient and hence the power conversion ratio is higher.

Output Stage
The output signal from the switching section is again rectified and filtered, to get the required DC
voltage. This is a regulated output voltage which is then given to the control circuit, which is a feedback
circuit. The final output is obtained after considering the feedback signal.

Control Unit
This unit is the feedback circuit which has many sections.

The above figure explains the inner parts of a control unit. The output sensor senses the signal and joins
it to the control unit. The signal is isolated from the other section so that any sudden spikes should not
affect the circuitry. A reference voltage is given as one input along with the signal to the error amplifier
which is a comparator that compares the signal with the required signal level.

By controlling the chopping frequency the final voltage level is maintained. This is controlled by
comparing the inputs given to the error amplifier, whose output helps to decide whether to increase or
decrease the chopping frequency. The PWM oscillator produces a standard PWM wave fixed frequency.

.
The SMPS is mostly used where switching of voltages is not at all a problem and where efficiency of the
system really matters. SMPS circuit is operated by switching and hence the voltages vary continuously.

 The switching device is operated in saturation or cut off mode.

 The output voltage is controlled by the switching time of the feedback circuitry.

 Switching time is adjusted by adjusting the duty cycle.

 The efficiency of SMPS is high because, instead of dissipating excess power as heat, it
continuously switches its input to control the output.

Disadvantages

 The noise is present due to high frequency switching.


 The circuit is complex.
 It produces electromagnetic interference.
Advantages

 The efficiency is as high as 80 to 90%


 Less heat generation; less power wastage.
 Reduced harmonic feedback into the supply mains.
 The device is compact and small in size.
 The manufacturing cost is reduced.
 Provision for providing the required number of voltages.
Applications
There are many applications of SMPS. They are used in the motherboard of computers, mobile phone
chargers, HVDC measurements, battery chargers, central power distribution, motor vehicles, consumer
electronics, laptops, security systems, space stations, etc.

Types of SMPS
SMPS is the Switched Mode Power Supply circuit which is designed for obtaining the regulated DC
output voltage from an unregulated DC or AC voltage. There are four main types of SMPS such as

 DC to DC Converter
 AC to DC Converter
 Fly back Converter
 Forward Converter
EXPERIMENT-4

Aim: Study of different troubleshooting of a dot matrix printer using LX 1050+ printer trainer module

Dot Matrix Printer Troubleshooting

Most problems associated with the printer can be traced to improper setup, installation, or cabling.
The following table will assist you in identifying and correcting some of the more common problems.
Ink smears
Possible cause: Head gap lever is not in the proper position
Solution: Move the lever toward the (+) position until ink does not smear

Printout is faint
Head gap lever is not in the proper position
Adjust the lever the proper position

Carriage moves but there is no printing

Ribbon is not installed correctly


Re-insert ribbon

Paper out detector inoperative


Paper out detect if OFF
Set paper out detect to ON

Paper slips around platen

paper feed selector is set to " "


Set selector to

Printer does not power up


No AC Power
Check power cord
Power is on but printer does not print
Printer is not ON LINE.
Press ON LINE

Interface cable is not properly connected


Secure connection

Out of paper
Install new paper

Smoked plastic cover is open


Ensure cover is completely closed

Printhead has become overheated


Allow the printhead some time to cool down and The Printer will automatically resume printing

Carriage stops moving, all indicators start blinking


Path of printhead is blocked
Turn the power off, clear the path.
Turn the power back on to resume printing

Paper wrinkles when using tractor feed


No reverse tension on paper
Set paper supply lower than printer

Buzzer sounds when installing single sheet

Paper feed selector is set to

Set paper feed selector to

Printer cannot load single sheet through the top


CSF mode is ON
Set CSF MODE to OFF when not using the cut sheet feeder

Cut Sheet Feeder option (KX-P38) is installed but does not work
CSF MODE is OFF
Set CSF MODE to ON

Unexpected characters appear in printing


EMULATION is set incorrectly
Check printer driver of your software package and set EMULATION accordingly
Printout is double-spaced
AUTO LF is ON
Set Auto LF to OFF

Keeps printing on the same line


Computer is not sending a LF command
Set Auto LF to OFF

Wrong character set is printed


Wrong character set is selected
Set the character set as required

Cannot print ASCII characters with code above 127


Data length is set incorrectly
Set data length as required

Fanfold paper is jamming


Paper not installed correctly in tractor

Set paper feed selector to " " and rotate platen knob to easily remove jammed paper.
Reinstall paper correctly into tractor

KX-PS14 (serial interface board) is installed but cannot print


I/F is set to PARALLEL
Set I/F to SERIAL

Cannot use parallel interface when installing serial interface board


KX-PS14 I/f is set to SERIAL
Set I/F to PARALLEL
KX-PS13 Parallel interface cannot be used when a KX-PS13 is installed
Remove KX-PS13 when using parallel interface

EXPERIMENT-5

AIM: Write a C/C++ program for IEEE 754 floating point representation and perform addition and
subtraction.

Input: real number = 16.75


Output: 0 | 10000011 | 00001100000000000000000

Input: floating point number = 0 | 10000011 | 00001100000000000000000


Output: 16.75
Program to IEEE 754 floating point representation

//
#include <stdio.h>

void printBinary(int n, int i)


{

// Prints the binary representation


// of a number n up to i-bits.
int k;
for (k = i - 1; k >= 0; k--) {

if ((n >> k) & 1)


printf("1");
else
printf("0");
}
}

typedef union {

float f;
struct
{

// Order is important.
// Here the members of the union data structure
// use the same memory (32 bits).
// The ordering is taken
// from the LSB to the MSB.
unsigned int mantissa : 23;
unsigned int exponent : 8;
unsigned int sign : 1;
} raw;
} myfloat;

// Function to convert real value


// to IEEE foating point representation
void printIEEE(myfloat var)
{

// Prints the IEEE 754 representation


// of a float value (32 bits)

printf("%d | ", var.raw.sign);


printBinary(var.raw.exponent, 8);
printf(" | ");
printBinary(var.raw.mantissa, 23);
printf("\n");
}

// Driver Code
int main()
{

// Instantiate the union


myfloat var;

// Get the real value


var.f = -2.25;

// Get the IEEE floating point representation


printf("IEEE 754 representation of %f is : \n",
var.f);
printIEEE(var);

return 0;
}

Output:

IEEE 754 representation of -2.250000 is :


1 10000000 00100000000000000000000

Program to IEEE 754 floating point Addition


include <cstdlib>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;


#define SIGN 0
#define EXP 1
#define FRAC 2

#define MANTISSA_MAX ((2<<22)-1)


#define HIDDEN_MANTISSA (2 << 22)

#define max(a,b) ((a>b)?a:b)


#define min(a,b) ((a>b)?b:a)
#define zero(x) (x[EXP] == 0 && x[FRAC] == 0)
#define denorm(x) (x[EXP] == 0 && x[FRAC] != 0)
#define sign(x) ((x[SIGN]==1)?-1:1)
#define hideMantissaBit(x) (x=x&MANTISSA_MAX);
#define convertToSignificand(x)
x[FRAC]=((!denorm(x))?(x[FRAC]+HIDDEN_MANTISSA):(x[FRAC]));x[EXP]+=(denorm(x))?1:0
#define shift(x,y) x[FRAC] = shiftAndRound(x[FRAC],max(y[EXP] - x[EXP], 0));
#define renormalize(x,d) x[FRAC]=(d>0)?(shiftAndRound(x[FRAC],d)):(x[FRAC]<<(-d));

int msb_length(long l) {
int cnt = 0;
while (l >= 1) {
l >>= 1;
cnt++;
}
return cnt;
}

long shiftAndRound(long x, int d) {


d = min(d, msb_length(x));
int result = x >> d;
if (d == 0)
return result;
int r = (x & ((d > 1) ? (2 << (d - 2)) : 1)) >> (d - 1);
if (r == 1) {
int lb = result & 1;
int s = 0;
for (int i = 0; i < d - 1 && s == 0; i++) {
s |= x & 1;
x >>= 1;
}
if (s == 1 || lb == 1)
result += 1;
}
return result;
}

long* get(long x) {
long* arr;
arr = new long[3];
arr[SIGN] = (x & 0x80000000) >> 31;
arr[EXP] = (x & 0x7F800000) >> 23;
arr[FRAC] = (x & 0x7FFFFF);
return arr;
}

long add(long x, long y) {


long* a = get(x);
long* b = get(y);
if (zero(a))
return y;
if (zero(b))
return x;
convertToSignificand(a);
convertToSignificand(b);
if (a[EXP] != b[EXP]) {
shift(a, b)
shift(b, a)
}
long* sum;
sum = new long[3];
sum[FRAC] = sign(a) * a[FRAC] + sign(b) * b[FRAC];
sum[SIGN] = ((sum[FRAC] >= 0) ? 0 : 1);
sum[FRAC] = abs(sum[FRAC]);
if (sum[FRAC] != 0) {
sum[EXP] = max(a[EXP], b[EXP]);
int deltaExp = msb_length(sum[FRAC]) - 24;
sum[EXP] += deltaExp;
renormalize(sum, deltaExp)
if (!denorm(sum))
hideMantissaBit(sum[FRAC])
} else {
sum[EXP] = 0;
}
return (sum[SIGN] << 31) + (sum[EXP] << 23) + sum[FRAC];
}

int main() {
ifstream inputStream;
inputStream.open("src/input.txt");
int r = 0, w = 0;
long i = 0;
while (!inputStream.eof()) {
long a;
long b;
long c;
inputStream >> dec >> i;
inputStream >> hex >> a;
inputStream >> hex >> b;
inputStream >> hex >> c;
if (c == add(a, b)) {
r++;
cout << "Test " << i << " PASSED" << endl;
} else {
w++;
cout << "Test " << i << " FAILED" << endl;
}
}
inputStream.close();
cout << "Total " << r << " " << "PASSED " << w << " FAILED." << endl;
}

EXPERIMENT-6

AIM: Write a C/C++ program to perform signed bit multiplication using Booth's algorithm

Program Code:

//Booth's Multiplication for two 8-bit numbers


#include<stdio.h>
#include<conio.h>
void disp_binary(int x)
{
char a[16];
int masks[16]={0x8000,0x4000,0x2000,0x1000,0x0800,
0x0400,0x200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001};
int i;
for(i=0;i<16;i++)
if((x &masks[i])==0)
printf("0");
else
printf("1");
}
void main()
{
int acq,m,q_1,i,q_0;
printf("\nEnter multiplicand(-128 to 127) : ");
scanf("%d",&m);
disp_binary(m);
printf("\nEnter multiplier (-128 to 127) : "); scanf("%d",&acq);
acq=(acq & 0x00ff);
q_1=0;
printf("\n");
disp_binary(acq);
printf("%d",q_1);
for(i=0;i<8;i++)//booth's cycle
{
q_0=acq & 0x0001;
if(q_0==1 && q_1==0)
acq=acq - (m<<8);
else
if(q_0==0 && q_1==1)
acq=acq + (m<<8);
q_1=(acq & 0x0001);
acq=(acq>>1); printf("\n");

disp_binary(acq);
printf("%d",q_1);
}
printf("\nProduct = ");
disp_binary(acq);
getch();
}

Output :

Enter multiplicand(-128 to 127) : -7


1111111111111001
Enter multiplier(-128 to 127) : 3

0000000000000011 0
0000001110000001 1
0000000111000000 1
1111110101100000 1
1111111010110000 0
1111111101011000 0
1111111110101100 0
1111111111010110 0
1111111111101011 0
Product = 1111111111101011

EXPERIMENT-7

AIM: To study of Half Adder

THEORY:

To understand what is a half adder you need to know what is an adder first. Adder circuit is a
combinational digital circuit that is used for adding two numbers. A typical adder circuit produces a
sum bit (denoted by S) and a carry bit (denoted by C) as the output. Typically adders are realized for
adding binary numbers but they can be also realized for adding other formats like BCD (binary coded
decimal, XS-3 etc. Besides addition, adder circuits can be used for a lot of other applications in digital
electronics like address decoding, table index calculation etc. Adder circuits are of two types:
1. Half adder
2. Full adder.
Half adder circuit:

Half adder is a combinational arithmetic circuit that adds two numbers and produces a sum bit
(S) and carry bit (C) as the output. If A and B are the input bits, then sum bit (S) is the X-OR of A and B
and the carry bit (C) will be the AND of A and B. From this it is clear that a half adder circuit can be
easily constructed using one X-OR gate and one AND gate. Half adder is the simplest of all adder
circuit, but it has a major disadvantage. The half adder can add only two input bits (A and B) and has
nothing to do with the carry if there is any in the input. So if the input to a half adder have a carry, then it
will be neglected it and adds only the A and B bits. That means the binary addition process is not
complete and that’s why it is called a half adder.

NAND gates or NOR gates can be used for realizing the half adder in universal logic and the relevant
circuit diagrams are shown in the figure below.

Using NOR Gate


Using NAND Gate

Here is the truth table description of a half adder. We denote the sum A + B.

A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

We need equations for each of the Sum and Carry. Because we have used a truth table to
specify these functions, we consider Boolean expressions.
The carry is the logical AND of the two inputs: Carry = A·B.

The sum can be given in two equivalent expressions. The simplest


expression uses the exclusive OR function: Sum = AÅB. An equivalent expression in
terms of the basic AND, OR, and NOT.

Conclusion: Thus we have studied Half Adder Successfully.


EXPERIMENT-8

AIM: To study of Full Adder

Adder(7483). THEORY:

Introduction:
This type of adder is a little more difficult to implement than a half-adder. The main difference between
a half-adder and a full-adder is that the full-adder has three inputs and two outputs. The first two inputs are
A and B and the third input is an input carry designated as CIN. When a full adder logic is designed we
will be able to string eight of them together to create a byte-wide adder and cascade the carry bit from one
adder to the next.
The output carry is designated as COUT and the normal output is designated as S. Take a look at the truth-
table.
Full-adder logic diagram with truth-table

From the above truth-table, the full adder logic can be implemented. The output S is an EXOR between
the input A and the half-adder SUM output with B and CIN inputs. The COUT will only be true if any of
the two inputs out of the three are HIGH.
Thus, implementation a full adder circuit with the help of two half adder circuits. The first will half
adder will be used to add A and B to produce a partial Sum. The second half adder logic can be used to
add CIN to the Sum produced by the first half adder to get the final S output. If any of the half adder logic
produces a carry, there will be an output carry. Thus, COUT will be an OR function of the half-adder
Carry outputs.

Conclusion: Thus we have studied Full Adder(7483) Successfully.

EXPERIMENT-9

Aim: Design of digital circuits (MUX,DEMUX &ALU) in VHDL using Active VHDl.

A multiplexer allows digital signals from several sources to be routed onto a single bus or line. A 'select'
input to the multiplexer allows the source of the signal to be chosen. The first multiplexes two 4-bit input
buses to a single 4-bit output bus, the second example multiplexes four single input lines to a single
output line.

Four-Bit Wide 2 to 1 Multiplexer


The 2 to 1 multiplexer is shown below. A logic 1 on the SEL line will connect the 4-bit input bus A to the
4-bit output bus X. A logic 0 on the SEL line will connect input bus B to output bus X.

VHDL Code
The VHDL code for implementing the 4-bit 2 to 1 multiplexer
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity mux_2to1_top is
Port ( SEL : in STD_LOGIC;
A : in STD_LOGIC_VECTOR (3 downto 0);
B : in STD_LOGIC_VECTOR (3 downto 0);
X : out STD_LOGIC_VECTOR (3 downto 0));
end mux_2to1_top;

architecture Behavioral of mux_2to1_top is


begin
X <= A when (SEL = '1') else B;
end Behavioral;

VHDL Code for a Demultiplexer

Library ieee;

use ieee.std_logic_1164.all;

entity demux is

port(S1,S0,D:in bit; Y0,Y1,Y2,Y3:out bit);

end demux;

architecture data of demux is

begin

Y0<= ((Not S0) and (Not S1) and D);

Y1<= ((Not S0) and S1 and D);

Y2<= (S0 and (Not S1) and D);

Y3<= (S0 and S1 and D);

end data;

VHDL code for 16-bit ALU

Library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use ieee.NUMERIC_STD.all;
-----------------------------------------------
---------- ALU 8-bit VHDL ---------------------
-----------------------------------------------
entity ALU is
generic (
constant N: natural := 1 -- number of shited or rotated bits
);

Port (
A, B : in STD_LOGIC_VECTOR(7 downto 0); -- 2 inputs 8-bit
ALU_Sel : in STD_LOGIC_VECTOR(3 downto 0); -- 1 input 4-bit for selecting function
ALU_Out : out STD_LOGIC_VECTOR(7 downto 0); -- 1 output 8-bit
Carryout : out std_logic -- Carryout flag
);
end ALU;
architecture Behavioral of ALU is

signal ALU_Result : std_logic_vector (7 downto 0);


signal tmp: std_logic_vector (8 downto 0);

begin
process(A,B,ALU_Sel)
begin
case(ALU_Sel) is
when "0000" => -- Addition
ALU_Result <= A + B ;
when "0001" => -- Subtraction
ALU_Result <= A - B ;
when "0010" => -- Multiplication
ALU_Result <= std_logic_vector(to_unsigned((to_integer(unsigned(A)) * to_integer(unsigned(B))),8))
;
when "0011" => -- Division
ALU_Result <= std_logic_vector(to_unsigned(to_integer(unsigned(A)) / to_integer(unsigned(B)),8)) ;
when "0100" => -- Logical shift left
ALU_Result <= std_logic_vector(unsigned(A) sll N);
when "0101" => -- Logical shift right
ALU_Result <= std_logic_vector(unsigned(A) srl N);
when "0110" => -- Rotate left
ALU_Result <= std_logic_vector(unsigned(A) rol N);
when "0111" => -- Rotate right
ALU_Result <= std_logic_vector(unsigned(A) ror N);
when "1000" => -- Logical and
ALU_Result <= A and B;
when "1001" => -- Logical or
ALU_Result <= A or B;
when "1010" => -- Logical xor
ALU_Result <= A xor B;
when "1011" => -- Logical nor
ALU_Result <= A nor B;
when "1100" => -- Logical nand
ALU_Result <= A nand B;
when "1101" => -- Logical xnor
ALU_Result <= A xnor B;
when "1110" => -- Greater comparison
if(A>B) then
ALU_Result <= x"01" ;
else
ALU_Result <= x"00" ;
end if;
when "1111" => -- Equal comparison
if(A=B) then
ALU_Result <= x"01" ;
else
ALU_Result <= x"00" ;
end if;
when others => ALU_Result <= A + B ;
end case;
end process;
ALU_Out <= ALU_Result; -- ALU out
tmp <= ('0' & A) + ('0' & B);
Carryout <= tmp(8); -- Carryout flag
end Behavioral;
EXPERIMENT-10

AIM: Study of assembly language program in pc using 8086 architecture.

8086 Assembly programming means develop programs in 8086 assembly programming language. 8086
Assembly is a low level programming language. The developer have to deal with object of the
processor like segment and register..

 A more convenient language to use is assembly language


 In it, we use symbolic names to represent operations, registers, and memory locations
 If location 0 is symbolized by A, the preceding program would look like this:

Assembly Language Operation


Instruction

MOV AX,A Fetch contents of memory word 0 and put it in register AX


ADD AX,4 Add 4 to AX
MOV A,AX Store the contents of AX in memory word 0

 A program written in assembly language must be converted to machine language before the CPU
can execute it
 A program called an assembler translates each assembly language statement into a single
machine language instruction

Basic elements of 8086 assembly programming language

8086 assembly programming language instructions


Structure:
OperationCode [Operand1 [, Operand2]]
Operations
The operation are usually logic or arithmetic, but we can also find some special operation like the Jump
(JMP) operation.

JUMP operation is an operation that stop the linear execution of the code and indicate the next instruction
to execute. It is more complex because it can be unconditional or conditional on the result of some
previous operations or on flag value.
Operands
Operands are the parameters of the operation in the instruction. They can be use in 3 way:

Immediate
This means a direct access of a variable that have been declared in the program.

Register
Here we use the content of a register to be a parameter.

Memory
Here we access to the content of a specific part of the memory using a pointer.

Special instructions
DECLARATION
In 8086, we need to declare the name of the variable, the size of the variable and it value.
Structure:

VariableName SizeDirective value [ dup (num)]

VariableName : name of your variable.


SizeDirective: word system to define the size, DB will define byte byte.
value is your variable value
dub: a system word that means duplicate, used for vector.
num: number of time you duplicate, the size of your vector.

INTERRUPT
Interrupt calls a sub routine of the system to be executed. we will see 2 simple interrupt:

1 – read character from standard input, result is stored in AL.

MOV AH,01h

INT 21h

2 – write character to standard output, DL = character to write.

MOV AH,02h

INT 21h
Assembly Language Program

%TITLE "SAMPLE PROGRAM"


.MODEL SMALL
.STACK 100H
.DATA
A DW 2
B DW 5
SUM DW ?
.CODE
MAIN PROC
initialize DS;
MOV AX,@DATA
MOV DS,AX
add the numbers;
MOV AX,A AX has A ;
ADD AX,B AX has A+B ;
MOV SUM,AX SUM = A+B;
exit to DOS;
MOV AX,4C00h
INT 21h
MAIN ENDP
END MAIN

You might also like