2020年1月5日 星期日

Verilog SR Latch using Behavior Modeling

Verilog SR Latch using Behavior Modeling 




//=================================================
//Design of SR Latch using Behavior Modeling Style
//=================================================
module RS_Latch( s ,r ,enable ,q ,qb );

output q ;
reg q ;
output qb ;
reg qb ;

input s ;
wire s ;
input r ;
wire r ;
input enable ;
wire enable ;

always @ (enable or s or r ) begin
 if (enable) begin
if (s!=r) begin
q = s; qb = r;
end 
else if (s==1 && r==1) begin
q = 1'bZ; qb = 1'bZ;
end
end
 else
  begin
q = 1'bZ; qb = 1'bZ;
end
end

endmodule


// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps     
module Test_bench;
//module RS_Latch( s ,r ,enable ,reset ,q ,qb );
 reg s,r,enable;
 wire q, qb;

RS_Latch UUT( s ,r ,enable ,q ,qb );

initial begin
    // Initialize Inputs
    s = 0; r = 1;enable=1;
     
    // Add stimulus here
    
    #100 s = 1;r = 0; 
    #100 s = 1;r = 1;
    #100 s = 1;r = 0;
    #100 s = 0;r = 0;
    #100 s = 0;r = 1;
    #100 s = 1;r = 1;
    #100 s = 0;r = 0;
    #100 $stop;
end

endmodule

沒有留言:

張貼留言

作業2 MQTT (Relay + DHT22) 控制 ------- 利用Node-Red

作業2 MQTT (Relay + DHT22) 控制 ------- 利用Node-Red 1) 安裝Node-Red  https://ithelp.ithome.com.tw/articles/10201795 https://www.youtube.com/watch?v...