2020年4月1日 星期三

Half Adder Structural Model in Verilog

Half Adder Structural Model in Verilog



Code:

module xor1(input a, b, output s);
xor (s, a, b);
endmodule 

module and1(input a, b, output c);
and (c, a, b);
endmodule 

module halfadder8 (input a, b, output s, c);
xor1 u1(a, b, s);
and1 u2(a, b, c);
endmodule

Testbench Code:

module half_adder_verilog_tb();

reg a, b;
wire s, c;

halfadder8 dut (.a(a), .b(b), .s(s), .c(c));

initial
begin

a = 1'b0;
b = 1'b0;
#50;

a = 1'b0;
b = 1'b1;
#50;

a = 1'b1;
b = 1'b0;
#50;

a = 1'b1;
b = 1'b1;

end

endmodule

Output:

沒有留言:

張貼留言

Telegram +ESP32自動發報機

  Telegram   +ESP32自動發報機 這套系統是一個典型的 IoT(物聯網)架構 ,結合了遠端配置(Python)、通訊中介(MQTT)與硬體執行(ESP32)。 以下我為您拆解這兩支程式的核心運作原理: 一、 系統架構流程 Python 端 (控制台) :使用者輸入...