2021年5月12日 星期三

HBLbits_Verilog Basic_Tb/tff

HBLbits_Verilog Basic_Tb/tff 

You are given a T flip-flop module with the following declaration:

module tff (
    input clk,
    input reset,   // active-high synchronous reset
    input t,       // toggle
    output q
);

Write a testbench that instantiates one tff and will reset the T flip-flop then toggle it to the "1" state.


`timescale 1ps / 1ps

    reg clk;
    reg reset;
    reg t;
    wire q;
    
tff dut(
        .clk(clk),
    .reset(reset),  // active-high synchronous reset
        .t(t),        // toggle
        .q(q)
);
    
  initial begin
        clk=1'b0;
        forever
        #5 clk=~clk;
    end
    
    initial begin
        reset = 1'b0;
        #3;
        reset = 1'b1;
        #10;
        reset = 1'b0;   
    end
    
    always@(posedge clk)begin
        if(reset)begin
            t <= 1'b0;
        end
        else begin
            t <= 1'b1;
        end
    end
 
endmodule

module top_module ();


沒有留言:

張貼留言

設定並測試 Flutter

  設定並測試 Flutter https://docs.flutter.dev/install/quick 使用基於開源軟體的編輯器(例如 VS Code)在您的裝置上安裝 Flutter,即可開始使用 Flutter 開發您的第一個多平台應用程式! 學習如何使用任何基於開源軟...