simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Simulavr-devel] Uniform the code


From: Knut Schwichtenberg
Subject: [Simulavr-devel] Uniform the code
Date: Sat, 11 Apr 2009 18:22:15 +0200
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

Hi writers,

first of all I must clarify I'm NOT a C++ specialist. Mostly I can read it,
repair a little but designing or deciding which code is more C++ is far beyond
my scope. For C that's no problem but C++ is not my business.

Currently there is a problem with the atmega48 which leads to segmentation
fault. While M128 is okay M48 should be simplified. But the module looks fully
different! I expect it works the same, but why is it programmed different?

Normally everyone could say if it works, okay who cares about the way it is
hacked, but just these modules have to be created for each CPU and we are at the
very beginning and now it is the time to decide M128 way or M48 way or fully
different. If this is not fixed now, maintenance in the future will become a
nightmare.

I'll take some examples to clarify:
atmega128.cpp:

AvrDevice_atmega128::AvrDevice_atmega128():
AvrDevice(224, 4096, 0xef00, 128*1024),
aref()
{
        irqSystem = new HWIrqSystem(this, 4); //4 bytes per vector
        eeprom = new HWMegaEeprom(this, irqSystem, 4096, 22);
        stack = new HWStack(this, Sram, 0xffff);
        porta= new HWPort(this, "A");         <-- explicit assignment
...


AvrDevice_atmega48::AvrDevice_atmega48():
AvrDevice(      224,    // I/O space above General Purpose Registers
                        512,    // RAM size
                        0,      // External RAM size
                        4*1024  // Flash Size
                        ),
aref(),
adc6(),
adc7(),
portb(this,"B"),                         <--- Initial assignment
portc(this,"C"),
portd(this,"D"),
prescaler(this),
admux(  this,
                &portc.GetPin(0),
                &portc.GetPin(1),
                &portc.GetPin(2),
                &portc.GetPin(3),
                &portc.GetPin(4),
                &portc.GetPin(5),
                &adc6,
                &adc7
                )
{
        irqSystem = new HWIrqSystem(this,2);

        eeprom = new HWMegaEeprom( this, irqSystem, 256, 23);
        stack = new HWStack(this, Sram, 0xffff);
....
Personally I like explicit assignment because of my old age understanding.

The differences of the way the variables are assigned leads to a different
assignment of the physical address to the name:

m128:
        rw[0x32]= new RWPort(this, portd);


m48:
        rw[0x2B]= new RWPort(this, &portd);

The difference 0x32 / 0x28 is Atmel based, but the portd vs. &portd is selfmade
and that's not good.

There should be one unique way how the atmegaxxx / attinyxxx modules will be
created! Please discuss.

Knut




reply via email to

[Prev in Thread] Current Thread [Next in Thread]