2020年2月5日 星期三

數位IC設計入門-Verilog combinational logic Full subtractor 全減器 Behavioral Modeling (& Test Bench)

數位IC設計入門-Verilog combinational logic 
Full subtractor 全減器 Behavioral Modeling  (& Test Bench)


//數位IC設計入門-Verilog combinational logic 
//Full subtractor 全減器 Behavioral Modeling  (& Test Bench)
// a = 被減數 b=減數 前一級借位  difference=差 , borrow=借位 

module FS (a, b, c, difference, borrow);
  input a, b, c;
  output difference, borrow;
  reg difference, borrow;

  always@(a or b or c)
  begin
        {borrow, difference} = a - b - c;
  end

 endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps    
module Test_bench;
// a = 被減數 b=減數 前一級借位  difference=差 , borrow=借位 
//module FS (a, b, c, difference, borrow);
  //input a, b ,c ;
  //output difference, borrow;

// Inputs
reg a=0 ,b=0 ,c=0 ;

// Outputs
wire difference, borrow;

// Instantiate the Unit Under Test (UUT)
//module HS (a, b, difference, borrow);

FS UUT(a, b,c, difference, borrow);

initial begin
 $monitor(a, b,c, difference, borrow);
    // Initialize Inputs
 #25 a=0 ; b=0 ; c=1 ;
 #25 a=0 ; b=1 ; c=0 ;
 #25 a=0 ; b=1 ; c=1 ;
 #25 a=1 ; b=0 ; c=0 ;
 #25 a=1 ; b=0 ; c=1 ;
 #25 a=1 ; b=1 ; c=0 ;
 #25 a=1 ; b=1 ; c=1 ;

end

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


endmodule

沒有留言:

張貼留言

2026 作業1 MQTT基本觀念

 2026 作業1MQTT基本觀念 作業  參考下面網址 https://alex9ufoexploer.blogspot.com/2025/02/1-mqtt-relay-dht22-mqtt-box-pc-mymqtt.html https://alex9ufoexploer...