2021年3月24日 星期三

DE2-115 開發 以 D Filp-Folp 7474 為例(Verilog gate level modeling )

DE2-115 開發 以 D Filp-Folp 7474  為例(Verilog gate level modeling )

參考來源:http://www.barrywatson.se/dd/dd_d_flip_flop_edge_triggered.html

The following function table shows the operation of a D flip-flop. The column header Q(t+1) means "the value of Q at the start of the next clock period", similarly for Qn(t+1).

DQ(t+1)Qn(t+1)Meaning
001Reset
110Set


module d_flip_flop_edge_triggered(SW, LEDR, LEDG , CLOCK_50 ,KEY,HEX0 ,HEX1 ,HEX2,HEX3 ,HEX4 ,HEX5 ,HEX6 ,HEX7 );

 input  [17:0] SW;   // toggle switches

 input  [3:0] KEY;   // Push bottom

 input  CLOCK_50;    //Clock 27MHz , 50Mhz

 output [17:0] LEDR;   // red  LEDS

 output [8:0] LEDG;   // green LEDs

 

 output [6:0] HEX0,HEX1,HEX2,HEX3,HEX4,HEX5,HEX6,HEX7 ; //7-segment display

  assign HEX0=7'b111_1111; //off 7-segment Display

 assign HEX1=7'b111_1111;

 assign HEX2=7'b111_1111;   //off 7-segment Display

 assign HEX3=7'b111_1111;

 assign HEX4=7'b111_1111;

 assign HEX5=7'b111_1111;

 assign HEX6=7'b111_1111;

 assign HEX7=7'b111_1111;

d_flip_flop_gatelevel(LEDR[0],LEDR[1],CLOCK_50,SW[0]);

endmodule


//=========================================================

//D Flip-Flop (edge-triggered)

//=========================================================

module d_flip_flop_gatelevel(Q, Qn, Ck, D);

   output Q;

   output Qn;

   input  Ck;

   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, Ck);

   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

沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...