File: probe.c

package info (click to toggle)
gplcver 2.12a-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,604 kB
  • ctags: 9,129
  • sloc: ansic: 126,201; sh: 1,539; makefile: 86; perl: 22
file content (122 lines) | stat: -rw-r--r-- 3,260 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* Copyright (c) 1994-2003 Pragmatic C Software Corp. */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "veriuser.h"
#include "cv_veriuser.h"
 
#define MAXSIZE 500
/* upto 10 parameters, MAXSIZE time values upto 64 bits long */ 
/* (16 chars plus 0 end byte) */
static char value_ar[10][MAXSIZE][17];  

static int time_ar[MAXSIZE];
static int total_nump;
static int last_entry = 0;
static char *setup_inst_p; 

/* local function prototypes */
static void vu_setup_values(void);
static void vu_update_values(int, int, int);
static void vu_doupdate(void);
static void vu_flash_values(void);

static void vu_setup_values(void)
{
 int nparam;

 s_tfexprinfo einfo_s;
 p_tfexprinfo info_p = &einfo_s;
 /* get total number of parameters */
 total_nump = tf_nump();
 /* get the setup instance for updating values */
 setup_inst_p = tf_getinstance();
 /* if this is a second call to setup and asynchronous updating has been */
 /* disabled then resume the asynchronous calls */
 tf_asynchon();
 for (nparam = 1; nparam <= total_nump; nparam++)
 { 
  /* check param lengths */
  tf_exprinfo(nparam, info_p);
  if (info_p->expr_ngroups > 2)
   {
    tf_error("parameters msut be less than 65 bits");
   }
 }
 /* save initial values */
 last_entry = 0; 
 vu_doupdate();
}

/* this routine is aynchronously called during simulation */
static void vu_update_values(int data, int reason, int pnum)
{
 /* test reason called */ 
 if (reason == reason_paramvc)
  {
   io_printf("now %d parameter %d changed - reason paramvc_sync\n",
    tf_gettime(), pnum);
   tf_synchronize();
  }
 else if (reason == reason_synch)
  {
   io_printf("now %d misctf called for #0 reason_sync\n", tf_gettime());
   vu_doupdate();
  }
}

static void vu_doupdate(void)
{
 int nparam;

 if (++last_entry == MAXSIZE)
  {
   /* the array is full. stop calling this routine */
   tf_asynchoff();
   return;
  } 
 /* obtain current simulation time */ 
 time_ar[last_entry] = tf_gettime();
 for (nparam = 1; nparam <= total_nump; nparam++)
  /* obtain hex value of the parameter number nparam */
  {
  strcpy(value_ar[nparam][last_entry], tf_istrgetp(nparam, 'h', setup_inst_p));
   io_printf("** now %d assign %s to param %d\n", time_ar[last_entry],
   value_ar[nparam][last_entry], nparam);
  }
}

/* this routine displays the values of variables at a given time */
static void vu_flash_values(void)
{
 int nparam, find_time, entry_num;
 /* get the value of time which is the only param */
 find_time = tf_getp(1);
 for (entry_num = last_entry; (entry_num > 0); entry_num--)
  if (time_ar[entry_num] <= find_time)
   break;
 io_printf("For time %d\n", find_time);
 /* this needs to go from 1 to number of params since task not func */ 
 for (nparam = 1; nparam <= total_nump; nparam++)
  io_printf("    value of parameter %d = %s\n", 
   nparam, value_ar[nparam][entry_num]);
} 

s_tfcell veriusertfs[] =
{
 {usertask, 0,
  0, 0, (int (*)()) vu_setup_values, (int (*)()) vu_update_values,
  "$setup_values", 0 }, 
 {usertask, 0,
  0, 0, (int (*)()) vu_flash_values, 0,
  "$flash_values", 0 }, 
 {0} /* this line must always be last */
};

/* dummy +loadpli1 boostrap routine - return old style veriusertfs tab */
s_tfcell *pli1_compat_bootstrap(void)
{
 return(veriusertfs);
}