-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathtest_ghdl_expanded.js
More file actions
313 lines (266 loc) · 10.6 KB
/
test_ghdl_expanded.js
File metadata and controls
313 lines (266 loc) · 10.6 KB
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#!/usr/bin/env node
/**
* Test script to verify that the expanded GHDL configuration options work correctly
* This script simulates the command generation with various GHDL options enabled.
*/
const fs = require('fs');
const path = require('path');
// Mock GHDL configuration with many options enabled
const mockGhdlConfig = {
installation_path: "",
vhdl_standard: "vhdl08",
ieee_library: "standard",
relaxed_parsing: false,
unicode_support: true,
psl_enabled: true,
work_library: "work",
library_paths: ["/usr/lib/ghdl", "/opt/ghdl/lib"],
optimization_level: "O2",
parallel_jobs: 4,
debug_level: "full",
verbose: true,
warnings_as_errors: false,
suppress_warnings: ["binding", "elaboration"],
relaxed_rules: true,
bind_checks: true,
vital_checks: false,
assert_level: "warning",
coverage_enabled: true,
coverage_options: ["--coverage-file=coverage.out"],
simulation_time: "1ms",
resolution_limit: "1ps",
stack_size: "16MB",
max_delta_cycles: 10000,
stop_delta_cycles: 5000,
display_time: 1000,
unbuffered_output: true,
max_stack_alloc: "1MB",
backtrace_severity: "warning",
ieee_asserts: "disable-at-0",
asserts_policy: "enable",
sdf_file: "timing.sdf",
vpi_modules: ["vpi_debug", "vpi_trace"],
vhpi_modules: ["vhpi_monitor"],
stmt_coverage: true,
branch_coverage: true,
toggle_coverage: false,
dump_file: "signals.dump",
trace_signals: true,
trace_processes: false,
wave_start_time: "10ns",
vcd_4states: true,
expect_failure: false,
no_run: false,
waveform_enabled: true,
waveform_format: "vcd",
waveform_options: ["--vcd-4states"],
generate_makefile: false,
analyze_options: ["--warn-unused"],
elaborate_options: ["--warn-binding"],
run_options: ["--trace-processes"],
synthesis_options: [],
extra_flags: ["--custom-flag"]
};
// Simulate the buildGhdlArgs function (simplified version)
function buildGhdlArgs(config, commandType) {
const baseArgs = [];
const runArgs = [];
// Add verbose flag
if (config.verbose) {
baseArgs.push('-v');
}
// Add VHDL standard
const standardMap = {
'vhdl87': '87',
'vhdl93': '93',
'vhdl02': '02',
'vhdl08': '08',
'vhdl19': '19'
};
const standardValue = standardMap[config.vhdl_standard] || '08';
baseArgs.push(`--std=${standardValue}`);
// Add optimization level
if (config.optimization_level && config.optimization_level !== 'O0') {
baseArgs.push(`-${config.optimization_level}`);
}
// Add debug level
if (config.debug_level) {
switch (config.debug_level) {
case 'minimal':
baseArgs.push('-g');
break;
case 'full':
baseArgs.push('-g', '--debug');
break;
}
}
// Add library configuration
if (config.ieee_library !== 'standard') {
baseArgs.push(`--ieee=${config.ieee_library}`);
}
// Add library paths
if (config.library_paths && config.library_paths.length > 0) {
config.library_paths.forEach(path => {
baseArgs.push(`-P${path}`);
});
}
// Add assertion level
if (config.assert_level && config.assert_level !== 'error') {
if (config.assert_level === 'none') {
baseArgs.push('--assert-level=none');
} else {
baseArgs.push(`--assert-level=${config.assert_level}`);
}
}
// Add various flags
if (config.relaxed_rules) baseArgs.push('--mb-comments');
if (config.relaxed_parsing) baseArgs.push('--relaxed');
if (config.psl_enabled) baseArgs.push('--psl');
if (config.unicode_support) baseArgs.push('--unicode');
if (!config.bind_checks) baseArgs.push('--no-bind-checks');
if (config.vital_checks) baseArgs.push('--vital-checks');
if (config.warnings_as_errors) baseArgs.push('-Werror');
// Add warning suppressions
if (config.suppress_warnings && config.suppress_warnings.length > 0) {
config.suppress_warnings.forEach(warning => {
baseArgs.push(`-Wno-${warning}`);
});
}
// Add time resolution
if (config.resolution_limit && config.resolution_limit.trim() !== '') {
baseArgs.push(`--time-resolution=${config.resolution_limit}`);
}
// Command-specific options
switch (commandType) {
case 'analyze':
if (config.coverage_enabled && config.coverage_options.length > 0) {
baseArgs.push('--coverage');
baseArgs.push(...config.coverage_options);
}
baseArgs.push(...config.analyze_options);
break;
case 'elaborate':
baseArgs.push(...config.elaborate_options);
break;
case 'run':
// Simulation runtime options (after entity name)
if (config.waveform_enabled && config.waveform_format) {
const waveformFile = `wave.${config.waveform_format}`;
runArgs.push(`--${config.waveform_format}=${waveformFile}`);
}
if (config.waveform_options && config.waveform_options.length > 0) {
runArgs.push(...config.waveform_options);
}
if (config.simulation_time && config.simulation_time.trim() !== '') {
runArgs.push(`--stop-time=${config.simulation_time}`);
}
if (config.stack_size && config.stack_size.trim() !== '') {
runArgs.push(`--stack-size=${config.stack_size}`);
}
if (config.max_delta_cycles > 0) {
runArgs.push(`--max-delta=${config.max_delta_cycles}`);
}
if (config.stop_delta_cycles > 0) {
runArgs.push(`--stop-delta=${config.stop_delta_cycles}`);
}
if (config.display_time > 0) {
runArgs.push(`--disp-time=${config.display_time}`);
}
if (config.unbuffered_output) {
runArgs.push('--unbuffered');
}
if (config.max_stack_alloc && config.max_stack_alloc.trim() !== '') {
runArgs.push(`--max-stack-alloc=${config.max_stack_alloc}`);
}
if (config.backtrace_severity && config.backtrace_severity !== 'error') {
if (config.backtrace_severity === 'none') {
runArgs.push('--backtrace-severity=none');
} else {
runArgs.push(`--backtrace-severity=${config.backtrace_severity}`);
}
}
if (config.ieee_asserts && config.ieee_asserts !== 'enable') {
runArgs.push(`--ieee-asserts=${config.ieee_asserts}`);
}
if (config.asserts_policy && config.asserts_policy !== 'enable') {
runArgs.push(`--asserts=${config.asserts_policy}`);
}
if (config.sdf_file && config.sdf_file.trim() !== '') {
runArgs.push(`--sdf=${config.sdf_file}`);
}
if (config.vpi_modules && config.vpi_modules.length > 0) {
config.vpi_modules.forEach(module => {
runArgs.push(`--vpi=${module}`);
});
}
if (config.vhpi_modules && config.vhpi_modules.length > 0) {
config.vhpi_modules.forEach(module => {
runArgs.push(`--vhpi=${module}`);
});
}
if (config.stmt_coverage || config.branch_coverage || config.toggle_coverage) {
runArgs.push('--coverage');
}
if (config.dump_file && config.dump_file.trim() !== '') {
runArgs.push(`--dump=${config.dump_file}`);
}
if (config.trace_signals) {
runArgs.push('--trace-signals');
}
if (config.trace_processes) {
runArgs.push('--trace-processes');
}
if (config.wave_start_time && config.wave_start_time.trim() !== '') {
runArgs.push(`--wave-start-time=${config.wave_start_time}`);
}
if (config.vcd_4states && config.waveform_format === 'vcd') {
runArgs.push('--vcd-4states');
}
if (config.expect_failure) {
runArgs.push('--expect-failure');
}
if (config.no_run) {
runArgs.push('--no-run');
}
runArgs.push(...config.run_options);
break;
}
// Add extra flags
if (config.extra_flags && config.extra_flags.length > 0) {
baseArgs.push(...config.extra_flags);
}
return { baseArgs, runArgs };
}
// Test different command types
console.log('GHDL Expanded Configuration Test');
console.log('=================================\n');
console.log('Testing ANALYZE command:');
const analyzeResult = buildGhdlArgs(mockGhdlConfig, 'analyze');
console.log('Base Args:', analyzeResult.baseArgs.join(' '));
console.log('Run Args:', analyzeResult.runArgs.join(' '));
console.log('Full Command: ghdl -a', analyzeResult.baseArgs.join(' '), '--work=work test.vhdl\n');
console.log('Testing ELABORATE command:');
const elaborateResult = buildGhdlArgs(mockGhdlConfig, 'elaborate');
console.log('Base Args:', elaborateResult.baseArgs.join(' '));
console.log('Run Args:', elaborateResult.runArgs.join(' '));
console.log('Full Command: ghdl -e', elaborateResult.baseArgs.join(' '), 'test_entity\n');
console.log('Testing RUN command:');
const runResult = buildGhdlArgs(mockGhdlConfig, 'run');
console.log('Base Args:', runResult.baseArgs.join(' '));
console.log('Run Args:', runResult.runArgs.join(' '));
console.log('Full Command: ghdl -r', runResult.baseArgs.join(' '), 'test_entity', runResult.runArgs.join(' '), '\n');
console.log('Summary of supported GHDL options:');
console.log('- VHDL standards: 87, 93, 02, 08, 19');
console.log('- IEEE library variants: standard, synopsys');
console.log('- Debug levels: none, minimal, full');
console.log('- Optimization levels: O0, O1, O2, O3');
console.log('- Assert levels: note, warning, error, failure, none');
console.log('- Waveform formats: VCD, GHW, FST');
console.log('- Backtrace severities: note, warning, error, failure, none');
console.log('- IEEE assertions: enable, disable, disable-at-0');
console.log('- Coverage options: statement, branch, toggle');
console.log('- Signal tracing and dumping options');
console.log('- VPI/VHPI module support');
console.log('- SDF timing annotation support');
console.log('- Advanced simulation control options');
console.log('\nAll GHDL runtime simulation options are now supported!');