From e6eb938344d6dd74bd7bdde5e8d17c468898b433 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Tue, 7 Mar 2017 18:41:37 +0000 Subject: [PATCH] vcd: Added 'floating' support Also, fixed a bug int he input file reading code. Signed-off-by: Michel Pollet --- simavr/sim/sim_vcd_file.c | 23 ++++++++++++++++------- simavr/sim/sim_vcd_file.h | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/simavr/sim/sim_vcd_file.c b/simavr/sim/sim_vcd_file.c index 18ae4b1..10dc273 100644 --- a/simavr/sim/sim_vcd_file.c +++ b/simavr/sim/sim_vcd_file.c @@ -134,8 +134,10 @@ avr_vcd_input_parse_line( avr_vcd_log_t e = { .when = vcd->period, .sigindex = sigindex, + .floating = !!floating, .value = val, }; + // printf("%10u %d\n", e.when, e.value); avr_vcd_fifo_write(&vcd->log, e); } return res; @@ -151,13 +153,15 @@ avr_vcd_input_read( { char line[1024]; - while (fgets(line, sizeof(line), vcd->input) && - avr_vcd_fifo_get_read_size(&vcd->log) < 128) { + while (fgets(line, sizeof(line), vcd->input)) { + // printf("%s", line); if (!line[0]) // technically can't happen, but make sure next line works continue; vcd->input_line = argv_parse(vcd->input_line, line); - /* stop once we found a new timestamp */ avr_vcd_input_parse_line(vcd, vcd->input_line); + /* stop once the fifo is full enough */ + if (avr_vcd_fifo_get_read_size(&vcd->log) >= 128) + break; } return avr_vcd_fifo_isempty(&vcd->log); } @@ -196,7 +200,7 @@ _avr_vcd_input_timer( // we already have it avr_vcd_fifo_read_offset(&vcd->log, 1); avr_vcd_signal_p signal = &vcd->signal[log.sigindex]; - avr_raise_irq(&signal->irq, log.value); + avr_raise_irq_float(&signal->irq, log.value, log.floating); } if (avr_vcd_fifo_isempty(&vcd->log)) { @@ -300,7 +304,6 @@ avr_vcd_init_input( uint32_t ioc = AVR_IOCTL_DEF( ioctl[0], ioctl[1], ioctl[2], ioctl[3]); avr_irq_t * irq = avr_io_getirq(vcd->avr, ioc, index); - printf(" irq %p\n", irq); if (irq) { vcd->signal[i].irq.flags = IRQ_FLAG_INIT; avr_connect_irq(&vcd->signal[i].irq, irq); @@ -416,8 +419,13 @@ avr_vcd_flush_log( // mark this trace as seen for this timestamp seen |= (1 << l.sigindex); fprintf(vcd->output, "%s\n", - _avr_vcd_get_signal_text(&vcd->signal[l.sigindex], - out, l.value)); + l.floating ? + _avr_vcd_get_float_signal_text( + &vcd->signal[l.sigindex], + out) : + _avr_vcd_get_signal_text( + &vcd->signal[l.sigindex], + out, l.value)); } } @@ -448,6 +456,7 @@ _avr_vcd_notify( .sigindex = s->irq.irq, .when = vcd->avr->cycle, .value = value, + .floating = !!(avr_irq_get_flags(irq) & IRQ_FLAG_FLOATING), }; if (avr_vcd_fifo_isfull(&vcd->log)) { AVR_LOG(vcd->avr, LOG_WARNING, diff --git a/simavr/sim/sim_vcd_file.h b/simavr/sim/sim_vcd_file.h index 221081d..e274a51 100644 --- a/simavr/sim/sim_vcd_file.h +++ b/simavr/sim/sim_vcd_file.h @@ -63,6 +63,7 @@ typedef struct avr_vcd_signal_t { typedef struct avr_vcd_log_t { uint64_t when; uint64_t sigindex : 8, // index in signal table + floating : 1, value : 32; } avr_vcd_log_t, *avr_vcd_log_p; -- 2.39.5