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 ();


沒有留言:

張貼留言

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

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