PC struggle

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

PC struggle

kingphamduy
 I have already tried 2 ways to build my PC. The first one using ALU and the second one using MUX16 but i still encoutered the same mistake: the output is evaluated earlier than I expected. Can anyone give me an explaination about why it happens and may be some hints to overcome the problem?

    // False code1:
    // Not(in = reset, out = notreset);
    // Not(in = load, out = notload);
    // And(a = notreset, b = notload, out = notrl);
    // And(a = notrl, b = inc, out = inno);
    // Or(a = reset, b = inno, out = inf);
    // Register(in = in, load = load, out = outx);
    // ALU(x = outx, y = outx, zx = reset, nx = inno, zy = true, ny = notreset, no = inno, f = inf, out = out);

    // False code2:
    // Register(in = in, load = load, out = out0);
    // Not(in = load, out = notload);
    // Not(in = reset, out = notreset);
    // And(a = notload, b = notreset, out = and0);
    // And(a = and0, b = inc, out = sel);
    // Inc16(in = out0, out = out1);
    // Mux16(a = out0, b = out1, sel = sel, out = out2);
    // Mux16(a = out2, b = false, sel = reset, out = out);

Hope you guys have a nice day,
--King
Reply | Threaded
Open this post in threaded view
|

Re: PC struggle

cadet1620
Administrator
Hint: If you connect a Register's load to true it turns the Register into a 16-bit DFF.

Then you can make PC like you made bit Bit, except that the feedback wire is replaced with a circuit that computes the next value for the PC.

Also, in hardware it is often easier to generate all the options you might need and select the one that's required by the current control values.  Think about handling the f bit in the ALU, but in this case there are more options.

--Mark

Reply | Threaded
Open this post in threaded view
|

Re: PC struggle

kingphamduy
I think I understand the ideal. I will keep working on it.
Thanks for your great hints.
--King