2019年12月26日 星期四

Verilog HDL XOR XNOR NAND NOR Gate

Verilog HDL XOR XNOR NAND NOR Gate






module xor_xnor_nand_nor(A, B,f1_xor,f1_xnor,f1_nand,f1_nor);

input  A, B; // A, B 1位元輸入
output f1_xor,f1_xnor,f1_nand,f1_nor; // Output 1位元輸出

xor (f1_xor, A, B);
xnor (f1_xnor, A, B);
nand (f1_nand, A, B);
nor  (f1_nor, A, B);

endmodule


// 時間單位 1ns, 時間精確度1 ps
`timescale 1ns/1ps
module Test_bench;
reg tA = 1'b0;  // A 暫存器資料初值為‘0’
reg tB = 1'b0;  // B 暫存器資料初值為‘0’
wire t_f1_xor,t_f1_xnor,t_f1_nand,t_f1_nor;

xor_xnor_nand_nor  DUT(.A(tA),.B(tB),.f1_xor(t_f1_xor),.f1_xnor(t_f1_xnor),.f1_nand(t_f1_nand),.f1_nor(t_f1_nor));

// initial程序結構區塊, 產生A、B輸入信號波形
initial
begin
  #100;    // 100ns
    tB = 1'b1;    // “01”

  #100;    // 200ns
    tA = 1'b1;   // “10”
    tB = 1'b0;

  #100;    // 300ns
    tB = 1'b1;   // “11”

  end

initial
begin
  #400;   // 模擬終止時間  400 ns
    $stop;
end

endmodule

沒有留言:

張貼留言

ESP32 微控制器 採集的環境數據,經由 MQTT 協定 轉換並寫入工業標準的 Modbus 暫存器 中

  一個典型的 IoT(物聯網)與工業自動化系統整合(SCADA/機台連線) 的架構圖。它透過 Node-RED 作為核心資料網關,將前端 ESP32 微控制器 採集的環境數據,經由 MQTT 協定 轉換並寫入工業標準的 Modbus 暫存器 中。 1. 各模組功能拆解...