# 數位系統 第三次實驗報告 ###### tags: `digital system` 姓名:高聖傑 系級:資工113 學號:B093040016 實驗日期:2021/10/18 ## 實驗一 ### 內容 - 目標 & 要求 - 找出 sum of minterm as $F_1$ - 找出 product of maxterm as $F_2$ - 根據模擬結果的波形圖,驗證 $F_1$ 等效於 $F_2$ ### 過程 $F_1$, sum of minterm(先找 True , 再對全部取 OR ): $=w'x'y'z+ w'x'yz'+ w'x'yz+ w'xyz'+ wx'yz+ wxy'z'+ wxyz'+ wxyz$ $=\Sigma(m_1, m_2, m_3, m_6, m_{11}, m_{12}, m_{14}, m_{15})$ $F_2$, product of maxterm(先找 False , 再對全部取 AND ): $=( w+x+y+z)( w+x'+y+z)(w+x'+y+z')(w+x'+y'+z)\\(w'+x+y+z)(w'+x+y+z')(w'+x+y'+z)(w'+x'+y+z')$ $=\Pi(M_0, M_4, M_5, M_7, M_8, M_9, M_{10}, M_{13})$ ```verilog= `timescale 1ns / 1ps module exe1_1(w, x, y, z, res); input w, x, y, z; output res; assign res = (~w&~x&~y&z) | (~w&~x&y&~z) | (~w&~x&y&z) | (~w&x&y&~z) | (w&~x&y&z) | ( w&x&~y&~z) | ( w&x&y&~z) | ( w&x&y&z); endmodule module exe1_2(w, x, y, z, res); input w, x, y, z; output res; assign res = ( w|x|y|z) & ( w|~x|y|z) & (w|~x|y|~z) & (w|~x|~y|~z) & (~w|x|y|z) & (~w|x|y|~z) & (~w|x|~y|z) & (~w|~x|y|~z); endmodule ``` ### 模擬結果 | w | x | y | z | res | |:---:|:---:|:---:|:---:|:---:| | 0 | 0 | 0 | 0 | 0 | | 0 | 0 | 0 | 1 | 1 | | 0 | 0 | 1 | 0 | 1 | | 0 | 0 | 1 | 1 | 1 | | 0 | 1 | 0 | 0 | 0 | | 0 | 1 | 0 | 1 | 0 | | 0 | 1 | 1 | 0 | 1 | | 0 | 1 | 1 | 1 | 0 | | 1 | 0 | 0 | 0 | 0 | | 1 | 0 | 0 | 1 | 0 | | 1 | 0 | 1 | 0 | 0 | | 1 | 0 | 1 | 1 | 1 | | 1 | 1 | 0 | 0 | 1 | | 1 | 1 | 0 | 1 | 0 | | 1 | 1 | 1 | 0 | 1 | | 1 | 1 | 1 | 1 | 1 | $F_1$ → res1, $F_2$ → res2 ![e1](https://i.imgur.com/57jacxW.png =600x) 兩個 function 所產生的波形圖一樣,因此可證明 $F_1, F_2$ 等效, 且 $F_1, F_2$ 在 canonical form 表示法中,挑出的數字為補集。 ## 實驗二 ### 內容 - 目標 & 要求 - 使用德摩根定律,算出下列 - $(x↓y)↓z=(x+y)z'$ - $z↓(y↓x)=z'(x+y)$ - $x↓(y↓z)=x'(y+z)$ - 利用 Structural level modeling,模擬以下 boolean function - $F_1 = (x↓y)↓z$ - $F_2 = z↓(y↓x)$ - $F_3 = x↓(y↓z)$ - 根據模擬結果的波形圖,驗證 $F_1$ 等效於 $F_2$,且 $F_1,F_3$ 並非等效邏輯 ### 過程 ### $(x↓y)↓z=(x+y)z'$ $(x↓y)↓z$ $=(x↓y)'z'$ $=(x+y)z'$ ### $z↓(y↓x)=z'(x+y)$ $z↓(y↓x)$ $=z'(x↓y)'$ $=z'(x+y)$ ### $x↓(y↓z)=x'(y+z)$ $x↓(y↓z)$ $=x'(y↓z)'$ $=x'(y+z)$ ```verilog= `timescale 1ns / 1ps module exe2_1(x, y, z, res); input x, y, z; output res; wire nor1; nor(nor1, x, y); nor(res, nor1, z); endmodule module exe2_2(x, y, z, res); input x, y, z; output res; wire nor1; nor(nor1, y, x); nor(res, z, nor1); endmodule module exe2_3(x, y, z, res); input x, y, z; output res; wire nor1; nor(nor1, z, y); nor(res, nor1, x); endmodule ``` > 其實不難發現,$z↓(y↓x)$ 只是刮號內左右互換的 $(x↓y)↓z$ ... ### 模擬結果 $(x↓y)↓z$ → res1, $z↓(y↓x)$ → res2, $x↓(y↓z)$→ res3 ![e2](https://i.imgur.com/r7ETq29.png =600x) 三個 function 所產生的波形圖裡, $(x↓y)↓z, z↓(y↓x)$ 輸出相同,因此可證明 $(x↓y)↓z, z↓(y↓x)$ 等效。 $(x↓y)↓z, x↓(y↓z)$ 輸出有異,說明其為非等效邏輯 ## 實驗三 ### 內容 - 目標 & 要求 - 求出 F(w, x, y, z) 的真值表 - 利用 Structural level modeling,模擬以下 boolean function - $F_1 = (w⊕x)⊕(y⊕z)$ - $F_2 = w⊕(x⊕(y⊕z))$ - $F_3 = w⊕x⊕y⊕z$ - 根據模擬結果的波形圖,驗證 $F_1,F_2,F_3$ 等效 ### 過程 ```verilog= `timescale 1ns / 1ps module exe3_1(x, y, z, res); input w, x, y, z; output res; wire x1, x2; xor(x1, w, x); xor(x2, y, z); xor(res, x1, x2); endmodule module exe3_2(x, y, z, res); input w, x, y, z; output res; wire x1, x2; xor(x1, y, z); xor(x2, x, x1); xor(res, w, x2); endmodule module exe3_3(x, y, z, res); input w, x, y, z; output res; xor(res, w, x, y, z); endmodule ``` - truth table | w | x | y | z | F | |:---:|:---:|:---:|:---:|:---:| | 0 | 0 | 0 | 0 | 0 | | 0 | 0 | 0 | 1 | 1 | | 0 | 0 | 1 | 0 | 1 | | 0 | 0 | 1 | 1 | 0 | | 0 | 1 | 0 | 0 | 1 | | 0 | 1 | 0 | 1 | 0 | | 0 | 1 | 1 | 0 | 0 | | 0 | 1 | 1 | 1 | 1 | | 1 | 0 | 0 | 0 | 1 | | 1 | 0 | 0 | 1 | 0 | | 1 | 0 | 1 | 0 | 0 | | 1 | 0 | 1 | 1 | 1 | | 1 | 1 | 0 | 0 | 0 | | 1 | 1 | 0 | 1 | 1 | | 1 | 1 | 1 | 0 | 1 | | 1 | 1 | 1 | 1 | 0 | ### 模擬結果 $F_1$ → res1, $F_2$ → res2, $F_3$ → res3 ![e3](https://i.imgur.com/UuMuoVO.png =600x) 三個 function 所產生的波形圖皆一樣,因此可證明 $F_1, F_2, F_3$ 等效,且觀察到 XOR 邏輯閘只有在輸入奇數個 1 會輸出 1,**輸入數量或順序不影響其結果**。 ## 實驗心得 > 這次的實驗主要是練習 verilog 程式碼。 > 第一個實驗中,使用 dataflow level 觀察在同個 truth table 中 sum of minterm & product of maxterm 是否相同。我看到有同學的程式碼是全部擠在一起的,這樣若要 debug 會造成閱讀上的困難,可見排版的重要性。 > 第二個實驗是觀察 NOR 邏輯閘是否符合結合率。 > 第三個實驗是觀察 XOR 邏輯閘在不同的輸入數量或順序時,結果有無差異,最後是觀察到, XOR 邏輯閘只有在輸入奇數個 1 會輸出 1。 > 此外,在助教的指導下,我學會如何一次同步模擬多個 module,這樣在比較不同 module 間的輸出更為方便,也不用花時間創建一大堆專案,時間效率提升了不少。 > 在整體上,我已經大致熟悉 vivado 的流程,這次出現一點命名錯誤之類的小 bug,可以快速解掉,可說是一回生,二回熟,希望以後還是能這麼順利。