23
SISTEMI EMBEDDED Basic Concepts about Computers Federico Baronti Last version: 20170307

01a Basic Concepts - unipi.it

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 01a Basic Concepts - unipi.it

SISTEMIEMBEDDED

BasicConceptsaboutComputers

FedericoBaronti Lastversion:20170307

Page 2: 01a Basic Concepts - unipi.it

EmbeddedSystemBlockDiagram

EmbeddedSystem

Processor

Device/Equipmenttobecontrolled

Memory

Peripherals

EmbeddedComputer

Actuator

Actuator

Indicator

DRIVER

SENSO

RCO

NDITIONING

Sensor

Sensor

Sensor

OutputInput

Page 3: 01a Basic Concepts - unipi.it

FunctionalUnitsofaComputer

Page 4: 01a Basic Concepts - unipi.it

InstructionsandPrograms

• Aninstruction specifiesanoperationandthelocationsofitsdataoperands

• A32-bitwordtypicallyholdsoneencodedinstruction

• Asequenceofinstructions,executedoneafteranother,constitutesaprogram

• Bothaprogramanditsdata arestoredin themainmemory

Page 5: 01a Basic Concepts - unipi.it

Instructiontypes

• Fourbasicinstructiontypes:– Load: Readadataoperandfrommemoryoraninputdeviceintotheprocessor

– Store: Writeadataoperandfromaprocessorregistertomemoryoranoutputdevice

– Operate: Performanarithmeticorlogicoperationondataoperandsinprocessorregisters

– Branch: Alter,ifaconditionisverified,thesequentialexecutionoftheinstructions

Page 6: 01a Basic Concepts - unipi.it

ProgramExample• A,B,andC,arelabels representingmemorywordaddresses;Ri areprocessorregisters

• Aprogram forthecalculationC=A+B

is:

Load R2,ALoad R3,BAdd R4,R2,R3Store R4,C

Page 7: 01a Basic Concepts - unipi.it

MainProcessorElements(1)

• Theprogram counter (PC)registerholdsthememoryaddressofthecurrentinstruction

• Theinstruction register (IR)holdsthecurrentinstruction

• General-purpose registers holddataandaddresses

• Control circuits andthearithmeticandlogicunit(ALU)fetchandexecuteinstructions

Page 8: 01a Basic Concepts - unipi.it

MainProcessorElements(2)

Page 9: 01a Basic Concepts - unipi.it

Fetchingandexecutinginstructions

Example: Load R2,LOC

Theprocessorcontrolcircuitsdothefollowing:

• SendaddressinPCtomemory;issueRead• LoadinstructionfrommemoryintoIR• IncrementPCtopointtonextinstruction• SendaddressLOCtomemory;issueRead• LoadwordfrommemoryintoregisterR2

Page 10: 01a Basic Concepts - unipi.it

RepresentationofInformation• Whateveristhesourceofinformation,dataarerepresentedbyastringofbits(usuallyinanumbermultipleof8,i.e.,1BYTE)

• AnarrayofbitsdirectlyrepresentsaNaturalnumberinbase2 (positionalbinarynotation)– B=bn-1…b1b0 representsthenumberV(B)=bn-1x2n-1 +... b1x21+b0x20

• AnyotherinformationcanbeencodedbyaNaturalusingaspecificrepresentation– E.g.signednumbers,floatingpointnumbers,chars,…

– Representationstypicallyuse1,2,4,8BYTES

Page 11: 01a Basic Concepts - unipi.it

SignedNumbers(1)

Forsignedintegers,theleftmostbit(MSB)containsthesigninformation:0 forpositive1 fornegative

Therearethreewaystorepresentsignedintegers:

• Signandmagnitude• 1’scomplement• 2’scomplement(theMSBhasweight-2n-1)

Page 12: 01a Basic Concepts - unipi.it

SignedNumbers(2)

Page 13: 01a Basic Concepts - unipi.it

SignedNumbers(3)2’s-complementrepresentationisusedincurrentcomputers

Considerafour-bitsignedintegerexample,wherethevalue+5isrepresentedas:0101

Toformthevalue-5,complementallbitsof0101 toobtain 1010andthenadd1toobtain1011

Page 14: 01a Basic Concepts - unipi.it

SignedNumbers(4)

Replicatethesignbittoextend4-bitsignedintegersto8-bitsignedintegers

0101 00000101

1110 11111110

Page 15: 01a Basic Concepts - unipi.it

CharacterEncoding• AmericanStandardCodeforInformationInterchange(ASCII)

• Uses7-bitcodes(extendedversion1BYTE)• Someexamples:

characterbinarycode(decimal,0xhexadecimal)A 100 0001 (65,0x41)a 110 0001 (97,0x61)0 011 0000(48, 0x30)1 011 0001(49,0x31)9 0111001(57,0x39)

Page 16: 01a Basic Concepts - unipi.it
Page 17: 01a Basic Concepts - unipi.it

MemoryOrganization

• Memoryconsistsofmanymillionsofcells– Eachcellholdsabitofinformation,0or1

• Informationisusuallyhandledinlargerunits:bytesorwords

• Aword isagroupofn bytes• Wordlengthcanbe16,32or64bits• Memory canbeseenaseitheracollectionofconsecutivebytesorwords(ofthesizespecifiedbythewordlength)

Page 18: 01a Basic Concepts - unipi.it

WordandByteEncoding

• Acommonwordlengthis32bits• Suchawordcanstorea32-bitsignedintegerorfour8-bitbytes(e.g.,ASCIIcharacters)

• Wordsinmemorymaystoredataormachineinstructionsforaprogram

• Eachmachineinstructionmayrequireone(ormoreconsecutivewordsforencoding)

Page 19: 01a Basic Concepts - unipi.it

AddressesforMemoryLocation

• Tostoreorretrieveitemsofinformation,eachmemorylocationhasadistinctaddress

• Numbers0to2k - 1areusedasaddressesforsuccessivelocationsinthememory

• The2k locationsconstitutetheaddressspace• Memorysizesetbyk (numberofaddressbits)• Examples: k = 20 ® 220 or1Mlocations,

k = 32 ® 232 or4Glocations

Page 20: 01a Basic Concepts - unipi.it

ByteAddressability

• Bytesizeisalways8bits• Butwordlengthmayrangefrom16to64bits• Abyte-addressable memoryassignsanaddresstoeachbyte

• Bytelocationshaveaddresses0,1,2,…• Assumingthatthewordlengthis32bits,wordlocationshaveaddresses0,4,8,…

Page 21: 01a Basic Concepts - unipi.it

Big- Little-Endianess

• Twowaystoassignbyteaddressacrosswords• Big-endian addressingassignsloweraddressestomoresignificant(leftmost)bytesofword

• Little-endian addressingusesoppositeorder• Commercialcomputersuseeitherapproach,andsomecansupportbothapproaches

• Addressesfor32-bitwordsarestill0,4,8,…• Bitsineachbytelabeledb7 …b0,lefttoright

Page 22: 01a Basic Concepts - unipi.it
Page 23: 01a Basic Concepts - unipi.it

WordAlignment

• #ofbytesperwordisnormallyapowerof2• Wordlocationshavealigned addressesiftheybeginatbyteaddressesthataremultiplesofthenumberofbytesinaword

• Examplesofalignedaddresses:2bytesperword® 0,2,4,…8bytesperword® 0,8,16,…

• Somecomputerspermitunalignedaddresses