nasim
New Member
Offline
Posts: 1
|
Hello everyone,
I have a simple PLI question which I hope someone can help me with. I have a data file that has lines like this (it is a long file) :
#2 a 2 b 5 c 7 #4 a 6 #3 b 8
The # numbers are simulation time and the rest are input port names with values to be driven at that particular time.
Then, I have the following Verilog code, where I call a user defined task:
always @(a) $mycode (a) ; always @(b) $mycode (b); always @(c) $mycode (c);
What I have currently in the .c file, which I hope is correct, is something like this:
typedef struct OBJ { ... } *OBJp;
int mycalltf { tf_getdelay(0); return 0; }
int mymisctf (int data, int reason, int paramvc) { OBJp obj; switch (reason) { case REASON_ENDOFCOMPILE: tf_setworkarea ((char *)obj); long j=0; FILE *f; // open file using fopen while (fgets(line, sizeof(line),f) !=NULL) { strcpy(array[j],line); // copy in a data structure, i.e. 2D char array j++ } // close file break;
case REASON_REACTIVATE: obj = (OBJp) tf_getworkarea(); // search the data structure here to find signal name and value, // and if found , drive that value using acc_set_value() break;
return 0; }
What I am trying to do is whenever the task is called, it is going to find the value of the input port passed (i.e. a or b or c) from within the data structure (which I will create from parsing the data file) and then drive that value onto that port at that intended time.
My questions are : (1) How can I tell the misctf routine that I actually want to parse the data file only 1 time, and not 3 times (which is happening since I am instantiating the task 3 times) ? I mean I want to parse the data file just 1 time, put all of the contents inside a data structure, and then traverse the data structure whenever the task is subsequently called. (2) Are the routines I have set out above correct ? As you can see, what I am doing is that everytime the user task instance is called, it would come inside calltf, which has tf_setdelay(0), meaning it would then schedule a callback with 0 delay, i.e. branch to the REASON_REACTIVATE case inside misctf, and then I will do the search for the input port passed, if found, drive the value on that port at that time. (3) I don't know if I need to use tf_isetworkarea() and tf_igetworkarea(), 'cause I don't really know if it makes a difference here.
Please help.
Thanks, -Nasim
|