S
Sean Durkin
Hi *,
I've come across something I don't quite understand and thought I'd ask
the experts here. I've prepared a simple test case and put it here:
http://www.wiggy.de/testcase.html
Basically, what I'm doing is this:
I have two different entities with differing port lengths, and want to
instantiate one or the other depending on the value of a constant
defined in a package. So, in pseudo-code, what I have is this:
if (CONSTANT=value1) generate
instantiate_entity_1;
end generate;
if (CONSTANT=value2) generate
instantiate_entity_2;
end generate;
The entities connect to top-level ports, whose lengths are defined by
the same constant in the package.
Now, this works fine in ModelSim, but when I'm trying to synthesize in
Xilinx' XST, it throws an error about not-matching port lengths between
the top-level ports and the ports of the entity in the "wrong" generate
block. It seems that what's inside the generate blocks is ALWAYS
evaluated even if the if-condition is not met, or maybe it is evaluated
BEFORE the if-condition.
If I do the whole thing using a GENERIC, it works in both XST and
ModelSim, but in my eyes it shouldn't really make a difference.
Sometimes I prefer to do stuff like that with constants instead of
GENERICs so I don't have to drag a GENERIC through the entire hierarchy
and can just edit one central configuration package.
Now, is this a bug in XST or in ModelSim, or am I trying something
"illegal" here? What in general is the preferable way to do something
like this?
Looking at what XST does I would think that using a GENERIC, things are
thrown out or configured right at compile time, whereas when I use a
constant, stuff would not be thrown out until later in the optimization
stage.
Are there any differences in the end result in current tools? From a
pure language standpoint, there should be no difference, right?
cu,
Sean
I've come across something I don't quite understand and thought I'd ask
the experts here. I've prepared a simple test case and put it here:
http://www.wiggy.de/testcase.html
Basically, what I'm doing is this:
I have two different entities with differing port lengths, and want to
instantiate one or the other depending on the value of a constant
defined in a package. So, in pseudo-code, what I have is this:
if (CONSTANT=value1) generate
instantiate_entity_1;
end generate;
if (CONSTANT=value2) generate
instantiate_entity_2;
end generate;
The entities connect to top-level ports, whose lengths are defined by
the same constant in the package.
Now, this works fine in ModelSim, but when I'm trying to synthesize in
Xilinx' XST, it throws an error about not-matching port lengths between
the top-level ports and the ports of the entity in the "wrong" generate
block. It seems that what's inside the generate blocks is ALWAYS
evaluated even if the if-condition is not met, or maybe it is evaluated
BEFORE the if-condition.
If I do the whole thing using a GENERIC, it works in both XST and
ModelSim, but in my eyes it shouldn't really make a difference.
Sometimes I prefer to do stuff like that with constants instead of
GENERICs so I don't have to drag a GENERIC through the entire hierarchy
and can just edit one central configuration package.
Now, is this a bug in XST or in ModelSim, or am I trying something
"illegal" here? What in general is the preferable way to do something
like this?
Looking at what XST does I would think that using a GENERIC, things are
thrown out or configured right at compile time, whereas when I use a
constant, stuff would not be thrown out until later in the optimization
stage.
Are there any differences in the end result in current tools? From a
pure language standpoint, there should be no difference, right?
cu,
Sean