1 /*
2 * Copyright (c) 2002 Michael Ruff (mruff at chiaro.com)
3 *
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #include <stdio.h>
21 #include <assert.h>
22 #include <veriuser.h>
23 #include <vpi_user.h>
24
25 /*
26 * tf_putlongp implemented using VPI interface
27 */
tf_putlongp(int n,int lowvalue,int highvalue)28 void tf_putlongp(int n, int lowvalue, int highvalue)
29 {
30 vpiHandle sys_h, sys_i, arg_h = 0;
31 s_vpi_value val;
32 int type;
33 char str[20];
34
35
36 assert(n >= 0);
37
38 /* get task/func handle */
39 sys_h = vpi_handle(vpiSysTfCall, 0);
40 sys_i = vpi_iterate(vpiArgument, sys_h);
41
42 type = vpi_get(vpiType, sys_h);
43
44 /* verify function */
45 assert(!(n == 0 && type != vpiSysFuncCall));
46
47 /* find nth arg */
48 while (n > 0) {
49 if (!(arg_h = vpi_scan(sys_i))) assert(0);
50 n--;
51 }
52 if (!arg_h) arg_h = sys_h;
53
54 /* fill in vpi_value */
55 sprintf(str, "%x%08x", highvalue, lowvalue);
56 val.format = vpiHexStrVal;
57 val.value.str = str;
58 vpi_put_value(arg_h, &val, 0, vpiNoDelay);
59
60 vpi_free_object(sys_i);
61 }
62