vhdl:data memory

Discussion in 'VHDL' started by agnese.rosi@gmail.com, Feb 29, 2008.

  1. Guest

    Hi,

    I'm trying to writing a code suitable for a data memory but I have
    some problem with the input decoder and the multiplexer:
    - the decoder receives an address as input (std_logic_vector(7 downto
    0)) in order to select one of 256 rows of the storage unit,which has
    the typical row-column structure. Each row is formed by a 16-bit-
    register (flip-flop) I've built the storage unit with e "generate"
    command.
    - the mux is driven by the same adress and has to choose one of the
    256 rows.

    The question is:how can I write the code for a mux that can accept as
    input 256 16 bit-long std_logic_vector elements?And how can I write
    the code for a decoder whose input is an 8 bit-long address?A for-loop
    maybe?
    I really don't know.

    Thanks
    Bye
    , Feb 29, 2008
    #1
    1. Advertising

  2. Tricky Guest

    On Feb 29, 12:30 pm, wrote:
    > Hi,
    >
    > I'm trying to writing a code suitable for a data memory but I have
    > some problem with the input decoder and the multiplexer:
    > - the decoder receives an address as input (std_logic_vector(7 downto
    > 0)) in order to select one of 256 rows of the storage unit,which has
    > the typical row-column structure. Each row is formed by a 16-bit-
    > register (flip-flop) I've built the storage unit with e "generate"
    > command.
    > - the mux is driven by the same adress and has to choose one of the
    > 256 rows.
    >
    > The question is:how can I write the code for a mux that can accept as
    > input 256 16 bit-long std_logic_vector elements?And how can I write
    > the code for a decoder whose input is an 8 bit-long address?A for-loop
    > maybe?
    > I really don't know.
    >
    > Thanks
    > Bye


    Convert the std_logic_vector to an integer using the numeric_std
    packages:

    my_int := to_integer(unsigned(my_slv));

    then use my_int to index into an array. You can do this for both the
    mux and the memory address.
    You can quite happily do the coversion to an int as a variable inside
    a process:

    signal addr : std_logic_vector(7 downto 0);

    type my_mux_type is array(0 to 255) of std_logic_vector(15 downto 0);
    signal mux_signals : my_mux_type;
    ...
    ...
    ...
    conv_proc : process(addr)
    variable addr_int : integer range mux_signals'range; --you need
    to specify range to stop the synthesiser making it a 32 bit bus
    begin
    addr_int := to_integer(unsigned(addr));
    output <= mux_signals(addr_int);
    end process;


    But with a mux this wide, it is likely you will need some registering
    in there somewhere, otherwise you may find it struggles to meet timing
    requirements.
    Tricky, Feb 29, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    4,785
    walala
    Sep 18, 2003
  2. Replies:
    2
    Views:
    8,630
    Jim Lewis
    Mar 21, 2006
  3. dude

    VHDL 2002 vs VHDL 1993

    dude, Mar 23, 2006, in forum: VHDL
    Replies:
    1
    Views:
    1,261
    Nicolas Matringe
    Mar 23, 2006
  4. pygmalion
    Replies:
    6
    Views:
    5,489
    Dave Higton
    Jun 23, 2006
  5. afd
    Replies:
    1
    Views:
    8,273
    Colin Paul Gloster
    Mar 23, 2007
Loading...

Share This Page