- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Prefix# when you use a parameter:
if (counter <= switches*# sd)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you need a semicolon at the end of the parameter line. it's flowing over to the 'input clock;' declaration and bombing there
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page