E
Evan Lavelle
Guest
The definition of an expression seems to be rather curious:
not an expression. I've checked 3 sims, and they all seem to think
that a string actually *is* a primary (code below; see the line 'c =
~stringvar'), so presumably all 3 sims are non-conforming.
Secondly, with a C world view you might expect to be allowed to do 'c
= ~~a' (see below), but all 3 sims agree that this is illegal
(because, from the production above, '~a' is an expression, so you
can't apply another unary op to it). This is slightly surprising,
because it's an arbitrary limitation, and the rest of the expression
syntax is fairly C-like.
Thoughts?
Evan
--------------------------------------------------------------
module test;
reg [8*11:1] stringvar;
initial
main;
task main;
integer a, b, c;
begin
stringvar = "Hello world";
a = 3;
b = ~a;
// c = ~~a; syntax error
c = ~stringvar;
$display("a: %h; b: %h; c: %h\n", a, b, c);
end
endtask
endmodule
From a C point of view, you might expect a string to be a primary, andexpression ::=
primary
| unary_operator { attribute_instance } primary
| expression binary_operator { attribute_instance } expression
| conditional_expression
| string
not an expression. I've checked 3 sims, and they all seem to think
that a string actually *is* a primary (code below; see the line 'c =
~stringvar'), so presumably all 3 sims are non-conforming.
Secondly, with a C world view you might expect to be allowed to do 'c
= ~~a' (see below), but all 3 sims agree that this is illegal
(because, from the production above, '~a' is an expression, so you
can't apply another unary op to it). This is slightly surprising,
because it's an arbitrary limitation, and the rest of the expression
syntax is fairly C-like.
Thoughts?
Evan
--------------------------------------------------------------
module test;
reg [8*11:1] stringvar;
initial
main;
task main;
integer a, b, c;
begin
stringvar = "Hello world";
a = 3;
b = ~a;
// c = ~~a; syntax error
c = ~stringvar;
$display("a: %h; b: %h; c: %h\n", a, b, c);
end
endtask
endmodule