1 / 17

EEE342 Digital Electronics

EEE342 Digital Electronics. Lecture 1: The story of ‘1’. Ian McCrum Room 5B18, 02890366364 IJ.McCrum@ulster.ac.uk http://www.eej.ulst.ac.uk/~ian/modules/EEE342. The real world. The temperature of air – is a continuously varying value; the “value” changes over “time”

Download Presentation

EEE342 Digital Electronics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EEE342 Digital Electronics Lecture 1: The story of ‘1’ Ian McCrum Room 5B18, 02890366364 IJ.McCrum@ulster.ac.uk http://www.eej.ulst.ac.uk/~ian/modules/EEE342

  2. The real world • The temperature of air – is a continuously varying value; the “value” changes over “time” • Time is a continuously varying value as well. • We code these into units, Celsius / Fahrenheit / Kelvin, seconds, microseconds etc.,

  3. Computers • Computers must manipulate data; they take inputs, do something and produce outputs. • Internally how do they represent the things they manipulate. • It is easy to make devices that can hold/store/manipulate voltages, it is easier if only two voltages are allowed. • We can describe this two values system as being a binary system • We can use various symbols/phrases for the two values. EEE342 Digital Electronics

  4. Various binary symbols • True /False • One /zero • Active /inactive • Current flowing in one direction or the other (+/-20uA) • Current of one value, or a different value (4-20mA) • Positive voltage/negative voltage (+/-12Volts) • Presence of a voltage/ absence of a voltage (+5V / 0V )

  5. Traditional Logic Circuit values • +5 Volts / 0Volts. – this is approximate! • Typically +4.5V and +0.4V • Guaranteed output >2.4V and <0.4V • Input recognises >2.0V and <0.8V • This allows “noise margin” of 400mV Note: • Modern chips use less “traditional” (old) values. • 3.3V chips common, internally large chips often reduce to 1.8V, 1.2V or less. The reason is to consume less power and go faster – but the chips are harder to make (i.e more expensive) until you have the foundry running well.

  6. 99.999% of the time it is ok to use ‘1’ and ‘0’ or to talk about 5 volts as a ‘1’ • How can we use ‘1’s and ‘0’s to represent real world values – such as temperature or time?

  7. Binary codes • Consider a number of bits as a group • Each bits position indicates its importance • Simplest is to use powers of 2 (but note it is NOT the only way) • E.g if we use 4 bit groups we have “weights” of [8 4 2 1] • So 1001 is considered as 8+1 (actually 8x1 + 4x0 + 2x0 + 1x1 ) • A 4 bit binary word (sometimes called a “nibble”) can represent any number between 0 and 15 inclusive. • Note the binary weights can also be written as x23, x22, x21, x20 and that a 4 bit group can represent from 0 to 24-1 values (0-15 here) • An 8 bit group is called a byte and can hold 0-255 values (0 - 28-1) • A 16 bit group CAN be called a word – 0-65535 values • Technically a word is the base size of the registers within a machine. A machine with 32 bit registers has a word size of 32 bits which can hold numbers of about 4 billion

  8. Natural Binary – the 8421 weights • We can convert binary to decimal by just adding up the weights • To convert decimal to binary we can successively divide by two and note the remainder. E.g 1110 11/2 = 5 remainder 1 5/2 = 2 remainder 1 2/2 = 1 remainder 0 1/2 = 0 remainder 1 so 1110 is 11012

  9. Conventions • 11012 can also be written as b’1101’ Some software tools accepts this as an input • 4 bits can be replaced by a single symbol, we can’t just use numbers as we need 16. The HEX convention allows use of 0-9 and then ‘A’, ‘B’, ‘C’, ‘D’, ‘E’ and ‘F’ • Many software tools use a prefix of 0x • So 0xC is 12 in decimal or 11002 in binary • Of most use in large binary numbers – too errorprone to write down as b’11011010101010101010111101110101’

  10. 0000 = 0 0001 = 1 0010 = 2 0011 = 3 0100 = 4 0101 = 5 0110 = 6 0111 = 7 1000 = 8 1001 = 9 1010 = A 1011 = B 1100 = C 1101 = D 1110 = E 1111 = F HEX numbers • b’11011010101010101010111101110101’ • To convert binary to hex, split the binary up in 4 bit nibbles. NB always start at the rightmost bit, the least significant bit b0 • Add leading zeros so that you are dealing with a multiple of 4, not needed here as the example is a 32 bit number. • 1101 1010 1010 1010 1010 1111 0111 0101 • Use a lookup table to convert each nibble to a single symbol • 1101 1010 1010 1010 1010 1111 0111 0101 • D A AAA F 7 5 • Collect the symbols together and prefix with 0x • The HEX representation of this number is 0xDAAAAF75 • This way of showing you HEX implies it is just a way of saving ink – just a way of conveniently working with binary. Alternatively you can treat HEX numbers as BASE-16 numbers the same way we used BASE 2 numbers with binary

  11. HEX numbers • To convert 0x247E to decimal • Treat the weights as x163, x162, x161, x160 • (if you do a lot of these you end up remembering that the weights are x4096, x256, x16 and x1.) • 4 hex digits can represent 16 bits, 0-65535 • 4 hex digits can represent 0 to 164-1 • 32 bit binary numbers require 8 hex digits.

  12. Coding numbers in ‘1’s and ‘0’s • Irrespective of whether we write down hex or binary, the computer stores ‘1’s and ‘0’s • Given an arbitrary binary number we need to know what it is representing. • Some (old)calculators uses 8421 codes but do not allow codes above 1001. • Some (old)caluclators use a 2421 code • There is also an excess-3 code in use.

  13. Uses for binary numbers • You can use binary numbers to represent positive whole numbers. • You can use “natural binary” or any weighted binary code • You can use a subset of the available codes e.g 10 out of 16 - This is “Binary Coded Decimal” also called BCD, this suits humans... • Positive and negative numbers (2 conventions are in common use) • The tones on a piano! (i.e anything) • Floating point numbers (a couple of conventions exist) • Character codes (usually 7 or 8 bit ASCII codes or unicode– up to 16 bits ) I.E you must know the convention that is being used if you want to make sense of a binary number. Do not assume it is just natural binary.

  14. Positive and Negative binary • One method suits humans, one suits chips • If we set aside a single bit out of the binary word (usually the leftmost bit). We can use it as a “sign” bit where a ‘1’ means ‘-’ and a ‘0’ means ‘+’ This is called “Signed Binary” • So 1101 might mean [1] 101 = -5 • We can change the sign of the left most weight. • So for 4 bits we’d use (x -8),(x4),(x2),(x1). • So 1101 = (-8) + (4) +(1) = -3. • This method is called “Two’s Complement” • Calculating the equivalent decimal value by using the sign of the leftmost bit is not the only way. An alternative is to convert the binary number to its “ones complement” and add 1. • Hence 1101 has a ones complement of 0010 and by adding 1 we get 0011 which is +3 for the twos complement of the 1101. Taking the two’s complement is the equivalent of changing the sign so the original number must have been -3

  15. Floating Point numbers • As humans, we are used to fractions such as 12.75 • In the binary world we can design our own conventions. i.e code 1275 into 16 bits and assume there is a implied “binary point” in the middle. This would be BCD • Or extend the binary system to use weights of ½ , ¼ , 1/8 This might mean some loss of precision. (we can code 12.75 exactly into our extended weighted natural binary. 1100.110 ) but we could not do 12.80 • The scientific notation 2.4 x 103 can also be encoded in binary. There is an IEEE standard for this (IEEE754)(although some others exist as well) Basically we “normalise” and encode the mantissa and exponent into fixed size fields. • When you normalise a binary number it will always begin with a ‘1’ so we can leave it out! • The 32 bit IEEE standard reserves one bit for the sign, 8 bits for the exponent and 23 bits for a representation of the mantissa (without its leading ‘1’) the exponent is stored with a bias of +127 and can be in the range -126 to +127 to fit in the 8 bits. Zero and other “special numbers” can use codes at the extremities of the allowable range.

  16. ASCII codes for characters Copied from http://en.wikipedia.org/wiki/File:ASCII_Code_Chart.svg So the 8 bit HEX code 0x47 is the ASCII character ‘G’

  17. Summary • Be able to convert Binary, hex and decimal to and from each others representations • Be able to convert signed and 2’s complement numbers to other representations • Be able to convert fractions and scientific notations to and from decimal • Be able to work out the hex or binary codes for characters using ASCII

More Related