summaryrefslogtreecommitdiff
path: root/tools/builtInChips/RAM4K.hdl
blob: 8f1b2110c009fd6db863eed1f6f0db2e62526f26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: tools/builtIn/RAM4K.hdl

/**
 * Memory of 4K registers, each 16-bit wide.  
 * The chip facilitates read and write operations, as follows:
 *     Read:  out(t) = RAM4K[address(t)](t)
 *     Write: If load(t-1) then RAM4K[address(t-1)](t) = in(t-1)
 * In words: the chip always outputs the value stored at the memory 
 * location specified by address. If load == 1, the in value is loaded 
 * into the memory location specified by address.  This value becomes 
 * available through the out output starting from the next time step.
 */

CHIP RAM4K {

    IN  in[16], load, address[12];
    OUT out[16];

    BUILTIN RAM4K;
    CLOCKED in, load;
}