Sidan # Address The Instruction space To work with a space we must - - PDF document

sidan
SMART_READER_LITE
LIVE PREVIEW

Sidan # Address The Instruction space To work with a space we must - - PDF document

Data representation String of bits! How do we represent data in a digital system? Everything we work with is represented as a string of bits . Digital data is stored as bits : Example: a bit is a binary number {0, 1} We don't work


slide-1
SLIDE 1

Sidan ‹#›

Computer Engineering InstrDataFormat page 1

Data representation

■ How do we represent data in a digital system? ■ Digital data is stored as bits: – a bit is a binary number {0, 1} – in a hardware design this is usually interpreted as

■ 0 Volt, GND ■ {5, 3.3, 1.8, … } Volt, VCC

Computer Engineering InstrDataFormat page 2

String of bits!

Everything we work with is represented as a string of bits. Example:

– We don't work with integers! – We represent (encode) integers as strings of bits and manipulate those.

1 0 1 0 (binary) represents 1*23 + 0*22 + 1*21 + 0*20 (decimal) 8 + 0 + 2 + 0 = 10 (decimal)

Computer Engineering InstrDataFormat page 3

Ask yourself:

■ How many bits are required to represent this thing? ■ How can we do it? – We need to structure the information.

Computer Engineering InstrDataFormat page 4

Word, halfword and byte

■ “The word: 32 bits”. ■ “The halfword: 16 bits”. ■ “The byte: 8 bits”.

31 15 7 Low order bit High order bit

Computer Engineering InstrDataFormat page 5

“The Space”

■ We can group a large number of bit strings into an

array called a space.

■ We use at least three spaces: – the register space. – the instruction space. – the data space. ■ Do not confuse them!

Computer Engineering InstrDataFormat page 6

The Register Space

(or Register “file”)

■ An array of words. ■ Smallest addressable unit is the word. ■ 32 choices, how do we select? – 2x = 32, x? – x=5 – i.e., we need 5 bits!

1 2 3 29 30 31

slide-2
SLIDE 2

Sidan ‹#›

Computer Engineering InstrDataFormat page 7

Address

■ To work with a space we must be able to address the

elements of the space.

■ Each space may have a different address method.

Computer Engineering InstrDataFormat page 8

The Instruction space

(or instruction memory)

■ An array of bytes. ■ Smallest addressable unit is a byte, but

the smallest accessible unit is a word.

■ 232 bytes gives 230 accessible words.

Computer Engineering InstrDataFormat page 9

What's that mean?

■ An instruction address is 32 bits long. ■ Same as a word. ■ An instruction address fits into a word!

Computer Engineering InstrDataFormat page 10

But:

■ Only every fourth address is legal. ■ The ones whose last two bits are “00”. ■ We can access 230 instructions.

Computer Engineering InstrDataFormat page 11

Instruction memory 1

■ Address “4”:

0000........00100

■ Hardware accesses an entire 32-bit word.

3 2 1 4 7 6 5 8 11 10 9 12 15 14 13 Computer Engineering InstrDataFormat page 12

Instruction memory 2

■ Address "3":

0000........00011

■ The hardware will complain! ■ This is called an “alignment error”. ■ The address was not “word aligned”.

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

slide-3
SLIDE 3

Sidan ‹#›

Computer Engineering InstrDataFormat page 13

Byte order

Addr 0 Addr 3 Addr 2 Addr 1

■ Big endian ■ Little endian

Byte 0 Byte 1 Byte 2 Byte 3 Addr 0 Addr 3 Addr 2 Addr 1 Byte 3 Byte 2 Byte 1 Byte 0 Computer Engineering InstrDataFormat page 14

Instruction memory 3

■ An instruction is represented by 32 bits. ■ There are two “instruction formats”. (Not the whole truth, but don't worry about it)

3 2 1 4 7 6 5 8 11 10 9 12 15 14 13 Computer Engineering InstrDataFormat page 15

Instruction formats

Remember:

– Never immediate field together with rd-field. – Immediate field is only 16 bits!

Opcode rs rt rd Opcode rs rt Immediate Format 1 (reg) Format 2 (imm) 6 bits 5 5 5 6 bits 5 5 16

Computer Engineering InstrDataFormat page 16

“Data space”

■ 232 bytes, byte addressable, byte accessible. ■ A data address fits into 32 bits. ■ Halfword accesses must be halfword aligned;

(low order bit = 0).

■ Word accesses must be word aligned;

(low order 2 bits = 0).

Computer Engineering InstrDataFormat page 17

Review - How many bits??

■ Instruction address

?

■ Instruction

?

– Immediate field

?

– Register address

?

■ Register

?

■ Data address

?

■ Data

?

Computer Engineering InstrDataFormat page 18

Review - How many bits??

■ Instruction address

32, word aligned

■ Instruction

32

– Immediate field

16

– Register address

5

■ Register

32

■ Data address

32, byte aligned

■ Data

8 (byte) 16 (halfword) 32 (word)

slide-4
SLIDE 4

Sidan ‹#›

Computer Engineering InstrDataFormat page 19

Questions?

Feedback from the lectures: Per.Lindgren@ltu.se