1-bit register HDL implementation

classic Classic list List threaded Threaded
23 messages Options
12
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
drv
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

drv
In reply to this post by ybakos
Hi,
How come, DFF() is taking three params ? When it has only 2 params namely "in" and "out". Did I missed some explanation in the video ?
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

xedover
drv wrote
Hi,
How come, DFF() is taking three params ? When it has only 2 params namely "in" and "out". Did I missed some explanation in the video ?
you can have multiple output pins. It was mentioned very briefly in Appendex A, and in some more detail in the HDL Survival Guide
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

cadet1620
Administrator
In reply to this post by drv
drv wrote
Hi,
How come, DFF() is taking three params ? When it has only 2 params namely "in" and "out". Did I missed some explanation in the video ?
You should not think of these as "parameters", but rather as "wire connections".

The "in" connection receives electricity. It can only have one wire connected to it -- there would be a conflict if it had two wires and one of them was FALSE and the other one was TRUE. In real hardware this conflict would result in large current flow and potential circuit damage.

The out connection can have multiple wires connecting to it since it is supplying electricity.

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

Re: 1-bit register HDL implementation

drv
Then why is it if I do the same thing in Mux e.g.
Mux(a=in, b=someOut, sel=load, out=out, out=someOtherOut), the simulator does not accept this ?
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

cadet1620
Administrator
drv wrote
Then why is it if I do the same thing in Mux e.g.
Mux(a=in, b=someOut, sel=load, out=out, out=someOtherOut), the simulator does not accept this ?
This should work in general, but you may be running into a limitation in the HardwareSimulator. If someOut is a chip output -- named in the OUT section -- then you will get a "Can't connect gate's output pin to part" error.

Also, if you have "out=out" in both the Mux and the DFF, then you have two parts connecting to a single CHIP output and should get "An output pin may only be fed once by a part's output pin".

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

Re: 1-bit register HDL implementation

Minoshi
In reply to this post by Jyda Mint Mohamed Moussa
why does switching the inputs make any difference ??
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

cadet1620
Administrator
Switching the Mux a and b inputs makes the Bit load new data when the 'load'' input is 0 and maintain its current value when the 'load' input is 1.
Reply | Threaded
Open this post in threaded view
|

Re: 1-bit register HDL implementation

fmiren
Could you please explain what does DFF having two outputs mean exactly?
Like DFF (in=outmux, out=loop, out=out) - what does this mean? If outmux is 1, then out = loop; otherwise, out = out?
I'm confused.
12