Title: Digital Techniques
1Digital Techniques
- Instructor Dr. André Deutz
- Office Room 116
- Office Phone 071 - 527 7071
- Email Address deutz_at_liacs.nl
- Office Hours Mondays 1630-1800
-
2Digital Techniques
- Lab Assistants
- Gerben van der Lubbe (email spoofedexistence_at_gmai
l.com ) - Drs. Dmitry Nadezhkin (email dmitry_at_liacs.nl
phone 071-527-5775) - Sjoerd Henstra (email shenstra_at_liacs.nl), BSc
in Computer Science - Simon Zaaijer (email szaaijer_at_liacs.nl )
3Digital Techniques
- Text Book
- M.Morris Mano and Charles R. Kime, Logic and
Computer Design Fundamentals, 4th Ed., 2008,
Pearson Education isbn-13 978-0-13-198926-9
isbn-10 0-13-198926-X - Useful Link
- The URL of the Companion Website
http//www.prenhall.com/mano - Tip see also the errata
Fall 2007 Digital Techniques by André Deutz,
Leiden University
4Digital Techniques
- References
- Snyder, L., Fluency with Information Technology,
second edition, 2005, Addison-Wesley (third
edition due in October of 2007) (NB this textbook
is not required!) - The site of Great Principles of Computing
http//cs.gmu.edu/cne/pjd/GP/
Fall 2007 Digital Techniques by André Deutz,
Leiden University
5Digital Techniques
Tentative Course Outline
Lecture Date Topic Reading Assignments
1 Sep 10 Org computer science number systems Chapter 1
2 Sep 17 Number systems digital systems information Chapter 1
3 Sep 24 Combinational logic circuits Chapter 2
4 Oct 1 Combinational logic design Chapter 3
5 Wed 10 Oct 15.00 16.45 Physical implementation Part of Chapter 6
6 Oct 15 Arithmetic functions and circuits Part of Chapter 4
Oct 22 test
7 Oct 29 Sequential circuits flip-flops and latches Part of Chapter 5
8 Nov 5 Sequential circuits flip-flops and latches registers Part of Chapter 5
9 Nov 12 Counters memory Part of Chapter 5 Part of Chapter 8
10 Nov 19 Memory Part of Chapter 8
11 Nov 26 Processor design Chapter 9 10
12 Dec 3 Processor design Chapter 9 10
13 Dec 10 Processor design Chapter 9 10
Exam (tentamen) Test, Monday, 22 October
Friday, Jan. 11, 2008 retake 1, Wednesday, Mar.
26, 2008 retake 2, Friday, Aug. 8, 2008
6Digital Techniques
- Test 1400 1700 Monday, October 22, 2007
- Exam 1400-1700 Friday, Jan. 11, 2008
- retake 1 1400-1700 Wednesday, Mar. 26, 2008
- retake 2 1000-1300 Friday, Aug. 8, 2008
7Digital Techniques
- Assignments
- There are two kinds of assignments 1)
pencil-and-paper assignments and 2)
processor-project assignments.
8Digital Techniques
- Collaboration
- The pencil-and-paper assignments are done
individually. You may work on the
processor-project assignments in teams of two.
You may consult any source for design and
implementation ideas, as long as the synthesis
and implementation of these ideas is your own
work. It goes without saying that you need to
credit any source you are using in your work. The
above remarks pertain to both kinds of
assignments. If in doubt on how to proceed in
this matter, consult the instructor of the
course.
9Digital Techniques
- Deadlines
- Please submit the assignments by the stated
deadlines. Pencil-and-paper are due 7 days after
availability on the web or by email . Therefore
you are obliged to check your email and/or web
daily (as already stated above). The deadlines
for the processor-project assignments will be
stated separately. Deadlines are hard deadlines
because the answers to the assignments will be
posted on the web shortly after the deadline. It
goes without saying that we will deal
appropriately with exceptionally harsh
circumstances beyond your control.
10Digital Techniques
- Grade
- The grade for the course will be determined by
considering the grade for the exam (tentamen),
the assignments, and the practicum project. The
weights for computing the course grade are as
follows - Exam and Test 50
- Pencil-and-Paper Assignments 10
- Processor-Project Assignments 40
- Moreover the grade for the Exam as well as the
grade for the Processor-Project Assignment should
exceed 6..
11Digital Techniques
- Give a definition of the term Computer Science
(informatica).
12Digital Techniques
- Give a definition of the term Computer Science
(informatica). - Possible answers
- To make the digital world (faster), more
efficient, and above all more intelligent. - The study of phenomena with respect to (digital)
computers. - The study of representation, analysis,
transformation of information - van Dale leer van de mechanische verzameling en
verwerking van informatie - Van Dale (paar jaar geleden) leer van het
verzamelen en de verwerking van gegevens m.b.v.
computers - Computing is the study of information processes,
natural and artificial.
13Digital Techniques
- Goal of the Course
- Our goal is to gain more insight into natural
and man-made/artificial information processes
with a focus on man-made/artificial information
processing. This goal is, of course, too
ambitious and encompasses more than one (if not
all) course(s) of our BSc in Computer Science
program. A slightly more modest (and perhaps more
feasible) goal is to learn to understand
information processing à la von Neumann.
14Digital Techniques
- Objective
- Build a simple computer based on the von Neumann
model of computation (which in the man-made world
is still the ubiquitous model of computation).
15Digital Techniques
- Description
- In this course we will learn how to build a
simple computer based on the von Neumann model of
computation. - To that end we need to study the following
topics Digital Systems and Information, Number
Systems, Binary Arithmetic Operations, Decimal
and Alphanumeric Codes, Boolean Algebra,
Combinational Logic Circuits, Logic Functions and
Circuits, Arithmetic Functions and Circuits,
Sequential Circuits, Memory Basics, Registers and
Register Transfers, Computer Design Basics. - As simulation tool we will use Digital Works
3.04.The key for Digital Works
8290-0018-0300-0087
16Number Systems
17Overview
- Number Systems
- Positional Number Systems (decimal, binary,
octal, and hexadecimal) - Number Conversions (r-to-decimal, decimal-to-r,
other conversions) - Representations of Numbers in Digital Computers
- Integer Numbers (unsigned and signed
representations) - Arithmetic Operations
- General Remarks
- Unsigned, Signed,
- Decimal Codes
- BCD code, Alphanumeric Codes
- ASCII and Unicode
18Digital Systems General Remarks
- A Digital System manipulates discrete
elements/quantities of information - Discrete quantities of information emerge from
- the nature of the data being processed
- the data may be purposely quantized from
continues values - Early computer systems were used mostly for
numeric computations the discrete elements used
were the digits, hence the term digital
computer/system emerged. - In general, any system uses an alphabet (set of
symbols) to represent information - The English language system uses an alphabet of
26 symbols (letters) - The decimal number system uses an alphabet of 10
symbols (digits) - What about the alphabet of the Digital Systems?
19The Digital Systems Alphabet is Binary
- Digital Systems use only one alphabet with two
symbols (digits) 0 and 1 (hence binary ). - A binary digit is called a bit
- Information is represented by groups of bits
- Why is a binary alphabet used?
- Digital systems have a basic building block
called a switch, that can only be on or off,
i.e., two discrete values 0 and 1 can be
distinguished. - An electric device, called a transistor,
physically implements the switch. - The two discrete values are physically
represented by ranges of voltage values called
HIGH and LOW. - on (closed) switch corresponds to bit value 0
and is represented by LOW voltage value (between
0.0 and 1.0 Volt). - off (open) switch corresponds to bit value 1
and is represented by HIGH voltage value (between
4.0 and 5.0 Volts). - More information will be given later in another
lecture.
20Information Representation
- All information in Digital Systems is represented
in binary form. - An Aside
- Wine merchants in England (13th century or
earlier) - 2 gills 1 chopin
- 2 chopins 1 pint
- 2 pints 1 quart
- 2 quarts 1 pottle
- 2 pottles 1 peck
- 2 pecks 1 demibushel
- 2 demibushels 1 bushel or firkin
- 2 firkins 1 kilderkins
- 2 kilderkins 1 barrel
- 2 barrels 1 hogshead
- 2 hogshead 1 pipe
- 2 pipes 1 tun
21Information Representation
- All information that is not binary is converted
to binary before processed by a Digital Systems. - Decimal numbers are expressed in the binary
number system or by means of a binary code. - How is this done?
- That is not too difficult, once we understand how
all number systems, not only the decimal one
(0-9), have a similar formal representation and
how a number in one number system can be
converted into another. - Let us look into number systems and conversions.
Fall 2007 Digital Techniques by André Deutz,
Leiden University
22Number Systems
Number Systems are employed in arithmetic to
represent numbers by strings of digits. There are
two types of number systems
- Positional number systems
- The meaning of each digit depends on its position
in the number. - Example
- Decimal number system (we know it very well and
use it in everyday arithmetic). - 585.5 is a decimal number in positional code 5
hundreds plus 8 tens plus 5 units plus 5 tenths.
The hundreds, tens, units, and tenths are powers
of 10 implied by the position of the digits. - Decimal number system is said to be of base or
radix 10 because it uses 10 distinct digits (0
9) and the digits are multiplied by power of 10 - 585.5 5x102 8x101
5x100 5x10-1 - Non-positional number systems
- Old Roman numbers for example, XIX equals to 19
-
23Positional Number Systems
We can represent numbers in any number system
with base r
- Number in positional code
- (An-1An-2A1A0.A-1A-2A-m1A-m)r
- r is the base (radix) of the system, r ? 2, 3,
, I. - every digit Ai ? 0, 1, 2, , r-1, where 0, 1,
2, , r-1 is the digit set. - . is called the radix point.
- An-1 is referred to as the most significant
digit. - A-m is referred to as the least significant
digit. - Number in base r expressed as power series of r
- An-1 r n-1 An-2 r n-2 A1 r 1 A0 r 0 A-1
r -1 A-2 r -2 A-m1 r m1 A-m r -m - Example a number in number systems with base 5
- (132.4)5 1x52 3x51 2x50 4x5-1 25 15
2 0.8 (42.8)10
24Binary Number System
This is the system used for arithmetic in all
digital computers
- Number in positional code
- (bn-1bn-2b1b0.b-1b-2b-m1b-m)r
- r 2 is the base of the binary system.
- every digit bi ? 0, 1
- the digits bi in a binary number are called bits
- bn-1 is referred to as the most significant bit
(MSB). - b-m is referred to as the least significant bit
(LSB). - Number in base 2 expressed as power series of 2
- bn-1 2 n-1 bn-2 2 n-2 b1 2 1 b0 2 0 b-1
2 -1 b-2 2 -2 b-m1 2 m1 b-m 2 -m - Example a number in the binary number system
- (1011.01)2 1x23 0x22 1x21 1x20 0x2-1
1x2-2 8 2 1 0.25 (11.25)10
25Memorize this table by heart!!!!!!!!
Power of Two
26Other Useful Number System
Apart from the ordinary binary number system, the
octal (base-8) and the hexadecimal (base-16)
number systems are useful for representing binary
quantities indirectly because their bases are
powers of two. These systems have a more compact
representation of binary quantities.
- Octal number system
- (on-1on-2o1o0.o-1o-2o-m1o-m)8
- every digit oi ? 0, 1, 2, 3, 4, 5, 6, 7.
- on-1 8 n-1 on-2 8 n-2 o1 8 1 o0 8 0 o-1
8 -1 o-2 8 -2 o-m1 8 m1 o-m 8 -m - (127.4)8 1x82 2x81 7x80 4x8-1 (87.5)10
(001 010 111.100)2 - Hexadecimal number system
- (hn-1hn-2h1h0.h-1h-2h-m1h-m)16
- every digit hi ? 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
A, B, C, D, E, F. - hn-1 16 n-1 hn-2 16 n-2 h1 16 1 h0 16 0
h-1 16 -1 h-2 16 -2 h-m1 16 m1 h-m 16
m - (B6F.4)16 11x162 6x161 15x160 4x16-1
(2927.25)10 (1011 0110 1111.0100)2
27Another Important Table
Decimal (base 10) Binary (base 2) Octal (base 8) Hex (base 16)
0 0000 00 0
1 0001 01 1
2 0010 02 2
3 0011 03 3
4 0100 04 4
5 0101 05 5
6 0110 06 6
7 0111 07 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
28Conversion from base r to Decimal
The conversion of a number in base r to decimal
number (base 10) is done by expanding the number
in power series and adding all the terms as shown
below (An-1An-2A1A0.A-1A-2A-m1A-m)r
An-1 r n-1 An-2 r n-2 A1 r 1 A0 r 0
A-1 r -1 A-2 r -2 A-m1 r m1 A-m r -m
- Example of converting Binary (base 2) to Decimal
(base 10) - (1011.01)2 1x23 0x22 1x21 1x20 0x2-1
1x2-2 8 2 1 0.25 (11.25)10
- Example of converting number in base 5 to Decimal
(base 10) - (132.4)5 1x52 3x51 2x50 4x5-1 25 15
2 0.8 (42.8)10
- Example of converting Octal (base 8) to Decimal
(base 10) - (127.4)8 1x82 2x81 7x80 4x8-1 (87.5)10
- Example of converting Hexadecimal (base 16) to
Decimal (base 10) - (B6F.4)16 11x162 6x161 15x160 4x16-1
(2927.25)10
29Conversion from Decimal to base r
- The conversion is done as follows
- If the number has a radix point then separate the
number into an integer part and a fraction part,
since the two parts must be converted
differently. - The conversion of a decimal integer part to a
number in base r is done by dividing the integer
part and all successive quotients by r and
accumulating the remainders. - The conversion of a decimal fraction part to a
number in base r is done by multiplying the
fractional parts by r and accumulating integers.
- Example of converting Decimal (base 10) to Binary
(base 2) (41.6875)10
30Other Conversions
- Binary to Octal or Hexadecimal grouping bits
starting from the radix point - (1101010.01)2 to Octal (groups of 3)
(001101010.010)2 (152.2)8 - (1101010.01)2 to Hex (groups of 4)
(01101010.0100)2 (6A.4)16 - Octal to Binary convert each digit to binary
using 3 bits - (475.2)8 (100 111 101. 010)2
- Hexadecimal to Binary convert each digit to
binary using 4 bits - (7A5F.C)16 (0111 1010 0101 1111. 1100)2
(111101001011111.11)2 - Hexadecimal to Octal
- Hexadecimal ? Binary ? Octal
- Octal to Hexadecimal
- Octal ? Binary ?Hexadecimal
31Number Ranges
- The range of numbers in base (radix) r depends on
the number of digits used to represent the
numbers. - Assume the number (An-1An-2A1A0.A-1A-2A-m1A-m)r
represented by n digits for the integer part
and m digits for the fraction part. - The smallest integer number is 0 and the largest
is (r-1) r n-1 (r-1) r n-2 (r-1)r 1
(r-1) r 0 rn-1 ,i.e., the range is from 0 to
rn-1 - The smallest fraction number is 0.0 and the
largest is (r-1) r -1 (r-1) r -2 (r-1) r
m1 (r-1) r m 1- r m ,i.e., the range is
from 0.0 to 1- r m - The range of numbers is from 0.0 to rn - r m
- Examples
- Largest 3-digit integer decimal (base 10) number
is 103-1 1000 - 1 999 - Largest 8-digit integer binary (base 2) number is
(11111111)2 ,i.e., 28-1 255 - Largest 5-digit decimal (base 10) fraction is
1-10-5 1 0.00001 0.99999 - Largest 16-digit binary (base 2) fraction is
1-2-16 0.9999847412 - What about the range of negative numbers?
32Representations of Numbers in Digital Computers
(1)
- Numbers are represented in binary format as
strings of bits - Bit is the smallest binary quantity with a value
of 0 or 1. - Byte is a string (sequence) of eight bits.
- Word is a string (sequence) of n bits (n gt 8). In
most cases n is a power of 2 (n 24 16, n 25
32, n 26 64, etc). - Examples ? bit 1 byte 01101111 16-bit word
11110100 10001010 - Positive Integer Numbers
- Positive integers and the number zero can be
represented as unsigned binary numbers using a
byte or an n-bit word. - Magnitude representation number N in binary
having n bits. - Example 00001001 ( represents integer number 9
using 8 bits ). - Radix complement ( rs complement )
representation in our case 2s complement Given
number N in binary having n bits, the 2s
complement of N is defined as 2n N . - Example 11110111 ( 2s complement of integer
number 9 ). - Diminished radix complement ( (r-1)s complement
) representation in our case 1s complement -
Given number N in binary having n bits, the 1s
complement of N is defined as (2n 1) N . - Example 11110110 ( 1s complement of integer
number 9 ).
33Representations of Numbers in Digital Computers
(2)
- Positive and Negative Integer Numbers
- Positive and negative integers and the number
zero can be represented as signed binary numbers
using a byte or an n-bit word where the most
significant bit is interpreted as a sign bit. The
convention is to make the sign bit 0 for positive
numbers and 1 for negative numbers. - Signed-Magnitude representation
- Example 00001001 ( represents integer number
9 using 8 bits ). - Example 10001001 ( represents integer number
-9 using 8 bits ). - Signed-Radix complement ( signed-rs complement )
representation in our case signed-2s complement
(n8 in the example below) - Example 00001001 ( signed-2s complement of
integer number 9 ). - Example 11110111 ( signed-2s complement of
integer number -9 ). - How do we get the signed complement?
-
34Arithmetic Operations
- Arithmetic operations with numbers in base r
follow the same rules as for decimal numbers. - Examples addition, subtraction, and
multiplication in base-2. - For more information study pages 18-20 in the
text book. - In Digital Computers arithmetic operations are
done with the binary number system (base-2) -
Binary Arithmetic. - In many cases binary subtraction is done in a
special way by binary addition. Why? - It is much more simple to do it that way.
- One simple building block called adder can be
implemented and used for both binary addition and
subtraction.
35Unsigned Binary Subtraction
- Binary subtraction by 2s complement addition
- Assume two n-bit unsigned numbers M and N, M - N
can be done as follows - Add the 2s complement of N to M. This performs
the sum M (2n - N) M N 2n . - If M N, the sum produces an end carry, 2n. We
can discard it, leaving the correct result M N.
- If M lt N, the sum does not produces an end carry
since it is equal to 2n (N - M), which is the
2s complement of N M. To obtain the correct
result take the 2s complement of the sum, i.e.,
2n (2n (N - M)) (N - M) and place a minus
sign in front. - Examples
- What about binary subtraction by 1s complement
addition? - I leave this for you as a home work
36Signed Binary Addition/Subtraction
- Signed binary addition using 2s complement
representation - Assume two n-bit signed numbers M and N
represented in signed-2s complement format. The
sum M N can be obtained as follows - Add M to N, including their sign bits to get the
correct sum in signed-2s complement format. A
carry out of the sign bit position is discarded.
- Examples
- Signed binary subtraction using 2s complement
representation - Assume two n-bit signed numbers M and N
represented in signed-2s complement format. The
difference M - N can be obtained as follows - Take the 2s complement of N (including the sign
bit) and add it to M (including the sign bit). A
carry out of the sign bit position is discarded. - Examples
( 9) ( 5) (14)
01001 00101 01110
37Decimal Codes
- The binary number system is the most natural
system for a digital computer, but people are
accustomed to the decimal system. - How to resolve this difference?
- Convert decimal numbers to binary, perform all
arithmetic calculations in binary, and then
convert the binary result back to decimal. - You already know how to do this.
- Digital computers can do this as well, but
- We have to store the decimal numbers in the
computer in a way that they can be converted to
binary. - Since the computer can accept only binary values,
we must represent the decimal digits by a code
that contains 1s and 0s.
38Binary Coded Decimals (BCD) (1)
- The BCD code is the most commonly used code. Each
decimal digit (0, 1, 2, , 9) is coded by a
4-bit string (half a byte) called BCD digit. - A decimal number is converted to a BCD number by
replacing each decimal digit of the number with
the corresponding BCD digit code. - Example
- (369)10 ( 0011 0110 1001 )BCD (101110001)2
- 3 6 9
- A BCD number needs more bits than its equivalent
binary value. However, the advantages of using
BCD are - Computer input and output data are handled by
people who use the decimal system. - BCD numbers are decimal numbers (not binary
numbers) even though they are represented in
bits. - Computers can store decimal numbers using BCD,
convert the BCD numbers to binary, perform binary
operations, and convert the result back to BCD.
Decimal Digit BCD Digit
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Note the binary combinations 1010 through 1111
are not used and have no meaning in the BCD code.
39Binary Coded Decimals (BCD) (2)
- Converting a BCD number to a binary number
- (25)10 (0010 0101)BCD (0010)2 x 101
(0101)2 x 100 (0010)2 x (1010)2
(0101)2 x (0001)2 (10100)(0101)
(11001)2 - Converting a binary number to a BCD number
- BCD Arithmetic
- Digital computers can performed arithmetic
operations directly with decimal numbers when
they are stored in BDC format. - How is this done? (study the text book or go to
internet for information).
40Other Useful Decimal CodesSeven-Segment Code
- Used to display numeric info on seven-segment
displays. - Seven-segment display
- 7 LEDs (light emitting diodes), each one
controlled by an input - 1 means on, 0 means off
- Display digit 3?
- Set a, b, c, d, g to 1
- Set e, f to 0
Decimal Digit 7- Segment Code
a b c d e f g
0 1 1 1 1 1 1 0
1 0 1 1 0 0 0 0
2 1 1 0 1 1 0 1
3 1 1 1 1 0 0 1
4 0 1 1 0 0 1 1
5 1 0 1 1 0 1 1
6 1 0 1 1 1 1 1
7 1 1 1 0 0 0 0
8 1 1 1 1 1 1 1
9 1 1 1 1 0 1 1
a
f
b
g
e
c
d
41Alphanumeric Codes
- Many applications of digital computers require
the handling of data consisting not only of
numbers, but also of letters. - Alphanumeric character set of English includes
- The 10 decimal digits
- The 26 letters of the alphabet (uppercase and
lowercase letters) - Several (more than three) special characters
- We need to code these symbols
- The code must be binary computers can handle
only 0s and 1s - We need binary code of at least seven bits (27
128 symbols) - American Standard Code for Information
Interchange (ASCII) - ASCII is a 7-bit standard code for representing
the symbols of the English language. - Unicode
- A 16-bit standard code for representing the
symbols and ideographs for the worlds languages.
42ASCII Code Table
43ASCII Character Code
ASCII is a 7-bit code, commonly stored in 8-bit
bytes. A is at 4116. To convert upper case
letters to lower case letters, add 2016. Thus a
is at 4116 2016 6116. The character 5 at
position 3516 is different than the number 5. To
convert character-numbers into number-numbers,
subtract 3016 3516 - 3016 5.
44ASCII Code Table
45Gray Codes
Fall 2007 Digital Techniques by André Deutz,
Leiden University
46What is What?
- How do you know whether binary bit string
00110001 represents an ASCII code with odd parity
for the character 1 , the positive number 49,
or the positive number 31?