sembt4 arch cpu

Upload: joao-moreira

Post on 04-Jun-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Sembt4 Arch Cpu

    1/79

    RMR2012

    Maths is not everything

  • 8/13/2019 Sembt4 Arch Cpu

    2/79

    RMR2012

    Maths is not everything

  • 8/13/2019 Sembt4 Arch Cpu

    3/79

    RMR2012

    Maths is not everything

    200

    8WayneWolf

    3

  • 8/13/2019 Sembt4 Arch Cpu

    4/79

    RMR2012

    Maths is not everything

    200

    8WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    5/79

    CPU

    PC

    200

    RMR2012

    Maths is not everything

    200

    8WayneWolf

    memory

    address

    IR

    data

    ADD r5,r1,r3200

    ADD r5,r1,r3

  • 8/13/2019 Sembt4 Arch Cpu

    6/79

    RMR2012

    Maths is not everything

    200

    8WayneWolf

    CPU

    PC

    data memory

    program memory

    address

    data

    address

    data

  • 8/13/2019 Sembt4 Arch Cpu

    7/79

    RMR2012

    Maths is not everything

    200

    8WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    8/79

    RMR2012

    Maths is not everything

    200

    8WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    9/79

    RMR2012

    Maths is not everything

    200

    8WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    10/79

    RMR2012

    Maths is not everything

    200

    8WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    11/79

    RMR2012

    Maths is not everything

    200

    8WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    12/79

    RMR2012

    Maths is not everything

    2008WayneWolf

    header LDR r1,[r4]

    SUB r0,r0,r1 ;3 addresses instruction MOV sp,#INIT_SP ; set-up stack pointer ADR lr, start+1 ; Processor starts in ARM state,

    BX lr ; so small ARM code header used; to call Thumb main program.

    CODE16 ; Subsequent instructions are Thumb.

    start

    ;**********************************************************************;* This an example of 16 bits code (Thumb mode);**********************************************************************

    BL irq_init ; init. interruptsforever BL seg_rot ; check display of hex digits MOV r0,#0xf

    BL leds_on ; sw on the ledschksw0 BL sw_rd ; read DIP_SW port, r0 carries word AND r0,r0 ; check if any DIP_SW has been mod. BEQ chksw0 ; if not, keep checking

  • 8/13/2019 Sembt4 Arch Cpu

    13/79

    RMR2012

    Maths is not everything

    2008WayneWolf

    MOV.w #0x05,R5 ; move source to destination

    ; assign a hexadecimal value 0x05 to Register R5

    MOV.w #0x03,R6 ; move source to destination

    ; assign a hexadecimal value 0x03 to Register R6

    CMP.w R6, R5 ; compare source to destination

    ; R5-R6 = 5-3 = 2 greater than 0, so R5 > R6

    JNEsomewhere ; jump if not equal

    ; The program will jump to somewhere because R5 "R6

  • 8/13/2019 Sembt4 Arch Cpu

    14/79

    RMR2012

    Maths is not everything

  • 8/13/2019 Sembt4 Arch Cpu

    15/79

    RMR2012

    Maths is not everything

  • 8/13/2019 Sembt4 Arch Cpu

    16/79

    RMR2012

    Maths is not everything

  • 8/13/2019 Sembt4 Arch Cpu

    17/79

    RMR2012

    Maths is not everything

    6

  • 8/13/2019 Sembt4 Arch Cpu

    18/79

    RMR2012

    Maths is not everything

    2008WayneWolf

    r0

    r1

    r2r3

    r4

    r5

    r6

    r7

    r8

    r9

    r10r11

    r12

    r13r14

    link reg. in BL

    r15 (PC)

    CPSR

    31 0

    N Z C V

    Status Register

    sp for procedure linkage

  • 8/13/2019 Sembt4 Arch Cpu

    19/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    20/79

    RMR2012

    Maths is not everything

    2008WayneWolf

    byte 3 byte 2 byte 1 byte 0 byte 0 byte 1 byte 2 byte 3

    bit 31 bit 0 bit 31 bit 0

    little-endian big-endian

  • 8/13/2019 Sembt4 Arch Cpu

    21/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    22/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    23/79

    RMR2012

    Maths is not everything

    2008WayneWolf

    15

    Processor CoreThe engine that fetches instructions and execute themE.g.: ARM7TDMI, ARM9TDMI, ARM9E-S

    CPU CoreConsists of the ARM processorcore and some tightly coupledfunction blocks

    Cache and memorymanagement blocks

    E.g.: ARM710T, ARM720T,ARM74T, ARM920T, ARM922T,ARM940T, ARM946E-S, andARM966E-S ARM710T

  • 8/13/2019 Sembt4 Arch Cpu

    24/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    25/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    26/79

    RMR2012

    Maths is not everything

    2008WayneWolf

    AND, ORR, EOR

    BIC : bit clear

    LSL, LSR : logical shiftleft/right

    ASL, ASR : arithmetic

    shift left/right

    ROR : rotate rightRRX : rotate right

    extended with C

  • 8/13/2019 Sembt4 Arch Cpu

    27/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    28/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    29/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    30/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    31/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    32/79

    RMR2012

    Maths is not everything

    2008WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    33/79

    RMR2012

    Maths is not everything

    20

    08WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    34/79

    RMR2012

    Maths is not everything

    20

    08WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    35/79

    RMR2012

    Maths is not everything

    20

    08WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    36/79

    RMR2012

    Maths is not everything

    20

    08WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    37/79

  • 8/13/2019 Sembt4 Arch Cpu

    38/79

    RMR2012

    Maths is not everything

    20

    08WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    39/79

    RMR2012

    Maths is not everything

    20

    08WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    40/79

  • 8/13/2019 Sembt4 Arch Cpu

    41/79

  • 8/13/2019 Sembt4 Arch Cpu

    42/79

    RMR2012

    Maths is not everything

    20

    08WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    43/79

    RMR2012

    Maths is not everything

    20

    08WayneWolf

  • 8/13/2019 Sembt4 Arch Cpu

    44/79

    RMR2012

    Maths is not everything

  • 8/13/2019 Sembt4 Arch Cpu

    45/79

    RMR2012

    Maths is not everything

    45

  • 8/13/2019 Sembt4 Arch Cpu

    46/79

    RMR2012

    Maths is not everything

    46

  • 8/13/2019 Sembt4 Arch Cpu

    47/79

    RMR2012

    Maths is not everything

    47

  • 8/13/2019 Sembt4 Arch Cpu

    48/79

    RMR2012

    Maths is not everything

    48

    Carry bitC

    Zero bitZ

    Negative bitN

    General interrupt enableGIE

    Turns off the CPU.CPUOFF

    Oscillator offOSCOFF

    Turns off the DCO dc generator.SCG0

    Turns off the SMCLK.SCG1

    Overflow bitV

    R3 (CG2) Constant Generator

    R4-R15 General Purpose registers

  • 8/13/2019 Sembt4 Arch Cpu

    49/79

    RMR2012

    Maths is not everything

    49

  • 8/13/2019 Sembt4 Arch Cpu

    50/79

    RMR2012

    Maths is not everything

    50

  • 8/13/2019 Sembt4 Arch Cpu

    51/79

    RMR2012

    Maths is not everything

    51

  • 8/13/2019 Sembt4 Arch Cpu

    52/79

    RMR2012

    Maths is not everything

    52

  • 8/13/2019 Sembt4 Arch Cpu

    53/79

    RMR2012

    Maths is not everything

    53

  • 8/13/2019 Sembt4 Arch Cpu

    54/79

    RMR2012

    Maths is not everything

    54

  • 8/13/2019 Sembt4 Arch Cpu

    55/79

    1111

    1110

    1101

    1100

    1011

    1010

    10011000

    0111

    0110

    0101

    0100

    0011

    0010

    0001

    0000

    4 to 16

    Decoder

    Op-code Op-code Instruction Format

    0000 UndefinedSingle Operand

    0001 RCC, SWPB, RRA, SXT, PUSH, CALL, RETI

    0010 JNE, JEQ, JNC, JCJumps

    0011 JN, JGE, JL, JMP

    0100 MOV

    Double Operand

    0101 ADD

    0110 ADDC

    0111 SUBC1000 SUB

    1001 CMP

    1010 DADD

    1011 BIT

    1100 BIC

    1101 BIS

    1110 XOR

    1111 ANDRMR2012

    Maths is not everything

    55

    Memory0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0 mov.w r5,r4

    0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 rrc.w r5

    0 0 1 0 1 1 1 1 1 1 1 0 0 1 0 0 jc main

    0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 mov.w #0x0600,r1

    0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0

    PC

    Instruction Register15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

    0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0

  • 8/13/2019 Sembt4 Arch Cpu

    56/79

    RMR2012

    Maths is not everything

    56

  • 8/13/2019 Sembt4 Arch Cpu

    57/79

    RMR2012

    Maths is not everything

    57

    15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

    Op-code S-reg Ad b/w As D-reg

    15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

    Op-code b/w Ad D/S-reg

    15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

    Op-code Condition 10-bit, 2s complement PC offset

  • 8/13/2019 Sembt4 Arch Cpu

    58/79

    RMR2012

    Maths is not everything

    58

    Mnemonic Operation Description

    Arithmetic instructionsADD(.B or .W) src,dst src+dstdst Add source to destinationADDC(.B or .W) src,dst src+dst+Cdst Add source and carry to destinationDADD(.B or .W) src,dst src+dst+Cdst (dec) Decimal add source and carry to destinationSUB(.B or .W) src,dst dst+.not.src+1

    dst Subtract source from destinationSUBC(.B or .W) src,dst dst+.not.src+Cdst Subtract source and not carry from destinationLogical and register control instructions

    AND(.B or .W) src,dst src.and.dstdst AND source with destinationBIC(.B or .W) src,dst .not.src.and.dstdst Clear bits in destinationBIS(.B or .W) src,dst src.or.dstdst Set bits in destinationBIT(.B or .W) src,dst

    src.and.dst

    Test bits in destination

    XOR(.B or .W) src,dst src.xor.dstdst XOR source with destinationData instructionsCMP(.B or .W) src,dst dst-src Compare source to destination

    MOV(.B or .W) src,dst srcdst Move source to destination

  • 8/13/2019 Sembt4 Arch Cpu

    59/79

  • 8/13/2019 Sembt4 Arch Cpu

    60/79

    RMR2012

    Maths is not everything

    60

    Mnemonic Operation Description

    Logical and register control instructions

    RRA(.B or .W) dst MSBMSB!LSBC

    Roll destination right

    RRC(.B or .W) dst CMSB!LSBC Roll destination right through carrySWPB( or .W) dst Swap bytes Swap bytes in destination

    SXT dst bit 7bit 8!bit 15 Sign extend destinationPUSH(.B or .W) src SP-2SP, src@SP Push source on stackProgram flow control instructions

    CALL(.B or .W) dst SP-2SP,PC+2@SPdstPC

    Subroutine call to destination

    RETI @SP+SR, @SP+SP Return from interrupt

  • 8/13/2019 Sembt4 Arch Cpu

    61/79

    RMR2012

    Maths is not everything

    61

    Op-coderrc

    b/w16-bits

    AdRegister

    D-regr5

    0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1

  • 8/13/2019 Sembt4 Arch Cpu

    62/79

    RMR2012

    Maths is not everything

    62

    15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

    Op-code Condition 10-bit, 2s complement PC offset

  • 8/13/2019 Sembt4 Arch Cpu

    63/79

    RMR2012

    Maths is not everything

    63

  • 8/13/2019 Sembt4 Arch Cpu

    64/79

    RMR2012

    Maths is not everything

    64

    Op-codeJC

    ConditionCarry Set

    10-Bit, 2s complement PC offset

    -28

    0 0 1 0 1 1 1 1 1 1 1 0 0 1 0 0

  • 8/13/2019 Sembt4 Arch Cpu

    65/79

    RMR2012

    Maths is not everything

    65

  • 8/13/2019 Sembt4 Arch Cpu

    66/79

    RMR2012

    Maths is not everything

    66

  • 8/13/2019 Sembt4 Arch Cpu

    67/79

    RMR2012

    Maths is not everything

    67

    add.w r4,r10 ;r10 = r4 + r10

    Registers

    CPUMemory

    ADDER

    PCPC

    R10

    R4

    IRDataBus(1cycle) 0x540a

    0x540a

    Addres

    sBus

    PC

    ALU

  • 8/13/2019 Sembt4 Arch Cpu

    68/79

  • 8/13/2019 Sembt4 Arch Cpu

    69/79

  • 8/13/2019 Sembt4 Arch Cpu

    70/79

    Memory

    Registers

    DataBus(+1cycle)

    CPU

    ADDER

    PCPC

    R10

    R4

    IRDataBus(1cycle) 0x543a

    Addres

    sBus

    PC0x543a

    Ad

    dress

    Bus

    0002

    ALU

    RMR2012

    Maths is not everything

    70

    add.w @r4+,r10 ;r10 = M(r4+) + r10

  • 8/13/2019 Sembt4 Arch Cpu

    71/79

    Memory

    Registers

    AddressBus

    DataBus(+1cycle)

    DataBus(+1cycle)

    CPU

    ADDER

    0x000cPCPC

    PC

    PC

    R10

    IRDataBus(1cycle) 0x501a

    Addres

    sBus

    0x501aPC

    ALU

    RMR2012

    Maths is not everything

    71

    add.w cte,r10 ;r10 = M(cte) + r10

  • 8/13/2019 Sembt4 Arch Cpu

    72/79

    Memory

    Registers

    AddressBus

    DataBus(+1cycle)

    DataBus(+1cycle)

    CPU

    ADDER

    0000

    0xc018PCPCPC

    R10

    IRDataBus(1cycle) 0x521a

    Addres

    sBus

    0x521aPC

    ALU

    RMR2012

    Maths is not everything

    72

    add.w &cte,r10 ;r10 = M(cte) + r10

  • 8/13/2019 Sembt4 Arch Cpu

    73/79

    Memory

    Registers

    CPU

    ADDER

    PCPC

    PC

    R10

    DataBus(+1cycle)

    IRDataBus(1cycle) 0x503a

    Addres

    sBus

    PC0x503a

    0x0064

    ALU

    RMR2012

    Maths is not everything

    73

    add.w #100,r10 ;r10 = #100 + r10

  • 8/13/2019 Sembt4 Arch Cpu

    74/79

    Memory

    Registers

    CPU

    ADDER

    PCPC

    R10

    0000

    0001

    0002

    0004

    0008

    ffff

    IRDataBus(1cycle) 0x531a

    Addres

    sBus

    PC0x531a

    ALU

    RMR2012

    Maths is not everything

    74

    add.w #1,r10 ;r10 = #1 + r10

  • 8/13/2019 Sembt4 Arch Cpu

    75/79

    Memory

    Registers

    AddressBus

    Data Bus (+1 cycle)

    DataBus(+1cycle)

    CPU

    ADDER

    0x000c

    PCPC

    PC

    Address Bus

    Data Bus (+1 cycle)

    DataBus(+1cycle)

    PC Data Bus (+1 cycle)0x0218

    IRDataBus(1cycle) 0x501a

    Addres

    sBus

    0x501a PCPC

    ALU

    RMR2012

    Maths is not everything

    75

    add.w cte,var ;var = M(cte) + M(var)

  • 8/13/2019 Sembt4 Arch Cpu

    76/79

  • 8/13/2019 Sembt4 Arch Cpu

    77/79

    RMR2012

    Maths is not everything

    77

  • 8/13/2019 Sembt4 Arch Cpu

    78/79

    Example Src Dst Cycles Length

    add R5,R8 Rn Rm 1 1

    add @R5,R6 @Rn Rm 2 1

    mov @R5+,R0 @Rn+ PC 3 1add R5,4(R6) Rn x(Rm) 4 2

    add R8,EDE Rn EDE 4 2

    add R5,&EDE Rn &EDE 4 2

    add #100,TAB(R8) #n x(Rm) 5 3

    add &TONI,&EDE &TONI &EDE 6 3

    add #1,&EDE #1 &EDE 4 2RMR2012

    Maths is not everything

    78

  • 8/13/2019 Sembt4 Arch Cpu

    79/79