题解 | #异步复位的串联T触发器#
异步复位的串联T触发器
https://www.nowcoder.com/practice/9c8cb743919d405b9dac28eadecddfb5
//详细解读文章:https://blog.csdn.net/H19981118/article/details/124036395 //零保一翻T触发 `timescale 1ns/1ns module Tff_2 ( input wire data, clk, rst,//低电平复位应该用rstn output reg q ); //*************code***********// reg data1; always @(posedge clk or negedge rst)begin//为了规范,减少出现问题的情况,以后不管是一句代码还是多句,都用begin——end if(!rst) data1 <= 0; else if(data)//这里判断的是输入data data1 <= ~data1;//注意这里是翻转的是自身,而不是data else data1 <= data1; end always @(posedge clk or negedge rst)begin if(!rst) q <= 0; else if(data1) q <= ~q; else q <= q; end //*************code***********// endmodule