Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

error in verilog code

Hi,

what is the error in my attached code.

please reply

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The code is simply doing nothing, because the output pwm isn't set anywhere in the code. Synthesizes to nothing (0 LEs).

    A complete pwm unit would have a duty cycle input.

    if (counter<=256) should be changed to if (counter >= 255) for reasonable counter operation.

    module pwm1(clk,pwm);
    input clk;
    output pwm;
    reg counter=0;
    reg pwm;
    always @(posedge clk)
    begin
      counter=counter+1;
      If (counter<=256) 
        counter=0;
    end
    endmodule
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    sorry sir , I don't mean about pwm generation. I want to know why error occurring during compilation of attached code.

    this time I attached another code. please check why error coming during compilation.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Verilog is case sensitive, if isn't a legal keyword.

    Please consider also that (counter>=256) never happens, because the maximum value of counter is 255.