+ All Categories
Home > Documents > Basic Computer System

Basic Computer System

Date post: 18-Dec-2021
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
18
Basic Computer System (c) Bharadwaj V Dept of ECE NUS (2013) 1 RAM CPU I/O Devices (or) Peripeherals MEMORY DMA Direct Memory Access controller External Unit External External units
Transcript

BasicComputerSystem

(c)BharadwajVDeptofECENUS(2013) 1

RAM CPU

I/ODevices(or)PeripeheralsMEMORY DMA

DirectMemoryAccesscontroller

ExternalUnit External

Externalunits

Binarynumbersystem…Quickreview

(c)BharadwajVDeptofECENUS(2013) 2

BinaryNumbersystem-Oand1representa8on

Example:(Decimal)42=4x101+2x100Weknowthis!J(Binary)42=1x25+0x24+1x23+0x22+1x21+0x20

=32+8+2SothepaVernwillbe:101010(Verifythereverse!)Hence:Withjust2digits–YY–{0,1,2,3}–4dis_nctnumbersWithjust3digits–YYY–{0,1,…,7}–8dis_nctnumbersWithjust4digits–YYYY–{0,1,2,…,15}–16dis_nctnumbers…Withkdigits:(YYYY….YY)–{0,1,….,2k-1}–(2k)dis_nctnumbers

Binarynumbersystem…Quickreview

(c)BharadwajVDeptofECENUS(2013) 3

Hexa-decimal–ValidNumbers:{0,1,…,15}andtheyarerepresentedas

{0,1,2…,9,A,B,C,D,E,F}Example:(Hexa-Decimal)42=2x161+10x160(=32+10)SothepaVernwillbe:2A(Verifythereverse!)Weusuallyrepresentahexadecimalnumberas‘2AH’;Hence:4E8H=1024+224+8=1256(decimal)

ComputerSystem…Cont’d

(c)BharadwajVDeptofECENUS(2013) 4

RAM...

1Byte=8Bits(eachslot)

Addressing:EachslothasauniqueaddressAddressisrepresentedasabinarywordRAM8Slotsimpliesweneed3bitnumberrepresen_ng(addressing)eachslot;RAM16Slotsimpliesweneed4bitnumberrepresen_ng(addressing)eachslot;

01001010

LeastSignificantBit(LSB)MostSignificantBit(MSB)

01001010-ThispaVernisrepresentedasahexa-decimalnumber4AintheMemoryfortheeaseofreading

(c)BharadwajVDeptofECENUS(2013) 5

ComputerSystem…Cont’d

APPLICATION

COMPUTERPROGRAM(Languages–C/C++/Java/Assembly…)

MODELING(Mathema_cal/Sta_s_cal/Empirical,etc)

Compile–Link–ExecutableàRun!

Howdoesourprogramgetexecuted?Whatdowemeanby“running”aprogram?

(c)BharadwajVDeptofECENUS(2013) 6

Programmustbebroughttothememory(RAM)forExecu_on;Eachlineoftheprogramwillbetranslatedintoasetofmachineinstruc-ons(0’sand1’s)andallinstruc_onsarestoredinRAMinacon_guousorder;Instruc_onsarefetchedfromRAM,oneata_me,andgetexecutedintheCPU;Allsuchinstruc_onswillliveinthememoryun_ltheen_reprogramgetsexecuted;

ProgramExecu_on/Running

(c)BharadwajVDeptofECENUS(2013) 7

ProgramExecu_on/Running…(Cont’d)

prins(“MynameisBV\n”);/*Csyntax*/

101010111100010101010010100111101100

Example

Morethan1byte!!

101010111100010101010010100111101100

Hence,

Inthiscase,thisinstruc_onoccupies5bytes;Thelast4mostsignificantbitswillbepaddedwith0s.

ControlStructuresn  Analgorithmisasetofinstruc_ons,whicharefollowedsequen_allybydefault.

n  However,some_mesweneedtochangethedefaultsequen_alflow.

n  Wewillstudy3controlstructuresusedpredominantlyinprogramming

-Sequence -Selec_on -Repe__on

(c)BharadwajVDeptofECENUS(2017) ACK:ThanksDr.Alanforcontrolstructuresslides

True False? True

False ?

ControlStructures:Sequence

©NUS

n  Task:Computetheaverageofthreeintegers

Eachboxrepresentsavariable.Importantconcepts:Eachvariablehasauniquenameandcontainsavalue.

Apossiblealgorithm:

entervaluesfornum1,num2,num3aveß(num1+num2+num3)/3printave

Variablesused:num1 num2 num3

ave

Anotherpossiblealgorithm:

entervaluesfornum1,num2,num3totalß(num1+num2+num3)aveßtotal/3printave

Variablesused:num1 num2 num3

ave

total

(c)BharadwajVDeptofECENUS(2017)

ControlStructures:Selec_on

©NUS

n  Task:Arrangetwointegersinascendingorder(sort)AlgorithmA:

entervaluesfornum1,num2//Assignsmallernumberintofinal1,//andlargernumberintofinal2if(num1<num2)

then final1ßnum1 final2ßnum2

else final1ßnum2 final2ßnum1//Transfervaluesinfinal1,final2backtonum1,num2num1ßfinal1num2ßfinal2//Displaysortedintegersprintnum1,num2

Variablesused:

num1 num2

final1 final2

True False?

(c)BharadwajVDeptofECENUS(2017)

ControlStructures:Repe__on

©NUS

n  Task:Findsumofposi_veintegersupton(assumen>0)

Algorithm:entervalueforn /*Ini8aliseacountercountto1,andansto0*/countß1ansß0

REPEAT_UNTIL(count<=n)do ansßans+count //addcounttoans

countßcount+1 //increasecountby1//Displayanswerprintans

Variablesused:

n

count

ans

Ini_alisa_onisveryimportant!

True

False?

(c)BharadwajVDeptofECENUS(2017)

Algorithm

©NUS

n  Analgorithmisawell-definedcomputa_onalprocedureconsis_ngofasetofinstrucCons,thattakessomevalueorsetofvaluesasinput,andproducessomevalueorsetofvaluesasoutput.

‘Algorithm’stemsfrom‘Algoritmi’,theLa_nformofal-Khwārizmī,aPersianmathema_cian,astronomerandgeographer.Source:hVp://en.wikipedia.org/wiki/Algorithm

(c)BharadwajVDeptofECENUS(2017)

Inputs Output(s)

Algorithm

Algorithm

©NUS

n  Waysofrepresen_nganalgorithm:

Flowchart Pseudocode

lynda.com

(c)BharadwajVDeptofECENUS(2017)

Flow-Charts

14(c)BharadwajVDeptofECENUS(2013)

• VisualRepresenta_onofthework-flow/process-flow

• Pre-definedsymbolsandrepresenta_onsthatcapturetheflow• TypicallystartswithaSTARTblockandendswithanENDblock• Forverylargeflow-chartsconnectorsaregenerallyused

Flow

-cha

rtsC

ont’d

(c)BharadwajVDeptofECENUS(2013) 15

Flow-Chart/Algorithm:Example1

©NUS (c)BharadwajVDeptofECENUS(2017)

(c)BharadwajVDeptofECENUS(2013) 17

Example2-Flow-Chart/Algorithm

START

END

x,y,z=0

Computethevaluesusingfunc_ons:

F(x,y),G(y,z)andH(x,z)

IsG(y,z)>

F(x,y)?

UpdatexusingQ(x)

DecreaseyusingP(y)

Displaythefunc_onvalues

YES

NO

Systema_cdesignprocessinvolvesdrawingflow-charts/wri_ngpseudocodesYoushoulddrawflow-chartsinallthethreelabassignmentswhichreflectsyourdesign;Drawingflow-chartcarriesmarks.

(c)BharadwajVDeptofECENUS(2013) 18


Recommended