SimAVR
AVR Simulator
sim_vcd_file.h
Go to the documentation of this file.
1 /*
2  * sim_vcd_file.c
3  *
4  * Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5  *
6  * This file is part of simavr.
7  *
8  * simavr is free software: you can redistribute it and/or modify it under the terms of the GNU
9  * General Public License as published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * simavr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with simavr. If not, see
17  * <http://www.gnu.org/licenses/>.
18  */
19 
29 #ifndef __SIM_VCD_FILE_H__
30 #define __SIM_VCD_FILE_H__
31 
32 #include <stdio.h>
33 #include "sim_irq.h"
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 #define AVR_VCD_MAX_SIGNALS 32
41 
44  typedef struct avr_vcd_signal_t
45  {
47  char alias;
48  int size;
49  char name[32];
51 
52  typedef struct avr_vcd_log_t
53  {
54  uint64_t when;
56  uint32_t value;
58 
59 #define AVR_VCD_LOG_CHUNK_SIZE (4096 / sizeof(avr_vcd_signal_t))
60 
61  typedef struct avr_vcd_t
62  {
63  struct avr_t *avr;
64 
65  char filename[74];
66  FILE *output;
67 
70 
71  uint64_t period;
72  uint64_t start;
73 
74  size_t logsize;
75  uint32_t logindex;
76  avr_vcd_log_p log;
77  } avr_vcd_t;
78 
80  int avr_vcd_init (struct avr_t *avr, const char *filename, // filename to write
81  avr_vcd_t * vcd, // vcd struct to initialize
82  uint32_t period); // file flushing period is in usec
84  void avr_vcd_close (avr_vcd_t * vcd);
85 
88  int avr_vcd_add_signal (avr_vcd_t * vcd, avr_irq_t * signal_irq, int signal_bit_size, const char *name);
89 
91  int avr_vcd_start (avr_vcd_t * vcd);
93  int avr_vcd_stop (avr_vcd_t * vcd);
94 
95 #ifdef __cplusplus
96 };
97 #endif
98 
99 #endif /* __SIM_VCD_FILE_H__ */
100 
struct avr_vcd_log_t avr_vcd_log_t
char name[32]
full human name
Definition: sim_vcd_file.h:49
avr_irq_t irq
receiving IRQ
Definition: sim_vcd_file.h:46
struct avr_t * avr
AVR we are attaching timers to.
Definition: sim_vcd_file.h:63
avr_vcd_signal_t * signal
Definition: sim_vcd_file.h:55
void avr_vcd_close(avr_vcd_t *vcd)
Close a vcd file.
Definition: sim_vcd_file.c:48
struct avr_vcd_signal_t avr_vcd_signal_t
This structure registers IRQ change hooks to various "source" IRQs and dumps their values (if changed...
int signal_count
Definition: sim_vcd_file.h:68
size_t logsize
Definition: sim_vcd_file.h:74
uint64_t period
Definition: sim_vcd_file.h:71
char alias
vcd one character alias
Definition: sim_vcd_file.h:47
avr_t * avr
Definition: run_avr.c:54
Definition: sim_vcd_file.h:52
int avr_vcd_start(avr_vcd_t *vcd)
Starts recording the signal value into the file.
Definition: sim_vcd_file.c:199
int size
in bits
Definition: sim_vcd_file.h:48
uint32_t value
Definition: sim_vcd_file.h:56
avr_vcd_signal_t signal[AVR_VCD_MAX_SIGNALS]
Definition: sim_vcd_file.h:69
uint64_t start
Definition: sim_vcd_file.h:72
struct avr_vcd_t avr_vcd_t
int avr_vcd_add_signal(avr_vcd_t *vcd, avr_irq_t *signal_irq, int signal_bit_size, const char *name)
Add a trace signal to the vcd file.
Definition: sim_vcd_file.c:171
#define AVR_VCD_MAX_SIGNALS
Definition: sim_vcd_file.h:40
uint32_t logindex
Definition: sim_vcd_file.h:75
This structure registers IRQ change hooks to various "source" IRQs and dumps their values (if changed...
Definition: sim_vcd_file.h:44
avr_vcd_log_p log
Definition: sim_vcd_file.h:76
struct avr_vcd_log_t * avr_vcd_log_p
struct avr_vcd_t * vcd
Value Change Dump file (waveforms) This is the VCD file that gets allocated if the firmware that is l...
Definition: sim_avr.h:285
Main AVR instance.
Definition: sim_avr.h:142
int avr_vcd_stop(avr_vcd_t *vcd)
Stops recording signal values into the file.
Definition: sim_vcd_file.c:238
Public IRQ structure.
Definition: sim_irq.h:76
int avr_vcd_init(struct avr_t *avr, const char *filename, avr_vcd_t *vcd, uint32_t period)
Initializes a new VCD trace file, and returns zero if all is well.
Definition: sim_vcd_file.c:35
uint64_t when
Definition: sim_vcd_file.h:54
FILE * output
Definition: sim_vcd_file.h:66
Definition: sim_vcd_file.h:61
char filename[74]
output filename
Definition: sim_vcd_file.h:65