Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tbg / tbg_Check.c
1 /* functions for the pattern.c file */
2
3 #include "tbg.h"
4
5 void Check (char *port_name, int expected_value)
6 {
7 char bval[1024];
8 int range;
9
10 t_port *port = tbg_GetPort (port_name);
11
12 if (!port) {
13 fprintf (stderr, "Port %s does not exist in design %s\n", port_name, DESIGN_NAME);
14 EXIT (1);
15 }
16
17 port->FLAG = 1;
18 range = abs (port->B0 - port->B1) + 1;
19 bval[0] = 'C'; /* check */
20
21 if (range == 1)
22 switch (expected_value) {
23 case DONTCARE: bval[1] = '-'; bval[2] = '\0'; break;
24 case 0: bval[1] = '0'; bval[2] = '\0'; break;
25 case 1: bval[1] = '1'; bval[2] = '\0'; break;
26 default:
27 fprintf (stderr, "type mismatch for port %s\n", port_name);
28 EXIT (1);
29 }
30
31 if (range > 1) {
32 dec_to_bin (&bval[0] + 1, expected_value, range);
33 if (port->B0 > port->B1)
34 reverse_endianess (&bval[0] + 1);
35 }
36
37 port->VALUE = strdup (bval);
38 }