题解 | #异步复位的串联T触发器#

异步复位的串联T触发器

http://www.nowcoder.com/practice/9c8cb743919d405b9dac28eadecddfb5

`timescale 1ns/1ns
module Tff_2 (
input wire data, clk, rst,
output wire q  
);
// 关键点: 输入输出都是wire型,不是reg
//*************code***********//
wire data_d1;

Tff u_tff1(
    .t    (data),
    .clk  (clk),
    .rst_n(rst),
    .q_cur(data_d1)
);

Tff u_tff2(
    .t    (data_d1),
    .clk  (clk),
    .rst_n(rst),
    .q_cur(q)
);

//*************code***********//
endmodule

module Tff(    
    input t,clk,rst_n,
    output reg q_cur);
    always @(posedge clk or negedge rst_n) begin
        if (!rst_n) begin
            q_cur <= 1'b0;
        end 
        else q_cur <= q_cur^t;
    end

endmodule
全部评论

相关推荐

牛客96763241...:杭电✌️也是打完招呼,没人回吗
点赞 评论 收藏
分享
09-29 15:34
已编辑
北京航空航天大学 C++
做个有文化的流氓:结果是好的,过程不重要,而且你的offer太多了
软开人,秋招你打算投哪些...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务