Results 1 to 9 of 9

Thread: How to use Shared Variable

  1. #1
    Join Date
    Jan 2017
    Posts
    5
    Rep Power
    1

    Default How to use Shared Variable

    Tell how you use Shared Variable


    What you think about Shared Variable


    What they for

  2. #2
    Join Date
    Nov 2014
    Posts
    5
    Rep Power
    1

    Default Re: How to use Shared Variable

    The main use for shared variables is in test benches

    have a look at OSVVM. ORG

    the free packages there make extensive use of SHARED VARIABLES


    They are also very useful verification packages.

    creating good stimulus is often a lot of work & is boring.

    SAVE YOURSELF A LOT OF WORK

    have a look at intelligent coverage at OSVVM. ORG

    Those packages can create intelligent random functional coverage stimulus for you.

    With very little effort from you they can create stimulus for all the functions you ask them to cover in your testbench.

    The OSVVM packages are written by Jim Lewis & he leads the IEEE VHDL standard group who are working on the next version of VHDL after VHDL2008.

  3. #3
    Join Date
    Jan 2017
    Posts
    5
    Rep Power
    1

    Default Re: How to use Shared Variable

    Thank

    Is any other person have OSVVM opinion

  4. #4
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    5,607
    Rep Power
    1

    Default Re: How to use Shared Variable

    A shared variable is just a variable that can be used in several processes, similar to a signal, but it will update immediately.
    In VHDL 93, they could be declared for any type, but in 2002 onwards shared variables must be a protected type. (this rule is ignored by default in modelsim/quartus to maintain backwards compatability).
    Shared variables can be used to infer write-before read behaviour in infered rams rather than using a signal.

    On the testbenching side - they can be used with protected types (like OSVVM) so that you have variables with some behaviour simular to OO programming, although there are many restrictions.

    What are you goals, as this is a very open question. In FPGAs, they are most often used for ram behaviour inference, as I specified above.

    Be warned though, if used incorrectly, they can become prone to compile order dependency. Consisder the following:

    Code:
    shared variable a : std_logic;
    
    process(clk)
    begin
      if rising_edge(clk) then
        a := '1';
      end if;
    end process;
    
    process(clk)
    begin
      if rising_edge(clk) then
        a := '0';
      end if;
    end process;
    here, you have no idea if "a" will end up as '1' or '0', as you do not know which process will act on the variable last. There are no 'X' values to denote unknown in simulation as its down to the compiler which process "wins". (quartus will throw multiple driver error though)
    Last edited by Tricky; April 20th, 2017 at 05:12 AM.

  5. #5
    Join Date
    Jan 2017
    Posts
    5
    Rep Power
    1

    Default Re: How to use Shared Variable

    Thank tricky good info

    Is any other person have opinion

  6. #6
    Tricky is offline Moderator **Forum Master**
    Join Date
    Oct 2008
    Posts
    5,607
    Rep Power
    1

    Default Re: How to use Shared Variable

    Quote Originally Posted by wanjoe View Post
    Thank tricky good info

    Is any other person have opinion
    As for an opinion - just dont use them in synthesisable code. Stick to signals like everyone else.

  7. #7
    Join Date
    Nov 2014
    Posts
    5
    Rep Power
    1

    Default Re: How to use Shared Variable

    As I said above
    The main use for shared variables is in test benches

    the free OSVVM packages make extensive use of SHARED VARIABLES

    You will find this webinar very useful

    https://www.doulos.com/content/event...rification.php

  8. #8
    Join Date
    Nov 2014
    Posts
    5
    Rep Power
    1

    Default Re: How to use Shared Variable

    Here is another OSVVM Shared Variable Webinar Link for You

    I was going to post it last week but I couldn't find it.

    This shows how VERY useful Shared Variables can be in testbenches.

    http://www.aldec.com/en/support/reso.../webinars/1719

  9. #9
    Join Date
    Jan 2017
    Posts
    5
    Rep Power
    1

    Default Re: How to use Shared Variable

    Thank Tricky

    thank DoItRight
    2 webinar you link GOOD GOOD GOOD

    see good info in 2 webinar

Similar Threads

  1. Replies: 2
    Last Post: October 22nd, 2016, 11:52 AM
  2. Replies: 9
    Last Post: April 15th, 2014, 11:07 AM
  3. Replies: 1
    Last Post: March 17th, 2013, 03:07 AM
  4. How to define a variable and assign a variable
    By tesleft in forum General Altera Discussion
    Replies: 4
    Last Post: February 16th, 2013, 05:49 PM
  5. Replies: 0
    Last Post: July 21st, 2010, 01:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •