2021年5月12日 星期三

HBLbits_Verilog Basic_Tb/tb2

HBLbits_Verilog Basic_Tb/tb2 

The waveform below sets clkin, and s:

Module q7 has the following declaration:

module q7 (
    input clk,
    input in,
    input [2:0] s,
    output out
);

Write a testbench that instantiates module q7 and generates these input signals exactly as shown in the waveform above.

`timescale 1ps / 1ps
module top_module();
    reg clk;
    reg in;
    reg [2:0] s;
    wire out;
    
    q7  dut(
        .clk(clk),
        .in(in),
        .s(s),
        .out(out)
    );
    
    initial begin
        clk=0;
        s = 3'b010;in=0;
        #10;
        s = 3'b110;
        #10;
        s = 3'b010;in=1;
        #10;
        s = 3'b111;in=0;
        #10;
        s = 3'b000;in=1; 
        #30;  in=0;       
    end

   
  always
begin
           #5 clk=~clk;
end 
   
endmodule



沒有留言:

張貼留言

2026 作業3 RFID+ Telegram 練習

 2026 作業3  RFID+ Telegram  練習 (Wokwi 與 Telegram 二者溝通訊息反映比較慢 ) 歡迎 Alex 使用 RFID 控制系統 /on : 開啟 LED /off : 關閉 LED /flash : 閃爍模式 /timer : 開啟 5 秒 ...