1. Engineering
  2. Computer Science
  3. using nand2tetris hdl how do you write an 8bit to...

Question: using nand2tetris hdl how do you write an 8bit to...

Question details

Using Nand2Tetris HDL, how do you write an 8-bit to 3-bit priority encoder?

So far I have:

//Priority Encoder
//input is 8-bit long array
//output is 3-bit long array

CHIP PriorityEncoder83
{
   IN a[8];
   OUT out[3], idle;

   PARTS:
   //00000000
   Or(a=a[0], b=a[1], out=ab);
   Or(a=a[2], b=a[3], out=bc);
   Or(a=a[4], b=a[5], out=cd);
   Or(a=a[6], b=a[7], out=de);
   Or(a=ab, b=bc, out=ef);
   Or(a=ef, b=cd, out=fg);
   Or(a=fg, b=de, out=notIdle);
   Not(in=notIdle, out=idle);

   //00000001
  
   //00000010
   And(a=a[1], b=a[1], out=out[0]);
  
   //00000100
   And(a=a[2], b=a[2], out=out[1]);

}

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution