---
# System prepended metadata

title: 數位邏輯導論

---

# 數位邏輯導論
## 二進位 
## 101101 ={(2^5)*1} +{(2^4)*0} +{(2^3)*1} +{(2^2)*1} +{(2^1)*0} +{(2^0)*1} 

### EX: 123 (十進位轉二進位)
### > 123/2=61...1
### > 61/2=30...1
### > 30/2=15...0
### > 15/2=7...1
### > 7/2=3...1
### > 3/2=1...1
### > 1/2=0...1

###### tags:  +U+U+U+U+U+U+U+U+U+U+U+U+U+U+U 好><

## 有符號數處理
###### tags: 以4個bit來表示，一個bit有0,1兩種可能，所以總共有2^4種表示法。
### >> Sign-magnitude(原碼)
* 硬體的實現較困難
* 最高有效位數為0表示正數，1表示負數!


| +0   | +1   |   +2|   +3|   +4|   +5|   +6|   +7|  +8|
| ---- | ---- | --- | --- | --- | --- | --- | --- | ---- |
| 0000 | 0001 | 0010| 0011|0100 | 0101| 0110|0111| /|


|-0|-1|-2|-3|-4|-5|-6|-7| -8|
| -------- | -------- | --- | --- | --- | --- | --- | --- | -------- |
|1000|1001    | 1010    |  1011   | 1100   |1101     | 1110   |  1111   |    /    |
### >> 1's complement(1補數)
* 改善 Sign-magnitude(原碼) 正負相似，容易出錯的問題
* 負數為正數的補數(0,1互補)

| -0 | -1 | -2| -3 |    -4 |-5     |   -6  |   -7  |    -8 |
| -------- | -------- | -------- | --- | --- | --- | --- | --- | --- |
| 1111    |1110    | 1101     |  1100   |1011     |1010     |1001     |1000     |  /   |


### >>2's complement(2補數)
* 解決+0及-0的問題
* 兩正整數相加需小於2^3，否則會造成溢質(overflow)的錯誤
  ######  tags: n=4(bit) 總和小於2^(n-1)
* 將一補數的負數數字+1，使負數從-1開始


| -0 | -1| -2 |  -3   |    -4 |  -5   | -6    |   -7  |-8     |
| -------- | -------- | -------- | --- | --- | --- | --- | --- | --- |
| /   | 1111 | 1110  | 1101| 1100    |1011     | 1010    |1001     |1000     |

## Boolean algebra(布林運算)
![](https://i.imgur.com/n1s63p5.png)   (Z=X•Y)
> #### 0•0=0  , 0•1=0  , 1•0=0  , 1•1=1

![](https://i.imgur.com/4mXFc0v.png)
> #### 0+0=0  , 0+1=1  , 1+0=1  , 1+1=1

![](https://i.imgur.com/gl70wRQ.png)
> ####  A=1 A'=0 , A=0 A'=1
### EX.

![](https://i.imgur.com/nSTzexo.png)
![](https://i.imgur.com/sKvk9r0.png)


---

### >> 交換律( Commutative Law )
![](https://i.imgur.com/Nbw3aJH.png)

### >> 結合律( Associative Law )
![](https://i.imgur.com/7kfihoR.png)

### >> 分配律( Distributive Law )
###       X(Y+Z)= XY+XZ   ,   X+YZ= (X+Y) • (X+Z)


---
## 2-level logical realization 二層邏輯的實現方式
#### Sum of product form(SOP) & Product of sum(POS)
![](https://i.imgur.com/0acq5BM.png)
###### tags: 右邊用分配律變成左邊,   SOP ➝ POS
![](https://i.imgur.com/gIO3a7u.png)

---
# Demorgan's Law (笛摩根定律)
![](https://i.imgur.com/IjJPeYB.png)

![](https://i.imgur.com/xYS6gQB.png)

![](https://i.imgur.com/bGxRaRl.png)

![](https://i.imgur.com/ytZ9Cgd.png)

EX
![](https://i.imgur.com/RzdElM9.png)
## General Form 
### >> One-step rule
#### 不用一層一層做，and 跟 or 互換，補數跟沒補數互換，0,1互換
![](https://i.imgur.com/k081ycF.png)

###### tags: 要注意順序，先做的交換之後也是要先做 
#### EX
![](https://i.imgur.com/SlFlXhs.png)
### >> Duality (對偶性)
####   and 跟 or互換，1,0互換 ，補數不用
![](https://i.imgur.com/Ns4p2cu.png)
#### EX
![](https://i.imgur.com/sIrQtIT.png)

### 對偶的特性
![](https://i.imgur.com/nZof4Eg.png)
#### EX
![](https://i.imgur.com/fGVvyy6.png)


---

## 乘法跟因式表達方式
1. ### x(y+z) = xy+xz
###### tags: pos ➝ sop
2. ### x+yz = (x+y)(x+z)  
###### tags: sop ➝ pos  
3. ### (x+y)(x'+z) = xz+yx'
###### tags: pos ➝ sop
###### 證明 1. : 分配律➝ xx'+ xz + x'y + yz 
###### ➝ 0+ xz + x'y + (x+x')yz
###### ➝ 0+ xz + x'y + xyz + x'yz
###### ➝ xz 比 xyz 大，則可捨棄xyz， x'yz也是
###### ➝ 得 xz + yx'
###### 證明 2. : 假設 x=1,x=0時，左邊都會等於右邊，得兩式子相等

### EX
![](https://i.imgur.com/u03QRJz.png)
###### tags:  POS變SOP

### EX
![](https://i.imgur.com/0GnkYri.png)
###### tags: SOP變POS



---
## Exclusive-or!(x-or)[](https://i.imgur.com/XGUjUrj.png)
#### 有排他性
![](https://i.imgur.com/0dQvZMU.png)
證!!!!!! ![](https://i.imgur.com/UwZzkJc.png)
## Equivalence Operation(xNor) ![](https://i.imgur.com/QKPUm80.png)




 





















