`timescale 1ns / 10ps ////////////////////////////////////////////////////////////////////////////////// // // Filename: tb_pwm.v // // Author: Mike Wirthlin // // Description: // // Version 1.2 // // Change Log: // 1.1: - Removed the enable for the PWM module and associated tests // - Updated output messages (messages given for correct output) // 1.2: - Removed parameterized COUNT_WIDTH // - Change the testbench names (tb_) // ////////////////////////////////////////////////////////////////////////////////// module tb_pwm(); localparam COUNT_WIDTH = 14; reg tb_clk; wire tb_pulse; reg [COUNT_WIDTH-1:0] tb_width; integer j, errors; time d_time,e_time,t_time; // Instance the DUT PWM dut(.clk(tb_clk), .width(tb_width), .pulse(tb_pulse)); // Need to create a clock initial begin #100 // wait 100 ns before starting clock (after inputs have settled) tb_clk = 0; forever begin #5 tb_clk = ~tb_clk; end end initial begin // print %t with scaled in ns (-9), with 2 precision digits, and would print the " ns" string $timeformat(-9, 0, " ns", 20); $display("*** Start of Simulation ***"); // Start off with PWM turned off (make sure there are no pulses) /* en1 = 0; width1 = 0; repeat (2**12+100) @ (negedge clk); */ errors = 0; // Turn on PWM with varying width (using powers of 2) //en1 = 1; for (j=0; j<12; j=j+1) begin tb_width = 1<