quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif regions

A region is a mutual exclusion mechanism that guarantees that the requested values are unique in the simulation. This feature is provided mostly for random type simulations that may depend on the uniqueness of specific values such as addresses or data-IDs.

   

space.gif

Note : I not seen a code that uses regions, so you can skip this page and move on to next page.

   

space.gif

Like semaphore, regions comes with following methods to work with.

   

space.gif

  • region allocation
  • using values in region
  • Removing a value from region
   

space.gif

Region Allocation

   

space.gif

function integer alloc(REGION, integer region_id, integer region_count);
   

space.gif

Where

   

space.gif

  • region_id : Is the ID number of the particular region being created. It must be an integer value. You should generally use 0. When you use 0, Vera automatically generates a region ID.
  • region_count : Specifies how many regions you want to create. It must be an integer value.
   

space.gif

Region Check

   

space.gif

function integer region_enter(NO_WAIT | WAIT, integer
region_id, reg|integer value1, ..., reg|integer valueN);
   

space.gif

Where

   

space.gif

  • NO_WAIT : Option continues code execution even if the specified region is in use.
  • WAIT : Suspends the process until the specified region is no longer in use.
  • region_id : Specifies which region that is being entered.
  • value : Is an integer or bit vector up to 64 bits, without X's or Z's. This value specifies the unique region value.
   

space.gif

   

space.gif

Remove Value from Region

   

space.gif

task region_exit(integer region_id, reg|integer value1, ...,
reg|integer valueN);
   

space.gif

Where

   

space.gif

  • region_id : Specifies which region that is being exited.
  • value : Is an integer or bit vectors up to 64 bits, without X's or Z's. These values specify the unique region values.
   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : regions
   

space.gif


  1 #include "vera_defines.vrh"
  2 
  3 program region {
  4   integer portid;
  5   portid = alloc(REGION,0,1);
  6   fork
  7     { drive_port("PORT 0"); }
  8     { drive_port("PORT 1"); }
  9   join all
 10 }
 11 
 12 
 13 task drive_port(string portname) {
 14   bit [2:0] addr;
 15   integer i;
 16   for(i = 0; i < 4; i ++ ) {
 17     delay(5);
 18     addr = random(); 
 19     region_enter(WAIT, portid, addr);
 20     printf("[%0d] Generated address %x for  %s\n", get_time(LO),addr, portname);
 21     delay(5);
 22     region_exit(portid, addr);
 23   }
 24 }
You could download file region.vr here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation : regions
   

space.gif

 [5] Generated address 6 for  PORT 0
 [5] Generated address 3 for  PORT 1
 [15] Generated address 4 for  PORT 0
 [15] Generated address 0 for  PORT 1
 [25] Generated address 5 for  PORT 0
 [30] Generated address 5 for  PORT 1
 [35] Generated address 2 for  PORT 0
 [40] Generated address 2 for  PORT 1
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com