0% found this document useful (0 votes)
12 views16 pages

02.number Code Complement

The document covers various number codes and registers used in digital logic and computer design, including 2's complement, Binary Coded Decimal (BCD), Gray codes, and ASCII. It explains how these codes are utilized for data storage and processing, highlighting their importance in computer architecture. Additionally, it discusses the role of parity codes in data transmission and the function of registers in storing binary data.

Uploaded by

Zeeshan Qasim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views16 pages

02.number Code Complement

The document covers various number codes and registers used in digital logic and computer design, including 2's complement, Binary Coded Decimal (BCD), Gray codes, and ASCII. It explains how these codes are utilized for data storage and processing, highlighting their importance in computer architecture. Additionally, it discusses the role of parity codes in data transmission and the function of registers in storing binary data.

Uploaded by

Zeeshan Qasim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Digital Logic and Computer Design

Number Codes and Registers

ENGIN112 L4: Number Codes and Registers


Overview

° 2’s complement numbers


• Addition and subtraction

° Binary coded decimal


° Gray codes for binary numbers
° ASCII characters
° Moving towards hardware
• Storing data
• Processing data

ENGIN112 L4: Number Codes and Registers


2’s Complement Subtraction

° Let’s compute (13)10 - (5)10.


• (13)10 = +(1101)2 = (01101)2
• (-5)10 = -(0101)2 = (11011)2

° Adding these two 5-bit codes…


0 1 1 0 1
carry + 1 1 0 1 1
--------------
1 0 1 0 0 0
° Discarding the carry bit, the sign bit is seen to be
zero, indicating a correct result.

ENGIN112 L4: Number Codes and Registers


2’s Complement Subtraction

° Let’s compute (5)10 – (12)10.


• (-12)10 = -(1100)2 = (10100)2
• (5)10 = +(0101)2 = (00101)2

° Adding these two 5-bit codes…

0 0 1 0 1
+ 1 0 1 0 0
--------------
° Here, there 1 1 0carry
is no 0 1bit and the sign bit is 1.
This indicates a negative result, which is what we
expect. (11001)2 = -(7)10.

ENGIN112 L4: Number Codes and Registers


Binary Coded Decimal
Digit BCD Digit BCD
Code Code

0 0000 5 0101

1 0001 6 0110

2 0010 7 0111

° Binary coded 3 decimal


0011
(BCD)8 represents
1000 each decimal
digit with four bits
4 0100 9 1001
• Ex. 0011 0010 1001 = 32910
3 2 9

° This is NOT the same as 0011001010012


° Why do this? Because people think in decimal.

ENGIN112 L4: Number Codes and Registers


Putting It All Together

° BCD not very efficient


° Used in early computers
(40s, 50s)
° Used to encode
numbers for
seven-segment
displays.
° Easier to read?

ENGIN112 L4: Number Codes and Registers


Gray Code
Digit Binary Gray
Code ° Gray code is not a number
system.
0 0000 0000 • It is an alternate way to represent
four bit data

1 0001 0001 ° Only one bit changes from


one decimal digit to the next
° Useful for reducing errors in
2 0010 0011 communication.
° Can be scaled to larger
3 0011 0010 numbers.

4 0100 0110

5 0101 0111

6 0110 0101
ENGIN112 L4: Number Codes and Registers
ASCII Code

° American Standard Code for Information


Interchange
° ASCII is a 7-bit code, frequently used with an 8th bit
for error detection (more about that in a bit).

Character ASCII (bin) ASCII (hex) Decimal Octal

A 1000001 41 65 101

B 1000010 42 66 102

C 1000011 43 67 103


Z
a

ENGIN1121L4: Number Codes and Registers
ASCII Codes and Data Transmission

° ASCII Codes
° A – Z (26 codes), a – z (26 codes)
° 0-9 (10 codes), others (@#$%^&*….)
° Complete listing in Mano text
° Transmission susceptible to noise
° Typical transmission rates (1500 Kbps, 56.6 Kbps)
° How to keep data transmission accurate?

ENGIN112 L4: Number Codes and Registers


Pari
ty
Cod
°esParity codes are formed by concatenating a parity
bit, P to each code word of C.
° In an odd-parity code, the parity bit is specified so
that the total number of ones is odd.
° In an even-parity code, the parity bit is specified
so that the total number of ones is even.

P Information Bits
1 1 0 0 0 0 1 1 0 1 0 0 0 0 1 1
↑ ↑
Added even parity bit Added odd parity bit

ENGIN112 L4: Number Codes and Registers


Pari
ty
Cod
°e Concatenate a parity bit to the ASCII code for the
characters 0, X, and = to produce both odd-parity
Exa
and even-parity codes.
mpl
e
Character ASCII Odd-Parity Even-Parity
ASCII ASCII

0 0110000 10110000 00110000

X 1011000 01011000 11011000

= 0111100 10111100 00111100

ENGIN112 L4: Number Codes and Registers


Binary Data Storage

• Binary cells store individual bits of data


• Multiple cells form a register.
• Data in registers can indicate different values
• Hex (decimal)
• BCD
• ASCII

0 0 1 0 1 0 1 1

Binary Cell

ENGIN112 L4: Number Codes and Registers


Register Transfer

° Data can move from register to register.


° Digital logic used to process data
° We will learn to design this logic

Register A Register B

Digital Logic
Circuits

Register C

ENGIN112 L4: Number Codes and Registers


Transfer of Information

° Data input at keyboard


° Shifted into place
° Stored in memory

NOTE: Data input in ASCII

ENGIN112 L4: Number Codes and Registers


Building a Computer
° We need processing
° We need storage
° We need communication

° You will learn to use and


design these components.

ENGIN112 L4: Number Codes and Registers


Summary

° Although 2’s complement most important, other


number codes exist
° ASCII code used to represent characters (including
those on the keyboard)
° Registers store binary data

ENGIN112 L4: Number Codes and Registers

You might also like