proj1(review)
1.1 Boolean Logic
==The Formula == The Truth table.==
So if you ‘re struggling with the formula, you can use the truth table instead.

(This is a function we define. You can define other functions as desired.)
⭐Some useful equations
Note that the last two equations are particularly important.

Boolean Algebra can be simplified (2 ways)


1.2 Boolean Function
001:
- ==理论上,任何布尔函数都可以用NotAndOr表示出来(通过真值表选取f=1的情况)(做芯片有用)==


002:
- ==(or可以通过And和Not表示)==

003:
- ==而Nand可以表示出And、Not芯片(根本的根本)==


1.3 Logic Gates
上一节是抽象的逻辑运算,这一节是实际的芯片/逻辑门




一个接口,可以有不同的实现

1.4 Hardware Description Language
一种硬件描述语言(做硬件/芯片用的)

芯片接口 和 芯片实现
==⭐实现:用真值表看1,写出布尔函数化简,画出逻辑图==





1.5 Hardware Simulation
- for 模拟芯片测试
- way:在给定的硬件模拟器中 + 使用编写的测试文件





1.6 Mutil-bit Buses
多位总线(eg16位总线,一条线上有16个位bit)
(最左边第一位是高位。 最右边的最低位一般标记为第 0 位)


⭐ useful

可以进行多个output,比如前8位输出,后八位输出,全部输出
内部引脚宽度自动推断
“false” 和 “true” 可作为任意宽度的总线使用
1.7 proj 7 preview


tip几个


(既可以用作And门,也可以用作Mux门)



And 16 : 两个输入,都是16位的,一个输出(每位进行And运算),也是十六位的


16-bit,4way multiplexor : 输入都是16位的,4个输入,一个16bit输出(mux逻辑,根据which sel进行选择)。


⭐ notes

API

1.8 code
Nand
| x | y | out |
|---|---|---|
| 1 | 1 | 0 |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 0 | 0 | 1 |
Not
1 | // Not gate : if (in) out = 0, else out = 1 |
And
1 | // And gate : if (a and b) out = 1, else out = 0 |
Or
1 | // Or gate : if (a or b) out = 1, else out = 0 |
Xor
(图片最下面的 0 0 → 0)
1 | // Exclusive-or gate: if ((a and Not(b)) or (Not(a) and b)) out = 1, else out = 0 |
Nor
1 | // Nor: if (a=0 and b=0,out=1,else out=0) |
Mux(二1bit并一)
1 | // Multiplexor: if (sel = 0) out = a, else out = b |
Dmux(一解二)
1 | // Demultiplexor: [a, b] = [in, 0] if sel = 0 [0, in] if sel = 1 |
Not16
把一个16位的数,每一位都取反
1 | // 16-bit Not gate: for i = 0, ..., 15: out[i] = Not(a[i]) |
And16
把两个16位的数,每一位都求And
1 | // 16-bit And gate: for i = 0, ..., 15: out[i] = a[i] And b[i] |
Or16
Or 16 :把两个16位的数,每一位都求Or

Or 16 Way :单个16位数,串行进行or操作,输出最后的一个结果0/1
1 | // 16-bit Or gate: for i = 0, ..., 15: out[i] = a[i] Or b[i] |
Mux16(二16bit并一)
- 实现方式:16个Mux 并排(just拼一起而已) 作用于每一个bit
1 | // 16-bit multiplexor: for i = 0, ..., 15: if (sel = 0) out[i] = a[i], else out[i] = b[i] |
Or8Way
1 | // 8-way Or gate! out = in[0] Or in[1] Or ... Or in[7] |
Mux4Way16(四16bit并一)
解析名字含义:
Mux16 是 16-bit 的意思。
Mux4Way16 是 16-bit,4-way 的意思
那为啥 Or8Way 是 8-bit,1-way?的意思?
1 | /** |
Mux8Way16(八16bit并一)
1 | /** |
DMux4Way(一解四)
(无sel[2],是多余的,可删)
1 | /** |
DMux8Way(一解八)
1 | /** |

