On 13 Feb, 19:49, "Niv (KP)" <kev.pars...@mbda-systems.com> wrote:
> On 13 Feb, 17:46, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
> wrote:
>
>
>
>
>
> > On Fri, 13 Feb 2009 17:34:05 +0000, Alan Fitch wrote:
> > > * *process(clock)
> > > * *begin
> > > * * *if rising_edge(clock) then
> > > * * * *if enable = '1' then
> > > * * * * *for i in 0 to n-1 loop
> > > * * * * * *if to_integer(unsigned(address)) = i then
> > > * * * * * * *read_bus(i) <= adc_bus(i);
> > > * * * * * *end if;
> > > * * * * *end loop;
> > > * * * *end if;
> > > * *end process;
>
> > >Due to "last assignment wins" a.k.a intertial delay, this will mean
> > >effectively there is a higher priority to higher addresses - but as only
> > >one address can be true (they're mutually exclusive) I would hope
> > >synthesis would produce sensible code,
>
> > If synthesis doesn't sort out the mutual-exclusivity
> > for itself, you can give it a helpful hint by implying
> > an AND-OR tree instead of the pri-mux. *I've used this
> > with some success in designs that have a large number
> > of readable registers. *
>
> > Similar overall shape to Alan's solution, but with an
> > extra variable to accumulate the sum-of-products:
>
> > * * process(clock)
> > * * * variable readback: std_logic_vector(read_bus'range);
> > * * begin
> > * * * if rising_edge(clock) then
> > * * * * readback := (others => '0'); *-- start with all-zero
> > * * * * if enable = '1' then
> > * * * * * for i in 0 to n-1 loop
> > * * * * * * if to_integer(unsigned(address)) = i then
> > * * * * * * * readback := readback or adc_bus(i);
> > * * * * * * end if;
> > * * * * * end loop;
> > * * * * * read_bus <= readback;
> > * * * * end if;
> > * * end process;
>
> > Note that this iterate-through-the-addresses arrangement
> > also allows for more complex address matching schemes.
> > Instead of the equality test on the address, consider
> > using a user-written address matching function:
>
> > * if adrs_match(address, i) then ...
>
> > This allows for sparse address spaces, "registers" that
> > span more than one address (they would then use a few
> > low-order address bits internally to determine their
> > functionality), and "interesting" variable register maps.
> > --
> > Jonathan Bromley, Consultant
>
> > DOULOS - Developing Design Know-how
> > VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
>
> > Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
> > jonathan.brom...@MYCOMPANY.comhttp://www.MYCOMPANY.com
>
> > The contents of this message may contain personal views which
> > are not the views of Doulos Ltd., unless specifically stated.- Hide quoted text -
>
> > - Show quoted text -
>
> Thanks chaps,
> Plenty of options & food for thought there.
> Regards, Niv.- Hide quoted text -
>
> - Show quoted text -
I wasn't quite right when I said "N" was a generic!
I have a package with the following:
PACKAGE ad7476_pkg IS
CONSTANT num_of_convs : INTEGER := 5; -- Number of parallel
ADC's.
TYPE d_conv_bus IS ARRAY(num_of_convs-1 DOWNTO 0)
OF STD_LOGIC_VECTOR(31 DOWNTO 0);
TYPE d_convs_in IS ARRAY(num_of_convs-1 DOWNTO 0)
OF STD_LOGIC;
END ad7476_pkg;
The "d_conv_bus" is used to declare the o/p port on teh ADC controller
and the
i/p port on my address decoder, so the results get read in ascending
order (loop dependent).
The ADC controller also has an i/p port of "d_convs_in", which
promulgates to the top level of the block.
I would like to instnace this top level block with a generic that
overrides the package constant
"num_of_convs", but can't figure how to do this.
As it is, with the constant 5, all works fine, and I can read the
values back as suggested in earlier posts.
I'd just like to make it more flexible.
TIA, Niv.
|