We can make some intelligent estimates for gate counts for ROM and Screen.
A ROM bit is just a wire to 0 or 1, so it counts as 0 Nands.
int rombit = 0;
int romreg = 16*rombit;
int rom8 = 8*romreg + mux8way16;
int rom64 = 8*rom8 + mux8way16;
int rom512 = 8*rom64 + mux8way16;
int rom4k = 8*rom512 + mux8way16;
int rom32k = 8*rom4k + mux8way16;
ROM32K comes out 2 097 088 Nands
Trickier is Screen. Since the Hack computer has no provision for wait cycles, the
Screen buffer needs to be dual port RAM. In this case It can be dual read/single
write which is quite a bit simpler than true dual port RAM.
DpRAM8 will look something like:
// DpRAM8.hdl -- dual port 8 byte RAM -- 1 RW port, 1 RO port
CHIP RAM8Dual {
IN inA[16], loadA, addressA[3], addressB[3];
OUT outA[16], outB[16];
PARTS:
DMux8Way(sel=addressA, in=loadA, a=ld0, b=ld1, c=ld2, d=ld3, e=ld4,
f=ld5, g=ld6, h=ld7);
Register(in=inA, load=ld0, out=d0);
Register(in=inA, load=ld1, out=d1);
Register(in=inA, load=ld2, out=d2);
Register(in=inA, load=ld3, out=d3);
Register(in=inA, load=ld4, out=d4);
Register(in=inA, load=ld5, out=d5);
Register(in=inA, load=ld6, out=d6);
Register(in=inA, load=ld7, out=d7);
Mux8Way16(sel=addressA, a=d0, b=d1, c=d2, d=d3, e=d4, f=d5, g=d6, h=d7,
out=outA);
Mux8Way16(sel=addressB, a=d0, b=d1, c=d2, d=d3, e=d4, f=d5, g=d6, h=d7,
out=outB);
}
The same pattern as was used to build up to RAM16K from RAM8 is used to build up
to DpRAM8K for the Screen buffer.
int dpram8 = dmux8way + 8*reg + 2*mux8way16;
int dpram64 = dmux8way + 8*dpram8 + 2*mux8way16;
int dpram512 = dmux8way + 8*dpram64 + 2*mux8way16;
int dpram4k = dmux8way + 8*dpram512 + 2*mux8way16;
int dpram8k = dmux + 2*dpram4k + 2*mux16;
The Screen buffer comes out 2 793 339 Nand gates. This does not include any of
hardware required to display the screen buffer.
The Keyboard does not require any additional logic in the Hack computer; it's
just a bunch of wires coming from the physical keyboard.
CPU | 1 528 |
Memory decoding | 253 |
RAM16K | 4 538 299 |
ROM32K | 2 097 088 |
Screen buffer | 2 793 339 |
|
Computer | 9 430 507 |
Not a bad little computer for under 10 million Nand gates!
--Mark