|
|
Hello guys,
i am trying to make 16 bit NOT gate...but i dont know how to define 16 bit buses.... i wrote this code below but it's not working...can you please give me the right code to implement it
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Not16.hdl
/**
* 16-bit Not:
* for i=0..15: out[i] = not in[i]
*/
CHIP Not16 {
IN in[16];
OUT out[16];
PARTS:
Nand(a[7]=in[7],b[7]=in[7],out[15]=out[15]);
}
|
Administrator
|
sarab wrote
Hello guys,
i am trying to make 16 bit NOT gate...but i dont know how to define 16 bit buses.... i wrote this code below but it's not working...can you please give me the right code to implement it
Nand(a[7]=in[7],b[7]=in[7],out[15]=out[15]);
Think of a bus as a bundle of wires. The [] syntax selects one wire from a bus.
What you've done with this line of HDL is connect wire 7 from the in bus to the Nand's inputs and the Nand's output to wire 15 of the out bus.
You will need one line of HDL for each of the 16 wires.
Hint for building the Not16: use your Not chip.
--Mark
|
|
Sarab,
When working on the chips, I recommend making some quick drawings before you write any HDL code.
For Not16, you should realize that there is an input called a, which is a "16-bit bus," meaning that it is essentially 16 wires: a[0], a[1], ... a[15].
Here's a hint. To built Not16, you only need one kind of part... but you need 16 of them.
In the implementation you wrote above, you are trying to wire up a[7] to a Nand input's a[7], which does not exist. What inputs does Nand have? a and b.
|
|
Looks like Mark is up earlier than me today.
|
|
thanx for replying...
i tried this...but it's saying address out of range
CHIP Not16 {
IN in[16];
OUT out[16];
PARTS:
Not(in[0]=in[0],out[0]=out[0]);
Not(in[1]=in[1],out[1]=out[1]);
Not(in[2]=in[2],out[2]=out[2]);
Not(in[3]=in[3],out[3]=out[3]);
Not(in[4]=in[4],out[4]=out[4]);
Not(in[5]=in[5],out[5]=out[5]);
Not(in[6]=in[6],out[6]=out[6]);
Not(in[7]=in[7],out[7]=out[7]);
Not(in[8]=in[8],out[8]=out[8]);
Not(in[9]=in[9],out[9]=out[9]);
Not(in[10]=in[10],out[10]=out[10]);
Not(in[11]=in[11],out[11]=out[11]);
Not(in[12]=in[12],out[12]=out[12]);
Not(in[13]=in[13],out[13]=out[13]);
Not(in[14]=in[14],out[14]=out[14]);
Not(in[15]=in[15],out[15]=out[15]);
}
|
|
thnx for replying....i tried the code below but its not working
CHIP Not16 {
IN in[16];
OUT out[16];
PARTS:
Not(in[0]=in[0],out[0]=out[0]);
Not(in[1]=in[1],out[1]=out[1]);
Not(in[2]=in[2],out[2]=out[2]);
Not(in[3]=in[3],out[3]=out[3]);
Not(in[4]=in[4],out[4]=out[4]);
Not(in[5]=in[5],out[5]=out[5]);
Not(in[6]=in[6],out[6]=out[6]);
Not(in[7]=in[7],out[7]=out[7]);
Not(in[8]=in[8],out[8]=out[8]);
Not(in[9]=in[9],out[9]=out[9]);
Not(in[10]=in[10],out[10]=out[10]);
Not(in[11]=in[11],out[11]=out[11]);
Not(in[12]=in[12],out[12]=out[12]);
Not(in[13]=in[13],out[13]=out[13]);
Not(in[14]=in[14],out[14]=out[14]);
Not(in[15]=in[15],out[15]=out[15]);
}
|
Administrator
|
This post was updated on .
Another useful resource is this list of Chip Interfaces.
All Not chips must follow the pattern "Not(in=___, out=___);"
In particular, since the Not is a single bit chip, its in and out can't have [].
--Mark
|
|
then how to make a 16-bit bus using single Not gate :\
please help i'm stuck...
Actually i use xilinx....so i am confused
|
Administrator
|
What you'd like to write would be something like
for (i = 0; i < 16; i = i +1) begin
Not(in=in[i], out=out[i]); // out[i] = ~ in[i]
end
but n2t HDL doesn't support for loops like VHDL so you need to explicitly write out each of the Nots.
(Copy-and-paste is your friend in most of the XXX16 chips 8-).
--Mark
|
|
i wrote this but it's not working..plz help
CHIP Not16 {
IN in[16];
OUT out[16];
PARTS:
Not(in[0]=in[0],out[0]=out[0]);
Not(in[1]=in[1],out[1]=out[1]);
Not(in[2]=in[2],out[2]=out[2]);
Not(in[3]=in[3],out[3]=out[3]);
Not(in[4]=in[4],out[4]=out[4]);
Not(in[5]=in[5],out[5]=out[5]);
Not(in[6]=in[6],out[6]=out[6]);
Not(in[7]=in[7],out[7]=out[7]);
Not(in[8]=in[8],out[8]=out[8]);
Not(in[9]=in[9],out[9]=out[9]);
Not(in[10]=in[10],out[10]=out[10]);
Not(in[11]=in[11],out[11]=out[11]);
Not(in[12]=in[12],out[12]=out[12]);
Not(in[13]=in[13],out[13]=out[13]);
Not(in[14]=in[14],out[14]=out[14]);
Not(in[15]=in[15],out[15]=out[15]);
}
|
Administrator
|
sarab wrote
Not(in[0]=in[0],out[0]=out[0]);
"in[0]=" and "out[0]=" are illegal because Not's in and out are single bit signals.
You need to have exactly "in=" and "out=" in all Not chips.
--Mark
|
|
Got it....thanx a lotttt
|
|