|
|
|
|
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
Note : I not seen a code that uses regions, so you can skip this page and move on to next page. |
|
|
|
|
|
Like semaphore, regions comes with following methods to work with. |
|
|
|
|
|
- region allocation
- using values in region
- Removing a value from region
|
|
|
|
|
|
Region Allocation |
|
|
|
|
|
function integer alloc(REGION, integer region_id, integer region_count);
|
|
|
|
|
|
Where |
|
|
|
|
|
- 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.
|
|
|
|
|
|
Region Check |
|
|
|
|
|
function integer region_enter(NO_WAIT | WAIT, integer
region_id, reg|integer value1, ..., reg|integer valueN);
|
|
|
|
|
|
Where |
|
|
|
|
|
- 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.
|
|
|
|
|
|
|
|
|
Remove Value from Region |
|
|
|
|
|
task region_exit(integer region_id, reg|integer value1, ...,
reg|integer valueN);
|
|
|
|
|
|
Where |
|
|
|
|
|
- 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.
|
|
|
|
|
|
|
|
|
|
|
|
Example : regions
|
|
|
|
|
|
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
|
|
|
|
|
|
Simulation : regions
|
|
|
|
|
|
[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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|