1 /*
2 * Copyright (c) 2013-2015 Stephen Williams (steve@icarus.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 "config.h"
21 # include "priv.h"
22 # include <stdlib.h>
23 # include <inttypes.h>
24 # include <assert.h>
25
show_constant(ivl_net_const_t net)26 void show_constant(ivl_net_const_t net)
27 {
28 assert(net);
29
30 fprintf(out, "constant ");
31 switch (ivl_const_type(net)) {
32 case IVL_VT_BOOL:
33 case IVL_VT_LOGIC:
34 {
35 const char*bits = ivl_const_bits(net);
36 unsigned idx;
37 assert(bits);
38 for (idx = 0 ; idx < ivl_const_width(net) ; idx += 1)
39 fprintf(out, "%c", bits[idx]);
40 }
41 break;
42 case IVL_VT_REAL:
43 fprintf(out, "%f", ivl_const_real(net));
44 break;
45 default:
46 fprintf(out, "<unsupported type>");
47 break;
48 }
49 fprintf(out, " at %s:%u\n", ivl_const_file(net), ivl_const_lineno(net));
50 }
51