Re: [vhdl-200x] Parallel execution of procedures within sequentiel statements

From: Jim Lewis <Jim@synthworks.com>
Date: Wed Feb 15 2012 - 11:30:39 PST

Hi Martin,
What you have is separate executions of the a procedure
running in a single thread.

To create a separate thread, use a separate process:
> ....
> procedure my_proc
> (signal din : in std_logic_vector;
> signal dout : out std_logic) is
> begin
> -- procedure statements
> ...
> wait for 8 ns;
> ...
> end my_proc;
>
> signal sig1, sig2: std_logic_vector (31 downto 0);
> signal data1, data2: std_logic;
>
> begin
    thread1_proc: process
    begin
      my_proc(sig1, data1);
      wait for 8 ns ;
      my_proc(sig1, data1);
      barrier_sync_proc(JoinPoint1) ;
      ...
    end process thread1_proc ;

    thread2_proc: process
    begin
      wait for 8 ns ;
      my_proc(sig2, data2);
      wait for 8 ns ;
      my_proc(sig2, data2);
      barrier_sync_proc(JoinPoint1) ;
      ...
    end process thread2_proc ;

The use model for threads is a little different than other
languages that use fork/join. In VHDL a join would be like
have a barrier synchronization point in both processes.

The procedure WayPointBlock, shown below, does barrier
synchronization using the resolved type std_logic. It
requires the signal to be initialized to a 0 (in the
architecture declaration region). It is crude, but it
gets the job done.

signal JoinPoint1 : std_logic := '0' ;
...

    ------------------------------------------------------------
    procedure WayPointBlock (
    -- Stop until multiple processes have all set Sig to 'H'
    ------------------------------------------------------------
      signal Sig : InOut std_logic
    ) is
    begin
      Sig <= 'H' ;

      -- Wait until all processes set Sig to H
      -- Level check not necessary since local value /= H yet
      wait until Sig = 'H' ;

      -- Deactivate and propagate to allow back to back calls
      Sig <= '0' ;
      wait for 0 ns ;
    end procedure WayPointBlock ;

It might be more appropriate to do this with a summing
resolution function based on integer, but then we would
have to talk about how to do that.

The VHDL-200X list is for language development. So general
questions would be better asked on comp.lang.vhdl or
on one of the linkedin groups.

OTOH, one of the items we need to develop for the next language
revision is a set of synchronization primitives, such as
WayPointBlock. So if you are working in that direction, we are
definitely interested in hearing more.

Best,
Jim

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis
Director of Training             mailto:Jim@SynthWorks.com
SynthWorks Design Inc.           http://www.SynthWorks.com
1-503-590-4787
Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Feb 15 11:30:29 2012

This archive was generated by hypermail 2.1.8 : Wed Feb 15 2012 - 11:31:01 PST