I have tried this code, but it shows the error:
gray_counter\gray_counter.v(2): (vlog-2110) Illegal reference to net "code"
module gray_counter(code,clk,rst,count);//module declaration
input [2:0]code=3'b000;
input clk,rst;
output reg count;
reg [2:0]conv_code;
always@(posedge clk , posedge rst)
begin
if(rst)
begin
count=0;
end
else
begin
conv_code={code[0],code[0]^code[1],code[1]^code[2]};//converting binary code to gray
case(conv_code)
3'b000:count=count+1;
3'b001:count=count+1;
3'b011:count=count+1;
3'b010:count=count+1;
3'b110:count=count+1;
3'b100:count=count+1;
3'b101:count=count+1;
3'b111:count=count+1;
default:count=count+0;
endcase
end
end
endmodule