Professional Documents
Culture Documents
01 Intro
01 Intro
Todays Topics
Course description
Whats it about
Mechanics: grading, etc.
Material from Chapter 1 (review)
What is digital logic?
Binary signaling
Number systems
Codes
computers
Stay above transistor level
Schematic Diagram
Verilog
/*
* 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 [3:0] out;
reg [31:0] count;
always @ (posedge res or posedge clk)
if(res)
count <= 0;
else
count <= count + 1;
assign out[3] = count[28];
assign out[2] = count[27];
assign out[1] = count[26];
assign out[0] = count[25];
endmodule
Xilinx Software
Use design tools from chip maker
Have full version on lab PCs
Can install on your PC
ModelSim simulator or built-in
http://www.cs.unc.edu/~montek
All notes posted
Will try to put them there before class
Overview of Textbook
Chapters 1-6: Digital logic
Combinational and sequential
Chapter 7-8: Register Transfer and State
Machines
Chapter 9: Memories
Chapters 10-12: Computer design
Chapter 13: I/O
Chapter 14: Memory Hierarchies
Order of Topics
Will change order from that in book
To try to get you working on interesting labs sooner
Move sequential design earlier
Then backfill details on combinational design
Grading
Labs 35%
Easier at first; later ones will count more
Homework 20%
Two tests spaced evenly 12.5% each
Final 20% (optional for some)
Labs
Paced slowly at first
Familiarization with tools, simple combinational
design, design a digital lock or similar
Peripheral VGA, opt. keyboard interface or
joystick
Build up computer components
Registers, ALU, decoder
computer
Final demo game or similar
Lab Sections
No lab this Friday
You need a little more info to begin
Begin next week
Lab is in SN 027, down the hall by the back
entrance
Late Policy
Homework assignments and lab reports due by
class time
Office Hours
Would like to wait a week to set
Send email if you want to meet
20
Binary Signaling
Zero volts
FALSE or 0
3.3 or 5 volts
TRUE or 1
Modern chips down to 1V
Discrete Data
Some data inherently discrete
Names (sets of letters)
Some quantized
Music recorded from microphone
Note that other examples like music from CD or
Hexadecimal,
Arithmetic
Lets cover
Other codes, parity
BCD
Binary Coded Decimal
Decimal digits stored in binary
Four bits/digit
Like hex, except stops at 9
Example
assigned by us.
Ref: http://lib-www.lanl.gov/numerical/bookcpdf/c20-2.pdf
Shaft Encoder
Character Codes
From numbers to letters
ASCII
Stands for American Standard Code for Information
Interchange
Only 7 bits defined
Unicode
You may make up your own code for the MIPS
VGA
ASCII table
Even Parity
Sometimes high-order bit of ASCII coded to
Odd Parity
Similar except make the number of 1s odd
Examples
A (01000001) with odd parity is 11000001
C (01000011) with odd parity is 01000011
Error Detection
Note that parity detects only simple errors
One, three, etc. bits
More complex methods exist
Some that enable recovery of original info
Cost is more redundant bits
Todays Topics
Introduction
Digital logic
Number systems
Arithmetic
Codes
Parity
The encoding is key
Standards are used to agree on encodings
Special purpose codes for particular uses
Homework
None, but
I expect you to know number systems well and be able
Reading
Skim chapter 1
Quick read to make sure youre comfortable with
material
Read Chapter 2
Next Week
Combinational Logic Basics
Lab preview
Ill demo tools in class, probably Thursday
Lab on Friday the 19th
Schematic capture
Maybe simple Verilog
Run on FPGA
Lab Walkthrough
Lets go see the lab
Shared with LEGO 1st year seminar
Backup Slides
Should be all review material
38
Binary Numbers
Strings of binary digits (bits)
One bit can store a number from 0 to 1
n bits can store numbers from 0 to 2n
Binary Powers of 2
Positional representation
Each digit represents a power of 2
So 101 binary is
1 22 + 0 21 + 1 20
or
14 + 02 + 11=5
27
26
25
24
23
22
21
20
128
64
32
16
128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156
4
Decimal 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)
number
Make the appropriate binary digit a 1
Subtract the power of 2 from decimal
Do the same thing again
27
26
25
24
23
22
21
20
128
64
32
16
Hexadecimal
Strings of 0s and 1s too hard to write
Use base-16 or hexadecimal 4 bits
Dec
Bin
Hex
Dec
Bin
Hex
0000
1000
0001
1001
0010
10
1010
0011
11
1011
0100
12
1100
0101
13
1101
0110
14
1110
0111
15
1111
Hexadecimal
Letters to represent 10-15
Dec
Bin
Hex
Dec
Bin
Hex
0000
1000
0001
1001
0010
10
1010
0011
11
1011
0100
12
1100
0101
13
1101
0110
14
1110
0111
15
1111
Why use
base 16?
Power of 2
Size of byte
4
Hex to Binary
Bin
Hex
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
0x2ac
0010 1010 1100
0x2ac = 001010101100
Binary to Hex
Just convert groups of 4 bits
101001101111011
0101 0011 0111 1011
5
101001101111011 = 0x537b
Bin
Hex
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Hex to Decimal
Dec
Hex
10
11
12
13
14
15
0x2ac
2 256 + 10 16 + 12 1 = 684
163
162
161
160
4096
256
16
Decimal to Hex
1.
2.
3.
4.
Decimal to Hex
684
684/256 = 2
0x2__
684%256 = 172
172/16 = 10 = a
0x2a_
172%16 = 12 = c 0x2ac
163
162
161
160
4096
256
16
Dec
Hex
10
11
12
13
14
15
Octal
Octal is base 8
Similar to hexadecimal
Conversions
Less convenient for use with 8-bit bytes
Arithmetic -- addition
Binary similar to decimal arithmetic
No carries
1 0 1 1 0 0
0 1 1 0 0
1 0 1 1 0
+ 1 0 0 0 1
+ 1 0 1 1 1
1 1 1 0 1
1 0 1 1 0 1
Carries
Arithmetic -- subtraction
0 0 1 1 0
No borrows
1 1 1 1 0
1 0 1 1 0
-
1 0 0 1 0
0 0 1 0 0
Borrows
1 0 0 1 1
0 1 0 1 1
0 - 1 results in a borrow
5
Arithmetic -- multiplication
1 0 1 1
X
1 0 1
1 0 1 1
0 0 0 0
1 0 1 1
Successive additions of
multiplicand or zero,
multiplied by 2 (102).
Note that multiplication
by 102 just shifts bits
left.
1 1 0 1 1 1
Hexadecimal Arithmetic
Similar
If youre doing by hand, easiest to convert