Simulator crashes when loading chip

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Simulator crashes when loading chip

dave
I am trying to build a 32-bit register out of two 16-bit registers as follows:

CHIP Register32 {

    IN  in[32], load;
    OUT out[32];

    PARTS:
    Register(in=in[0..15],  out=out[0..15], load=load);
    Register(in=in[16..31], out=out[16..31], load=load);
}

However, loading this chip crashes the hardware simulator with this exception:

Exception in thread "Thread-35" java.lang.ArrayIndexOutOfBoundsException: 16
        at Hack.Gates.PinInfo.isInitialized(Unknown Source)
        at Hack.Gates.CompositeGateClass.addConnection(Unknown Source)
        at Hack.Gates.CompositeGateClass.readPinNames(Unknown Source)
        at Hack.Gates.CompositeGateClass.readParts(Unknown Source)
        at Hack.Gates.CompositeGateClass.<init>(Unknown Source)
        at Hack.Gates.GateClass.readHDL(Unknown Source)
        at Hack.Gates.GateClass.getGateClass(Unknown Source)
        at Hack.HardwareSimulator.HardwareSimulator.loadGate(Unknown Source)
        at Hack.HardwareSimulator.HardwareSimulatorController$LoadChipTask.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:680)

Is this a bug in the simulator or am I not seeing an indexing mistake in my code?

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Simulator crashes when loading chip

dave
As I am working on this same 32-bit register problem, I tried another solution, namely to build it out of 32 single bits, namely:

CHIP Register32 {

    IN  in[32], load;
    OUT out[32];

    PARTS:
    Bit(in=in[0], out=out[0], load=load);
    Bit(in=in[1], out=out[1], load=load);
    Bit(in=in[2], out=out[2], load=load);
    ...
    Bit(in=in[15], out=out[15], load=load);
    Bit(in=in[16], out=out[16], load=load);  // <== this is the line that causes the problem
    ...
}

but the index 16 on the last line shown above generates the same exception in the hardware simulator.
Does that mean that I can never use indices larger than 15 in my hdl??? Someone, please help me find a way around this 8^) Thank you!!!
Reply | Threaded
Open this post in threaded view
|

Re: Simulator crashes when loading chip

cadet1620
Administrator
dave wrote
As I am working on this same 32-bit register problem, I tried another solution, namely to build it out of 32 single bits, namely:
...
    Bit(in=in[16], out=out[16], load=load);  // <== this is the line that causes the problem
...
Does that mean that I can never use indices larger than 15 in my hdl??? Someone, please help me find a way around this 8^) Thank you!!!
From the PinInfo class source code:

    /**
     * Constructs a new empty PinInfo.
     */
    public PinInfo() {
        initialized = new boolean[16];
    }

It looks like the simulator does not support buses wider than 16 bits.

I think you will need to split your 32-bit buses:
    CHIP Register32 {

        IN  inH[16], inL[16], load;
        OUT outH[16], outL[16];

        PARTS:
        Register(in=inH, out=outH, load=load);
        Register(in=inL, out=outL, load=load);
    }

Ugly, but workable.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Simulator crashes when loading chip

dave
All right; that's too bad, since the interface of the chip does not hide its internals (2 16-bit registers), but that will have to do for now.