3 #include "asg_module.h"
7 /*----------------------------------------------------------------------*/
8 int toModuleType(char *mtName
) {
9 char *s
= toupper(mtName
);
10 if (!strcmp(s
, GATE_AND_STR
)) return AND_ASG
;
11 if (!strcmp(s
, GATE_OR_STR
)) return OR_ASG
;
12 if (!strcmp(s
, GATE_NAND_STR
)) return NAND_ASG
;
13 if (!strcmp(s
, GATE_NOR_STR
)) return NOR_ASG
;
14 if (!strcmp(s
, GATE_CAPC_STR
)) return CAPACITOR_ASG
;
15 if (!strcmp(s
, GATE_RESTR_STR
)) return RESISTOR_ASG
;
16 if (!strcmp(s
, GATE_INDR_STR
)) return INDUCTOR_ASG
;
17 if (!strcmp(s
, GATE_XOR_STR
)) return XOR_ASG
;
18 if (!strcmp(s
, GATE_XNOR_STR
)) return XNOR_ASG
;
19 if (!strcmp(s
, GATE_NOT_STR
)) return NOT_ASG
;
20 if (!strcmp(s
, GATE_INVNOT_STR
)) return INVNOT_ASG
;
21 if (!strcmp(s
, GATE_NULL_STR
)) return BUFFER_ASG
;
22 if (!strcmp(s
, BUFFER_GATE
)) return BUFFER_ASG
;
23 if (!strcmp(s
, INPUT_TERM
)) return INPUT_SYM_ASG
;
24 if (!strcmp(s
, OUTPUT_TERM
)) return OUTPUT_SYM_ASG
;
25 if (!strcmp(s
, INOUT_TERM
)) return INOUT_SYM_ASG
;
26 if (!strcmp(s
, GENERIC_BLOCK
)) return BLOCK_ASG
;
27 if (!strcmp(s
, GATE_NMOS_STR
)) return NMOS_ASG
;
28 if (!strcmp(s
, GATE_PMOS_STR
)) return PMOS_ASG
;
29 if (!strcmp(s
, GATE_NMOS_4_STR
)) return NMOS_4_ASG
;
30 if (!strcmp(s
, GATE_PMOS_4_STR
)) return PMOS_4_ASG
;
31 if (!strcmp(s
, GATE_VAMP_STR
)) return VSOURCE_ASG
;
32 if (!strcmp(s
, GATE_IAMP_STR
)) return ISOURCE_ASG
;
33 if (!strcmp(s
, GATE_MSFET_STR
)) return PMOS_ASG
;
34 else return(UNKNOWN_ASG
);
36 /*----------------------------------------------------------------------*/
38 char *toString(int mt
) {
41 case UNKNOWN_ASG
: rv
= strdup("UNKNOWN"); break;
42 case CAPACITOR_ASG
: rv
= strdup("CAPACITOR"); break;
43 case INDUCTOR_ASG
: rv
= strdup("INDUCTOR"); break;
44 case RESISTOR_ASG
: rv
= strdup("RESISTOR"); break;
45 case NMOS_ASG
: rv
= strdup("NMOS"); break;
46 case PMOS_ASG
: rv
= strdup("PMOS"); break;
47 case PMOS_4_ASG
: rv
= strdup("PMOS_4"); break;
48 case NMOS_4_ASG
:rv
= strdup("NMOS_4"); break;
49 case VSOURCE_ASG
: rv
= strdup("VSOURCE"); break;
50 case ISOURCE_ASG
: rv
= strdup("ISOURCE"); break;
51 case NOT_ASG
: rv
= strdup("NOT"); break;
52 case INVNOT_ASG
: rv
= strdup("INVNOT"); break;
53 case AND_ASG
: rv
= strdup("AND"); break;
54 case NAND_ASG
: rv
= strdup("NAND"); break;
55 case OR_ASG
: rv
= strdup("OR"); break;
56 case NOR_ASG
: rv
= strdup("NOR"); break;
57 case XOR_ASG
: rv
= strdup("XOR"); break;
58 case XNOR_ASG
: rv
= strdup("XNOR"); break;
59 case BUFFER_ASG
: rv
= strdup("BUFFER"); break;
60 case INPUT_SYM_ASG
: rv
= strdup("IN"); break;
61 case OUTPUT_SYM_ASG
: rv
= strdup("OUT"); break;
62 case INOUT_SYM_ASG
: rv
= strdup("INOUT"); break;
63 case BLOCK_ASG
: rv
= strdup("BLOCK"); break;
65 rv
= strdup("UNKNOWN");
70 /* ------------------------------------------------------------------------
72 * create a new object/module and install it in the global module list
73 * ------------------------------------------------------------------------
76 // module *new_asg_module(char *module_name, int gate_type)
80 // object = (module *)calloc(1, sizeof(module));
81 // object->index = module_count++;
82 // object->name = strdup(gate_name);
83 // object->type = toString(gate_type);
86 // object->flag = UNSEEN;
87 // object->placed = UNPLACED;
88 // object->rot = LEFT; /* assme no rotation */
89 // object->primary_in = NULL;
90 // object->primary_out = NULL;
91 // object->terms = NULL;
92 // object->fx = create_var_struct(ADD, NULL, NULL);
93 // object->fy = create_var_struct(ADD, NULL, NULL);
94 // set_default_object_size(object->type, &object->x_size, &object->y_size);
96 // modules = (mlist *)concat_list(object, modules);
101 /*--------------------------------------------------------------------------------- */
103 /* ModuleType validate_module_type(s) */
107 /* SEE string definitions in "network.h" */
108 if (!strcmp(s
, GATE_AND_STR
)) return AND
;
109 if (!strcmp(s
, GATE_OR_STR
)) return OR
;
110 if (!strcmp(s
, GATE_NAND_STR
)) return NAND
;
111 if (!strcmp(s
, GATE_NOR_STR
)) return NOR
;
112 if (!strcmp(s
, GATE_PMOS_STR
)) return PMOS
;
113 if (!strcmp(s
, GATE_CAPC_STR
)) return CAPC
;
114 if (!strcmp(s
, GATE_RESTR_STR
)) return RESTR
;
115 if (!strcmp(s
, GATE_INDR_STR
)) return INDR
;
116 if (!strcmp(s
, GATE_XOR_STR
)) return XOR
;
117 if (!strcmp(s
, XNOR_GATE
)) return XNOR
;
118 if (!strcmp(s
, GATE_NOT_STR
)) return NOT_
;
119 if (!strcmp(s
, GATE_INVNOT_STR
)) return INVNOT_
;
120 if (!strcmp(s
, GATE_NULL_STR
)) return BUFFER
;
121 if (!strcmp(s
, BUFFER_GATE
)) return BUFFER
;
122 if (!strcmp(s
, INPUT_TERM
)) return INPUT_SYM
;
123 if (!strcmp(s
, OUTPUT_TERM
)) return OUTPUT_SYM
;
124 if (!strcmp(s
, INOUT_TERM
)) return INOUT_SYM
;
125 if (!strcmp(s
, GENERIC_BLOCK
)) return BLOCK
;
126 if (!strcmp(s
, GATE_NMOS_STR
)) return NMOS
;
127 if (!strcmp(s
, GATE_VAMP_STR
)) return VAMP
;
128 if (!strcmp(s
, GATE_MSFET_STR
)) return MSFET
;
129 else return(DONT_KNOW
);
131 /* Also adjust "set_default_object_size" whenever this is modified. */
133 /*------------------------------------------------------------------------ */
135 int xc_print_asg_module(XCWindowData
*areastruct
, module
*m
)
138 float arcLen
, noOfExtensions
, fractional
, theta
, mid_y
, mid_x
;
142 type
= validate(m
->type
);
144 xc_print_sym(areastruct
, m
->type
, m
->name
, m
->x_pos
, m
->y_pos
,
145 m
->x_size
, m
->y_size
, m
->rot
);
147 if ((type
== BLOCK
) || (type
== DONT_KNOW
)) xc_attach_outerms(areastruct
, m
);
148 xc_attach_interms(areastruct
, m
);
151 /* Special case stuff for mulit-terminal ANSI AND, NAND, OR, NOR, XOR, and
154 if ((m
->y_size
> ICON_SIZE
) && (type
!= BLOCK
) && (type
!= DONT_KNOW
))
156 if ((type
== AND
) || (type
== NAND
))
157 { /* AND family - display a line to connect all inputs to the icon */
158 mid_x
= (float)m
->x_pos
+ (float)m
->x_size
/ 2.0;
160 //code to be attached
163 else if ((type
== OR
) || (type
== NOR
))
164 { /* OR family -- Add line to the 1st Back Curve: */
165 mid_x
= (float)m
->x_pos
+ (float)m
->x_size
/2.0 - 0.4;
167 noOfExtensions
= ((float)m
->y_size
- arcLen
)/(2.0 * arcLen
);
168 n
= (int)noOfExtensions
;
169 fractional
= (noOfExtensions
- (float)n
) * arcLen
;
170 for (i
= n
; i
>= 0; i
--)
171 { /* put down one arc, or fraction thereof */
172 theta
= (i
> 0) ? 28.072 :
173 (180.0/M_PI
) * asin(fractional
/20) - 28.072;
174 if (theta
> (-28.072 * 1.10)) /* 10% margin */
176 mid_y
= (float)m
->y_pos
+ (float)m
->y_size
/2.0 +
177 (float)(n
- i
+ 1) * arcLen
;
179 mid_y
= (float)m
->y_pos
+ (float)m
->y_size
/2.0 -
180 (float)(n
- i
+ 1) * arcLen
;
181 //code to be attached
185 else if ((type
== XOR
) || (type
== XNOR
))
186 { /* OR family -- Add line to the 2nd Back Curve: */
187 mid_x
= (float)m
->x_pos
+ (float)m
->x_size
/2.0;
189 noOfExtensions
= ((float)m
->y_size
- arcLen
)/(2.0 * arcLen
);
190 n
= (int)noOfExtensions
;
191 fractional
= (noOfExtensions
- (float)n
) * arcLen
;
192 for (i
= n
; i
>= 0; i
--)
193 { /* put down one arc, or fraction thereof */
194 theta
= (i
> 0) ? 28.072 :
195 (180.0/M_PI
) * asin(fractional
/20) - 28.072;
196 if (theta
> (-28.072 * 1.10)) /* 10% margin */
198 mid_y
= (float)m
->y_pos
+ (float)m
->y_size
/2.0 +
199 (float)(n
- i
+ 1) * arcLen
;
200 /*fprintf(f, "newpath %f %f %f %f %f arc stroke\n",
201 mid_x - 31.5, mid_y, 20.0,
203 mid_y
= (float)m
->y_pos
+ (float)m
->y_size
/2.0 -
204 (float)(n
- i
+ 1) * arcLen
;
205 //code to be attached
209 /* height of arc in Y is 2*rad*sin(28.072) = 40*.47058 =