module pwm (
    input clk,
    input [7:0] pwm_in,
    output pwm_out
);
 
reg [7:0] cnt;
always @(posedge clk) cnt <= cnt + 1'b1;  //计数器
assign pwm_out = (pwm_in > cnt);          //比较器
 
endmodule