Dlcoa Lab Manual
Dlcoa Lab Manual
LABORATORYMANUAL
DLCOA R-19Scheme CSL304 Sem:III
Sr.No. NameofExperiment PageNo.
1 To apply the fundamentals of the digital logic for verifying the truth tables of 2-5
logic gates.
2 To develop binary to gray and gray to binary code converter. 6-10
3 To develop a half adder and full adder circuit using logic gates and verify it 11-14
using truth table.
4 To verify the truth tables of JK, D & T flip flop. 15-17
5 To implement Booth’s multiplication algorithm using C programming. 18-25
6 To implement restoring division algorithm using C programming 26-30
7 To implement non-restoring division algorithm using C programming 31-35
language.
8 To apply the basics of arithmetic & logical processing for ALU design. 36-38
9 To make use of the knowledge of memory organization for implementing 39-42
memory design.
10 To implement cache memory design with the help of concepts of memory 43-47
organization.
Prepared by:
Experiment No.01
STUDYOF BASICGATES
AIM: To study and verify the truth table of various logic gates using ICs and realize
APPARATUSREQUIRED:PowerSupply,Breadboard,Connectingwires
ICPINOUTS TRUTH-TABLE
NAND
A B Y=A.B
0 0 1
0 1 1
1 0 1
1 1 0
NOR
A B Y=A+B
0 0 1
0 1 0
1 0 0
1 1 0
NOT
A Y=A
0 1
1 0
AND
A B Y=A.B
0 0 0
0 1 0
1 0 0
1 1 1
OR
A B Y=A+B
0 0 0
0 1 1
1 0 1
1 1 1
EX-OR
A B Y=AB+AB
0 0 0
0 1 1
1 0 1
1 1 0
THEORY
Logic gates are the digital circuits with one output and one or more inputs. They are the basicbuilding
blocks of any logic circuit. Different logic gates are: AND, OR, NOT, NAND, NOR, EX-OR.They
AND:Logiceqn.Y=A.B
OR:Logiceqn.Y=A+B.
NOT:Logiceqn.Y= .
TheoutputofNOTgateis complementoftheinput.
NAND:Logiceqn.Y=
TheoutputofNANDgateistruewhenoneoftheinputs or boththeinputsarelowlevel.
NOR:Logicaleqn.Y= .
TheoutputofNORgateis truewhenboththeinputsarelow.
EX-OR:Logiceqn.Y= .
Inthegivenfunctioncompliment input, we are using the NOT gates at the input side. And to represent the sum
term,weuseORgates.Seethebelowgivenlogic diagramforrepresentationoftheBooleanfunction.
PROCEDURE
1) GivebiasingtotheICanddo necessaryconnections.
1)3)Realizetheexpressionusingbasicgates.
CONCLUSION
ExperimentNo.02
BINARYTOGREYCODEANDGREYTOBINARYCODECONVERSION
APPARATUS:Powersupply, Breadboard,connectingwire.
COMPONENTS:IC7486.
THEORY:
The availability of large variety of codes for the same discrete elements of information results inthe use of
different codes by different systems. A conversion circuit must be inserted betweenthe two systems if
each uses different codes for same information. Thus, code converter is a circuit that makes the two
The bit combination is assigned to binary code to gray code. Each code uses four bits torepresent a
decimal digit. There are four inputs and four outputs. Gray code is a non-weightedcode.
The input variables are designated as B3,B2,B1,B0 and the output variables are designated as C3, C2, C1,
Co. from the truth table, combinational circuit is designed. The Boolean functions are obtained from K-
A code converter is a circuit that makes the two systems compatible even though each uses adifferent
binary code. To convert from binary code to Excess-3 code, the input lines must
supplythebitcombinationofelementsasspecifiedbycodeandtheoutputlinesgeneratethecorresponding bit
combination of code. Each one of the four maps represent one of the fouroutputsofthecircuitasafunction
ofthefourinputvariables.
A two-level logic diagram may be obtained directly from the Boolean expressions derived by themaps.
These are various other possibilities for a logic diagram that implements this circuit. Now the OR gate
whose output is C+D has been used to implement partially each of three outputs.
TRUTHTABLE
B3 B2 B1 B0 G3 G2 G1 G0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 0 0 0 1 1
0 0 1 1 0 0 1 0
0 1 0 0 0 1 1 0
0 1 0 1 0 1 1 1
0 1 1 0 0 1 0 1
0 1 1 1 0 1 0 0
1 0 0 0 1 1 0 0
1 0 0 1 1 1 0 1
1 0 1 0 1 1 1 1
1 0 1 1 1 1 1 0
1 1 0 0 1 0 1 0
1 1 0 1 1 0 1 1
1 1 1 0 1 0 0 1
1 1 1 1 1 0 0 0
K-MapforG3: K-MapforG2:
G3 = B3
K-MapforG1 K-MapforG0
B3 =G3
PROCEDURE:
CIRCUITDIAGRAM:
RESULT:
Thus, conversionfromgrey tobinaryandbinarytogreycodeconversionisstudied.
ExperimentNo.03
DESIGNA(I)HALFADDERAND(II)FULLADDER
wire.COMPONENTS:IC 7408,7486,7404,7432.
THEORY:
HALFADDER:
A half adder has two inputs for the two bits to be added and two outputs one from the sum ‘S’and other
from the carry ‘c’ into the higher adder position. The circuit is called as a carry signalfrom the addition of
the less significant bits sum from the X-OR Gate the carry out from the ANDgate.
FULLADDER:
A full adder is a combinational circuit that forms the arithmetic sum of input; it consists of threeinputs
and two outputs. A full adder is useful to add three bits at a time but a half adder cannotdo so. In full
adder sum output will be taken from X-OR Gate, carry output will be taken from ORGate.
TRUTHTABLEOFHALFADDER:
A B CARRY SUM
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
K-MapforSUM: K-MapforCARRY
SUM=A’B+AB’ CARRY=AB
=AB
CIRCUITDIAGRAM:
TRUTHTABLEOFFULLADDER:
A B C CARRY SUM
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
K-MAPFORSUM:
SUM=A’B’C+A’BC’+ABC’+ABC
=A B C
K-MAPFORCARRY:
CARRY=AB+BC +AC
CIRCUITDIAGRAM:
PROCEDURE:
1) Connectionsaregivenaspercircuitdiagram.
2) Logicalinputsaregivenaspercircuitdiagram.
3) Observethe outputandverifythetruthtable.
RESULT:
Experiment
No. 04
FLIP-FLOPS
AIM: Design the JK and SR Flip Flop using NAND as Universal gate.
Verify the truth table of JK FlipFlop using IC7476. Implement T FlipFlop and DFlip Flop using
JK Flip Flop
COMPONENTS:IC7400,IC7410,IC7473, IC7474,IC7476
PindiagramofIC-
7476
CIRCUITDIAGRAMANDTRUTHTABLE:
I) SRFFusingNAND
III) JKFF(IC7476)
Clk J K Q Q Comment
0 0 NC NC NoChange
0 1 0 1 Reset
1 0 1 0 Set
1 1 Toggle Toggle
IV) TFFusingJK
Clk T Q Q
0 NC NC
1 Toggle
V) DFFusingJK
Clk D Q Q Comment
0 0 0 Reset
1 1 1 Set
THEORY:
Flip-flops are the basic building blocks of sequential ckt. The clocked FFs change their o/p state
depending upon i/p's at certain interval of time synchronized with the clock pulse applied to it.
Different types of FFs are S-R, J-K, D&T. Their operations are described by the respective
truthtables. MSI chip 7476 incorporates two negative edge triggered Master–Slave JK flip flops.
PROCEDURE:
CONCLUSION:
ThusR-S,J-K,D&TFlip-Flops arestudied.
EXPERIMENT 5
BOOTHS MULTIPLICATION ALGORITHM
Theory:
The multiplicand and multiplier are placed in the BR and QR registers respectively. A 1 bit
registeris placed logically to the right of the LSB (least significant bit) Qn of Q register. This is
denoted
byQn+1.AandQn+1isinitiallysetto0.ControllogicchecksthetwobitsQnandQn+1.Ifthetwobitsaresame(00
or11)thenallofthebitsofA,Q,Qn+1areshifted1bittotheright.Iftheyarenotthesameand if the combination
is 10 then the multiplicand is subtracted from A and if the combination is
01thenthemultiplicandisaddedwithA.InboththecasesresultsarestoredinA, andaftertheadditionor
subtraction operation, A, Q, Qn+1 are right shifted. The shifting is the arithmetic right
shiftoperationwheretheleftmostbitnamely,An-1isnotonlyshiftedintoAn-2butalsoremainsinAn-
1.ThisistopreservethesignofthenumberinAandQ.Theresultofthemultiplicationwillappearinthe A
andQ.
Program:
#include
<stdio.h>#includ
e<math.h>
inta =0,b= 0,c = 0,a1 = 0,b1 =0,com[5] ={ 1,0,0,0, 0};
intanum[5] = {0},anumcp[5] ={0}, bnum[5]= {0};
intacomp[5]={0},bcomp[5] ={0}, pro[5]= {0},res[5] ={0};
void
binary(){a1 =
fabs(a);b1=
fabs(b);
intr, r2,i,temp;
for(i=0;i<5;i++){
r= a1% 2;
a1 = a1 /
2;r2=b1%2;
b1 = b1 / 2;anum[i] =
r;anumcp[i]=r;bnum[i
] = r2;if(r2==0){
bcomp[i] =1;
}
if(r==0){
acomp[i]=1;
}
}
//part for two's
complementingc = 0;
for( i= 0;i<5;i++){
res[i] = com[i]+ bcomp[i] +
c;if(res[i]>= 2){
c = 1;
}
else
c = 0;
res[i]=res[i] %2;
}
for(i= 4;i>= 0;i--){
bcomp[i]=res[i];
}
//incaseofnegativeinputs
if (a
<0){c =
0;
for (i = 4; i>= 0; i--){res[i]= 0;
}
for( i= 0;i<5;i++){
res[i] = com[i] + acomp[i] +
c;if(res[i]>= 2){
c = 1;
}
else
c = 0;
res[i]=res[i]%2;
}
for(i= 4;i>= 0;i--){
anum[i] =
res[i];anumcp[i]=res[i];
}
}
if(b<0){
for (i = 0; i< 5; i++){temp =
bnum[i];bnum[i] =
bcomp[i];bcomp[i]=temp;
}
}
}
voidadd(intnum[]){
int
i;c=0
;
for( i= 0;i<5;i++){
res[i]=pro[i]+ num[i]+c;
if (res[i] >=
2){c = 1;
}
else{
c = 0;
}
res[i]=res[i]%2;
}
for(i= 4;i>= 0;i--){
pro[i] =
res[i];printf("%d",pro[i]);
}
printf(":");
for(i= 4;i>= 0;i--){
printf("%d",anumcp[i]);
}
}
voidarshift(){//forarithmeticshiftrighti
nttemp =pro[4],temp2=pro[0],i;
}
pro[4]=temp;
for (i = 1; i<5 ;i++){//shift the LSB of
productanumcp[i-1]=anumcp[i];
}
anumcp[4]=temp2;
printf("\nAR-SHIFT: ");//display
togetherfor(i= 4;i>= 0;i--){
printf("%d",pro[i]);
}
printf(":");
for(i =4;i>= 0;i--){
printf("%d",anumcp[i]);
}
}
void
main(){inti
,q=0;
printf("\t\tBOOTH'SMULTIPLICATIONALGORITHM");
printf("\nEntertwonumberstomultiply:");printf(
"\nBothmustbelessthan 16");
//simulating for two numbers each
below 16do{
printf("\nEnter A:
");scanf("%d",&a);
printf("EnterB:");
scanf("%d",&b);
subtractionarshift();
q=anum[i];
}
else{//add ans shift for
01printf("\n-->");
printf("\nADD B:
");add(bnum);
arshift();
q=anum[i];
}
}
printf("\nProduct is =
");for(i= 4;i>= 0;i--){
printf("%d",pro[i]);
}
for(i= 4;i>= 0;i--){
printf("%d",anumcp[i]);
}
}
Conclusion: Booths multiplication algorithm has studied and implemented successfully.
Output:
EXPERIMENT6
RESTORINGDIVISIONALGORITHM
Aim: ToimplementRestoringDivisionalgorithmusingCprogramminglanguage.
Software: Clanguage
Theory: Restoring division Restoring division operates on fixed-point fractional numbers
anddepends on the following assumptions: The following division methods are allbased on the
formQ= A/M
where
Q=Quotient
A=Numerator(dividend)
M=Denominator(divisor).
Step-1:Firsttheregistersareinitializedwithcorrespondingvalues(Q=Dividend,M=Divisor,A= 0,n =
number ofbitsin dividend)
Step-2:ThenthecontentofregisterAandQisshiftedleftasiftheyareasingleunit
Step-3:ThencontentofregisterMissubtractedfromAandresultisstoredinA
Step-
4:ThenthemostsignificantbitoftheAischeckedifitis0theleastsignificantbitofQissetto1otherwiseifitis1
theleastsignificantbitofQissetto0andvalueofregisterAisrestoredi.ethevalueofAbeforethesubtraction
withM
Step-5:Thevalueofcounternisdecremented
Step-6:Ifthevalueofnbecomeszerowegetoftheloopotherwisewerepeatfromstep2
Step-7:Finally,theregisterQcontainthequotientandAcontainremainder
Program:
/*ProgramforimplementingRestoringDivisionalgorithm.*/#include<stdio.h>#includ
e<math.h>
inta=0,b=0,c=0,com[5]={1,0,0,0,0},s=0;
intanum[5]={0},anumcp[5]={0},bnum[5]={0};
intacomp[5]={0},bcomp[5]={0},rem[5]={0},quo[5]={0},res[5]={0};
voidbinary(){
a=fabs(a);b=fabs(b);
intr,r2,i,temp; for(i=0;i<5;i++){
r=a%2;a=a
/2;r2=b%2;
b=b/2;anum[i]=r;anu
mcp[i]=r;bnum[i]=r2;
if(r2==0){
bcomp[i]=1;
}
if(r==0){
acomp[i]=1;
}
}
//partfortwo'scomplementingc=0;f
or(i=0;i<5;i++){
res[i]=com[i]+bcomp[i]+c;if(res[i]>=2){c=1
;
}
else
c=0;
res[i]=res[i]%2;
}
for(i=4;i>=0;i--){
bcomp[i]=res[i];
}
}
voidadd(intnum[]){inti;c=0;
for(i=0;i<5;i++){
res[i]=rem[i]+num[i]+c;
if(res[i]>=2){
c=1;
}
else
c=0;
res[i]=res[i]%2;
}
for(i=4;i>=0;i--){
rem[i]=res[i];printf("
%d",rem[i]);
}
printf(":");
for(i=4;i>=0;i--){
printf("%d",anumcp[i]);
}
}
voidshl(){//forshiftleftinti;
for(i=4;i>0;i--){//shifttheremainderrem[i]=rem[i-1];
}
rem[0]=anumcp[4];
for(i=4;i>0;i--){//shifttheremtientanumcp[i]=anumcp[i-1];
}
anumcp[0]=0;
printf("\nSHIFTLEFT:");//displaytogetherfor(i=4;i>=0;i--
){printf("%d",rem[i]);
}
printf(":");
for(i=4;i>=0;i--){
printf("%d",anumcp[i]);
}
}
voidmain(){
clrscr();inti;
printf("\t\tRESTORINGDIVISIONALGORITHM");
printf("\nEnter twonumbers tomultiply: ");printf("\nBoth
mustbelessthan16");
//simulatingfortwonumberseachbelow16do{
printf("\nEnterA:");s
canf("%d",&a);
printf("EnterB:");
scanf("%d",&b);
}while(a>=16||b>=16);
printf("\nExpectedQuotient
=%d",a/b);printf("\nExpectedRemainder=%d",a%b);if(a*b<0){
s=1;
}
binary();
printf("\n\nUnsignedBinaryEquivalentsare:");printf("\nA=");for(i=4;i>=0;i
--){
printf("%d",anum[i]);
}
printf("\nB=");
for(i=4;i>=0;i--){
printf("%d",bnum[i]);
}
printf("\nB'+1=");
for(i=4;i>=0;i--){
printf("%d",bcomp[i]);
}
printf("\n\n-->");
//divisionpartshl();for(i=0;i
<5;i++){
}
if(i<4)
}
anumcp[0]=1;
shl();printf("\n ");
printf("\nSignoftheresult=%d",s);printf("\nR
emainderis=");
for(i=4;i>=0;i--){
printf("%d",rem[i]);
}
printf("\nQuotientis=");for(i=4;i>=0;i--){
printf("%d",anumcp[i]);
}
getch();
}
Conclusion:Thus Restoring Division algorithm has been studied and implemented successfully.
Output:
EXPERIMENT 7
NON-RESTORINGDIVISIONALGORITHM
Aim: ToimplementNon-
RestoringDivisionalgorithmusingCprogramminglanguage.
Software: Clanguage
Theory:Non-restoringdivisionalgorithmisusedtodividetwounsignedintegers.Thisalgorithmis
different fromthe other algorithm becausehere, there is no conceptof restoration and
thisalgorithm is less complex than the restoring division algorithm. Algorithm for Non-
restoringdivisionisas givenbelow
Program:
/*CProgramForImplementationOfNon-RestoringDivision*/
#include<stdio.h>
#include<conio.h
>
inta[5]={0,0,0,0,0},q[4],b[5],b2c[5];
comp()
{
inti=4;
do
{
b2c[i
]=b[i
];i--;
}while(b[i+1]
!=1);
while(i>=0)
{
b2c[i]=(b[i]
+1)%2;i--;
}
printf("\n\tB'scomplement:");fo
r(i=0;i<
5;i++)printf("%d",b2c[i]);printf("
\n");
}
nonresdiv()
{
shiftleft();if(a
[0
]==0
)
a_minus_b();elsea
_plus_b(
);
q[3]=(a[0]+1)%2;
}
shiftleft()
{
int i;for(i=0;i<4;i++)
a[i]=a[i+1];a[4]=q[0];
for(i=0;i<3;i++)
q[i]=q[i+1];
}
a_minus_b()
{
inti,carry=0,sum
=0;
for(i=4;i>=0;i
--)
{
sum=(a[i]+b2c[i]+carry);a[i]
=sum%2;carry=sum/2;
}
}
a_plus_b()
{
inti,carry=0,sum
=0;
for(i=4;i>=0;i
--)
{
sum=(a[i]+b[i]+carry);a[i]=su
m%2;carry=sum/2;
}
}
voidmain()
{
inti,j,k;
clrscr();
printf("Enterdividend
inbinaryform\t:");for(i=0;i<4;i++)
scanf("%d",&q[i]);printf("Enter divisor
in binaryform\t:");for(i=0;i<5;i++)
scanf("%d",&b[i])
;comp();printf("\n\t[A]\t[M]
\n");for(i=0;i<4;i++)
{
nonresdiv()
;
printf("\t");for(j=0;j<5;
j++)
printf("%d"
,a[j]);
printf("\t");for(k=0;k<
4;k++)
printf("%d"
,q[k]);
printf("\n")
;
}
if(a[0
]==1
)
a_plus_b();printf("\t");for(
j=0;j<5;j++)
printf("%d",a[j]);
printf("\t");for(k=0;k<
4;k++)
printf("%d",q[k]);
printf("\n");printf("\n\tTheQu
otient Is\t:
");for(k=0;k<4;k++)
printf("%d",q[k]);printf("\n\tTheR
emainderIs\t: ");for(j=0;j<
5;j++)printf("%d",a
[j]);getch();
}
Conclusion:ThusNon-RestoringDivisionalgorithmhasbeenstudiedandimplementedsuccessfully.
Output:
ExperimentNo.08
Design of Arithmetic Logic Unit
OBJECTIVE:
1. Understandingbehaviorofarithmeticlogicunitfromworkingmoduleandthemoduledesignedby
thestudent aspartoftheexperiment.
2. Designinganarithmeticlogicunitforgivenparameter.
THEORY:
ALU or Arithmetic Logical Unit is a digital circuit to do arithmetic operations like addition,subtraction,
division, multiplication and logical operations like and, or, xor, nand, nor
etc.Asimpleblockdiagramofa4bitALUforoperationsand,or,xorandAddisshownhere
:
Design Issues:
Thecircuitfunctionalityofa1-
bitALUisshownhere,dependinguponthecontrolsignalS 1andS0thecircuitoperatesasfollows:
forControlsignalS1=0,S0=0,theoutputisAAndB,for
ControlsignalS1=1,S0=1,theoutput isAAdd B.
PROCEDURE:
Startthesimulatorasdirected.Thissimulatorsupports5-valuedlogic.
To design the circuit we need 4 1-bit ALU, 11 Bit switch (to give input, which
willtoggleitsvaluewithadoubleclick), 5Bitdisplays (forseeingoutput),wires.
Thepinconfigurationofacomponentisshownwheneverthemouseishoveredonany canned
component of the palette. Pin numbering starts from 1 and from thebottomleftcorner
(indicatingwiththecircle)andincreasesanticlockwise.
For1-bitALUinputA0isinpin-9,B0isinpin-10,C0isinpin-11(thisisinputcarry),for selection of
operation, S0 is in pin-12, S1 is in pin-13, output F is in pin-8 andoutputcarry is pin-7
Click on the 1-bit ALU component (in the Other Component drawer in the pallet)and then
click on the position of the editor window where you want to add thecomponent (no drag
and drop, simple click will serve the purpose), likewise add 3more 1-bit ALU (from the
Other Component drawer in the pallet), 11 Bit
switchesand5BitDisplays(fromDisplayandInputdrawerofthepallet,ifitisnotseenscrolldown
in the drawer), 3 digital display and 1 bit Displays (from Display and Inputdrawerof
thepallet, ifitisnot seenscrolldownin the drawer)
To connect any two components, select the Connection menu of Palette, and
thenclickontheSourceterminalandclickonthetargetterminal.Accordingtothe
circuit diagram connects all the components. Connect the Bit switches with theinputs and
Bit displays component with the outputs. After the connection is overclickthe selection
tool in thepallet.
See the output, in the screenshot diagram we have given the value of S1
S0=11whichwillperformaddoperationandtwonumber input asA0A1A2A3=0010andB0 B1
B2 B3=0100 so get output F0 F1 F2 F3=0110 as sum and 0 as carry
whichisindeedanaddoperation,youcanalsousemanyothercombinationsofdifferentvalues
and check the result. The operations are implemented using the truth tablefor4-
bitALUgiven in the theory.
Components:
Tobuildany4-bitALU,weneed:
ANDgate,ORgate,XORgate
FullAdder,
4-to-1 MUX<
Wirestoconnect.
OUTPUT:
CONCLUSION:ArithmeticLogicUnithasbeendesignedandsimulated.
ExperimentNo.09
Design Of4x3RAM
OBJECTIVE:Todesignmemoryunitsandunderstandhowitoperatesduringreadandwrite operation.
understandingbehaviorofmemoryfromworkingmoduleandthemoduledesignedby the
studentaspartoftheexperiment
designinganmemory forgivenparameter
THEORY:
A memory unit is a collection of storage cells together with associated circuits needed
totransform information in and out of the device. Memory cells which can be accessed
forinformation transfer to or from any desired random location is called random
accessmemory(RAM).Theblock diagramofamemoryunit-
InternalConstruction:Theinternalconstructionofarandom-accessmemoryofmwordswithn
bitsperwordconsists ofm*n binarystoragecellsand associateddecoding
circuitsforselectingindividualwords.Thebinarycellisthebasicbuildingblockofamemoryunit.
PROCEDURE:
1. Startthesimulatorasdirected.Thissimulatorsupports5-valuedlogic.
2. Todesignthecircuit,weneed12binaryRAMcell,9ORgate, 7-bitswitch (togiveinput,
which will toggle its value with a double click), 3-bit display (to see theoutput),
wires.
3. Thepinconfigurationofacomponentisshownwheneverthemouseishoveredonany
canned component of the palette or press the 'show pinconfig' button.
Pinnumbering starts from 1 and from the bottom left corner (indicated with the
circle)andincreasesanticlockwise.
4. For a binary RAM cell input is in pin-5, output is in pin-4 and select is pin-
8,Read/Write is in pin-6, for read operation give 1 input to Read/Write pin. For
writeoperationgive0input to Read/Writepin.
5. For a 'decoder with enable', input A is in pin-6, B is in pin-5, output D0 is in pin-
7. Toconnectanytwocomponents,selecttheConnectionmenuofPalette,andthenclickon
theSourceterminalandclickonthetargetterminal.Accordingtothecircuitdiagram
connect all the components, connect 2-bit switches to the inputs
ofthe'decoderwithenable'(whichwillactasaddressinput),1bitswitchtothe
enable pin of the 'decoder with enable' (which will act as memory enable input),connect a
bit switch to the Read/Write(R/W') line, 3-bit switches to the data inputsline, 3 bit displays
to the data output line and OR gates according to the diagramshown in the circuit
diagram. After the connection is over click the selection tool inthepallete.
8. Toseethecircuitworking,DosomereadorwriteoperationbyproperlysettingtheR/W',
memory enable then give input and check the output. suppose
yougive,R/W'=1,memoryenable=1,addressinput=01,datainput=101,thenitwillbear
eadoperationandyouwillnotsee101asoutput,itwillstore101intheword-
1. now again set, R/W'=0, memory enable=1, address input=01, then it will be
awriteoperationandyouwillsee101asthecontentofword-1ontheoutputdisplay.
OUTPUT:
CONCLUSION:A4*3RandomAccessMemoryhasbeendesignedandsimulated.
Experiment No.10
OBJECTIVE:
1. Understandingbehaviorofdirectmappedcachefromworkingmodule
2. Designingadirectmappedcacheforgivenparameters
THEORY:
Cache memory is a small (in size) and very fast (zero wait state) memory which sitsbetween the
CPU and main memory. The notion of cache memory actually rely on thecorrelation properties
observed in sequences of address references generated by CPUwhile executing a program
(principle of locality). When a memory request is generated,the request is first presented to the
cache memory, and if the cache cannot respond, therequestis thenpresented to mainmemory.
Hit:a cacheaccessfindsdataresidentin thecachememory
Miss: a cache access does not find data resident, so it forces to access the
mainmemory.
Cache treats main memory as a set of blocks. As the cache size is much smaller
thanmainmemorysothenumberofcachelinesareverylessthanthenumberofmainmemoryblocks. So
a procedure is needed for mapping main memory blocks into cache
lines.Cachemappingschemeaffectscostandperformance.Therearethreemethodsinblockplacemen
t-
DirectMappedCache
FullyAssociativeMappedCache
SetAssociativeMappedCache
DirectMappedCache
Agivenmemoryblockcanbemappedintooneandonlycacheline.
Block identification: let the main memory contains n blocks (which require log 2(n)) andcache
contains m blocks, so n/m different blocks of memory can be mapped (at differenttimes) to a
cache block. Each cache block has a tag saying which block of memory iscurrently present in it,
each cache block also contains a valid bit to ensure whether amemoryblock is
inthecacheblockcurrently.
Numberofbits inthetag:log2(n/m)
NumberofsetsintheCache:m
Numberofbitsto identifythecorrect set:log 2(m)
The memory address is divided into 3 parts- tag (most MSB), index, block
offset(mostLSB)inorder to do thecachemapping.
Selectsetusingindex,block fromsetusingtag.
Selectlocationfromblockusingblockoffset.
IfamissoccurCPUbringtheblockfromthemainmemorytothecache,ifthereis no free
block in the corresponding set it replaces a block and put the new one.CPU uses
different replacement policies to decide which block is to replace.
Thedisadvantage of the direct mapped cache is that it is easy to build, but suffer
themostfromthrashingdue tothe'conflictmisses'givingmoremiss penalty.
PROCEDURE:
To perform the experiment for Direct mapped cache, use the existing component 'DirectMapped
Cache' component in the 'other components' drawer in the simulator. Thissimulator supports 5-
valued logic. Below is a schematic diagram of the 'Direct
MappedCache'componentinthe'othercomponents'drawer inthesimulator:
OUTPUT: