每天进步一点点------基础实验_08_触发器 :D、T触发器各一

 1 /*********************************************************************************
 2 * Company                    : 
 3 * Engineer                    : 空气微凉
 4 * 
 5 * Create Date                : 00:00:00 22/03/2013 
 6 * Design Name                : 
 7 * Module Name                :         
 8 * Project Name                :  
 9 * Target Devices            : 
10 * Tool versions            : 
11 * Description                :  
12 *                       http://www.cnblogs.com/kongqiweiliang/             
13 * Dependencies                : 
14 *
15 * Revision                    : 
16 * Revision                    : 0.01 - File Created
17 * Additional Comments    : 基础实验_08_触发器 :D、T触发器各一
18 ********************************************************************************/
19 `timescale 1ns/1ps
20 `define    UD  #1
21 /*******************************************************************************/
22 module FLIP_FLOP    
23 ( 
24     //system interface
25     input                                     iCLK_50        ,//50MHz
26     input                                     iRESET         ,//system interface
27     //Interface package
28     input                                    iDFF_DAT        ,//
29     input                                    iTFF_DAT        ,//
30     output  reg                            oDFF_DAT        ,//
31     output  reg                            oTFF_DAT          //
32 );  
33 //-------------------------------------------------------------------------------
34 //D触发器
35 always@(posedge iCLK_50 or negedge iRESET)begin
36     if(!iRESET)
37         oDFF_DAT <= 1'h0;
38     else
39         oDFF_DAT <= iDFF_DAT;
40 end
41  
42 //T触发器
43 //具有保持和翻转功能的电路,即当T=0时能保持状态不变,
44 //T=1时一定翻转的电路,都称为T触发器
45 wire  oTFF_DAT_N;
46 always@(posedge iCLK_50 or negedge iRESET)begin
47     if(!iRESET)
48         oTFF_DAT <= 1'h0;
49     else    
50         oTFF_DAT <= oTFF_DAT_N;
51 end
52 assign oTFF_DAT_N = iTFF_DAT ? (~oTFF_DAT) : oTFF_DAT;
53 //-------------------------------------------------------------------------------
54 endmodule 
原文地址:https://www.cnblogs.com/kongqiweiliang/p/3246447.html