|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |


Tutorials



REGIONS

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.
Conceptually, regions can be viewed as a set of letters. First you allocate which letters are included in the set. These letters are the only letters from which words can be made. If one person uses the letters to spell CAT, no one else can spell TIN because the T is already in use. Once the T is returned, TIN can be created. Effectively, this ensures that data sets are unique, and it eliminates concurrent crossover.


To allocate a region, you must use the alloc() system function.
Syntax : function integer alloc(REGION, integer region_id, integer region_count);
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.


The region_enter() system function checks to see if a particular region is in use.
The region_exit() system task removes the specified values from the in-use state.


EXAMPLE:REGIONS
task CPU(integer id, integer grant, integer regID){
integer data, address;
reg[31:0] randVar;
repeat (10)
{
randVar=random();
address=randVar[13:6];
data=randVar[29:22];
region_enter(WAIT, regID, address);
disp(address,data,grant);
region_exit(regID, address);
}
}

task disp(integer add,integer data,integer id){
delay(random());
printf(" add %d data %d id %d\n",add,data,id);
}

program main {
integer regID;
regID=alloc(REGION, 0, 1);
fork
CPU(0, 2'b01, regID);
CPU(1, 2'b10, regID);
join

}
RESULTS

add 56 data 0 id 1
add 230 data 13 id 2
add 31 data 156 id 1
add 179 data 140 id 2
add 159 data 135 id 1
add 113 data 252 id 1
add 149 data 142 id 2
add 193 data 187 id 1
add 77 data 221 id 2
add 116 data 120 id 1
add 215 data 198 id 2
add 200 data 88 id 1
add 192 data 35 id 2
add 252 data 1 id 1
add 199 data 254 id 2
add 142 data 42 id 2
add 49 data 204 id 1
add 187 data 135 id 1
add 172 data 46 id 2
add 142 data 57 id 2




Index
Introduction
Data Types
Linked List
Operators Part 1
Operators Part 2
Operators Part 3
Operator Precedence
Control Statements
Procedures And Methods
Interprocess
Fork Join
Shadow Variables
Fork Join Control
Wait Var
Event Sync
Event Trigger
Semaphore
Regions
Mailbox
Timeouts
Oop
Casting
Randomization
Randomization Methods
Constraint Block
Constraint Expression
Variable Ordaring
Aop
Predefined Methods
String Methods
Queue Methods
Dut Communication
Functional Coverage

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright 2007-2017 :: all rights reserved www.testbench.in::Disclaimer