Title: COMP190 Digital Computer Design
1COMP190 Digital Computer Design
2Todays Topics
- Course description
- Whats it about
- Mechanics grading, etc.
- Administration
- Material from Chapter 1
- What is digital logic?
- Binary signaling
- Number systems
- Codes
3Whats Course About?
- Digital logic focusing on the design of computers
- Stay above transistor level
- Only brief discussion of this
- Each person design a MIPS CPU
- Mostly use high-level language
- Stay above gate level
4How Can We Do This?
- Field Programmable Gate Arrays
- Chips with a lot of circuits
- Tens of thousands to millions of transistors
- Programmable, either once or many times
- We write programs describing design
- Download to chip
5We Will Use This Board
6Schematic Diagram
7Verilog
- /
- A 32-bit counter with only 4 bits of output.
The idea is - to select which of the counter stages you
want to pass on. -
- Anselmo Lastra, November 2002
- /
-
- module cntr_32c(clk,res,out)
- input clk
- input res
- output 30 out
- reg 310 count
- always _at_ (posedge res or posedge clk)
- if(res)
- count lt 0
- else
- count lt count 1
8Intent
- The idea is to design the course and make part of
standard offering - Give it a regular number
- This is the debugging stage
9Class Web Pages
- http//www.cs.unc.edu/lastra/comp190
- Lets browse
- Off my home page in case you forget
- All notes posted
- Will try to make put them there before class
- Blackboard for grades and homework
- Class forum
- Lab web page linked
10Textbook
- Morris Mano and Charles Kime
- Logic and Computer Design Fundamentals, 2nd
Edition Updated - Prentice Hall, 1999.
- Will try to follow text
11Overview of Textbook
- Chapters 1-5 Digital logic
- Combinational and sequential
- Chapter 6 RAM
- Chapter 7 Datapaths
- Registers and logic for processing
- Chapter 8 Control units
- Control the datapath
- Chapters 9-12 Computer design
12Will Also Need
- COMP120 book
- For MIPS reference
- Verilog reference
- Web see course home page
13Grading
- Labs 30
- Easier at first latter ones will count more
- Homework 20
- Two tests spaced evenly 12.5 each
- One before drop day
- Final 25
14Labs
- Paced slowly at first
- Familiarization with tools
- Build up computer components
- Registers, ALU, decoder
- Assemble a simple MIPS
- Add more features
15Teaching Assistant
- Alexandra Krstic
- krstic_at_cs.unc.edu
- www.cs.unc.edu/krstic
- Alex will run labs
16Xylinx Webpack Software
- Use design tools from chip maker
- Well hand out CDs
17Whats Your Background?
- Course experience
- Work, etc.
- Whats your intent in taking class?
- Questions?
18Administration
- Need people to sign up for lab
- Fridays at 900 and 100 in SN027
- Best if people evenly divided
- MAKE LIST
- No lab this Friday
- Begins next week
19Office Hours
- Would like to wait a week to set
- Send email if you want to meet
20Now Shift to Technology
21Digital vs. Analog
- Analog infinite resolution
- Like (old fashioned) radio dial
- Digital a finite set of values
- Like money
- Cant get smaller than cents
- Typically also has maximum value
22Binary Signaling
- Zero volts
- FALSE or 0
- 3.3 or 5 volts
- TRUE or 1
- Why not multilevel signaling?
23Discrete Data
- Some data inherently discrete
- Names (sets of letters)
- Some quantized
- Music recorded from microphone
- Note that other examples like music from CD or
electronic keyboard already quantized - Mouse movement is quantized
24Numbers and Arithmetic
- Review of binary numbers
- Hexadecimal
- Arithmetic
- Other codes
25Binary Numbers
- Strings of binary digits (bits)
- One bit can store a number from 0 to 1
- Two bits can store from 0 to 3
- n bits can store numbers from 0 to 2n
26Review of Decimal Numbers
- Positional representation, powers of 10
- the number 537 is
- Similarly 9238 is
- 9 103 2 102 3 101 8 100
-
27Binary Powers of 2
- Each digit represents a power of 2
- So 101 binary is
- 1 22 0 21 1 20
- or
- 1 4 0 2 1 1 5
-
28Converting Binary to Decimal
- Easy, just multiply digit by power of 2
- Just like a decimal number is represented
- Example follows
29Conversion Table
30Binary ? Decimal Example
What is 10011100 in decimal?
128 0 0 16 8 4 0 0
156
31Decimal to Binary
- A little more work than binary to decimal
- Some examples
- 3 2 1 11 (thats 121 120)
- 5 4 1 101 (thats 122 021 120)
32Algorithm Decimal to Binary
- Find largest power-of-two smaller than decimal
number - Make the appropriate binary digit a 1
- Subtract the power of 2 from decimal
- Do the same thing again
33Decimal ? Binary Example
- Convert 28 decimal to binary
32 is too large, so use 16
Binary ? 10000
Decimal ? 28 16 12
Next is 8
Binary ? 11000
Decimal ? 12 8 4
Next is 4
Binary ? 11100
Decimal ? 4 4 0
34Hexadecimal
- Strings of 0s and 1s too hard to write
- People use base-16 or hexadecimal 4 bits
35Hexadecimal
- Letters to represent 10-15
36Hex to Binary
- Convention write 0x before number
- Hex to Binary just convert digits
0x2ac
0x2ac 001010101100
No magic remember hex digit 4 bits
37Binary to Hex
- Just convert groups of 4 bits
101001101111011
1011
0101 ?
0111 ?
0011 ?
101001101111011 0x537b
38Hex to Decimal
- Just multiply each hex digit by decimal value,
and add the results.
0x2ac
2 256
10 16
12 1
684
39Decimal to Hex
- Analogous to decimal ? binary.
- Find largest power-of-16 smaller than decimal
number - Divide by power-of-16. The integer result is hex
digit. - The remainder is new decimal number.
- Do the same thing again
40Decimal to Hex
684
0x2__
684/256 2
684256 172
0x2a_
172/16 10 a
0x2ac
17216 12 c
41Octal
- Octal is base 8
- Similar to hexadecimal
- Conversions
- Less convenient with 8-bit bytes
42BCD
- Binary Coded Decimal
- Decimal digits stored in binary
- Four bits/digit
- Like hex, except stops at 9
- Example
- 931 is coded as 1001 0011 0001
43Other Codes Exist
- Not positional
- Example Gray Code
- Only one bit changes at a time
- 000,001,011,010,110,111,101,100
- Why is this useful?
Ref http//lib-www.lanl.gov/numerical/bookcpdf/c2
0-2.pdf
44Arithmetic -- addition
- Binary similar to decimal arithmetic
No carries
Carries
11 is 2 (or 102), which results in a carry
45Arithmetic -- subtraction
No borrows
Borrows
0 - 1 results in a borrow
46Arithmetic -- multiplication
Successive additions of multiplicand or
zero, multiplied by 2 (102). Note that
multiplication by 102 just shifts bits left.
47Hexadecimal Arithmetic
- Similar
- If youre doing by hand, easiest to convert each
set of digits to decimal and back - Skill is not very useful
48Character Codes
- From numbers to letters
- ASCII
- Stands for American Standard Code for Information
Interchange - Only 7 bits defined
49ASCII table
50Even Parity
- Sometimes high-order bit of ASCII coded to enable
detection of errors - Even parity set bit to make number of 1s even
- Examples
- A (01000001) with even parity is 01000001
- C (01000011) with even parity is 11000011
51Odd Parity
- Similar except make the number of 1s odd
- Examples
- A (01000001) with odd parity is 11000001
- C (01000011) with odd parity is 01000011
52Error Detection
- Note that parity detects only simple errors
- One, three, etc. bits
- More complex methods exist
- Some that enable recovery of original code
53Todays Topics
- Introduction
- Digital logic
- Number systems
- Arithmetic
- Codes
- Parity
54Homework
- Look on Blackboard
- Link from class web page
- Due Monday
55Reading
- Read chapter 1
- Quick read
- Read Chapter 2, Sections 1-4