2021年4月4日 星期日

使用Quartus-II 9.1SP2 + ModelSim 6.5b-Aletra + Altera DE2-115 FPGA開發平台,設計D Flip Flop為例(TestBench平台)

使用Quartus-II 9.1SP2 + ModelSim 6.5b-Aletra + Altera DE2-115 FPGA開發平台,設計D Flip Flop為例(TestBench平台)








module d_flip_flop_edge_triggered(Q, Qn, C, D);
   output Q;
   output Qn;
   input  C;
   input  D;

   wire   Cn;   // Control input to the D latch.
   wire   Cnn;  // Control input to the SR latch.
   wire   DQ;   // Output from the D latch, input to the gated SR latch.
   wire   DQn;  // Output from the D latch, input to the gated SR latch.
   
   not(Cn, C);
   not(Cnn, Cn);   
   d_latch dl(DQ, DQn, Cn, D);
   sr_latch_gated sr(Q, Qn, Cnn, DQ, DQn);   
endmodule // d_flip_flop_edge_triggered

module d_latch(Q, Qn, G, D);
   output Q;
   output Qn;
   input  G;   
   input  D;

   wire   Dn; 
   wire   D1;
   wire   Dn1;

   not(Dn, D);   
   and(D1, G, D);
   and(Dn1, G, Dn);   
   nor(Qn, D1, Q);
   nor(Q, Dn1, Qn);
endmodule // d_latch

module sr_latch_gated(Q, Qn, G, S, R);
   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 // sr_latch_gated

`timescale 10ns/10ps
module D_FlipFlop_tb;
   wire q;
   wire qn;
   reg  ck;   
   reg  din;

d_flip_flop_edge_triggered DUT(
.Q(q),
.Qn(qn),
.C(ck),
.D(din)
);
initial begin
 ck=1'b0;din=1'b0;
 #500 $stop;
end  
always begin 
#50 ck=~ck; 
end
always  begin 
#100 din=~din;
end 
endmodule

沒有留言:

張貼留言

Arduino 物聯網應用 - 上課教材

Arduino 物聯網應用 - 上課教材 https://dic.vbird.tw/arduino/list.php Arduino 物聯網應用 - 課程列表 我們會從 Arduino 的認識、IDE 環境的熟悉、與操作電腦的序列埠連動的功能、Arduino 開發語言的熟悉、 簡...