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

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...