Hierarchal design
- Building high-level parts from lower-level parts (“black box” small units and building up to bigger units)
todo go over the example with 4 bits. Always remember -1, 0, 8. -8 since they don’t abide by the “slide hit invert” rule
- Acc its in the slide right after.
Shortcuts for signed numbers
There are two ways to add signed numbers. He says this is a common source of confusion
- You can either add two signed numbers
- subtract unsigned numbers
- We can implicitly negate the number and add them?
- Uhh i’m lost
Implementation of subtraction circuit
- Invert all the Y bits. Also will be 1 (as we add 1 as per the algorithm above)
- If we’re adding, then we don’t want to invert. We could use a multiplexer (so depending on if we’re adding or subtraction, we simply don’t invert and don’t add 1 at the start).
- Alternatively we can use an XOR gate.
X XOR 1 = NOT(X)- Let
Subbe the bit that determines if we’re subtracting or nah. Then you do things mhmmh.
- Let
Problem when adding
- Consider two signed 4-bit numbes
0110 + 0011. The result would be1001but that’s a negative number! 9 exceeds the range of 4-bit signed intgers (-8 to 7) - Same happens if we add two negative numbers.
1000 + 1111 = 0111but that’s positive. Oh no!
- Positive + Negative number will never overflow
- This is called
overflow