|
module pwm (clk,clk1, reset,pwm_out);
input clk;
input clk1;
input reset;
output pwm_out;
reg full;
reg [31:0]counter;
reg [31:0]z;
reg pwm_out ;
reg clk2;
always @( posedge clk )
begin clk2=1 ;
#10 clk2=0;
end
always @(posedge clk1 or negedge reset or posedge clk2)
begin
if (reset==0)
begin
counter<=0;
full<=0;
end
else
if( clk2==1 )
begin
counter<=0;
full<=1;
end
else
if((counter<=z)&&(full==1))
begin
counter<=counter+1;
pwm_out<=1;
end
else
begin
pwm_out<=0;
z<=counter+1 ;
end
end
endmodule |
|