On Mon Oct 18 18:02 , 'Petr Hluzín' <[email protected]> sent: >Hi Michael > >I noticed you did not send this to the mailing list. The question may >benefit from wider audience. Forward my reply to the list if you want.
Oops. I'd intended to. I'll send my reply to the list and only trim boilerplate. >All your suggestions suggestions would work. There are downsides, though. > >On 18 October 2010 23:06, [email protected] [email protected]> wrote: >> On Sun Oct 17 14:35 , 'Petr Hluzín' [email protected]> sent: >>> >>>Another proposal? >>>Are there more similar devices in family with ATmega16/ATmega32? >> >> If one wants to use common source code, >> templating would probably produce that fastest object code. >> A lot of computation could be done at compile time. > >Speed is non-issue since the constructors are going to be executed >once (for every core in simulation, usually also just one). > >The template would be parsed or instantiated only in the >src/atmega16_32.cpp file, even the factory would instantiate just the >object, not the template. I was thinking something like typedef ATMega8_group<ATMega8_interrupts, ...>; or class ATMega8 : public ATMega8_group_base<ATMega8_interrupts, ...> { ... }; If it can be done without contortions, the former is probably better. That way we get the constructors. IIRC the constructors are big enough to be subject to tipos.. >> To produce common object code, >> the differences would have to be stored as variables >> rather than as template constants. >> I'd do something like this: >> struct ATMega8_interrupts { >> enum { >> fred_interrupt=1, >> greg_interrupt=2, >> ivan_interrupt=3, >> jane_interrupt=4 >> hank_interrupt=5, >> ... >> } ; >> } ; >> Use ATmega8_interrupts as a template argument. >> >> >> If the object code get to large to be convenient, >> I see two solutions, >> a shared library or just compiling for the devices one wants. > >We are talking about 2 constructors making slightly larger. There will >be smaller than (twice) the largest device constructor so far. Less >than 4000 bytes. > >Simulavr is running on desktop. Users can afford waste few KB if it >makes their or our lives easier. Such optimization does not make a >sense. > >Was it a joke? No. For some reason, I was envisioning the possibility of a *lot* of devices. That said, even if there were that many, templating is no worse than separate code for each. I'll go fetch my other hat, the one with my head in it. -- Michael Hennebry [email protected] "War is only a hobby." ---- Msg sent via CableONE.net MyMail - http://www.cableone.net _______________________________________________ Simulavr-devel mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/simulavr-devel
