Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21618 Discussions

Help on clock pin assignment

Altera_Forum
Honored Contributor II
1,604 Views

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?
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
564 Views

Prefix# when you use a parameter: 

if (counter <= switches*# sd)
0 Kudos
Altera_Forum
Honored Contributor II
564 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
564 Views

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?
0 Kudos
Reply