1 / 19

Data representation

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. String of bits!.

Download Presentation

Data representation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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

  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)

  3. Ask yourself: • How many bits are required to represent this thing? • How can we do it? • We need to structure the information.

  4. Word, halfword and byte • “The word: 32 bits”. • “The halfword: 16 bits”. • “The byte: 8 bits”. 31 0 High order bit Low order bit 0 15 0 7

  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!

  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! 0 1 2 3 29 30 31

  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.

  8. The Instruction space (or instruction memory) • An array of bytes. • Smallest addressable unit is a byte, butthe smallest accessible unit is a word. • 232 bytes gives 230 accessible words.

  9. What's that mean? • An instruction address is 32 bits long. • Same as a word. • An instruction address fits into a word!

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

  11. Instruction memory 1 0 1 2 3 • Address “4”: 0000........00100 • Hardware accesses an entire 32-bit word. 4 5 6 7 8 9 10 11 12 13 14 15

  12. Instruction memory 2 0 1 2 3 • Address "3": 0000........00011 • The hardware will complain! • This is called an “alignment error”. • The address was not “word aligned”. 4 5 6 7 8 9 10 11 12 13 14 15

  13. Byte order Byte 0 Byte 1 Byte 2 Byte 3 • Big endian • Little endian Addr 0 Addr 1 Addr 2 Addr 3 Byte 3 Byte 2 Byte 1 Byte 0 Addr 0 Addr 1 Addr 2 Addr 3

  14. Instruction memory 3 0 1 2 3 • An instruction is represented by 32 bits. • There are two “instruction formats”. (Not the whole truth, but don't worry about it) 4 5 6 7 8 9 10 11 12 13 14 15

  15. Instruction formats 6 bits 5 5 5 Remember: • Never immediate field together with rd-field. • Immediate field is only 16 bits! Format 1 (reg) Opcode rs rt rd 6 bits 5 5 16 Opcode Format 2 (imm) Immediate rs rt

  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).

  17. Review - How many bits?? • Instruction address ? • Instruction ? • Immediate field ? • Register address ? • Register ? • Data address ? • Data ?

  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)

  19. Questions? Feedback from the lectures: Per.Lindgren@ltu.se

More Related