Computer Organisation and Design
Introduction
This is me looking at theory and documenting what I need to know. Primarily this was driven from my electronics and not IT.
Pulse Trains
- Non-Periodic pulse trains are digital signals with any pulses over time
- Periodic pulse trains are pulses in fixed time like a clock signal
- T=period (seconds/cycle)
- tw = pulse width
- frequency = cycles/second or frequency = 1/T
- duty cycle = % of time period train = 1 or tw /T x 100%
Binary
Lots of talk about binary and how it works. This is a placeholder to remind me we needed to know about this. Good terms were
- LSB Least significant bit
- MSB Most significant bit
BCD Binary Code Decimal
This is where we encode a number using the digits rather than the value e.g. we encode 94 as a '9' and a '4'
In BCD 94 would 1001 0100 9 4
Multiplications and Divisions
Distributive law was mentioned. You can solve a problem using the order of operations using distributive law.
Given 5(3+4) Order of operations would be 5(7) = 35 Distributive law would be (5x3)+(5x4) = 15 + 20 = 35
We looked at doubling a number below where each value could be solved with
3x2 or (2 x 2) + (2 x 1) = 6 6x2 or (2 x 4) + (2 x 2) = 12 12x2 or (2 x 8) + (2 x 4) = 24
3 = 2 + 1 = 00000011 6 = 4 + 2 = 00000110 12 = 8 + 4 = 00001100 24 = 16 + 8 = 00011000 48 = 32 + 16 = 00110000 96 = 64 + 32 = 01100000
192 = 128 + 64 = 11000000
We can multiply easily using the shift operators e.g.
a = a * 16 or 2 to the power of 4 or a = a << 4;
Or divide with >>
b = b/8 b = b >> 3
Converting to Binary
Let take 89 and continue to divide by 2
89 / 2 = 44 rem 1 - LSB 44 / 2 = 22 rem 0 22 / 2 = 11 rem 0 11 / 2 = 5 rem 1 5 / 2 = 2 rem 1 2 / 2 = 1 rem 0 1 / 2 = 0 rem 1
Therefore taking answers in reverse 89 = 01011001
ADC Explained
Really like this explanation for ADC. Obvious once you know. The bit depth represents how many divisions there are between the max and min values you are allowing. The image show an american cooker and they are using the following
- Min 300°F - Max 500°F
- Range is 200°F
- Bit Depth 8-bits
- Resolution is Range / By number of intervals which is 300 / 2⁸-1 (We minus one because we need the min and max for 1 byte) = 1.1764
Sampling and Sample Rates
Sampling Rate (Hz) = Number of samples /second. Nyquist Theorem suggests we need to same 2 as often as max
Average Ears here at 20Khz hence why audio is at 44.1 kHz
Gray Codes
This is a technique where we convert number from binary to gray. We do this because Gray reduces the bits we need to change to get to the next number. e.g. changing from 2 to 3 decimal requires a 1 bit change.
Here is a conversion table
Decimal | BCD | Gray Code |
0 | 0000 | 0000 |
1 | 0001 | 0001 |
2 | 0010 | 0011 |
3 | 0011 | 0010 |
4 | 0100 | 0110 |
5 | 0101 | 0111 |
6 | 0110 | 0101 |
7 | 0111 | 0100 |
8 | 1000 | 1100 |
9 | 1001 | 1101 |
10 | 1010 | 1111 |
A can also convert to gray using the following technique
1/ Add a zero to the binary number to convert 2/ Iterate over the number, if the preceeding number is different put 1, if the same put 0 Example 1 1100 01100 Add a prefix of zero and go through each pair 1010
Example 2 010111 0010111 011100
Compliments
10s Compliment
Really liked this and a surprise. Take a simple sum
5283 -2946 ----- 2337
Now if we follow these rules
1/ Subtract each of the second operator from 9 2/ Add 1 to the result
Gives
999999 002946 +1 ------ 997054
Now use this number as the second operator and disregard the carry
005283 +997054 ------ 002337
2s Compliment
This is possible in binary to but no example is provided here. The process to convert from 2s compliment is to invert all the bits and add 1
Binary formats
What was highlighted is that we need to be careful when given a binary number that we understand the format
10011000 = BCD is 1001 1000 or 9 and 8 = 98 = 2s is 01101000 = -104 = unsigned is 152
Overflow
With unsigned format we overflow when a number is carried beyond original e.g. 1111 +-0001 With 2s compliment to overflow when the sign byte changes for addition