module pwm(CLOCK,RESET,LED);
input CLOCK,RESET;
output reg [3:0] LED;
parameter T1s=32'd1_00000;
reg [31:0] t,count;
reg [31:0] w;
///*
always @(posedge CLOCK or negedge RESET)
if(!RESET)
begin
 count<=0;
 t<=0;
 LED[0]<=0;
end
   else if(count==T1s)
     begin
      count<=0;
      t<=t+1000;
      if(t==T1s)
      t<=0;
     end
         else
         begin
           count<=count+1;
           if(count<t)
           LED[0]<=0;
           else
           LED[0]<=1;
          end
//*/
/*
always @(posedge CLOCK or negedge RESET)
if(!RESET)
begin
 t<=0;
 LED[0]<=0;
end
    else if(t==T1s/10)
     begin
      t<=t+1;
      LED[0]<=~LED[0];
     end
        else if(t==T1s)
         t<=0;
                   else
            t<=t;
*/
         
/*
always @(posedge CLOCK or negedge RESET)
if(!RESET)
LED[0]<=0;
   else if(count<t)
     LED[0]<=0;
        else
         LED[0]<=1;
 */      
endmodule

相关文章:

  • 2021-12-15
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
  • 2021-12-12
  • 2021-11-01
猜你喜欢
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2021-12-26
  • 2022-01-21
  • 2021-07-07
相关资源
相似解决方案