SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
Endianness
A Lecture to FW and VLSI Engineers
CONVENTION
           Binary Numbers Presentation Notation
                 Each binary digit represents only a single bit of binary number – N-
                 digit binary number means the same as N-bit binary number
                 Binary digit weight
                       The most left positioned bit is called The Most Significant Bit – MSB
                       The most right positioned bit is called The Least Significant Bit – LSB
                       Each bit has its own weight
                           • LSB – the lowest
                           • MSB – the highest
                       For N-bit binary number each bit has a weight equal to 2i-1, where i∈[1,N]
                 Presenting N-bit binary numbers, it is acceptable to reference each
                 bit by its index – else it is called a bit order
                       The indices are incrementally growing from 0 to N-1
                       When indices grow from left to right the MSB is 0th bit and the LSB is (N-
                       1)th bit
                       When indices grow from right to left the MSB is (N-1)th bit and the LSB is
                       0th bit




© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-              Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                            +972- 544-              2
CONVENTION
           Storage Units
                 Byte – 8 bits



                 Half Word – 2 bytes

                                                        MSB               LSB




                 Word – 4 bytes
                                                               231...20

                                                                Word




                 Double Word – 8 bytes


           Register Storage Presentation – either CPU internal, standalone
           or functional blocks internal registers



© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-          Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                        +972- 544-        3
CONVENTION
           Memory Storage Presentation
                  Byte is the minimally addressable storage and therefore has not alignment
                  Half word is aligned at even address (dividable on 2)
                  Word is aligned at even address but dividable on 4, 8, etc…
                  Double word is aligned at even address but dividable on 8, 16, etc…
                                 MSB       LSB                 MSB       LSB                 MSB       LSB                 MSB       LSB


               Address Offset 0...7              Address Offset 0              Address Offset 0              Address Offset 0


                                                 Address Offset 1              Address Offset 1              Address Offset 1
                                      27...20

                                      Byte                                     Address Offset 2              Address Offset 2
                                                                    27...20

                                                                Half Word      Address Offset 3              Address Offset 3


                                                                                                             Address Offset 4
                                                                                                  27...20

                                                                                                  Word       Address Offset 5


                                                                                                             Address Offset 6


                                                                                                             Address Offset 7


                                                                                                                                27...20

                                                                                                                         Double Word

© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-                         Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                                       +972- 544-                                          4
1st station
           Some conclusions so far about binary numbers
           presentation convention
                 Writing, printing, showing the binary numbers use the same
                 convention as any other Number System – the higher
                 significant digits are located at the left of the number and
                 have higher weights, when the lower significant digits are
                 located at the right of the number and have lower weights
                 Binary digits or bits in binary numbers are referencing by
                 their indices growing from left to right or vice versa having at
                 the same time no any relation to weight of each bit
           Some conclusions so far about storage resources
                 Register may be a standalone storage resource or internal
                 storage resource of CPU or resource of any other functional
                 block in the system. Register completely represents the
                 binary numbers presentation convention and bits in the
                 register may be indexed in any direction
                 Memory is a storage resource representing an array of bytes
                 sequentially addressed depending on access width – byte,
                 half word, word or double word

© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-       Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                     +972- 544-        5
Endianness Introduction
           In computing, endianness is the byte (and sometimes bit)
           ordering used to represent some kind of data. Typical cases are
           the order in which integer values are stored as bytes in
           computer memory (relative to a given memory addressing
           scheme) and the transmission order over a network or other
           medium. When specifically talking about bytes, endianness is
           also referred to simply as byte order

           More Definitions
                 Increasing numeric significance with increasing memory addresses,
                 is known as little-endian
                 Opposite of the above, most-significant byte first, is called big-
                 endian

           All the definitions look simple, clear and unambiguous –
           however a lot of questions appear when HW implementation
           starts, especially when systems with mixed endianeess are
           created or integrated

© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-       Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                     +972- 544-        6
Basic But Necessary Statements
           Memory doesn’t have endianness – memory just stores the
           bytes of data
           Registers don’t have endianness – registers represent the data
           on their way from or to the memory for further processing
                 The LSB of Register contains the LSB of data after read from the
                 memory or before write to the memory
                 The MSB of Register contains the MSB of data after read from the
                 memory or before write to the memory
           The main questions of endianness
                 How the data are transferred from the memory to the register and
                 back
                 Which byte of the register and which addressable byte of the
                 memory correspond to each other during the read/write operation
           Fortunately there is a very simple answer – it depends on the
           interpretation of the CPU, functional block or any other
           operating unit in the system

           And Finally – Endianness is not less and not more than
           INTERPRETATION. Only operating unit decides about order and
           weight of bytes and bits during byte, half word, word, duble
           word or any other transaction size
© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-       Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                     +972- 544-        7
2nd Station
           Memory doesn’t have endianness – it’s only a
           data storage
           Register doesn’t have endianness – it’s
           another kind of data storage
           Endianness is interpretation of data on its
           way between memory and register




© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-       Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                     +972- 544-        8
Byte Access
           Each byte of register may be exchanged with any
           single byte of memory




           There is not a place for endianness interpretation – so
           particularly a byte memory access doesn’t have
           endianness
© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-        Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                      +972- 544-        9
Half Word Access
           Little-endian data exchange – more significant data byte
           corresponds to higher address




           Big-endian data exchange – more significant data byte
           corresponds to lower address




© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-          Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                        +972- 544-        10
Word Access
           Little-endian data exchange – more significant
           data byte corresponds to higher address,
           similar to half word




© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-        Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                      +972- 544-        11
Word Access
            Big-endian data exchange – more significant
            data byte corresponds to lower address,
            similar to half word
                                     MSB                                           LSB                MSB                       LSB                MSB              LSB



                                           A   B   C    D      A     B   C     D                            E   F     G     H                            I     J

                                                         263...20                                               231...20                                 215...20

                                                       Double Word                                              Word                                  Half Word
                      MSB        LSB                                                     MSB       LSB                                MSB       LSB


        Address Offset 0                                                 Address Offset 0                             Address Offset 0
                             A                                                                 E                                            I

        Address Offset 1                                                 Address Offset 1                             Address Offset 1
                             B                                                                 F                                            J

        Address Offset 2                                                 Address Offset 2                             Address Offset 2
                             C                                                                 G                                            I

        Address Offset 3                                                 Address Offset 3                             Address Offset 3
                             D                                                                 H                                            J

                           27...20                                                          27...20                                      27...20

                           Word                                                             Word                                         Word




© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-                                Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                                              +972- 544-                                                                  12
Double Word Access
           Little-endian data exchange – more significant
           data byte corresponds to higher address,
           similar to word and half word  MSB                                           LSB                MSB                       LSB                MSB              LSB



                                                A   B   C     D      E    F   G     H                            I   J     K     L                            M     N

                                                              263...20                                               231...20                                 215...20

                                                            Double Word                                              Word                                  Half Word
                           MSB        LSB                                                     MSB       LSB                                MSB       LSB


             Address Offset 0                                                 Address Offset 0                             Address Offset 0
                                  H                                                                 L                                            N

             Address Offset 1                                                 Address Offset 1                             Address Offset 1
                                  G                                                                 K                                            M

             Address Offset 2                                                 Address Offset 2                             Address Offset 2
                                  F                                                                 J                                            N

             Address Offset 3                                                 Address Offset 3                             Address Offset 3
                                  E                                                                 I                                            M

             Address Offset 4                                                 Address Offset 4                             Address Offset 4
                                  D                                                                 L                                            N

             Address Offset 5                                                 Address Offset 5                             Address Offset 5
                                  C                                                                 K                                            M

             Address Offset 6                                                 Address Offset 6                             Address Offset 6
                                  B                                                                 J                                            N

             Address Offset 7                                                 Address Offset 7                             Address Offset 7
                                  A                                                                 I                                            M

                                27...20                                                          27...20                                      27...20

                         Double Word                                                      Double Word                                  Double Word


© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-                                     Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                                                   +972- 544-                                                                  13
Double Word Access
           Big-endian data exchange – more significant
           data byte corresponds to lower address,
           similar to word and half word  MSB                                           LSB                MSB                       LSB                MSB              LSB



                                                A   B   C     D      E    F   G     H                            I   J     K     L                            M     N

                                                              263...20                                               231...20                                 215...20

                                                            Double Word                                              Word                                  Half Word
                           MSB        LSB                                                     MSB       LSB                                MSB       LSB


             Address Offset 0                                                 Address Offset 0                             Address Offset 0
                                  A                                                                 I                                            M

             Address Offset 1                                                 Address Offset 1                             Address Offset 1
                                  B                                                                 J                                            N

             Address Offset 2                                                 Address Offset 2                             Address Offset 2
                                  C                                                                 K                                            M

             Address Offset 3                                                 Address Offset 3                             Address Offset 3
                                  D                                                                 L                                            N

             Address Offset 4                                                 Address Offset 4                             Address Offset 4
                                  E                                                                 I                                            M

             Address Offset 5                                                 Address Offset 5                             Address Offset 5
                                  F                                                                 J                                            N

             Address Offset 6                                                 Address Offset 6                             Address Offset 6
                                  G                                                                 K                                            M

             Address Offset 7                                                 Address Offset 7                             Address Offset 7
                                  H                                                                 L                                            N

                                27...20                                                          27...20                                      27...20

                         Double Word                                                      Double Word                                  Double Word


© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-                                     Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                                                   +972- 544-                                                                  14
3rd Station
           A byte access doesn’t have endianness
           In big-endian and little-endian systems the
           half word, word and double word data is kept
           differently in the memory while keeping the
           same interpretation in the operating registers
           ATTENTION: Output of little-endian functional
           block will be INTERPRETED by big-endian
           block in OPPOSITE order and vice versa

           There is a number of mistaken approaches
           when integrating functional units with
           different endianness. Some of them are
           presented further
© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-       Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                     +972- 544-        15
Mistake #1 – Data lines crossing
             It is very known mistake when designer crosses the data lines to
             emulate opposite directions of big and little endianness                  MSB                      LSB                                                                                  MSB                      LSB



                                                                                             A   B     C    D                                                                                              C   D     ?    ?

                                     MSB                         LSB                                                                               MSB                         LSB



                                           A   B     C       D                               D   C     B    A                                            A   B     C       D                               ?   ?     D    C

                                               231...20                                          231...20                                                    231...20                                          231...20

                                                                                                 Word                                                                                                          Word
                      MSB        LSB                                    MSB        LSB                                              MSB        LSB                                    MSB        LSB


        Address Offset 0                                  Address Offset 0                                            Address Offset 0                                  Address Offset 0
                             A                                                 A                                                           C                                                 C

        Address Offset 1                                  Address Offset 1                                            Address Offset 1                                  Address Offset 1
                             B                                                 B                                                           D                                                 D

        Address Offset 2                                  Address Offset 2                                            Address Offset 2                                  Address Offset 2
                             C                                                 C                                                           ?                                                 ?

        Address Offset 3                                  Address Offset 3                                            Address Offset 3                                  Address Offset 3
                             D                                                 D                                                           ?                                                 ?

                           27...20                                           27...20                                                     27...20                                           27...20

                           Word                                              Word                                                        Word                                              Word


                                                                                                                                                                          Little-endian device reads 16-bit from
                                                            Little-endian device reads 32-bit from
          Big-endian device writes                                                                                      Big-endian device writes
                                                                                                                                                                          memory at address 0. Data read
          32-bit 0xABCD to memory                           memory at address 0. Data read                              16-bit 0xCD to memory at
                                                                                                                                                                          conversion scheme incorrectly converts
                                                            conversion scheme converts the read
          at address 0                                                                                                  address 0
                                                                                                                                                                          the read data so that 16-bit transaction
                                                            data to correct order
                                                                                                                                                                          may cause unpredictable result, and 32-
                                                                                                                                                                          bit transaction brings the data into the
                                                                                                                                                                          upper part of target register


             A single data lines crossing scheme causes the address logic to
             be dependent on transaction width. For problem resolving the
             dedicated lines crossing scheme should exist for each type of
             transaction
© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-                                                                Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                                                                              +972- 544-                                                                                            16
Mistake #2 – Expanding Data Access Width
                                                            A 32-bit little-endian device is
                                                            expected to support big-
                                                            endian 64-bit access

                                                            It happens that each 32-bit
                                                            part of the emulated 64-bit
                                                            transaction is converted
                                                            correctly to big-endian order,
                                                            when the entire transaction
                                                            doesn’t succeed
                                                            The usual reason – internal
                                                            data path remains little-
                                                            endian and less significant
                                                            internal registers are
                                                            accessed first on their way to
                                                            system memory
                                                            In its turn the memory is
                                                            accessed starting at lower
                                                            addresses what finally cause
                                                            data swapping on 32-bit
                                                            boundary
© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-       Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                     +972- 544-                17
Final Note
           Behind the work with byte orders representing two types of
           endianness some platforms include the bit order in their
           endianness definition. So, the big-endian order of bytes also
           introduces an order of bits in byte where bit 0 is the MSB and bit
           7 is the LSB
           Connection between the systems based on regular and “big-
           endian” bit order may look tricky, but actually it is very simple.
           There is only one rule – bits in bytes representing different
           orders are mutually connected from MSB to MSB of each other
           towards LSB respectively




© Georgiy Shenderovich, 2006-2009
          Shenderovich, 2006-       Email: georgiysh@gmail.com Mbl.: +972-544-491911
                                                                     +972- 544-        18

Mais conteúdo relacionado

Mais procurados

Register of 80386
Register of 80386Register of 80386
Register of 80386
aviban
 
8086 memory interface.pptx
8086 memory interface.pptx8086 memory interface.pptx
8086 memory interface.pptx
HebaEng
 

Mais procurados (20)

80286 microprocessor
80286 microprocessor80286 microprocessor
80286 microprocessor
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
3.programmable interrupt controller 8259
3.programmable interrupt controller 82593.programmable interrupt controller 8259
3.programmable interrupt controller 8259
 
Router 1X3 – RTL Design and Verification
Router 1X3 – RTL Design and VerificationRouter 1X3 – RTL Design and Verification
Router 1X3 – RTL Design and Verification
 
SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)
 
8086 in minimum mode
8086 in minimum mode8086 in minimum mode
8086 in minimum mode
 
8086
80868086
8086
 
Register of 80386
Register of 80386Register of 80386
Register of 80386
 
Introduction to Bus | Address, Data, Control Bus
Introduction to Bus | Address, Data, Control BusIntroduction to Bus | Address, Data, Control Bus
Introduction to Bus | Address, Data, Control Bus
 
dual-port RAM (DPRAM)
dual-port RAM (DPRAM)dual-port RAM (DPRAM)
dual-port RAM (DPRAM)
 
Direct memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerDirect memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA Controller
 
Deepu Kumar Shah.pptx
Deepu Kumar Shah.pptxDeepu Kumar Shah.pptx
Deepu Kumar Shah.pptx
 
Memory mapping
Memory mappingMemory mapping
Memory mapping
 
8086 memory interface.pptx
8086 memory interface.pptx8086 memory interface.pptx
8086 memory interface.pptx
 
Microprocessor 8086 instructions
Microprocessor 8086 instructionsMicroprocessor 8086 instructions
Microprocessor 8086 instructions
 
Axi protocol
Axi protocolAxi protocol
Axi protocol
 
MIPI DevCon 2016: A Developer's Guide to MIPI I3C Implementation
MIPI DevCon 2016: A Developer's Guide to MIPI I3C ImplementationMIPI DevCon 2016: A Developer's Guide to MIPI I3C Implementation
MIPI DevCon 2016: A Developer's Guide to MIPI I3C Implementation
 
8051 Microcontroller I/O ports
8051 Microcontroller I/O ports8051 Microcontroller I/O ports
8051 Microcontroller I/O ports
 

Destaque

Oracle 11gr2 on_rhel6_0 - Document from Red Hat Inc
Oracle 11gr2 on_rhel6_0 - Document from Red Hat IncOracle 11gr2 on_rhel6_0 - Document from Red Hat Inc
Oracle 11gr2 on_rhel6_0 - Document from Red Hat Inc
Filipe Miranda
 
L12 programmable+logic+devices+(pld)
L12 programmable+logic+devices+(pld)L12 programmable+logic+devices+(pld)
L12 programmable+logic+devices+(pld)
NAGASAI547
 
Embedded systems
Embedded systemsEmbedded systems
Embedded systems
kondalarao7
 
ppt on embedded system
ppt on embedded systemppt on embedded system
ppt on embedded system
manish katara
 

Destaque (20)

Lil endian.ppt
Lil endian.pptLil endian.ppt
Lil endian.ppt
 
Manual fet-pro430
Manual fet-pro430Manual fet-pro430
Manual fet-pro430
 
Oracle 11gr2 on_rhel6_0 - Document from Red Hat Inc
Oracle 11gr2 on_rhel6_0 - Document from Red Hat IncOracle 11gr2 on_rhel6_0 - Document from Red Hat Inc
Oracle 11gr2 on_rhel6_0 - Document from Red Hat Inc
 
Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 Introduction
 
Understanding the endianess and the benefits of RHEL for Power, little endian
Understanding the endianess and the benefits of RHEL for Power, little endianUnderstanding the endianess and the benefits of RHEL for Power, little endian
Understanding the endianess and the benefits of RHEL for Power, little endian
 
Cots testing
Cots testingCots testing
Cots testing
 
Cots integration
Cots integrationCots integration
Cots integration
 
L12 programmable+logic+devices+(pld)
L12 programmable+logic+devices+(pld)L12 programmable+logic+devices+(pld)
L12 programmable+logic+devices+(pld)
 
Sp chap2
Sp chap2Sp chap2
Sp chap2
 
Embedded System
Embedded SystemEmbedded System
Embedded System
 
Embedded systems
Embedded systemsEmbedded systems
Embedded systems
 
ASIC
ASICASIC
ASIC
 
E.s unit 6
E.s unit 6E.s unit 6
E.s unit 6
 
Osi , tcp/ip protocol and Addressing
Osi , tcp/ip protocol and Addressing Osi , tcp/ip protocol and Addressing
Osi , tcp/ip protocol and Addressing
 
Compilers
CompilersCompilers
Compilers
 
RTOS - Real Time Operating Systems
RTOS - Real Time Operating SystemsRTOS - Real Time Operating Systems
RTOS - Real Time Operating Systems
 
04 Cache Memory
04  Cache  Memory04  Cache  Memory
04 Cache Memory
 
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE
 
Cache memory presentation
Cache memory presentationCache memory presentation
Cache memory presentation
 
ppt on embedded system
ppt on embedded systemppt on embedded system
ppt on embedded system
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Endianness

  • 1. Endianness A Lecture to FW and VLSI Engineers
  • 2. CONVENTION Binary Numbers Presentation Notation Each binary digit represents only a single bit of binary number – N- digit binary number means the same as N-bit binary number Binary digit weight The most left positioned bit is called The Most Significant Bit – MSB The most right positioned bit is called The Least Significant Bit – LSB Each bit has its own weight • LSB – the lowest • MSB – the highest For N-bit binary number each bit has a weight equal to 2i-1, where i∈[1,N] Presenting N-bit binary numbers, it is acceptable to reference each bit by its index – else it is called a bit order The indices are incrementally growing from 0 to N-1 When indices grow from left to right the MSB is 0th bit and the LSB is (N- 1)th bit When indices grow from right to left the MSB is (N-1)th bit and the LSB is 0th bit © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 2
  • 3. CONVENTION Storage Units Byte – 8 bits Half Word – 2 bytes MSB LSB Word – 4 bytes 231...20 Word Double Word – 8 bytes Register Storage Presentation – either CPU internal, standalone or functional blocks internal registers © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 3
  • 4. CONVENTION Memory Storage Presentation Byte is the minimally addressable storage and therefore has not alignment Half word is aligned at even address (dividable on 2) Word is aligned at even address but dividable on 4, 8, etc… Double word is aligned at even address but dividable on 8, 16, etc… MSB LSB MSB LSB MSB LSB MSB LSB Address Offset 0...7 Address Offset 0 Address Offset 0 Address Offset 0 Address Offset 1 Address Offset 1 Address Offset 1 27...20 Byte Address Offset 2 Address Offset 2 27...20 Half Word Address Offset 3 Address Offset 3 Address Offset 4 27...20 Word Address Offset 5 Address Offset 6 Address Offset 7 27...20 Double Word © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 4
  • 5. 1st station Some conclusions so far about binary numbers presentation convention Writing, printing, showing the binary numbers use the same convention as any other Number System – the higher significant digits are located at the left of the number and have higher weights, when the lower significant digits are located at the right of the number and have lower weights Binary digits or bits in binary numbers are referencing by their indices growing from left to right or vice versa having at the same time no any relation to weight of each bit Some conclusions so far about storage resources Register may be a standalone storage resource or internal storage resource of CPU or resource of any other functional block in the system. Register completely represents the binary numbers presentation convention and bits in the register may be indexed in any direction Memory is a storage resource representing an array of bytes sequentially addressed depending on access width – byte, half word, word or double word © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 5
  • 6. Endianness Introduction In computing, endianness is the byte (and sometimes bit) ordering used to represent some kind of data. Typical cases are the order in which integer values are stored as bytes in computer memory (relative to a given memory addressing scheme) and the transmission order over a network or other medium. When specifically talking about bytes, endianness is also referred to simply as byte order More Definitions Increasing numeric significance with increasing memory addresses, is known as little-endian Opposite of the above, most-significant byte first, is called big- endian All the definitions look simple, clear and unambiguous – however a lot of questions appear when HW implementation starts, especially when systems with mixed endianeess are created or integrated © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 6
  • 7. Basic But Necessary Statements Memory doesn’t have endianness – memory just stores the bytes of data Registers don’t have endianness – registers represent the data on their way from or to the memory for further processing The LSB of Register contains the LSB of data after read from the memory or before write to the memory The MSB of Register contains the MSB of data after read from the memory or before write to the memory The main questions of endianness How the data are transferred from the memory to the register and back Which byte of the register and which addressable byte of the memory correspond to each other during the read/write operation Fortunately there is a very simple answer – it depends on the interpretation of the CPU, functional block or any other operating unit in the system And Finally – Endianness is not less and not more than INTERPRETATION. Only operating unit decides about order and weight of bytes and bits during byte, half word, word, duble word or any other transaction size © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 7
  • 8. 2nd Station Memory doesn’t have endianness – it’s only a data storage Register doesn’t have endianness – it’s another kind of data storage Endianness is interpretation of data on its way between memory and register © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 8
  • 9. Byte Access Each byte of register may be exchanged with any single byte of memory There is not a place for endianness interpretation – so particularly a byte memory access doesn’t have endianness © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 9
  • 10. Half Word Access Little-endian data exchange – more significant data byte corresponds to higher address Big-endian data exchange – more significant data byte corresponds to lower address © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 10
  • 11. Word Access Little-endian data exchange – more significant data byte corresponds to higher address, similar to half word © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 11
  • 12. Word Access Big-endian data exchange – more significant data byte corresponds to lower address, similar to half word MSB LSB MSB LSB MSB LSB A B C D A B C D E F G H I J 263...20 231...20 215...20 Double Word Word Half Word MSB LSB MSB LSB MSB LSB Address Offset 0 Address Offset 0 Address Offset 0 A E I Address Offset 1 Address Offset 1 Address Offset 1 B F J Address Offset 2 Address Offset 2 Address Offset 2 C G I Address Offset 3 Address Offset 3 Address Offset 3 D H J 27...20 27...20 27...20 Word Word Word © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 12
  • 13. Double Word Access Little-endian data exchange – more significant data byte corresponds to higher address, similar to word and half word MSB LSB MSB LSB MSB LSB A B C D E F G H I J K L M N 263...20 231...20 215...20 Double Word Word Half Word MSB LSB MSB LSB MSB LSB Address Offset 0 Address Offset 0 Address Offset 0 H L N Address Offset 1 Address Offset 1 Address Offset 1 G K M Address Offset 2 Address Offset 2 Address Offset 2 F J N Address Offset 3 Address Offset 3 Address Offset 3 E I M Address Offset 4 Address Offset 4 Address Offset 4 D L N Address Offset 5 Address Offset 5 Address Offset 5 C K M Address Offset 6 Address Offset 6 Address Offset 6 B J N Address Offset 7 Address Offset 7 Address Offset 7 A I M 27...20 27...20 27...20 Double Word Double Word Double Word © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 13
  • 14. Double Word Access Big-endian data exchange – more significant data byte corresponds to lower address, similar to word and half word MSB LSB MSB LSB MSB LSB A B C D E F G H I J K L M N 263...20 231...20 215...20 Double Word Word Half Word MSB LSB MSB LSB MSB LSB Address Offset 0 Address Offset 0 Address Offset 0 A I M Address Offset 1 Address Offset 1 Address Offset 1 B J N Address Offset 2 Address Offset 2 Address Offset 2 C K M Address Offset 3 Address Offset 3 Address Offset 3 D L N Address Offset 4 Address Offset 4 Address Offset 4 E I M Address Offset 5 Address Offset 5 Address Offset 5 F J N Address Offset 6 Address Offset 6 Address Offset 6 G K M Address Offset 7 Address Offset 7 Address Offset 7 H L N 27...20 27...20 27...20 Double Word Double Word Double Word © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 14
  • 15. 3rd Station A byte access doesn’t have endianness In big-endian and little-endian systems the half word, word and double word data is kept differently in the memory while keeping the same interpretation in the operating registers ATTENTION: Output of little-endian functional block will be INTERPRETED by big-endian block in OPPOSITE order and vice versa There is a number of mistaken approaches when integrating functional units with different endianness. Some of them are presented further © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 15
  • 16. Mistake #1 – Data lines crossing It is very known mistake when designer crosses the data lines to emulate opposite directions of big and little endianness MSB LSB MSB LSB A B C D C D ? ? MSB LSB MSB LSB A B C D D C B A A B C D ? ? D C 231...20 231...20 231...20 231...20 Word Word MSB LSB MSB LSB MSB LSB MSB LSB Address Offset 0 Address Offset 0 Address Offset 0 Address Offset 0 A A C C Address Offset 1 Address Offset 1 Address Offset 1 Address Offset 1 B B D D Address Offset 2 Address Offset 2 Address Offset 2 Address Offset 2 C C ? ? Address Offset 3 Address Offset 3 Address Offset 3 Address Offset 3 D D ? ? 27...20 27...20 27...20 27...20 Word Word Word Word Little-endian device reads 16-bit from Little-endian device reads 32-bit from Big-endian device writes Big-endian device writes memory at address 0. Data read 32-bit 0xABCD to memory memory at address 0. Data read 16-bit 0xCD to memory at conversion scheme incorrectly converts conversion scheme converts the read at address 0 address 0 the read data so that 16-bit transaction data to correct order may cause unpredictable result, and 32- bit transaction brings the data into the upper part of target register A single data lines crossing scheme causes the address logic to be dependent on transaction width. For problem resolving the dedicated lines crossing scheme should exist for each type of transaction © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 16
  • 17. Mistake #2 – Expanding Data Access Width A 32-bit little-endian device is expected to support big- endian 64-bit access It happens that each 32-bit part of the emulated 64-bit transaction is converted correctly to big-endian order, when the entire transaction doesn’t succeed The usual reason – internal data path remains little- endian and less significant internal registers are accessed first on their way to system memory In its turn the memory is accessed starting at lower addresses what finally cause data swapping on 32-bit boundary © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 17
  • 18. Final Note Behind the work with byte orders representing two types of endianness some platforms include the bit order in their endianness definition. So, the big-endian order of bytes also introduces an order of bits in byte where bit 0 is the MSB and bit 7 is the LSB Connection between the systems based on regular and “big- endian” bit order may look tricky, but actually it is very simple. There is only one rule – bits in bytes representing different orders are mutually connected from MSB to MSB of each other towards LSB respectively © Georgiy Shenderovich, 2006-2009 Shenderovich, 2006- Email: georgiysh@gmail.com Mbl.: +972-544-491911 +972- 544- 18