ArrayIndexOutofBounds exception when parsing my Memory.hdl

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

ArrayIndexOutofBounds exception when parsing my Memory.hdl

jephricon
This post was updated on .
I see the following exception on the Java console for the Hardware Simulator:

Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBoundsException: 3
        at Hack.Gates.CompositeGateClass.isLegalToPartEdge(Unknown Source)
        at Hack.Gates.CompositeGateClass.createConnectionsGraph(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(U
nknown Source)
        at java.lang.Thread.run(Unknown Source)


Here's my first stab at Memory.hdl.  I'm not sure what's tripping this:

CHIP Memory {
    IN in[16], load, address[15];
    OUT out[16];

    PARTS:
    // Put your code here
   
    //determine which address space to load
   
DMux4Way(in=load, sel[0]=address[13], sel[1]=address[14], a=ram16k1, b=ram16k2, c=screen, d=false);

 
/*
// deleted code
*/

   
}

Thanks!

Jeff
Reply | Threaded
Open this post in threaded view
|

Re: ArrayIndexOutofBounds exception when parsing my Memory.hdl

cadet1620
Administrator
jephricon wrote
I see the following exception on the Java console for the Hardware Simulator:

Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBoundsException: 3
        at Hack.Gates.CompositeGateClass.isLegalToPartEdge(Unknown Source)
        at Hack.Gates.CompositeGateClass.createConnectionsGraph(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(U
nknown Source)
        at java.lang.Thread.run(Unknown Source)


Here's my first stab at Memory.hdl.  I'm not sure what's tripping this:

CHIP Memory {
    IN in[16], load, address[15];
    OUT out[16];

    PARTS:
...
DMux4Way(in=load, sel[0]=address[13], sel[1]=address[14], a=ram16k1, b=ram16k2, c=screen, d=false);
...    
(For me, the simulator hangs trying to open the Memory.hdl file, rather than faulting.)

Your problem is the "d=false" in the DMux4Way. This is attempting to connect the output pin "d" to the constant "false". In a case where you don't need an output from a pin, all you need to do is not mention it in the part line:
    DMux4Way(in=load, sel[0]=address[13], sel[1]=address[14], a=ram16k1, b=ram16k2, c=screen);

Please edit your post to remove the good part of the HDL.

--Mark

Reply | Threaded
Open this post in threaded view
|

Re: ArrayIndexOutofBounds exception when parsing my Memory.hdl

jephricon
Ah.. That totally fixed it.  Thanks again!!