550 likes | 781 Views
COMP541 Digital Logic and Computer Design. Montek Singh Aug 20, 2014. Today’s Topics. Course description What ’ s this course about? Syllabus Textbook and Resources Course Requirements Grading Policies and Honor Code Material from Chapter 1 (self-study review)
E N D
COMP541 Digital Logic and Computer Design Montek Singh Aug 20, 2014
Today’s Topics • Course description • What’s this course about? • Syllabus • Textbook and Resources • Course Requirements • Grading • Policies and Honor Code • Material from Chapter 1 (self-study review) • What is digital logic? • Binary signaling • Number systems • Codes
What’s This Course About? • Digital Logic • transistors (briefly) • gates • combinational circuits • state machines • Computer Design • arithmetic circuits • memories • processor architecture • input and output • Emphasis on high-level descriptions • hardware description language (Verilog) instead of circuits • modern design practices
Key Learning Objectives • At the end of this course, you should be able to: • convert a specification into an implementation • hierarchically decompose a complex spec • into simpler components • understand concurrency • develop concurrent system specs and implementations • test a given design for correctness • develop a test bench and performing simulation • use state-of-the-art software tools for hardware design • “computer-aided-design” (CAD) tools • Each student will have: • designed a full microprocessor (basic MIPS) • implemented it on a development kit • programmed it in assembly to show a demo
Who is this course for? • Advanced course in digital logic and computer design • follow-up to COMP 411 (Computer Organization) • full-gate level implementation of MIPS processor from 411 • including memories and I/O • Who should take this course? • undergrads who want to pursue a career or further studies in the fields of: • computer architecture • chip design, or other engineering disciples • grad students looking to fill a gap in their coursework • anyone interested in learning how a digital system is implemented, in a hands-onmanner
How will we build an entire computer? • Labs on Fridays • hands-on experience in designing digital circuits/systems • start small, but quickly go to higher levels of abstraction • We will write descriptions of design • instead of drawing circuit diagrams • descriptions look like “code” • high-level language • BEWARE: these are not software programs! • use compilation tools to convert into gates and wires • map (“burn”) these designs onto a reconfigurable chip • called Field Programmable Gate Array (FPGAs) • chips with a lot of circuits (millions of transistors) • sort of like burning music to a rewritable CD
Development Kits • Each student will be loaned a kit for the semester • we have two types: 25 new and 25 old • both are more-than-sufficient for this course • a BIG thanks to NVIDIA for donating $$ for the Nexys 4 kits!! Nexys 3 Nexys 4
How to represent circuits? • Schematic Diagram: drawing showing components and their interconnections • visual representation • good for documentation • good for small circuits • infeasible for large-scale systems • typically use hierarchical drawings
How to represent circuits? • Hardware Description Language (HDL):textual description of the circuit • easier to type than to draw! • works well with automated design and test tools • we will use an HDL called Verilog /* A Mod 4 counter * Montek Singh, August 2014 */ module CounterMod4 (clock, reset, value); input clock; input reset; output reg[1:0] value = 0; always @(posedge clock) begin value <= reset ? 0 : (value + 1); end endmodule
How to compile HDL to circuits? • Use design tools from the kit maker • Each student must install her/his own copy • Download from web (linked from course website) • Big download: ~6 GB (allow overnight) • Do it before Friday’s lab session • DO IT TONIGHT! • Platforms: • Windows 7/8 and Linux: best support • Mac OS X: use Bootcamp+ Windows • harder to make it work with Parallels
Grading Criteria • Final grade will be based on: • Labs: 30% • Final Project: 20% • Homework: 15% • Quizzes: 10% • Midterm: 10% • Final Exam: 15% • Bonus Points: Up to 5 extra points for • extra credit work • stellar work on lab assignments/project • class participation • participation on Piazza discussion board
Grading Criteria • Labs • about one every week • each builds upon the previous ones • important to follow sequence, and DO THEM ALL • culminates in the final project • Project • everyone builds a full microprocessor (basic MIPS from 411) • write assembly code to show a demo (“game”) • demo in front of whole class • and other faculty and students may be invited • Homework: 3-4 assignments • Quizzes: 3-4 • announced, ~15 min long • Exams: Midterm and Final
Course Policies • Late Penalty • Labs: • electronic submissions • everyone gets 7 “free late days” • for each calendar day (or part of day) late, one free day is spent • once free days are exhausted, each late day results in 1 point taken out of the final total lab score (out of 100) • Homework: • due in hardcopy in class/lab session • one session late: 25% penalty • two sessions late: 50% penalty • after then, not accepted • no late work accepted once solutions are distributed
Course Policies • Missed classes, quizzes, exam conflicts • classes: while attendance is not required, there is no substitute to coming to class if you want a good grade • labs: • many assignments require demos during lab sessions • I provide lots of tips/hints during the session • quizzes: since the dates are announced, please see me well in advance if you have a compelling reason for absence • exams: bring any conflicts to my attention ASAP
Honor Code • Collaboration: • Allowed (even encouraged) to discuss basic concepts • use discussion board on Piazza • bonus points for active participation! • BUT: What you hand in must be your own • write solutions and code individually • Previous Semesters: • Cannot use homework solutions from previous offerings of this course • Cannot obtain lab assignments/code from students who have taken this course before • Not following these rules is a violation of honor code
Textbook and Resources • Textbook: • be sure to get the 2nd ed. • 25% discount coupon on course website • Other resources: • website • homework, labs, lectures, etc. • Verilog language reference • on course website • personal laptop computer • Windows or Linux • Mac OS with Bootcamp • development kits (provided) Harris and Harris, Digital Design and Computer Architecture, 2nd ed. (July 2012), ISBN 9780123944245, Morgan Kaufmann
Overview of Textbook • Chapters 1-5: Digital logic • Combinational, sequential, basic circuits, HDL • Chapter 6: Architecture • Fast – review for those who took COMP 411 • Chapter 7: Microarchitectures • Chapters 8: Memories • Appendix A: Implementation • FPGAs, etc. • Order of topics: • Will change order from that in book • to try to get you working on interesting labs sooner
Class Web Page Website: • http://comp541fall14.web.unc.edu • Linked from my home pagehttp://www.cs.unc.edu/~montek • All lecture slides, lab assignments posted there • Syllabus, homework, etc. posted there • See Sakai for scores/grades • Use Piazza for questions/discussions • TA and Office Hours • to be finalized by Friday, Aug 22
Now Shift to Technology Should be a review for all of you
Complexity and Abstraction • This course will span several abstraction levels • from transistors … • … to architecture • Mostly stay above transistor level • at most one class on transistors and chip layout • Mostly go “bottom up” • culminate in the design of a full computer in the labs
The Three -Y’s • Hierarchy • divide a system into modules and submodules • keep dividing until pieces are easy to understand • Modularity • modules have well-defined functions and interfaces • so can be connected easily without surprises • Regularity • encouraging uniformity, so modules can be easily reused • so same set of basic building blocks can be used • e.g., a 16-bit adder uses the same basic blocks as an 8-bit adder
Digital vs. Analog • Analog – infinite resolution • Like (old fashioned) radio dial • We’ll do very little with analog • VGA, maybe sound • Digital – a finite set of values • Like money • Can’t get smaller than cents • Typically also has maximum value
Binary Signaling • Zero volts • FALSE or 0 • 5 or 3.3 (or 1.8 or 1.5) volts • TRUE or 1 • Modern chips down to 1V • Why not multilevel signaling?
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
Numbers and Arithmetic • I have put most of these slides at end • Backup in case you’ve forgotten • Review of binary numbers, Hexadecimal,Arithmetic • Let’s cover • Other codes, parity
BCD • 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 • Remember: these are just encodings. Meanings are assigned by us.
Other Codes Exist • Non positional • Example: Gray Code • Only one bit changes at a time • 000,001,011,010,110,111,101,100 • Why is this useful? • Actually there’s a family of Gray codes Ref: http://lib-www.lanl.gov/numerical/bookcpdf/c20-2.pdf
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
Even Parity • Sometimes high-order bit of ASCII coded to enable 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
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
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
Reading • Read Chapter 1
Next Class • Combinational Logic Basics Next class: Friday, Aug 22 • I will demo tools • You should have your tools installed and bring your laptop
Backup Slides Should be all review material
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 1 • 4 + 0 • 2 + 1 • 1 = 5
Converting Binary to Decimal • Easy, just multiply digit by power of 2 • Just like a decimal number is represented • Example follows
Binary Decimal Example What is 10011100 in decimal? 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156
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)
Algorithm – 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
Decimal 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
Hexadecimal • Strings of 0s and 1s too hard to write • Use base-16 or hexadecimal – 4 bits
Hexadecimal Why use base 16? • Letters to represent 10-15 • Power of 2 • Size of byte
Hex to Binary 0010 1010 1100 • Convention – write 0x before number • Hex to Binary – just convert digits 0x2ac 0x2ac = 001010101100 No magic – remember hex digit = 4 bits
Binary to Hex 5 3 7 b • Just convert groups of 4 bits 101001101111011 1011 0101 0011 0111 101001101111011 = 0x537b
Hex to Decimal • Just multiply each hex digit by decimal value, and add the results. 0x2ac 2 • 256 + 10 • 16 + 12 • 1 = 684
Decimal 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
Decimal to Hex 684 0x2__ 684/256 = 2 684%256 = 172 0x2a_ 172/16 = 10 = a 0x2ac 172%16 = 12 = c