1-bit register HDL implementation

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

1-bit register HDL implementation

Jiyda Mint Mohamed Moussa
Hello everyone,

I am trying to make the 1-bit register following the figure given in the book, I understand how the register is built but my HDL implementation seems to be wrong since I get many Comparison Failures when I load the corresponding script in the Hardware simulator.
The figure is in page 43: http://www1.idc.ac.il/tecs/book/chapter%2003.pdf

My HDL code:

/**
 * 1-bit memory register.
 * If load[t-1]=1 then out[t] = in[t-1]
 * else out does not change (out[t] = out[t-1])
 */

CHIP Bit {

    IN  in, load;
    OUT out;

    PARTS:
        Mux(a = in, b = loopIn, sel = load, out = outMux);
        DFF(in = outMux, out = loopIn, out = out);


}

I do not see what's wrong with the code, any help is greatly appreciated!


Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

cadet1620
Administrator
What does load=true select in your hdl?

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

Re: 1-bit register HDL implementation

Jyda Mint Mohamed Moussa
Thank you Mark,
It seems that I switched the inputs a and b of the Mux. Now it's working properly! :)
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

Jorge Bendahan
I have implemented exactly like the code above and it's failing the test. It seems so simple:

                Mux(a = in, b = loop, sel = load, out = o1);
                DFF(in = o1, out=loop, out = out);

What am i missing?
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

Jorge Bendahan
oops... :S just realized the exact same thing tha Jyda did..
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

 Aparajith Bhaskar
What exactly did you change to make it wwork??
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

cadet1620
Administrator
Aparajith Bhaskar wrote
What exactly did you change to make it wwork??
Hint: when load is false, what signal does the Mux need to pass to the DFF's input?

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

Re: 1-bit register HDL implementation

daniel
This post was updated on .
i am confused. for me it does not work; even when i had the two inputs of the mux wrong, the DFF did not output the right value when I set sel=false.

now i have, what seems right to me but does not work:

<code removed again>

Any tip?

thanks,
Danil
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

cadet1620
Administrator
This is correct code; it passes the test on my system.

Make sure that you do not have a Mux.hdl nor a DFF.hdl in the directory with Bit.hdl.

Also, since the Bit.tst file is in 'projects\03\a' subdirectory, make sure that your Bit.hdl is in the 'a' subdirectory too. If your file is in the '03' directory the test will be loading the skeleton file from the 'a' directory and not your Bit.hdl.

[Please edit your post to remove the working code. We want students to develop their own solutions.]

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

Re: 1-bit register HDL implementation

ganesshk
Why Mux.hdl should not be in the directory? I don't get that. Sorry if it is a silly question. Thanks
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

ybakos
In Project 3, you simply rely on the simulator's built-in version of the primitive gates.
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

canbax
In reply to this post by Jiyda Mint Mohamed Moussa
Nice trick to multiplex the output pin.

I didn't know that we could write out=a, out=b