COMP541 (160) Digital Logic and Computer Design

Montek Singh
Jan 11, 2007

1

Today s Topics
Å Course description  What s it about  Mechanics: grading, etc. Å Material from Chapter 1 (review)  What is digital logic?  Binary signaling  Number systems  Codes

2

What s Course About?
Å Digital logic, focusing on the design of computers Å Stay above transistor level  Only one class on transistors and VLSI Å Each person designs a MIPS CPU  and peripheral logic (VGA, joystick)  Project like an Atari 2600 game Å High-level language High Modern design practices

3

How Can We Do This?
Å Field Programmable Gate Arrays  Chips with a lot of circuits 
Tens of thousands to millions of transistors 
Programmable

Å We write programs describing design Å Tools translate to gates/wires Å Download pattern to chip

4

We Will Use This Board

5

Schematic Diagram 6 .

always @ (posedge res or posedge clk) if(res) count <= 0. output [3:0] out. The idea is 32* to select which of the counter stages you want to pass on.res. November 2002 */ module cntr_32c(clk.out). assign out[3] = count[28]. input res. * * Anselmo Lastra. assign out[2] = count[27]. input clk. endmodule 7 . assign out[0] = count[25]. reg [31:0] count.Verilog /* * A 32-bit counter with only 4 bits of output. else count <= count + 1. assign out[1] = count[26].

Xilinx Software Å Use design tools from chip maker Å Have full version on lab PCs Å Can install on your PC Å ModelSim simulator or built-in built- 8 .

unc.edu/~montek Å All notes posted  Will try to put them there before class Å Lab documents there also Å See Blackboard for grades 9 .Class Web Pages Å Linked from my home page http://www.cs.

3rd Edition Å Prentice Hall.Textbook and Syllabus Å Largely follow Prof. Lastra s syllabus Å Morris Mano and Charles Kime Å Logic and Logic and Computer Design Fundamentals. 2004 Å Will largely follow text  Slightly different order  More emphasis on HLL 10 .

Overview of Textbook Å Chapters 1-6: Digital logic 1 Combinational and sequential Å Chapter 7-8: Register Transfer and State Machines 7Å Chapter 9: Memories Å Chapters 10-12: Computer design 10Å Chapter 13: I/O Å Chapter 14: Memory Hierarchies 11 .

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 12 .

May Also Need Å COMP120 book  For MIPS reference  How many have one?  I can copy the few necessary pages Å Verilog reference  Book optional  Web pages see course home page 13 .

later ones will count more Å Homework 20% Å Two tests spaced evenly 12.Grading Å Labs 35%  Easier at first.5% each Å Final 20% (optional for some) 14 .

simple combinational design. ALU. decoder Å Peripheral Å Assemble a simple MIPS Å Add more features. enough for simple computer Å Final demo game or similar 15 . opt. keyboard interface or joystick Å Build up computer components  Registers. design a digital lock or similar VGA.Labs Å Paced slowly at first  Familiarization with tools.

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 16 .

Late Policy Å Homework assignments and lab reports due by class time  Labs due on Tuesday after the lab period Å One class late. 10 points off Å Two classes late. 25 points off Å Not accepted later 17 .

Å Which COMP120? Å What s your intent in taking class? Å Questions? 18 . etc.What s Your Background? Å Course experience Å Work.

Office Hours Å Would like to wait a week to set Å Send email if you want to meet 19 .

Now Shift to Technology Should be review for all of you 20 .

Analog Å Analog infinite resolution  Like (old fashioned) radio dial  We ll do very little with analog  VGA.Digital vs. maybe sound Å Digital a finite set of values  Like money  Can t get smaller than cents  Typically also has maximum value 21 .

3 or 5 volts  TRUE or 1  Modern chips down to 1V Å Why not multilevel signaling? 22 .Binary Signaling Å Zero volts  FALSE or 0 Å 3.

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 electronic keyboard already quantized  Mouse movement is quantized  Well. some mice 23 .

Hexadecimal. parity 24 .Numbers and Arithmetic Å I ve put most of these slides at end  Backup in case you ve forgotten Å Review of binary numbers. Arithmetic Å Let s cover  Other codes.

except stops at 9  Example 931 is coded as 1001 0011 0001 Å Remember: these are just encodings. Meanings are assigned encodings.BCD Å Binary Coded Decimal Å Decimal digits stored in binary  Four bits/digit  Like hex. 25 . by us.

011.pdf 26 .001.101.Other Codes Exist Å Non positional Å Example: Gray Code  Only one bit changes at a time  000.gov/numerical/bookcpdf/c20-2.010.100  Why is this useful?  Actually there s a family of Gray codes Ref: http://lib-www.110.111.lanl.

Shaft Encoder 27 .

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 28 .

ASCII table 29 .

Even Parity Å Sometimes high-order bit of ASCII coded to enable high- detection of errors Å Even parity set bit to make number of 1 s even Å Examples A (01000001) with even parity is 01000001 C (01000011) with even parity is 11000011 30 .

Odd Parity Å Similar except make the number of 1 s odd Å Examples A (01000001) with odd parity is 11000001 C (01000011) with odd parity is 01000011 31 .

bits Å More complex methods exist Å Some that enable recovery of original info  Cost is more redundant bits 32 .Error Detection Å Note that parity detects only simple errors  One. three. etc.

Today s 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 33 .

1-4. 34 . but Å I expect you to know number systems well and be able to do conversions and arithmetic     Decimal Binary Binary Decimal Decimal Hex Hex Decimal Å Can do some of the problems 1-2. 1-7 if you think you 1. Answers on book website.Homework Å None.1need a refresher.

Reading Å Skim chapter 1  Quick read to make sure you re comfortable with material Å Read Chapter 2 35 .

probably Thursday Å Lab on Friday the 19th  Schematic capture  Maybe simple Verilog  Run on FPGA 36 .Next Week Å Combinational Logic Basics Å Lab preview  I ll demo tools in class.

Lab Walkthrough Å Let s go see the lab Å Shared with LEGO 1st year seminar 37 .

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 39 .

Binary Powers of 2 Å Positional representation Å 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 40 .

Converting Binary to Decimal Å Easy. just multiply digit by power of 2 Å Just like a decimal number is represented Å Example follows 41 .

Binary p Decimal Example 7 27 128 6 26 64 5 25 32 4 24 16 3 23 8 2 22 4 1 21 2 0 20 1 What is 10011100 in decimal? 1 0 0 1 1 1 0 0 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156 42 .

Decimal to Binary Å A little more work than binary to decimal Å Some examples  3 = 2 + 1 = 11 (that s 1 21 + 1 20)  5 = 4 + 1 = 101 (that s 1 22 + 0 21 + 1 20) 43 .

Algorithm Decimal to Binary Å Find largest power-of-two smaller than decimal power-of- number Å Make the appropriate binary digit a 1 Å Subtract the power of 2 from decimal Å Do the same thing again 44 .

Decimal p Binary Example Å Convert 28 decimal to binary 32 is too large. so use 16 Binary p 10000 Decimal p 28 ± 16 = 12 Next is 8 Binary p 11000 Decimal p 12 ± 8 = 4 Next is 4 Binary p 11100 Decimal p 4 ± 4 = 0 7 27 128 6 26 64 5 25 32 4 24 16 3 23 8 2 22 4 1 21 2 0 20 1 45 .

Hexadecimal Å Strings of 0s and 1s too hard to write Å Use base-16 or hexadecimal base- 4 bits Dec 0 1 2 3 4 5 6 7 Bin 0000 0001 0010 0011 0100 0101 0110 0111 Hex 0 1 2 3 4 5 6 7 Dec 8 9 10 11 12 13 14 15 Bin 1000 1001 1010 1011 1100 1101 1110 1111 Hex 8 9 ? ? ? ? ? ? 46 .

Hexadecimal Å Letters to represent 10-15 10- Dec 0 1 2 3 4 5 6 7 Bin 0000 0001 0010 0011 0100 0101 0110 0111 Hex 0 1 2 3 4 5 6 7 Dec 8 9 10 11 12 13 14 15 Bin 1000 1001 1010 1011 1100 1101 1110 1111 Hex 8 9 a b c d e f Why use base 16? ‡Power of 2 ‡Size of byte 47 .

Hex to Binary Bin 0000 0001 0010 Hex 0 1 2 3 4 5 6 7 8 9 a b c d e f 48 write 0x before number Å Hex to Binary just convert digits Å Convention 0011 0100 0101 0x2ac 0010 1010 1100 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0x2ac = 001010101100 No magic ± remember hex digit = 4 bits .

Binary to Hex Å Just convert groups of 4 bits Bin 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 Hex 0 1 2 3 4 5 6 7 8 9 a b c d e f 101001101111011 0101  0011  0111  1011 5 3 7 b 1011 1100 1101 101001101111011 = 0x537b 1110 1111 49 .

0x2ac 2 ‡ 256 ZYXW 163 4096 + 10 ‡ 16 + 12 ‡ 1 = 684 ZYXW 162 256 ZYXW ZYX 161 16 ZYXW ZYXW 160 1 . Dec 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hex 0 1 2 3 4 5 6 7 8 9 a b c d e f 50 and add the results.Hex to Decimal Å Just multiply each hex digit by decimal value.

3. Find largest power-of-16 smaller than decimal power-ofnumber Divide by power-of-16. Analogous to decimal p binary. 4. The remainder is new decimal number. The integer result is hex power-ofdigit. Do the same thing again 51 .Decimal to Hex 1. 2.

Decimal to Hex 684 684/256 = 2 684%256 = 172 172/16 = 10 = a ZYXW 163 4096 ZYXW 162 256 ZYXW ZYX 161 16 Dec 0 1 2 3 4 Hex 0 1 2 3 4 5 6 7 8 9 a b c d e f 52 0x2__ 5 6 7 8 9 10 11 12 13 14 15 0x2a_ 172%16 = 12 = c 0x2ac ZYXW ZYXW 160 1 .

Octal Å Octal is base 8 Å Similar to hexadecimal  Conversions Å Less convenient for use with 8-bit bytes 8- 53 .

which results in a carry 54 .Arithmetic -.addition Å Binary similar to decimal arithmetic No carries 1 0 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 1 1 Carries 0 + 1 1 1 0 1 1 0 1 + 1 1 0 1+1 is 2 (or 102).

Arithmetic -.1 results in a borrow 55 .subtraction No borrows 0 1 1 0 0 0 0 1 1 0 0 1 0 1 1 1 0 0 1 1 1 1 0 0 1 1 Borrows 1 1 0 0 0 0 1 0 1 0 .

Note that multiplication by 102 just shifts bits left. 1 1 56 .multiplication 1 X 1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 Successive additions of multiplicand or zero.Arithmetic -. multiplied by 2 (102).

Hexadecimal Arithmetic Å Similar Å If you re doing by hand. easiest to convert each set of digits to decimal and back Å Skill is not very useful 57 .

Sign up to vote on this title
UsefulNot useful