Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

error in verilog code

Altera_Forum
Honored Contributor II
1,381 Views

Hi, 

 

what is the error in my attached code. 

 

please reply
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
461 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
461 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
461 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
461 Views

Thank you sir

0 Kudos
Reply