Digital Electronics and Computer Interfacing Tim Mewes 3. Digital Electronics
Digital Electronics and Computer Interfacing2 3.1 Digital Information Information is stored in two distinct physical states –Charge state of a capacitor (DRAM) –Magnetization direction (Hard disk, MRAM) –… The two states are referred to as –TRUE/FALSE (Boolean) –1/0 –On/Off –High/Low
Digital Electronics and Computer Interfacing3 3.1 Digital Information Information can be transmitted using: discrete Voltage levels –TTL: 1: 2.0 V or greater 0: 0.8 V or less –CMOS: 1: 3.7 V or greater 0: 1.3 V or less –… Light –typical wavelengths: 850, 1310, or 1550 nm Radio frequencies –Bluetooth 2.4GHz –…
Digital Electronics and Computer Interfacing4 3.2 Digital number representation Unsigned integers use base 2 (binary) representation: =1 2 0 = Each digit in the binary representation is called a bit Eight bits are called a byte The largest possible number that can be represented by n-bits is 2 n -1 (255 in case of a byte) The leftmost bit is also called most significant bit The rightmost bit is also called least significant bit
Digital Electronics and Computer Interfacing Unsigned integers How to convert from base 2 to base 10? Example: , n=8 bits Most significant bit 1 2 n-1 =1 2 7 =128 2 n-2 =1 2 6 =64 64 0 2 n-3 =0 2 5 =0 0 0 2 n-4 =0 2 4 =0 0 1 2 n-5 =1 2 3 =8 8 0 2 n-6 =0 2 2 =0 0 0 2 n-7 =0 2 1 =0 0 1 2 n-8 =1 2 0 =1 1 Sum: 201
Digital Electronics and Computer Interfacing Unsigned integers How to convert from base 10 to base 2? Example: 100 with n=8 bits Most significant bit 2 n-1 =2 7 =128 > 100 0 2 n-2 =2 6 =64 < 100 = 362 n-3 =2 5 =32 < 36 = 42 n-4 =2 4 =16 > 4 0 2 n-5 =2 3 =8 > 4 0 2 n-6 =2 2 =4 = 4 =02 n-7 =2 1 =2> 0 0 2 n-8 =2 0 =1> 0 =
Digital Electronics and Computer Interfacing Signed integers Sign-and-magnitude Use the most significant bit to represent the sign 0 represents ‘+’, 1 represents ‘-’ For n-bits numbers from -2 n-1 +1 to 2 n-1 -1 can be represented Advantage: similar to the way we usually indicate the sign of a number Disadvantage: arithmetic calculations tricky Zero has two representations: = =
Digital Electronics and Computer Interfacing Signed integers Ones’ complement Negative numbers are represented by complementing all the bits (1 0) of the binary representation of the magnitude of the number = = Zero still has two representations
Digital Electronics and Computer Interfacing Signed integers Two’s complement For negative numbers calculate the ones’ complement and add 1 to the result: = Ones’ complement: = Two’s complement: = Zero has only one representation Range for n bits: -2 n-1 to 2 n-1 -1 (-128 to +127 for a byte) Advantage: convenient for computer arithmetic
Digital Electronics and Computer Interfacing Comparison (4-Bit) Base 10Unsigned IntegerSign-and-magnitudeOnes’ complementTwo’s comlement
Digital Electronics and Computer Interfacing Gates A logic gate is an arrangement of switches to calculate operations using Boolean logic in digital circuits The output of a gate only depends on its inputs and not its history
Digital Electronics and Computer Interfacing Gates A Q A B Q A B Q
Digital Electronics and Computer Interfacing Gates A B Q A B Q A B Q
Digital Electronics and Computer Interfacing Boolean algebra associativity: commutativity: absorption: complements: distributivity: De Morgan’s theorem:
Digital Electronics and Computer Interfacing Boolean algebra How many gates do we really need? Just one: either NAND or NOR (universal gates)! One can build all other gates using for example only NAND: AND: NOT: OR: XOR: