Systems Programming www.atomicrhubarb.com/systems Lecture 2 Review of Computer Architecture I
In The Book Patt & Patel Chapter 1,2,3 (review)
Outline Binary Bit Numbering Logical operations 2's complement Binary -> Decimal BCD Ascii Code Binary -> Hex Switches as gates Transistors as swithes CMOS Logic with Transistors Transistors -> Gates DeMorgans Law Larger Gates Combinational Logic Decoder 2-bit Adder, 8-bit adder R-S latch Gated D latch A Register 8-bit register Memory Sequential Logic Shift Register Counter
Binary Base 2 numbering system. 1 decimal 00000001 binary 2 00000010 3 00000011 4 00000100 5 00000101 6 00000110 7 00000111 8 00001000 16 00010000
Bit Numbering Least significant bit - Bit with the lowest value LSB 0 - Least Significant Bit is Bit #0 MSB 0 - Most Significant Bit is Bit #0 We will use LSB 0
Internet RFC Convention is MSB0 See! MSB0
Logical Operations We don't need to review AND, OR, XOR, NOT do we? 10101111 OR 01010011 11111111 10101111 AND 01010011 00000011
Logical Operations NOT = One's Complement NOT 01010011 10101100 NOT 10101111 01010000
Two's Complement Represents signed binary numbers 1s complement and adding one 0 0000 0000 1111 1111 0000 0000-1 0000 0001 1111 1110 1111 1111-5 0000 0101 1111 1010 1111 1011-16 0001 0000 1110 1111 1111 0000-128 1000 0000 0111 1111 1000 0000 I may frequently show binary as 2 nibbles.
Binary to Decimal Add up the decimal values of each binary bit position 128 064 032 016 008 004 002 001 00100101 + 001 004 032 ----037 decimal
Anyone recall what Binary Coded Decimal (BCD) is?
Binary Coded Decimal BCD is Decimal Numbers represented in binary using 4-bits for each digit of decimal. Makes it easy to store digits. 8423 decimal = 1000 0100 0010 0011 BCD 8 4 2 3
Ascii Code
Is ASCII the only way to represent characters?
Not ASCII Character Sets PETSCII ISO/IEC 646 DEC MCS ISO/IEC 8859 EBCDIC plenty of others that no one uses anymore. Unicode
Binary to Hex Since 1 nibble can represent the full HEX number range (0,1,2,3,4,5,6,7,8,9,A,B,C, D,E,F) its super easy to convert from binary to hex Also why I frequently show my binary bytes as 2 nibble). 231 decimal = 1110 0111 = 0xE7 E 7
Enough about number systems. Let move on to digital logic.
Switches as Inverter We will talk about voltage and current and what makes these thing work next week.
NAND and NOR
CMOS Metal-Oxide Semiconductor Field Effect Transistors (MOSFET) more suitable for digital electronics. Composed of N type and P type MOSFETs
Transistors as Switches n-type MOSFET p-type MOSFET
Logic with Transistors NOT NAND
Transistors to Gates
Gates NAND NOT = AND NOR NOT = OR
Gates AND OR OR NOT
DeMorgan's Theorem To simplify Circuits: A and B = A or B A or B = A and B
Bubble Pushing A shortcut based on DeMorgan's Theorem. 1 - Change AND to OR, OR to AND 2 - Invert all "bubbles" = = =
Universal Compatibility NOR or NAND gates can be combined with itself to form any other logic gate = =
Combinational Logic Combinational Logic = Digital logic where the output is a function of the input only. Sequential logic = Digital logic where the output depends on the input and the history of the input. In other words, sequential logic has memory while combinational logic does not.
Decoder 2 Input Decoder (or a 2 to 4 decoder) AB 1 if AB = 00 1 if AB = 01 1 if AB = 10 1 if AB = 11
2-bit Adder Or a Half Adder A0 Carryout Sumout B0 A C HA B S
Full Adder A B A C Carryout HA B S A C HA Carryin B S A Cout B FA S Cin Sumout
4-Bit Adder MSB LSB A3 B3 A2 B2 A1 B1 A B Cin A B Cin A B Cin FA FA FA Cout S S4 S3 Cout S S2 Cout A0 B0 A B HA S S1 Cout S S0
Sequential Logic Combinational Logic = Digital logic where the output is a function of the input only. Sequential logic = Digital logic where the output depends on the input and the history of the input. In other words, sequential logic has memory while combinational logic does not.
R-S Latch Store 1 bit of data S R Q Q S R /Q Q 0 0 1 1 not valid 0 1 1 0 set 1 0 0 1 reset 1 1 Q /Q hold
Gated D Latch Prevent invalid state of R-S Latch D Q WE Q WE D D Latch /Q Q
1-bit Register WE D D Latch Q
What can we do with several of these?
4-bit Register D3 WE D D2 WE D D1 WE D D0 WE D D Latch D Latch D Latch D Latch Q Q Q Q Q3 Q2 Q1 Q0
Clock D D WE D WE D WE /Q Q Q1 D Latch Q /Q Q0 D Latch Q /Q D Latch Q /Q D Latch WE Shift Register Q2 Q3 D
JK Flip Flop
What do you suppose we can make with these?
Counter
Need to easily think in binary and hex Bit numbering is LSB0 You can combine simple logic gate to make anything. Combinatorial Logic = Pure function Sequential Logic = Time ZNEO