vcd_signal_dumper.c 19.9 KB
Newer Older
1
/*******************************************************************************
nikaeinn's avatar
nikaeinn committed
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
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
    included in this distribution in the file called "COPYING". If not,
    see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr

  Address      : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.

*******************************************************************************/
29
30
31
32

/*! \file vcd_signal_dumper.c
 * \brief Dump functions calls and variables to VCD file. Use GTKWave to display this file.
 * \author S. Roux
nikaeinn's avatar
nikaeinn committed
33
34
 * \maintainer: navid nikaein
 * \date 2012 - 2104 
35
36
 * \version 0.1
 * \company Eurecom
nikaeinn's avatar
nikaeinn committed
37
 * \email: navid.nikaein@eurecom.fr
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 * \note
 * \warning
 */

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <error.h>
#include <time.h>
#include <unistd.h>

54
#include "assertions.h"
55
#include "signals.h"
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

#include "vcd_signal_dumper.h"

#if defined(ENABLE_RTAI_CLOCK)
#include "rtai_lxrt.h"
#endif

#define VCDSIGNALDUMPER_VERSION_MAJOR 0
#define VCDSIGNALDUMPER_VERSION_MINOR 1

// Global variable. If the VCD option is set at execution time, output VCD trace. Otherwise this module has no effect.
int ouput_vcd = 0;

struct vcd_module_s {
    const char     *name;
    int             number_of_signals;
    const char    **signals_names;
    vcd_signal_type signal_type;
    int             signal_size;
} vcd_module_s;
 
const char* eurecomVariablesNames[] = {
78
79
80
81
    "frame_number_eNB",
    "slot_number_eNB",
    "frame_number_UE",
    "slot_number_UE",
82
    "daq_mbox",
83
    "diff2",
knopp's avatar
   
knopp committed
84
85
    "hw_subframe",
    "hw_frame",
86
87
88
    "itti_send_msg",
    "itti_poll_msg",
    "itti_recv_msg",
89
90
91
    "itti_alloc_msg",
    "mp_alloc",
    "mp_free",
92
93
94
};
 
const char* eurecomFunctionsNames[] = {
95
96
97
98
  /*  softmodem signals   */  
    "rt_sleep",
    "trx_read",
    "trx_write",
knopp's avatar
   
knopp committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
    "eNB_thread_tx0",
    "eNB_thread_rx0",
    "eNB_thread_tx1",
    "eNB_thread_rx1",
    "eNB_thread_tx2",
    "eNB_thread_rx2",
    "eNB_thread_tx3",
    "eNB_thread_rx3",
    "eNB_thread_tx4",
    "eNB_thread_rx4",
    "eNB_thread_tx5",
    "eNB_thread_rx5",
    "eNB_thread_tx6",
    "eNB_thread_rx6",
    "eNB_thread_tx7",
    "eNB_thread_rx7",
    "eNB_thread_tx8",
    "eNB_thread_rx8",
    "eNB_thread_tx9",
    "eNB_thread_rx9",
119
120
121
122
123
124
125
126
127
128
129
    
    /* PHY signals  */
    "lte_ue_measurement_procedures",
    "lte_ue_pdcch_procedures",
    "lte_ue_pbch_procedures",
    "phy_procedures_eNb_tx",
    "phy_procedures_eNb_rx",
    "phy_procedures_ue_tx",
    "phy_procedures_ue_rx",
    "phy_procedures_eNB_lte",
    "phy_procedures_UE_lte",
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
    "pdsch_thread",
    "dlsch_thread0",
    "dlsch_thread1",
    "dlsch_thread2",
    "dlsch_thread3",
    "dlsch_thread4",
    "dlsch_thread5",
    "dlsch_thread6",
    "dlsch_thread7",
    "dlsch_decoding0",
    "dlsch_decoding1",
    "dlsch_decoding2",
    "dlsch_decoding3",
    "dlsch_decoding4",
    "dlsch_decoding5",
    "dlsch_decoding6",
    "dlsch_decoding7",
    "rx_pdcch",
148
149
150
151
152
    "dci_decoding",  
    "phy_ue_config_sib2", 
    "macxface_phy_config_sib1_eNB",
    "macxface_phy_config_sib2_eNB",
    "macxface_phy_config_dedicated_eNB",
153
154
    "phy_ue_compute_prach",
    "phy_enb_ulsch_decoding",
knopp's avatar
knopp committed
155
156
157
158
    "phy_enb_sfgen",
    "phy_enb_prach_rx",
    "phy_enb_pdcch_tx",
    "phy_enb_rs_tx",
159
160
    "phy_ue_ulsch_modulation",
    "phy_ue_ulsch_encoding",
knopp's avatar
knopp committed
161
    "phy_ue_ulsch_scrambling",
162
163
    "phy_eNB_dlsch_modulation",
    "phy_eNB_dlsch_encoding",
knopp's avatar
   
knopp committed
164
    "phy_eNB_dlsch_scrambling",
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
   
    /* MAC  signals  */
    "macxface_macphy_init",
    "macxface_macphy_exit",
    "macxface_eNB_dlsch_ulsch_scheduler",
    "macxface_fill_rar",
    "macxface_terminate_ra_proc",
    "macxface_initiate_ra_proc",
    "macxface_cancel_ra_proc",
    "macxface_get_dci_sdu",
    "macxface_get_dlsch_sdu",
    "macxface_rx_sdu",
    "macxface_mrbch_phy_sync_failure",
    "macxface_SR_indication",
    "mac_dlsch_preprocessor",
    "mac_schedule_dlsch",
    "mac_fill_dlsch_dci",
    "macxface_out_of_sync_ind",
    "macxface_ue_decode_si",
    "macxface_ue_decode_ccch",
    "macxface_ue_decode_bcch",
    "macxface_ue_send_sdu",
    "macxface_ue_get_sdu",
    "macxface_ue_get_rach",
    "macxface_ue_process_rar",
    "macxface_ue_scheduler",
    "macxface_ue_get_sr",
    
    "ue_send_mch_sdu",

    /*RLC signals   */
    "rlc_data_req",
    // "rlc_data_ind", // this calls "pdcp_data_ind",
    "mac_rlc_status_ind",
    "mac_rlc_data_req",
    "mac_rlc_data_ind",
    /* PDCP signals   */
    "pdcp_run",
    "pdcp_data_req",
    "pdcp_data_ind",
Cedric Roux's avatar
Cedric Roux committed
205
206
    "pdcp_apply_security",
    "pdcp_validate_security",
207
208
209
210
211
212
213
214
    /* RRC signals  */
    "rrc_mac_config_req",
    "rrc_ue_decode_sib1",
    "rrc_ue_decode_si",
    
    /* MISC signals  */
    "emu_transport",
    "log_record",
winckel's avatar
winckel committed
215
    "itti_enqueue_message",
216
    "itti_dump_enqueue_message",
217
    "itti_dump_enqueue_message_malloc",
218
    "itti_relay_thread",
219
220
221
222
    "test"
};

struct vcd_module_s vcd_modules[VCD_SIGNAL_DUMPER_MODULE_END] = {
winckel's avatar
winckel committed
223
    { "variables", VCD_SIGNAL_DUMPER_VARIABLES_END, eurecomVariablesNames, VCD_WIRE, 64 },
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    { "functions", VCD_SIGNAL_DUMPER_FUNCTIONS_END, eurecomFunctionsNames, VCD_WIRE, 1 },
//    { "ue_procedures_functions", VCD_SIGNAL_DUMPER_UE_PROCEDURES_FUNCTIONS_END, eurecomUEFunctionsNames, VCD_WIRE, 1 },
};

FILE *vcd_fd = NULL;
static inline unsigned long long int vcd_get_time(void);

#if defined(ENABLE_USE_CPU_EXECUTION_TIME)
struct timespec     g_time_start;
#elif defined(ENABLE_RTAI_CLOCK)
RTIME start;
#endif


#if defined(ENABLE_VCD_FIFO)

240
241
242
243
# define VCD_POLL_DELAY         (500)           // Poll delay in micro-seconds
# define VCD_MAX_WAIT_DELAY     (200 * 1000)    // Maximum data ready wait delay in micro-seconds
# define VCD_FIFO_NB_ELEMENTS   (1 << 20)       // Must be a power of 2
# define VCD_FIFO_MASK          (VCD_FIFO_NB_ELEMENTS - 1)
244

245
typedef struct vcd_queue_user_data_s {
246
247
    uint32_t log_id;
    vcd_signal_dumper_modules module;
248
249
    union data_u {
        struct function_s {
250
251
252
            vcd_signal_dump_functions function_name;
            vcd_signal_dump_in_out    in_out;
        } function;
253
        struct variable_s {
254
255
256
257
258
259
260
261
            vcd_signal_dump_variables variable_name;
            unsigned long value;
        } variable;
    } data;

    long long unsigned int time;
} vcd_queue_user_data_t;

262
263
264
265
266
267
268
269
270
typedef struct vcd_fifo_s {
    vcd_queue_user_data_t user_data[VCD_FIFO_NB_ELEMENTS];

    volatile uint32_t write_index;
    volatile uint32_t read_index;
} vcd_fifo_t;

vcd_fifo_t vcd_fifo;

271
pthread_t vcd_dumper_thread;
272
#endif
273

winckel's avatar
winckel committed
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#define BYTE_SIZE   8
#define NIBBLE_SIZE 4
static void uint64_to_binary(uint64_t value, char *binary)
{
    static const char * const nibbles_start[] =
            {
                 "",    "1",   "10",   "11",
              "100",  "101",  "110",  "111",
             "1000", "1001", "1010", "1011",
             "1100", "1101", "1110", "1111",
            };
    static const char * const nibbles[] =
            {
             "0000", "0001", "0010", "0011",
             "0100", "0101", "0110", "0111",
             "1000", "1001", "1010", "1011",
             "1100", "1101", "1110", "1111",
            };
    int nibble;
    int nibble_value;
    int nibble_size;
    int zero = 1;

    for (nibble = 0; nibble < (sizeof (uint64_t) * (BYTE_SIZE / NIBBLE_SIZE)); nibble++)
    {
        nibble_value = value >> ((sizeof (uint64_t) * BYTE_SIZE) - NIBBLE_SIZE);

        if (zero)
        {
            if (nibble_value > 0)
            {
                zero = 0;
                nibble_size = strlen(nibbles_start[nibble_value]);
                memcpy (binary, nibbles_start[nibble_value], nibble_size);
                binary += nibble_size;
            }
        }
        else
        {
            memcpy (binary, nibbles[nibble_value], NIBBLE_SIZE);
            binary += NIBBLE_SIZE;
        }
        value <<= NIBBLE_SIZE;
    }
    /* Add a '0' if the value was null */
    if (zero)
    {
        binary[0] = '0';
        binary ++;
    }
    /* Add a null value at the end of the string */
    binary[0] = '\0';
}

328
#if defined(ENABLE_VCD_FIFO)
329
330
331
332
333
334
335
336
337
338
inline static uint32_t vcd_get_write_index(void)
{
    uint32_t write_index;
    uint32_t read_index;

    /* Get current write index and increment it (atomic operation) */
    write_index = __sync_fetch_and_add(&vcd_fifo.write_index, 1);
    /* Wrap index */
    write_index &= VCD_FIFO_MASK;

339
340
    /* Check FIFO overflow (increase VCD_FIFO_NB_ELEMENTS if this assert is triggered) */
    DevCheck((read_index = vcd_fifo.read_index, ((write_index + 1) & VCD_FIFO_MASK) != read_index), write_index, read_index, VCD_FIFO_NB_ELEMENTS);
341
342
343
344

    return write_index;
}

345
346
347
void *vcd_dumper_thread_rt(void *args)
{
    vcd_queue_user_data_t *data;
winckel's avatar
winckel committed
348
    char binary_string[(sizeof (uint64_t) * BYTE_SIZE) + 1];
349
    struct sched_param sched_param;
350
    uint32_t data_ready_wait;
winckel's avatar
winckel committed
351

352
353
354
355
# if defined(ENABLE_ITTI)
    signal_mask();
# endif

356
357
358
    sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 1;
    sched_setscheduler(0, SCHED_FIFO, &sched_param);

359
    while(1) {
360
        if (vcd_fifo.read_index == (vcd_fifo.write_index & VCD_FIFO_MASK)) {
361
            /* No element -> sleep a while */
362
            usleep(VCD_POLL_DELAY);
363
        } else {
364
365
366
367
            data = &vcd_fifo.user_data[vcd_fifo.read_index];
            data_ready_wait = 0;
            while (data->module == VCD_SIGNAL_DUMPER_MODULE_FREE)
            {
368
                /* Check wait delay (increase VCD_MAX_WAIT_DELAY if this assert is triggered and that no thread is locked) */
369
370
371
372
373
374
                DevCheck(data_ready_wait < VCD_MAX_WAIT_DELAY, data_ready_wait, VCD_MAX_WAIT_DELAY, 0);

                /* data is not yet ready, wait for it to be completed */
                data_ready_wait += VCD_POLL_DELAY;
                usleep(VCD_POLL_DELAY);
            }
375
376
377
378
379
380
381
382
            switch (data->module) {
                case VCD_SIGNAL_DUMPER_MODULE_VARIABLES:
                    if (vcd_fd != NULL)
                    {
                        int variable_name;
                        variable_name = (int)data->data.variable.variable_name;
                        fprintf(vcd_fd, "#%llu\n", data->time);
                        /* Set variable to value */
winckel's avatar
winckel committed
383
384
                        uint64_to_binary(data->data.variable.value, binary_string);
                        fprintf(vcd_fd, "b%s %s_w\n", binary_string,
385
386
387
                                eurecomVariablesNames[variable_name]);
                    }
                    break;
388

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
                case VCD_SIGNAL_DUMPER_MODULE_FUNCTIONS:
                    if (vcd_fd != NULL)
                    {
                        int function_name;

                        function_name = (int)data->data.function.function_name;
                        fprintf(vcd_fd, "#%llu\n", data->time);

                        /* Check if we are entering or leaving the function ( 0 = leaving, 1 = entering) */
                        if (data->data.function.in_out == VCD_FUNCTION_IN)
                            /* Set event to 1 */
                            fprintf(vcd_fd, "1%s_w\n", eurecomFunctionsNames[function_name]);
                        else
                            fprintf(vcd_fd, "0%s_w\n", eurecomFunctionsNames[function_name]);
                        fflush(vcd_fd);
                    }
                    break;
406

407
                default:
408
                    DevParam(data->module, 0, 0);
409
410
                    break;
            }
411
412
            data->module = VCD_SIGNAL_DUMPER_MODULE_FREE;
            vcd_fifo.read_index = (vcd_fifo.read_index + 1) & VCD_FIFO_MASK;
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
        }
    }
    return NULL;
}
#endif

void vcd_signal_dumper_init(char *filename)
{
    if (ouput_vcd) {
      //        char filename[] = "/tmp/openair_vcd_dump.vcd";

        if ((vcd_fd = fopen(filename, "w+")) == NULL)
        {
            perror("vcd_signal_dumper_init: cannot open file");
            return;
        }

#if defined(ENABLE_USE_CPU_EXECUTION_TIME)
        clock_gettime(CLOCK_MONOTONIC, &g_time_start);
#elif defined(ENABLE_RTAI_CLOCK)
        start=rt_get_time_ns();
#endif

        vcd_signal_dumper_create_header();

#if defined(ENABLE_VCD_FIFO)
439
440
        vcd_fifo.write_index = 0;
        vcd_fifo.read_index = 0;
441

442
        fprintf(stderr, "[VCD] Creating dumper thread\n");
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554

        if (pthread_create(&vcd_dumper_thread, NULL, vcd_dumper_thread_rt, NULL) < 0)
        {
            fprintf(stderr, "vcd_signal_dumper_init: Failed to create thread: %s\n",
                    strerror(errno));
            ouput_vcd = 0;
            return;
        }
#endif
    }
}

void vcd_signal_dumper_close(void)
{
    if (ouput_vcd) {
#if defined(ENABLE_VCD_FIFO)
        
#else
        if (vcd_fd != NULL)
        {
            fclose(vcd_fd);
            vcd_fd = NULL;
        }
#endif
    }
}

static inline void vcd_signal_dumper_print_time_since_start(void)
{
    if (vcd_fd != NULL)
    {
#if defined(ENABLE_USE_CPU_EXECUTION_TIME)
        struct timespec time;
        long long unsigned int nanosecondsSinceStart;
        long long unsigned int secondsSinceStart;

        clock_gettime(CLOCK_MONOTONIC, &time);

        /* Get current execution time in nanoseconds */
        nanosecondsSinceStart = (long long unsigned int)((time.tv_nsec - g_time_start.tv_nsec));
        secondsSinceStart     = (long long unsigned int)time.tv_sec - (long long unsigned int)g_time_start.tv_sec;
        /* Write time in nanoseconds */
        fprintf(vcd_fd, "#%llu\n", nanosecondsSinceStart + (secondsSinceStart * 1000000000UL));
#elif defined(ENABLE_RTAI_CLOCK)
        /* Write time in nanoseconds */
        fprintf(vcd_fd, "#%llu\n",rt_get_time_ns()-start);
#endif
    }
}

static inline unsigned long long int vcd_get_time(void)
{
#if defined(ENABLE_USE_CPU_EXECUTION_TIME)
    struct timespec time;

    clock_gettime(CLOCK_MONOTONIC, &time);

    return (long long unsigned int)((time.tv_nsec - g_time_start.tv_nsec)) +
    ((long long unsigned int)time.tv_sec - (long long unsigned int)g_time_start.tv_sec) * 1000000000UL;
#elif defined(ENABLE_RTAI_CLOCK)
    return rt_get_time_ns() - start;
#endif
}

void vcd_signal_dumper_create_header(void)
{
    if (ouput_vcd) {
        struct tm *pDate;
        time_t intps;

        intps = time(NULL);
        pDate = localtime(&intps);

        if (vcd_fd != NULL)
        {
            int i, j;
            fprintf(vcd_fd, "$date\n\t%s$end\n", asctime(pDate));
            // Display version
            fprintf(vcd_fd, "$version\n\tVCD plugin ver%d.%d\n$end\n", VCDSIGNALDUMPER_VERSION_MAJOR, VCDSIGNALDUMPER_VERSION_MINOR);
            // Init timescale, here = 1ns
            fprintf(vcd_fd, "$timescale 1 ns $end\n");

            /* Initialize each module definition */
            for(i = 0; i < VCD_SIGNAL_DUMPER_MODULE_END; i++) {
                struct vcd_module_s *module;
                module = &vcd_modules[i];
                fprintf(vcd_fd, "$scope module %s $end\n", module->name);
                /* Declare each signal as defined in array */
                for (j = 0; j < module->number_of_signals; j++) {
                    const char *signal_name;
                    signal_name = module->signals_names[j];
                    if (VCD_WIRE == module->signal_type) {
                        fprintf(vcd_fd, "$var wire %d %s_w %s $end\n", module->signal_size, signal_name, signal_name);
                    } else  if (VCD_REAL == module->signal_type) {
                        fprintf(vcd_fd, "$var real %d %s_r %s $end\n", module->signal_size, signal_name, signal_name);
                    } else {
                        // Handle error here
                    }
                }
                fprintf(vcd_fd, "$upscope $end\n");
            }

            /* Init variables and functions to 0 */
            fprintf(vcd_fd, "$dumpvars\n");
            for(i = 0; i < VCD_SIGNAL_DUMPER_MODULE_END; i++) {
                struct vcd_module_s *module;
                module = &vcd_modules[i];
                /* Declare each signal as defined in array */
                for (j = 0; j < module->number_of_signals; j++) {
                    const char *signal_name;
                    signal_name = module->signals_names[j];
                    if (VCD_WIRE == module->signal_type) {
winckel's avatar
winckel committed
555
556
557
558
559
560
                        if (module->signal_size > 1) {
                            fprintf(vcd_fd, "b0 %s_w $end\n", signal_name);
                        }
                        else {
                            fprintf(vcd_fd, "0%s_w $end\n", signal_name);
                        }
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
                    } else  if (VCD_REAL == module->signal_type) {
                        fprintf(vcd_fd, "r0 %s_r $end\n", signal_name);
                    } else {
                        // Handle error here
                    }
                }
            }
            fprintf(vcd_fd, "$end\n");
            fprintf(vcd_fd, "$enddefinitions $end\n\n");
            //fflush(vcd_fd);
        }
    }
}

void vcd_signal_dumper_dump_variable_by_name(vcd_signal_dump_variables variable_name,
                                             unsigned long             value)
{
winckel's avatar
winckel committed
578
579
580
    DevCheck((0 <= variable_name) && (variable_name < VCD_SIGNAL_DUMPER_VARIABLES_END),
             variable_name, VCD_SIGNAL_DUMPER_VARIABLES_END, 0);

581
582
    if (ouput_vcd) {
#if defined(ENABLE_VCD_FIFO)
583
        uint32_t write_index = vcd_get_write_index();
584

585
586
587
588
        vcd_fifo.user_data[write_index].time = vcd_get_time();
        vcd_fifo.user_data[write_index].data.variable.variable_name = variable_name;
        vcd_fifo.user_data[write_index].data.variable.value = value;
        vcd_fifo.user_data[write_index].module = VCD_SIGNAL_DUMPER_MODULE_VARIABLES; // Set when all other fields are set to validate the user_data
589
#else
winckel's avatar
winckel committed
590
591
        char binary_string[(sizeof (uint64_t) * BYTE_SIZE) + 1];

592
593
594
595
596
        if (vcd_fd != NULL)
        {
            vcd_signal_dumper_print_time_since_start();

            /* Set variable to value */
winckel's avatar
winckel committed
597
598
            uint64_to_binary(value, binary_string);
            fprintf(vcd_fd, "b%s %s_w\n", binary_string, eurecomVariablesNames[variable_name]);
599
600
601
602
603
604
605
606
607
            //fflush(vcd_fd);
        }
#endif
    }
}

void vcd_signal_dumper_dump_function_by_name(vcd_signal_dump_functions  function_name,
                                             vcd_signal_dump_in_out     in_out)
{
winckel's avatar
winckel committed
608
609
610
    DevCheck((0 <= function_name) && (function_name < VCD_SIGNAL_DUMPER_FUNCTIONS_END),
             function_name, VCD_SIGNAL_DUMPER_FUNCTIONS_END, 0);

611
612
    if (ouput_vcd) {
#if defined(ENABLE_VCD_FIFO)
613
        uint32_t write_index = vcd_get_write_index();
614

615
616
617
618
        vcd_fifo.user_data[write_index].time = vcd_get_time();
        vcd_fifo.user_data[write_index].data.function.function_name = function_name;
        vcd_fifo.user_data[write_index].data.function.in_out = in_out;
        vcd_fifo.user_data[write_index].module = VCD_SIGNAL_DUMPER_MODULE_FUNCTIONS; // Set when all other fields are set to validate the user_data
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
#else
        if (vcd_fd != NULL)
        {
            vcd_signal_dumper_print_time_since_start();

            /* Check if we are entering or leaving the function ( 0 = leaving, 1 = entering) */
            if (in_out == VCD_FUNCTION_IN)
                /* Set event to 1 */
                fprintf(vcd_fd, "1%s_w\n", eurecomFunctionsNames[function_name]);
            else
                fprintf(vcd_fd, "0%s_w\n", eurecomFunctionsNames[function_name]);
            //fflush(vcd_fd);
        }
#endif
    }
}