All checks were successful
ci/woodpecker/push/test-workflow Pipeline was successful
The audio output is still messed up, but this commit gets everything as ready as it can get. Fixed up all the testbenches and added state machines for everything
58 lines
1.3 KiB
Systemverilog
58 lines
1.3 KiB
Systemverilog
/*****
|
|
* pwm_tb.sv - testbench for the pwm.sv module.
|
|
*
|
|
* @author: Dilanthi Prentice, Waylon Cude
|
|
* @date: 6/12/2025
|
|
* */
|
|
|
|
module pwm_tb;
|
|
bit clk, reset;
|
|
|
|
logic load;
|
|
wire pwm_pin;
|
|
logic [15:0] sample;
|
|
|
|
pwm #(16) dut (.*);
|
|
|
|
initial forever #10 clk = ~clk;
|
|
|
|
initial begin
|
|
reset = 1;
|
|
@(posedge clk);
|
|
@(posedge clk);
|
|
reset = 0;
|
|
load = 1;
|
|
sample = 0;
|
|
for (int i=0; i < (1<<16)-1; i++) begin
|
|
@(posedge clk) assert (pwm_pin === 0)
|
|
else $error("Should be low at %d",i);
|
|
end
|
|
reset = 0;
|
|
load = 1;
|
|
sample = '1;
|
|
@(posedge clk)
|
|
for (int i=0; i < (1<<16)-1; i++) begin
|
|
@(posedge clk) assert (pwm_pin === 'z)
|
|
else $error("Should be high at %d",i);
|
|
end
|
|
|
|
reset = 0;
|
|
load = 1;
|
|
// Should be about half on
|
|
sample = 1<<15;
|
|
@(posedge clk)
|
|
for (int i=0; i < (1<<15); i++) begin
|
|
@(posedge clk) assert (pwm_pin === 'z)
|
|
else $error("Should be high at %d",i);
|
|
end
|
|
sample = 1<<15;
|
|
for (int i = (1 << 15); i < (1<<16)-1; i++) begin
|
|
@(posedge clk) assert (pwm_pin === 0)
|
|
else $error("Should be low at %d",i);
|
|
end
|
|
$finish;
|
|
|
|
end
|
|
|
|
endmodule
|