Forum Discussion

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

Help on clock pin assignment

Hello, I'm new with FPGA programming. I created a simple program to generate PWM, but when I assigned the clock it shows as an error on compilation. Here is my code:

module PWMTest (clock, switches, pwm_o);

parameter sd = 3125; //t = 1ms, p = t/(20*10^-9), p = 50000, sd = 3125

input clock;

input [3:0] switches;

output pwm_o;

reg pwm;

reg [16:0] counter = 0;

always @ (posedge clock)

begin

counter = counter + 1;

if (counter <= switches*sd)

pwm_o = 1;

else pwm_o = 0;

if (counter == 50000)

counter = 0;

end

endmodule

the clock is assigned to H1 or DCLK pin (according to De0 Nano board), but when I turned on the Live I/O check, it said error on line 5 (input clock;) can somebody help me?

3 Replies

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

    you need a semicolon at the end of the parameter line. it's flowing over to the 'input clock;' declaration and bombing there

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

    thanks for the replies everyone, I found out the problem. Supposed to use pin R8 for the dedicated clock

    @jderrick: there is a semicolon, before the command

    @Cris72: actually the code works fine, but will the# make any differences?