|
|
Hi!
I tried to build Incrementer chip with the help of 16-bit Adder chip which was build and tested successfully.
What I don't understand is which value should be put for "b" pin of Adder chip. I tried with "true" keyword but the Hardware simulator reported an error while running a testing script. Input value was 16-bit value for 0. And Incrementer out pin was again 0.
My HDL code for Incrementer chip:
CHIP Inc16 {
IN in[16];
OUT out[16];
PARTS:
And16(a=in, b=true, out=out);
}
Thanks for your help!
Marko
|
|
Think of the symbols true and false being wires... that are one 'bit' wide and on/off.
As for your implementation, note that your hdl is using And16, not Add16 as you describe. Assuming the use of Add16, you'd have to individually wire false and true to each of the 16 connections of b[].
(hint: my implementation uses 16 chips)
|
|
Hi, ybakos!
I don't understand how I didn't notice that I have been using wrong chip in my implementation.. Probably, because I'm writing HDL code all day :)
I followed your hint and I implemented Incrementer with 16 full adder chips with parallel adding and serial carrying..
Thanks for your help!
|
|
I don't know if this would make any difference to your implementation (I don't know if you're counting chips inside chips)) but just lately reading appendix A I realized that in HDL you can directly set an input pin of a chip to any value you choose.
|
|
You can actually implement the Inc16 chip with a single Add16 chip. If you carefully read Appendix A, mainly the section on buses, it will tell you that you can set the values of the individual pins on a bus in the chip call by indexing the pins, you can also use the "n..x" notation to specify a range of pins to set to individual values. So you could set the value of bus b for the Add16 chip to 1 using the following:
Add16(a=a,b[15..1)=false,b[0]=true,out=out);
This would save you considerable typing, also since its not immediately obvious to those who just read the text really quick and assume the "n..x" notation is just used in the text and would not work in HDL. It does work and is very useful.
|
|
i just wanted to know whether the following code for the Inc16 chip works in the Hardware Simulator(coz its not working for me and i just wanted to clarify it again)...
Add16(a=a,b[15..1)=false,b[0]=true,out=out);
i really wanted to know why it does not work though its mentioned in Appendix A that each pin in the bus can be assigned individual values....this reduces a lot of writing work i know and just can be used to get the idea of using an Add16 chip for the Inc16 chip....please do help me on this!!!
|
|
Hi
It looks good except for a couple of small things I noticed.
You set a to take itself as input rather than the actual input to the chip.
You use a round bracket in one place where you need to use a square one.
|
|
You can even set a single bit of one of the inputs (and the rest appear to default to false):
SomeChip16(a=in, b[0]=true, out=out);
I didn't expect to be able to do something like
SomeChip16(a=in, b[1..15]=false, b[0]=true, out=out);
or
SomeChip16(a=in, b[0..15]=false, b[0]=true, out=out);
but they both work (though I don't know why you'd set b[0] then immediately re-set it).
|
|
This post was updated on .
Nice, shmcinto! The book says, "An n-bit incrementer can be implemented trivially from an n-bit adder." So I was thinking there had to be a way to set individual pin values. Since it all translates to boolean logic, setting pins to true or false makes complete sense to me.
|
|
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
|
|
TRUE is not true. The simulator (and most programming languages) are case-sensitive.
|
Administrator
|
Now that you have resolved your problem, please edit your post to remove the source code.
--Mark
|
|
Here's the correct syntax: Add16(a=in, b[1..15]=false, b[0]=true , out=out);
I think some of the other answers got it confused
|
|