James Aflred
James Aflred

Reputation: 97

What does "Illegal reference to net error" mean?

I wrote this code for a T Flipflop. The output is toggled at every 11th clk. The program is giving me this error:

Illegal reference to net "clkDivider"

What does this error mean? What is causing it?

Here is the code:

module TFF(clkDivider,clk,reset,q);

input clk,reset;
input [3:0]clkDivider;
output reg q;

always @(posedge clk or negedge reset)
begin
   if(~reset==0)
   begin
      q=0;
      clkDivider<=0;
   end
   else
      if(clkDivider==11)
      begin
         q=1;
         clkDivider<=0;
      end
      else
         clkDivider<=clkDivider+1;
end

endmodule

Upvotes: 2

Views: 29318

Answers (1)

toolic
toolic

Reputation: 61937

You should not assign values to a module input signal. Try:

output reg [3:0] clkDivider;

Also, you probably should use nonblocking assignments to q, such as:

q <= 0;

Upvotes: 5

Related Questions