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


沒有留言:

張貼留言

Modbus FC=1 (Coils read) & FC=15 (Coils Write)

Modbus FC=1  (Coils read)  & FC=15 (Coils Write)   「從 Modbus 設備讀取多個線圈(Coils)狀態,並立刻將這些狀態原封不動地轉寫到另一個記憶體位址(起始位址 16)」 。 整個流程使用了知名套件 node-red...