hard to make it generic

Discussion in 'VHDL' started by Pasacco, Sep 27, 2006.

  1. Pasacco

    Pasacco Guest

    hi all

    I need some help for making generic VHDL. Problem is following.

    Design module has input port X, output port Y, and internal control
    signal C, with following type.
    X : array (0 to 2) of std_logic_vector (1 downto 0);
    Y : array (0 to 2) of std_logic_vector (1 downto 0);
    C : array (0 to 2) of std_logic_vector (1 downto 0);

    Output 'Y' is determined by control signal 'C' and input 'X'.
    For example,
    consider possible cases for 'C' are only C(0)="00", C(0)="01",
    C(1)="01", C(2)="10".
    Y(0) <= X(0) when C(0) is "00"
    Y(0) <= X(1) when C(0) is "01"
    Y(1) <= X(1) when C(1) is "01"
    Y(2) <= X(2) when C(2) is "10"

    In VHDL, I did it asynchronously and manually, depending on possible
    'C' values.

    Y( 0 ) <= X( 0 ) when C( 0 )="00" else
    X( 1 ) when C( 0 )="01" else "00" ;
    Y( 1 ) <= X( 1 ) when C( 1 )="01" else "00" ;
    Y( 2 ) <= X( 2 ) when C( 2 )="10" else "00" ;

    Then it works fine.
    Problem is that I can not make thse VHDL descriptions "generic", when
    possible values of 'C' are known.
    For example, possible values C(1) are "00" and "01".
    I don't want to use 3 MUXs to accomodate all possible cases.

    Does someone has comment to do that ? Thankyou.
     
    Pasacco, Sep 27, 2006
    #1
    1. Advertising

  2. Pasacco

    KJ Guest

    Pasacco wrote:
    <snip>
    > In VHDL, I did it asynchronously and manually, depending on possible
    > 'C' values.
    >
    > Y( 0 ) <= X( 0 ) when C( 0 )="00" else
    > X( 1 ) when C( 0 )="01" else "00" ;
    > Y( 1 ) <= X( 1 ) when C( 1 )="01" else "00" ;
    > Y( 2 ) <= X( 2 ) when C( 2 )="10" else "00" ;
    >
    > Then it works fine.

    That's good!

    > Problem is that I can not make thse VHDL descriptions "generic", when
    > possible values of 'C' are known.
    > For example, possible values C(1) are "00" and "01".
    > I don't want to use 3 MUXs to accomodate all possible cases.

    Why not? If you're concerned about logic resources being 'wasted'
    inside a device then don't be. If it turns out that C(0) or C(1)
    happen to be constants as you mentioned than any synthesis tool will
    immediately catch on to this and optomize your code for the particular
    values that C(0) and C(1) actually have and the 'mux' will collapse
    right down into the exact same logic as if you had coded it ahead of
    time knowing this.

    It appears to me that what you have right now is the 'generic' solution
    so don't be afraid to turn the synthesis tool loose on it with your
    constants and watch the specific solution reduce down to exactly what
    it should. Try it.

    KJ
     
    KJ, Sep 27, 2006
    #2
    1. Advertising

  3. Pasacco

    Pasacco Guest

    Thankyou for comment.

    As you mentioned, MUXs are generic but I want to avoid 3 MUXs in order
    to reduce logic.
    Meanwhile, possible values of control signal 'C' are "known", but
    internally "generated" instead of "constant".

    I tried (1) full MUX generic implementation (2) manual implementation.
    (2) is better than (1).
    But I hope it is possible to avoid 3 MUXs, while keeping it generic.

    I am trying to use look-up table buffer to contain possible values of
    'C', since we already know possible values of 'C'. And I am trying to
    make "conditional assignments statements" generic. But it is not easy.
    Does anyone have comment? thankyou.
     
    Pasacco, Sep 28, 2006
    #3
  4. Pasacco

    KJ Guest

    "Pasacco" <> wrote in message
    news:...
    > Thankyou for comment.
    >
    > As you mentioned, MUXs are generic but I want to avoid 3 MUXs in order
    > to reduce logic.

    As I said with any reasonable synthesis tool, it won't reduce logic.

    > Meanwhile, possible values of control signal 'C' are "known", but
    > internally "generated" instead of "constant".

    What is the difference between "known", but internally "generated" and
    "constant"? If it's 'known' then you should be able to tell the synthesis
    tool this in your code. Note, 'constants' can actually be quite complicated
    VHDL functions that go through entire lots of lines of code to figure out
    what that constant is. You might want to post some code showing a bit more
    about how C() is generated and demonstrate the difference between "known",
    but internally "generated" and "constant".

    >
    > I tried (1) full MUX generic implementation (2) manual implementation.
    > (2) is better than (1).

    Then your manual implementation is not implementing the same function as
    your full mux implementation. The difference might come down to C() being
    treated as a signal in #1 but a constant in #2 or it might be something else
    but bottom line is they are doing something different.

    > But I hope it is possible to avoid 3 MUXs, while keeping it generic.
    >
    > I am trying to use look-up table buffer to contain possible values of
    > 'C', since we already know possible values of 'C'. And I am trying to
    > make "conditional assignments statements" generic. But it is not easy.
    > Does anyone have comment? thankyou.

    Post some code demonstrating #1 and #2 Not sure how a lookup table of
    possible C() values will help either but again posting some code would help

    KJ
     
    KJ, Sep 28, 2006
    #4
    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. Murat Tasan
    Replies:
    1
    Views:
    8,053
    Chaitanya
    Feb 3, 2009
  2. Replies:
    2
    Views:
    437
  3. Replies:
    13
    Views:
    531
    Andy Dingley
    May 27, 2008
  4. minlearn
    Replies:
    2
    Views:
    458
    red floyd
    Mar 13, 2009
  5. ali khanbaba
    Replies:
    0
    Views:
    336
    ali khanbaba
    May 21, 2009
Loading...

Share This Page