Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15539 Discussions

Getting an error :object "led" on left-hand side of assignment must have a variable data type

MShai9
Beginner
522 Views

module test (clk,led);

input clk;

output led;

 

reg [7:0] counter;

always@(posedge clk) begin

    if (counter < 100) counter <= counter +1;

    else counter <= 0;

end

 

always @ (counter) begin

     if (counter>0) led = 1;

     else if (counter<20) led = 1;

     else led = 0;

     end

endmodule 

 

trying to make sure that the value of led turns 1 only when the value of counter varies from 1 to 20. I want led to be zero when counter is zero. any workaround this or am i doing something wrong?

0 Kudos
1 Reply
a_x_h_75
New Contributor III
422 Views

You need to declare 'led' as a reg, in the same way you've declared counter. Declaring it as an output to the module isn't enough (as it is in other languages).

 

You can either add:

reg led;

 

or change the output declaration to:

output reg led;

 

Cheers,

Alex

Reply