# Week.2
## Digital Logic
[TOC]

`https://hackmd.io/@zxcj04/i2c-logic`
----
助教: 黃爾群
FanRende (030Mortal#5525)

---
## 作業網站
http://140.121.197.13/tutorial
請想辦法記住這個網址
不然就加到書籤裡
今天及未來的作業都要交到這上面
----
### Week2

---
## Logic Gate

###### credit: [SMALL LOGIC GATES — THE BUILDING BLOCKS OF VERSATILE DIGITAL CIRCUITS](https://www.nutsvolts.com/magazine/article/small-logic-gates-spawn-big-dreams-part-1)
----
### AND Gate
<div class="flex-container">
<div class="flex-content">

</div>
<div class="flex-content">
| Input 1 | Input 2 | Output |
| ------- | ------- | ------ |
| False | False | False |
| False | True | False |
| True | False | False |
| True | True | True |
</div>
</div>
----
### OR Gate
<div class="flex-container">
<div class="flex-content">

</div>
<div class="flex-content">
| Input 1 | Input 2 | Output |
| ------- | ------- | ------ |
| False | False | False |
| False | True | True |
| True | False | True |
| True | True | True |
</div>
</div>
----
### NOT Gate
<div class="flex-container">
<div class="flex-content">

</div>
<div class="flex-content">
| Input 1 | Output |
| ------- | ------ |
| False | True |
| True | False |
</div>
</div>
----
### NOR Gate
<div class="flex-container">
<div class="flex-content">

</div>
<div class="flex-content">
| Input 1 | Input 2 | Output |
| ------- | ------- | ------ |
| False | False | True |
| False | True | False |
| True | False | False |
| True | True | False |
</div>
</div>
----
### XOR Gate
<div class="flex-container">
<div class="flex-content">

</div>
<div class="flex-content">
| Input 1 | Input 2 | Output |
| ------- | ------- | ------ |
| False | False | False |
| False | True | True |
| True | False | True |
| True | True | False |
</div>
</div>
---
## Half Adder
<div class="flex-container">
<div class="flex-content">
用來將 1-bit 二進位的數字相加
結果以 S 表示 進位以 Cout 表示
| A | B | S | Cout |
| --- | --- | --- | ---- |
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
</div>
<div class="flex-content">

###### credit: [gitbook - Half-Adder](https://tomorrow0w0.gitbooks.io/nand2tetris-homework/content/chapter2/HalfAdder.html)
</div>
</div>
----
## Full Adder
<div class="flex-container">
<div class="flex-content">
用來將 1-bit 二進位的數字相加
有前一步的進位
| A | B | Cin | S | Cout |
| --- | --- | --- | --- | ---- |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
</div>
<div class="flex-content">

###### credit: [gitbook - Full-Adder](https://tomorrow0w0.gitbooks.io/nand2tetris-homework/content/chapter2/FullAdder.html)
</div>
</div>
---
## LogicCircuit

---
## Lab Questions
作業做完請上傳到 http://140.121.197.13/tutorial
並且注意上傳時間限制、檔名、其他規範
上課時提前做完可以直接給助教 demo 登記
就不需要上傳 demo 過的部分
----
1. 利用 LogicCircuit 畫出下圖的邏輯電路
並產生出他的 Truth Table
請注意接點位置及工整度

----
2. 利用 LogicCircuit 畫出下圖的 J-K flip flop
請注意接點位置及工整度

----
3. 利用 LogicCircuit 畫出前面介紹過的 1-bit Full Adder
並產生出他的 Truth Table
請注意接點位置及工整度
4. 結合上面的 1-bit Full Adder 做出 2-bit Full Adder
5. (\*) 結合上面的 2-bit Full Adder 做出 4-bit Full Adder
----
(不計分)
6. 多 bit 的 Full Adder 被稱為 Ripple Carry Adder
請查閱與 Carry Lookahead Adder 的差別
<style>
.flex-container {
display: flex;
justify-content: center;
}
.flex-content {
flex-grow: 1;
font-size: 0.7em;
}
</style>
<style>
/* Customize website's scrollbar like Mac OS */
::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
}
::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: rgba(128, 128, 128, 1);
-webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);
}
</style>
{"slideOptions":"{\"theme\":\"solarized\",\"transition\":\"fade\",\"allottedMinutes\":40}","image":"https://hackmd.io/_uploads/SyUtwHHk6.png","title":"Week.2 Digital Logic","description":"https://hackmd.io/@zxcj04/i2c-logic","contributors":"[{\"id\":\"82f6b599-31b8-4112-9dc5-7d7b7d6a3ebb\",\"add\":5357,\"del\":622}]"}