Here's my code, and as far as I can tell, LEDs in defined
module sevenseg (LEDs,in);
output reg [6:0] LEDs;
input [3:0] in;
always@(in) begin
case(in)
0 : LEDs = 7'b1000000;
1 : LEDs = 7'b1111001;
2 : LEDs = 7'b0100100;
3 : LEDs = 7'b0110000;
4 : LEDs = 7'b0011001;
5 : LEDs = 7'b0001010;
6 : LEDs = 7'b0000010;
7 : LEDs = 7'b1111000;
8 : LEDs = 7'b0000000;
9 : LEDs = 7'b00010000;
default : LEDs = 7'b1111111;
endcase
end
endmodule
here's the compilation error
Error (10161): Verilog HDL error at sevenseg2.v(39): object "LEDs" is not declared
Error: Quartus II 64-Bit Analysis & Synthesis was unsuccessful. 1 error, 1 warning
Error (293001): Quartus II Full Compilation was unsuccessful. 3 errors, 1 warning
I think the problem is you are trying to push a non-ANSI style output from an always block.
you can either
1. move to ANSI style (which is more convenient anyway) or
2. add a wire, push the case outcome to it and 'assign' the output with the wire, 3. remove the 'always' block and write:
assign LEDs = (in == 0) ? 7'b1000000 : (in == 1) ?
.....You are mixing ANSI and non-ANSI header styles. This is illegal syntax. Some simulator/synthesizer is allowing it, but it is bad practice.
You should use ANSI: IEEE Std 1800-2012 § 23.2.2.2 ANSI style list of port declarations
or non-ANSI: IEEE Std 1800-2012 § 23.2.2.1 Non-ANSI style port declarations
Non-ANSI is required for IEEE Std 1364-1995. Support for ANSI existed since IEEE Std 1364-2001.
The accepted answer is incorrect - this is not illegal, in either Verilog (2001/2005) or SystemVerilog. If your compiler thinks that it is, then it is either buggy or is assuming Verilog-1995 (which no sane commercial compiler does).
For Verilog (1364-2005), 12.3.3 states:
12-4 defines an
output_declaration
asSo
output reg
is valid when you have a plain list of port identifiers. The text below 12-4 statesSo the change suggested by Greg is allowed, rather than required (
reg
is of course a 'variable type'). In other words, if you don't haveoutput reg x
, then you are allowed to split this over two statements -output x
andreg x
.SystemVerilog (1800-2012) is essentially identical - note that
reg
is aninteger_vector_type
, which is adata_type
.Note also that the word ANSI is not used in 1364, and SystemVerilog uses it incorrectly. Task/function/port declarations do not look like ANSI-C, because you can't specify lists of objects in C or C++. You can't declare or define a function like
myfunc(int a, b)
, for example; it has to be(int a, int b)
.