Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.

Similar presentations


Presentation on theme: "1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012."— Presentation transcript:

1 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012

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

3 3 What’s Course About?  Digital logic, focusing on the design of computers  Stay mostly at a high level (i.e., above transistors)  Each person designs a MIPS CPU and peripheral logic (VGA, joystick) and peripheral logic (VGA, joystick) Project like an Atari 2600 game Project like an Atari 2600 game  High-level language Modern design practices Modern design practices

4 Focus  Stay above transistor level At most one class on transistors and VLSI At most one class on transistors and VLSI  Expect you to know assembly language programming 4

5 More Than Just Architecture  Designing and implementing a computer is also about Managing complexity (hierarchy, modularity, regularity). Managing complexity (hierarchy, modularity, regularity). Debugging Debugging Testing and verifying Testing and verifying 5

6 The Three -Y’s  Hierarchy A system divided into modules and submodules A system divided into modules and submodules  Modularity Having well-defined functions and interfaces Having well-defined functions and interfaces  Regularity Encouraging uniformity, so modules can be easily reused Encouraging uniformity, so modules can be easily reused

7 7 How Can We Do This?  Labs on Fridays  Use: Field Programmable Gate Arrays (FPGAs) Chips with a lot of circuits Chips with a lot of circuits  Tens of thousands to millions of transistors Programmable Programmable  We write descriptions of the design “programs” describing design “programs” describing design  Tools translate to gates/wires  Download pattern/interconnection to chip Sort of like burning music to a rewritable CD Sort of like burning music to a rewritable CD

8 8 We Will Use This Board What’s on it?

9 9 Schematic Diagram Old fashioned way to describe logic Still useful for documentation

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

11 11 Xilinx Software  Use design tools from chip maker  Have full version on lab PCs  Can install on your PC Download from web Download from web

12 12 Class Web Pages  Will be up by Thursday’s class  Linked from my home page http://www.cs.unc.edu/~montek http://www.cs.unc.edu/~montek  All lecture slides posted there Will try to put them there before class Will try to put them there before class  Schedule, homework, etc. posted there  Lab documents there also  See Blackboard/Sakai for scores/grades

13 Textbook  Harris and Harris  Digital Design and Computer Architecture  Morgan Kaufmann, 2007  Amazon has for $70  Extra material on http://www.elsevierdirect.com/companion.jsp?ISBN=9780123704979 13

14 14 Overview of Textbook  Chapters 1-5: Digital logic Combinational, sequential, basic circuits, HDL Combinational, sequential, basic circuits, HDL  Chapter 6: Architecture Fast – review for those who took COMP 411 Fast – review for those who took COMP 411  Chapter 7: Microarchitectures  Chapters 8: Memories  Appendix A: Implementation FPGAs, etc. FPGAs, etc.

15 15 Order of Topics  Will change order from that in book To try to get you working on interesting labs sooner To try to get you working on interesting labs sooner

16 16 May Also Need  COMP411 textbook (Patterson/Hennessy) For MIPS reference For MIPS reference How many have one? How many have one? I can copy the few necessary pages I can copy the few necessary pages  Verilog reference Book optional Book optional Web pages – see course home page Web pages – see course home page

17 17Grading  Labs – 35% Easier at first; later ones will count more Easier at first; later ones will count more  Lab final project – 15%  Homework – 25%  Two tests spaced evenly – 12.5% each

18 18Labs  Paced slowly at first Familiarization with tools, simple combinational design, design a digital lock or similar 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 Registers, ALU, decoder  Assemble a simple MIPS  Add more features, enough for simple computer  Final demo – game or similar

19 19 Lab Sections  No lab this Friday You need a little more info to begin You need a little more info to begin Begin next week Begin next week  Lab is in FB007

20 20 Late Policy  Homework assignments and lab reports due by class Labs due on Monday after the lab period Labs due on Monday after the lab period  One class late, 10 points off  Two classes late, 25 points off  Not accepted later

21 21 What’s Your Background?  Course experience  Work, etc.  Which COMP411?  What’s your intent in taking class?  Questions?

22 22 Office Hours  Would like to wait a week to set  Send email if you want to meet in the mean time

23 23 Now Shift to Technology Should be review for all of you

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

25 25 Binary Signaling  Zero volts FALSE or 0 FALSE or 0  5 or 3.3 (or 1.8 or 1.5) volts TRUE or 1 TRUE or 1  Modern chips down to 1V  Why not multilevel signaling?

26 26 Discrete Data  Some data inherently discrete Names (sets of letters) Names (sets of letters)  Some quantized Music recorded from microphone Music recorded from microphone Note that other examples like music from CD or electronic keyboard already quantized Note that other examples like music from CD or electronic keyboard already quantized Mouse movement is quantized Mouse movement is quantized  Well, some mice

27 27 Numbers and Arithmetic  I have put most of these slides at end Backup in case you’ve forgotten Backup in case you’ve forgotten  Review of binary numbers, Hexadecimal, Arithmetic  Let’s cover Other codes, parity Other codes, parity

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

29 29 Other Codes Exist  Non positional  Example: Gray Code Only one bit changes at a time Only one bit changes at a time 000,001,011,010,110,111,101,100 000,001,011,010,110,111,101,100 Why is this useful? Why is this useful? Actually there’s a family of Gray codes Actually there’s a family of Gray codes Ref: http://lib-www.lanl.gov/numerical/bookcpdf/c20-2.pdf

30 30 Shaft Encoder

31 31 Character Codes  From numbers to letters  ASCII Stands for American Standard Code for Information Interchange Stands for American Standard Code for Information Interchange Only 7 bits defined Only 7 bits defined  Unicode  You may make up your own code for the MIPS VGA

32 32 ASCII table

33 33 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

34 34 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

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

36 36 Today’s Topics  Introduction  Digital logic  Number systems  Arithmetic  Codes  Parity  The encoding is key Standards are used to agree on encodings Standards are used to agree on encodings Special purpose codes for particular uses Special purpose codes for particular uses

37 37Homework  None, but…  I expect you to know number systems well and be able to do conversions and arithmetic Decimal – Binary Decimal – Binary Binary – Decimal Binary – Decimal Decimal – Hex Decimal – Hex Hex – Decimal Hex – Decimal  Can do some of the problems – 1.7 to 1.27 are all about conversion – if you think you need a refresher. Answers to odd numbered on book website.

38 38Reading  Read Chapter 1

39 39 Next Class  Combinational Logic Basics Next Week: Lab preview I will demo tools in class, probably Wednesday I will demo tools in class, probably Wednesday

40 40 Backup Slides Should be all review material

41 41 Binary Numbers  Strings of binary digits (“bits”) One bit can store a number from 0 to 1 One bit can store a number from 0 to 1 n bits can store numbers from 0 to 2 n n bits can store numbers from 0 to 2 n

42 42 Binary – Powers of 2  Positional representation  Each digit represents a power of 2 So 101 binary is 1 2 2 + 0 2 1 + 1 2 0 1 2 2 + 0 2 1 + 1 2 0or 1 4 + 0 2 + 1 1 = 5 1 4 + 0 2 + 1 1 = 5

43 43 Converting Binary to Decimal  Easy, just multiply digit by power of 2  Just like a decimal number is represented  Example follows

44 44 Binary  Decimal Example 76543210 27272727 26262626 25252525 24242424 23232323 22222222 21212121 20202020 1286432168421 10011100 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156 What is 10011100 in decimal?

45 45 Decimal to Binary  A little more work than binary to decimal  Some examples 3 = 2 + 1 = 11 (that’s 12 1 + 12 0 ) 3 = 2 + 1 = 11 (that’s 12 1 + 12 0 ) 5 = 4 + 1 = 101 (that’s 12 2 + 02 1 + 12 0 ) 5 = 4 + 1 = 101 (that’s 12 2 + 02 1 + 12 0 )

46 46 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

47 47 Decimal  Binary Example  Convert 28 decimal to binary 76543210 27272727 26262626 25252525 24242424 23232323 22222222 21212121 20202020 1286432168421 32 is too large, so use 16 Binary  10000Decimal  28 – 16 = 12 Binary  11000Decimal  12 – 8 = 4 Next is 8 Binary  11100Decimal  4 – 4 = 0 Next is 4

48 48Hexadecimal  Strings of 0s and 1s too hard to write  Use base-16 or hexadecimal – 4 bits DecBinHex 000000 100011 200102 300113 401004 501015 601106 701117DecBinHex810008 910019 101010? 111011? 121100? 131101? 141110? 151111?

49 49Hexadecimal  Letters to represent 10-15 DecBinHex 000000 100011 200102 300113 401004 501015 601106 701117DecBinHex810008 910019 101010a 111011b 121100c 131101d 141110e 151111f Power of 2Power of 2 Size of byteSize of byte Why use base 16?

50 50 Hex to Binary  Convention – write 0x before number  Hex to Binary – just convert digits BinHex 00000 00011 00102 00113 01004 01015 01106 01117 10008 10019 1010a 1011b 1100c 1101d 1110e 1111f 0x2ac 001010101100 0x2ac = 001010101100 No magic – remember hex digit = 4 bits

51 51 Binary to Hex  Just convert groups of 4 bits BinHex 00000 00011 00102 00113 01004 01015 01106 01117 10008 10019 1010a 1011b 1100c 1101d 1110e 1111f 101001101111011 1011 537b 101001101111011 = 0x537b 0101  0111  0011 

52 52 Hex to Decimal  Just multiply each hex digit by decimal value, and add the results.  16 3 16 2 16 1 16 0 4096256161 0x2ac 2 256 + 10 16 + 12 1 = 684 DecHex00 11 22 33 44 55 66 77 88 99 10a 11b 12c 13d 14e 15f

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

54 54 Decimal to Hex  16 3 16 2 16 1 16 0 4096256161 DecHex00 11 22 33 44 55 66 77 88 99 10a 11b 12c 13d 14e 15f 684 684/256 = 2 0x2__ 684%256 = 172 172/16 = 10 = a 0x2a_ 172%16 = 12 = c 0x2ac

55 55Octal  Octal is base 8  Similar to hexadecimal Conversions Conversions  Less convenient for use with 8-bit bytes

56 56 Arithmetic -- addition  Binary similar to decimal arithmetic 01100 +10001 11101 No carries10110010110 +10111 101101 Carries 1+1 is 2 (or 10 2 ), which results in a carry

57 57 Arithmetic -- subtraction 10110 -10010 00100 No borrows0011011110 -10011 01011 Borrows 0 - 1 results in a borrow

58 58 Arithmetic -- multiplication 1011 0000 1011 110111 Successive additions of multiplicand or zero, multiplied by 2 (10 2 ). Note that multiplication by 10 2 just shifts bits left. 1011X 101


Download ppt "1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012."

Similar presentations


Ads by Google