2019年12月31日 星期二

SR Latch (gated) Verilog

SR Latch (gated) Verilog


module SR_Latch_gated(S,R,G,Q,Qn);
   output Q;
   output Qn;
   input  G; 
   input  S;
   input  R;

   wire   S1;
   wire   R1;
 
   and(S1, G, S);
   and(R1, G, R); 
   nor(Qn, S1, Q);
   nor(Q, R1, Qn);
 

endmodule



// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module Test_bench;
    reg  S,R,G;
    wire Q,Qn;

//SR_Latch_gated(S,R,G,Q,Qn);

SR_Latch_gated  DUT(
.S(S),
.R(R),
.G(G),
.Q(Q),
.Qn(Qn) );
   
initial begin
   
    $monitor(S,R,G,Q,Qn);
    // Initialize Inputs
    S = 0;
    R = 1;
    G = 1;
    // Add stimulus here
    #100 S = 0; R = 1;
    #100 S = 1; R = 0;
    #100 S = 1; R = 1;
    #100 R = 1; R = 0;
    #100 S = 0; R = 0;
    #100 S = 1; R = 1;
    #100 S = 0; R = 0;
   
    G = 0;
    #100 S = 0; R = 1;
    #100 S = 1; R = 0;
    #100 S = 1; R = 1;
    #100 R = 1; R = 0;
    #100 S = 0; R = 0;
    #100 S = 1; R = 1;
    #100 S = 0; R = 0; 
   
   
    #100 ;  $stop;
end

endmodule

沒有留言:

張貼留言

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

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