From ee9cd0feff4f724aca6cd61d73658fb7d391e5f4 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Sun, 2 Jun 2013 18:27:02 +0100 Subject: [PATCH] vcd: Initializes IRQs when needed only Also manufacture an IRQ name with the one passed in add_signal Signed-off-by: Michel Pollet --- simavr/sim/sim_vcd_file.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/simavr/sim/sim_vcd_file.c b/simavr/sim/sim_vcd_file.c index c6ce06c..e425032 100644 --- a/simavr/sim/sim_vcd_file.c +++ b/simavr/sim/sim_vcd_file.c @@ -38,11 +38,9 @@ int avr_vcd_init(struct avr_t * avr, const char * filename, avr_vcd_t * vcd, uin vcd->avr = avr; strncpy(vcd->filename, filename, sizeof(vcd->filename)); vcd->period = avr_usec_to_cycles(vcd->avr, period); - - for (int i = 0; i < AVR_VCD_MAX_SIGNALS; i++) { - avr_init_irq(&avr->irq_pool, &vcd->signal[i].irq, i, 1, NULL /* TODO IRQ name */); - avr_irq_register_notify(&vcd->signal[i].irq, _avr_vcd_notify, vcd); - } + + // No longer initializes the IRQs here, they can be initialized on the + // fly when traces are added return 0; } @@ -153,10 +151,24 @@ int avr_vcd_add_signal(avr_vcd_t * vcd, { if (vcd->signal_count == AVR_VCD_MAX_SIGNALS) return -1; - avr_vcd_signal_t * s = &vcd->signal[vcd->signal_count++]; + int index = vcd->signal_count++; + avr_vcd_signal_t * s = &vcd->signal[index]; strncpy(s->name, name, sizeof(s->name)); s->size = signal_bit_size; s->alias = ' ' + vcd->signal_count ; + + /* manufacture a nice IRQ name */ + int l = strlen(name); + char iname[10 + l + 1]; + if (signal_bit_size > 1) + sprintf(iname, "%d>vcd.%s", signal_bit_size, name); + else + sprintf(iname, ">vcd.%s", name); + + const char * names[1] = { iname }; + avr_init_irq(&vcd->avr->irq_pool, &s->irq, index, 1, names); + avr_irq_register_notify(&s->irq, _avr_vcd_notify, vcd); + avr_connect_irq(signal_irq, &s->irq); return 0; } -- 2.39.5