Thursday, March 15, 2012

PC the rest of the story



Activity 26:
Continued.
The order of things is when Mux are being used for if then else statements the last one goes first and the first one goes last.
So goes increment then load data the reset even though that seems backwards in coding since. It makes since in hardware because the last mux will change the output of all the rest.

That was the piece I was missing. It now works perfectly.
With that information I get
Increment then
Load then
reset    
with the register data having a feedback loop in it.

3 comments:

  1. Hey first off, I'm lovin the blog.
    I'm having some trouble implementing the PC chip. this is the code I have right now:

    CHIP PC {
    IN in[16],load,inc,reset;
    OUT out[16];

    PARTS:
    Mux16(a=false, b[1..15]=false, b[0]=true, sel=inc, out=out2);
    Mux16(a=new, b=in, sel=load, out=out1);
    Inc16(in=out2, out=out3);
    Mux16(a=out3, b=false, sel=reset, out=out4);
    Register(in=out4, load=true, out=new, out=out);
    }

    any suggestions?

    ReplyDelete
  2. Lets see if I can give a good hint with out giving too much away.

    The register is the main component and then the mux's are in an order of increment,load data and then reset and the register feeds into the inc16.

    /**
    * A 16-bit counter with load and reset control bits.
    * if (reset[t]==1) out[t+1] = 0
    * else if (load[t]==1) out[t+1] = in[t]
    * else if (inc[t]==1) out[t+1] = out[t] + 1 (integer addition)
    * else out[t+1] = out[t]
    */
    To me building these statements what seems backwards gets it to work.
    If this doesn't help let me know.

    In yours the

    Mux16(a=out3, b=false, sel=reset, out=out4);

    the b value is not false

    and in this
    Mux16(a=false, b[1..15]=false, b[0]=true, sel=inc, out=out2);

    the B does not need to be split and A should not be false.

    Also the mux's are not in the right order.

    ReplyDelete
  3. The feedback loop is not well described (as an hdl language construct I mean) in the documentation. I see many getting stuck in the out=out, out=loop of a clocked CHIP.

    Here's my take on it:

    Inc16(in=loop, out=loop1);
    Mux16(a[0..15]=loop, b[0..15]=loop1, sel=inc, out=r1);
    Mux16(a[0..15]=r1, b[0..15]=in, sel=load, out=r2);
    Mux16(a[0..15]=r2, b[0..15]=false, sel=reset, out=r3);
    Register(in[0..15]=r3, load=true, out=out, out=loop);

    ReplyDelete

Search Engine Submission - AddMe