simulavr-devel
[Top][All Lists]
Advanced

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

[Simulavr-devel] [bug #40586] example/feedback does not work


From: Michael Hennebry
Subject: [Simulavr-devel] [bug #40586] example/feedback does not work
Date: Sat, 16 Nov 2013 09:30:28 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20131029 Firefox/17.0

Follow-up Comment #6, bug #40586 (project simulavr):

I got portToggleFeature wrong.
'Tis a HWPort member.  HWPort's constructor defaults it to false.
There is no explicit mention of it in any atMega128 code.
That is correct for an atMega128.
>From the source, feedback does not appear to do much of anything.
>From the names in debugio.c it uses location 0x20 as an output location.
That would not work on a real atMega128. 0x20 refers to PINF.
feedback itself appears to use no input.

I noticed that portSize, portMask and portToggleFeature are separate non-const
members or HWPort.
At the least, they should be const.
I think that they should be implicit in the type,
which means that HWPort should be a class template.
Also, portMask is calculated from portSize.
The assumption seems to be that the high pins will be the missing pins.
Do we want to rely on that?
If so, it really shold be documented.

When making HWPort into a class template,
mosts of the work could be handled by a base class:
class HWPortBase {
public:
    HWPortBase::HWPortBase(AvrDevice *core, const string &name);
    void finish(int tt, int mask) ;
    void Reset(void) CalcOutputs();
    Pin& GetPin(unsigned char pinNo);
    virtual void CalcPin(void) = 0;
    void CalcOutputs(void);
    virtual string GetPortString(void) = 0;
    virtual void SetPin(unsigned char val);
    virtual ~HWportBase() {}
} ;

// 45678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 2345678
8

template<unsigned char portMask, bool portToggleFeature> 
class HWPort : public HWPortBase {
public:
    HWPort(AvrDevice *core, const std::string &name) : HWPortBase(core, name)
    {
        for(unsigned char tt=7, mask=0x80; mask; --tt, mask>>=1) {
            if(mask & portMask) finish(tt, mask);
        } // tt, mask
    } constructor

    virtual void CalcPin(void)
    {
        // calculating the value for register "pin" from the Pin p[] array
        pin = 0;
        for(unsigned tt = 7, mask=0x80; mask; --tt, mask>>=1) {
            if((mask & portMask) && p[tt].CalcPin()) pin |= mask;
        } // tt, mask
    } // CalcPin

    virtual void HWPort::SetPin(unsigned char val) {
        if(portToggleFeature) {
            port ^= val;
            CalcOutputs();
            port_reg.hardwareChange(port);
        } else {
            avr_warning("Writing of 'PORT%s.PIN' (with %d) is not
supported.",
                        myName.c_str(), val );
        }
    } // SetPin

    virtual HWPort::~HWPort() {
        for(unsigned char tt=7, mask=0x80; mask; --tt, mask>>=1) {
            if(mask & portMask) {
                UnregisterTraceValue(pintrace[tt]);
                delete pintrace[tt];
            }
        } // tt, mask
    } // destructor
} ;

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?40586>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

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