From: KJ on
On Jul 23, 7:22 pm, Andy Peters <goo...(a)latke.net> wrote:
> On Jul 22, 9:50 am, Rob Gaddi <rga...(a)technologyhighland.com> wrote:
>
> > What about more complicated cases such as the following
> > inferred RAM, in which the bottom 7 bits of addr can always be used to
> > address the RAM?
>
> >      if (addr < 128) then
> >          dout <= RAM(addr);
> >      else
> >          dout <= (others => '-');
> >      end if;
>
> Some hand-optimization might be good here:
>
>     dout <= RAM(addr);
>
> After all, in this (likely contrived!) case, you don't care about the
> assignment if the address is 128 or higher, so then not doing the
> comparison at all and just doing the assignment anyway gives the best
> result.
>
> A smart synthesis tool should do that optimization.
>

Not quite. As I mentioned in my earlier post, the way to write the
code is
dout <= ram(addr mod 128);

If you just write "dout <= RAM(addr);" then a larger memory will be
inferred. You're assuming that addr is not something 'big' like

signal addr: natural range 0 to 1048575; -- 20 bits

Kevin Jennings