Passing Signals to Procedure

Discussion in 'VHDL' started by Analog_Guy, Oct 3, 2005.

  1. Analog_Guy

    Analog_Guy Guest

    I am having difficulty with what seems to be a very simple thing.

    I want to code a generic testbench procedure to automatically check any
    n-input combinatorial function in my design.

    Currently, I used a quick and dirty way just to get the automatic
    checking working. For example, I have a separate combinatorial
    procedure to handle 6-input functions, and another to handle 9-input
    functions. This works fine, but now a requirements changes converted
    one of my outputs to a 7-input function. With my current approach,
    this means I now have to code a separate procedure to handle 7-input
    combinatorial functions. This does not seem like a good way of
    handling things.

    What I would like is if someone knows how to pass a variable number of
    input signals to a generic procedure?

    I know I can send an unconstrained vector to a procedure, and use a
    'range to determine the length inside the procedure, but am not sure if
    this would work with a concatenated vector of inputs? I think I would
    have to declare unique vectors for each of my different combinatorial
    functions. Example:

    Current Approach
    ================
    test_comb_6ip(ip_1, ip_2, ip_3, ip_4, ip_5, ip_6, output_function);

    Can I do this?
    ==============
    signal vector_6ip : STD_LOGIC_VECTOR(5 DOWNTO 0);
    vector_6ip <= ip_1 & ip_2 & ip_3 & ip_4 & ip_5 & ip_6;
    test_comb(vector_6ip, output_function);

    I have not yet convinced myself that the second approach will work?

    Note that the input signals are declared as INOUT in my PROCEDURE, so
    that I may force the various input combinations on my output_function.

    Any help would be appreciated.
     
    Analog_Guy, Oct 3, 2005
    #1
    1. Advertising

  2. When you say functions, you mean procedures, don't you.

    As you say, you can declare an array (natural range<>) of type. You can
    use concatiation or aggregates:

    test_comb((ip_1,ip_2,ip_3,ip_4,ip_5,ip_6),output_function);

    If you use inout signals, you cannot assign to vector_6ip, which is
    another signal. You must pass the signals you mean.

    Hubble.
     
    Reiner Huober, Oct 3, 2005
    #2
    1. Advertising

  3. Analog_Guy wrote:

    > I want to code a generic testbench procedure to automatically check any
    > n-input combinatorial function in my design.


    Functions are timeless and can be verified using assertions:

    assert my_function("10101010") = 170
    report "my_function: error in case 170.";

    > What I would like is if someone knows how to pass a variable number of
    > input signals to a generic procedure?


    I would leave time and signals out of it.
    Just loop through a constant array of
    stim and expected values.


    -- Mike Treseler
     
    Mike Treseler, Oct 3, 2005
    #3
  4. Analog_Guy

    Analog_Guy Guest

    Mike Treseler wrote:
    > Analog_Guy wrote:
    >
    > > I want to code a generic testbench procedure to automatically check any
    > > n-input combinatorial function in my design.

    >
    > Functions are timeless and can be verified using assertions:
    >
    > assert my_function("10101010") = 170
    > report "my_function: error in case 170.";
    >
    > > What I would like is if someone knows how to pass a variable number of
    > > input signals to a generic procedure?

    >
    > I would leave time and signals out of it.
    > Just loop through a constant array of
    > stim and expected values.
    >
    >
    > -- Mike Treseler


    For a 9-input combinatorial gate, wouldn't I have to create a constant
    array with 512 elements? I wanted to cycle through every combination
    of inputs. I was just trying to implement a 9-bit counter in a
    procedure, whereby ip_1 <= count(8), ip_2 <= count(7), etc.. I thought
    that by passing an unconstrained array, I could make a generic width
    counter to automatically adapt to the number of inputs. I just can't
    figure how to send the variable number of inputs to the procedure.
     
    Analog_Guy, Oct 4, 2005
    #4
  5. Analog_Guy wrote:

    > For a 9-input combinatorial gate, wouldn't I have to create a constant
    > array with 512 elements?


    Yes, to cover n inputs you would need
    2**n constant vectors of expected data
    for the assertion.

    > I wanted to cycle through every combination
    > of inputs. I was just trying to implement a 9-bit counter in a
    > procedure, whereby ip_1 <= count(8), ip_2 <= count(7), etc.. I thought
    > that by passing an unconstrained array, I could make a generic width
    > counter to automatically adapt to the number of inputs. I just can't
    > figure how to send the variable number of inputs to the procedure.


    I would use an unconstrained unsigned arg then
    declare a variable of the proper length in the process:
    variable vec : unsigned(arg'range) := arg;

    Or you could use access types (pointers). See:
    http://groups.google.com/groups?q=vhdl load_test_data

    -- Mike Treseler
     
    Mike Treseler, Oct 4, 2005
    #5
    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. Andy Peters

    Driving signals from a procedure

    Andy Peters, May 19, 2005, in forum: VHDL
    Replies:
    4
    Views:
    922
    Jonathan Bromley
    May 20, 2005
  2. Mike P
    Replies:
    0
    Views:
    3,311
    Mike P
    Jun 19, 2006
  3. Ved

    signals in Procedure

    Ved, Sep 12, 2006, in forum: VHDL
    Replies:
    2
    Views:
    509
  4. Eli Bendersky
    Replies:
    15
    Views:
    2,939
    Jonathan Bromley
    Apr 28, 2007
  5. AlexWare
    Replies:
    2
    Views:
    763
    Paul Uiterlinden
    Oct 23, 2009
Loading...

Share This Page