Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Digital System Design

Chapter 2
Number Systems and Codes
Thái Truyển Đại Chấn
Outline

• Binary-to-Decimal Conversions • Putting It All Together

• Decimal-to-Binary Conversions • The Byte, Nibble, and Word


• Alphanumeric Codes
• Hexadecimal Number System
• Parity Method for Error
• BCD Code
Detection
• The Gray Code
• Applications
Binary-to-Decimal Conversions

LSB

MSB
Decimal-to-Binary Conversions
Decimal-to-Binary Conversions
• Repeated Division
Decimal-to-Binary Conversions
• Repeated Division

Start

Is Q = 0
Divide by 2

Collect R’s into desired


Record quotient (Q)
binary number with first
and remainder (R)
as LSB and last R as MSB

Start
Decimal-to-Binary Conversions
• Counting Range

Using N bits, we can represent decimal numbers ranging from 0 to 2N -1,


a total of 2N different numbers
Hexadecimal Number System
Hexadecimal Number System
• Hex-to-Decimal Conversion
Hexadecimal Number System
• Decimal-to-Hex Conversion
Hexadecimal Number System
• Hex-to-Binary Conversion
Hexadecimal Number System
• Binary-to-Hex Conversion

• Counting in Hexadecimal

• Usefulness of Hex
Conversion Summary
• Why is conversion is necessary?
• Summary
• Binary/Hex  Decimal
• Decimal  Binary/Hex
• Hex  Binary
• Binary  Hex
BCD Code
• Decimal ↔ Straight binary coding
• Binary-coded-decimal (hereafter abbreviated BCD)

• Comparison of BCD and Binary

BCD : Tách số ra thành từng con số rồi chia cho 2 => Sau đó hợp thành 1 dải số có 4 số
Binary: Lấy số đó chia 2 + Dư 1 thì ghi 1
+ Ko dư thì ghi 0
The Gray Code
• Only one bit ever changes between two successive
numbers in the sequence
The Gray Code
• Converting (a) binary to Gray and (b) Gray to binary
The Gray Code
• An eight-position, three-bit shaft encoder.
Putting All Together
Gray code for group of 4 bits
The Byte, Nibble, and Word
• Byte

• Nibble 4 Bits

• Word A byte is eight bits, a word is 2 bytes (16 bits), a doubleword is 4 bytes (32 bits), and a quadword is 8 bytes (64 bits). Figure
29-2 shows the byte order of each of the fundamental data types when referenced as operands in memory.
Alphanumeric Codes
• All of the various characters and functions that are
found on a computer keyboard
• A, B, C, …, a, b, c, …, 1, 2, 3, …, ., ,, ?, …, +, /, #, …
• American Standard Code for Information Interchange
(ASCII)
• 27 = 128 possible code groups
• Transfer of alphanumeric info.: a computer ↔ external
devices
• Store the information that an operator types in at the
computer’s keyboard.
Alphanumeric Codes
• Example

padding with 0s
=> They have equal plane of 4
bits
Parity Method for Error Detection
• Movement of binary data and codes from one
location
• Error can occur
• Electrical noise

• Detection code
• Correction code
Parity Method for Error Detection
• Parity bit
• Even-parity method

• Odd-parity method
• Detection code, not correction code
• Single-bit error detection
• Checking the parity, request for retransmission,
retransmission
Applications
• Transmitting an ASCII character
(Application 2-5)

• Example: transmit a Delete

You might also like