Gate and Circuit

Gate and Circuit

This lecture will cover sections 5.1 through 5.4 from Chapter 5 of the book.

In the beginning …

Origin of modern computing architectures

Modern computer architecture

Logic Gates

2.1 Basic Logic Gates

A B A AND B A OR B NOT A NOT B
0 0 0 0 1 1
0 1 0 1 1 0
1 0 0 1 0 1
1 1 1 1 0 0

2.2 Electronic Circuit

word-oriented memory organization

2.3 Other gates

A B A NAND B A NOR B A XOR B
0 0 1 1 0
0 1 1 0 1
1 0 1 0 1
1 1 0 0 0

Circuits

3.1. Arithmetic: Addition

\[\ 0010 \\ +\ 0110 \\ \hline \ 1000\] \[\ 1011 \\ +\ 1100 \\ \hline \ 10111\] \[\ 0101 \\ +\ 1001 \\ \hline \ 1110\]

$1110=(-1)(1)(8)+(1)(4)+(1)(2)+(0)*1=(-8)+4+2=(-2)$

3.2. Arithmetic: Multiplication

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
### 3.3. Negation


- Negate through complement and increment:
  - `~x + 1 == -x`



- Implement a C program called `negation.c` that implements and validates
the equation in slide 24. The program should take in a command line argument
that takes in a number of type `short` to be negated. 
- What happens if you try to negate `-32768`?

:::{dropdown} Solution
<script src="https://gist.github.com/linhbngo/d1e9336a82632c528ea797210ed0f553.js?file=negation.c"></script>
:::

The Processor’s Execution of Program Instructions

Add instruction example

https://diveintosystems.org/book/C5-Arch/instrexec.html

Fetch
Decode
Execution
WriteBack