File: zuse_switch.c

package info (click to toggle)
faumachine 20180503-4
  • links: PTS
  • area: main
  • in suites: buster
  • size: 61,272 kB
  • sloc: ansic: 272,290; makefile: 6,199; asm: 4,251; sh: 3,022; perl: 886; xml: 563; pascal: 311; lex: 214; vhdl: 204
file content (227 lines) | stat: -rw-r--r-- 3,915 bytes parent folder | download
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/*
 * Copyright (C) 2015 FAUmachine Team <info@faumachine.org>.
 * This program is free software. You can redistribute it and/or modify it
 * under the terms of the GNU General Public License, either version 2 of
 * the License, or (at your option) any later version. See COPYING.
 */

#define INP_0 1
#define INP_1 2
#define INP_2 3
#define INP_3 4

#define OUTP_0 5
#define OUTP_1 6
#define OUTP_2 7
#define OUTP_3 8


#ifdef STATE

#ifdef INP_0
#define IN_N 1
#endif

#ifdef INP_1
#undef IN_N
#define IN_N 2
#endif

#ifdef INP_2
#undef IN_N
#define IN_N 3
#endif

#ifdef INP_3
#undef IN_N
#define IN_N 4
#endif

#include "zuse_generic.c"

#endif /*STATE*/


#ifdef BEHAVIOUR

/* beautiful helper macros to create the function names*/
#define PASTER(x,y,z)	    x ## _ ## y ## _ ## z
#define EVALUATOR(x,y,z)    PASTER(x,y,z)

/* macros to concat function names */
#ifdef INP_0
#define NAME_IN_PORT_0_(z)  EVALUATOR(NAME, INP_0, z)
#endif

#ifdef INP_1
#define NAME_IN_PORT_1_(z)  EVALUATOR(NAME, INP_1, z)
#endif

#ifdef INP_2
#define NAME_IN_PORT_2_(z)  EVALUATOR(NAME, INP_2, z)
#endif

#ifdef INP_3
#define NAME_IN_PORT_3_(z)  EVALUATOR(NAME, INP_3, z)
#endif

#ifdef INP_4
#define NAME_IN_PORT_4_(z)  EVALUATOR(NAME, INP_4, z)
#endif

#ifdef OUTP_0
#define NAME_OUT_PORT_0_(z) EVALUATOR(NAME, OUTP_0, z)
#endif

#ifdef OUTP_1
#define NAME_OUT_PORT_1_(z) EVALUATOR(NAME, OUTP_1, z)
#endif

#ifdef OUTP_2
#define NAME_OUT_PORT_2_(z) EVALUATOR(NAME, OUTP_2, z)
#endif

#ifdef OUTP_3
#define NAME_OUT_PORT_3_(z) EVALUATOR(NAME, OUTP_3, z)
#endif

/* Debug makros */
#if DEBUG

#ifndef STR
#define STR(x)   #x
#endif /* STR */

#ifndef SHOW_DEFINE
#define SHOW_DEFINE(x) fprintf(stderr, "%s", STR(x))
#endif /* SHOW_DEFINE */

#endif /* DEBUG */

static void
NAME_(destroy)(struct cpssp *cpssp)
{
    return;
}

static void
NAME_(solve)(struct cpssp *cpssp) {
    unsigned int res = SIG_STD_LOGIC_Z;

#ifdef INP_0
    res = res && 2000 < SIG_mV(cpssp->NAME.states[0]);
#endif
#ifdef INP_1
    res = res && 2000 < SIG_mV(cpssp->NAME.states[1]);
#endif
#ifdef INP_2
    res = res && 2000 < SIG_mV(cpssp->NAME.states[2]);
#endif
#ifdef INP_3
    res = res && 2000 < SIG_mV(cpssp->NAME.states[3]);
#endif
#ifdef INP_4
    res = res && 2000 < SIG_mV(cpssp->NAME.states[4]);
#endif

#if DEBUG
    SHOW_DEFINE(NAME);
    fprintf(stderr, " sets to JUST A DUMMY\n");
#endif /* DEBUG */

#ifdef OUTP_0
    NAME_OUT_PORT_0_(out_set)(cpssp, res ? SIG_STD_LOGIC_1 : SIG_STD_LOGIC_0);
#endif
#ifdef OUTP_1
    NAME_OUT_PORT_1_(out_set)(cpssp, res ? SIG_STD_LOGIC_1 : SIG_STD_LOGIC_0);
#endif
#ifdef OUTP_2
    NAME_OUT_PORT_2_(out_set)(cpssp, res ? SIG_STD_LOGIC_1 : SIG_STD_LOGIC_0);
#endif
#ifdef OUTP_3
    NAME_OUT_PORT_3_(out_set)(cpssp, res ? SIG_STD_LOGIC_1 : SIG_STD_LOGIC_0);
#endif
}

#include "zuse_generic.c"

static void
NAME_(create)(struct cpssp *cpssp)
{
#ifdef INP_0
    NAME_IN_PORT_0_(in_set)(cpssp, SIG_STD_LOGIC_Z);
#endif
#ifdef INP_1
    NAME_IN_PORT_1_(in_set)(cpssp, SIG_STD_LOGIC_Z);
#endif
#ifdef INP_2
    NAME_IN_PORT_2_(in_set)(cpssp, SIG_STD_LOGIC_Z);
#endif
#ifdef INP_3
    NAME_IN_PORT_3_(in_set)(cpssp, SIG_STD_LOGIC_Z);
#endif
#ifdef INP_4
    NAME_IN_PORT_4_(in_set)(cpssp, SIG_STD_LOGIC_Z);
#endif
}

#ifdef INP_0
#undef NAME_IN_PORT_0_
#undef INP_0
#endif

#ifdef INP_1
#undef NAME_IN_PORT_1_
#undef INP_1
#endif

#ifdef INP_2
#undef NAME_IN_PORT_2_
#undef INP_2
#endif

#ifdef INP_3
#undef NAME_IN_PORT_3_
#undef INP_3
#endif

#ifdef INP_4
#undef NAME_IN_PORT_4_
#undef INP_4
#endif

#ifdef OUTP_0
#undef NAME_OUT_PORT_0_
#undef OUTP_0
#endif

#ifdef OUTP_1
#undef NAME_OUT_PORT_1_
#undef OUTP_1
#endif

#ifdef OUTP_2
#undef NAME_OUT_PORT_2_
#undef OUTP_2
#endif

#ifdef OUTP_3
#undef NAME_OUT_PORT_3_
#undef OUTP_3
#endif

#undef PASTER
#undef EVALUATOR

#endif /*BEHAVIOUR*/


#undef INP_0
#undef INP_1
#undef INP_2
#undef INP_3

#undef OUTP_0
#undef OUTP_1
#undef OUTP_2
#undef OUTP_3