Building the Hack computer's main memory unit (RAM).
So far (project 1 & 2) all operations happened instantaneously, completely disregarding the time component (combinatorial logic).
We want to be able to re-use hardware components (not just one-time I/O operations) in order to:
- create loops (e.g.
for i in range(100)
) - work with intermediate results (e.g.
sum = sum + i
)
Notes
- in reality, time is continuous -> break down into integer time units
- one integer time unit is equivalent to one cycle of an oscillating input signal (pyhsical)
- integer time unit needs to be just a tiny bit longer than how long it takes for the physical signal to stabilize
- build-up time portion of the interval is ignored and only the stabilized portion is taken into account
- within one integer time unit, operations happen instantaneously
- ignoring physical signal's build-up time
- combinatorial:
out[t] = function(in[t])
- sequential:
out[t] = function(in[t-1])
- can also be a combination of input at time
t-1
andt
- can also be a combination of input at time
- we now have states!
Gates that can (physically) flip between two states are called Flip Flops.
As such, Flip Flops will remember either of bit 0/1 at the end of time t-1
in order to use it in time t
.
The two states are therefore:
- "remembering 0"
- "remembering 1"
Resources (watch in order)
- [YouTube: Ben Eater] SR Latch
- [YouTube: Ben Eater] D Latch
- [YouTube: Ben Eater] D Flip Flop
- [YouTube: Ben Eater] JK Flip Flop
- [YouTube: Ben Eater] Master-Slave JK Flip Flop
- [YouTube: Ben Eater] Astable Oscillator (Clock)
Random Access Memory (RAM) is a chip that holds data indefinitely (that is, until the next load operation tells it to hold new data).
In contrast to sequential access (one after another), registers within RAM can be accessed arbitrarily, hence "random".
Each Register in the RAM structure holds exactly one 16-bit (in this implementation) binary number.
Structure
RAM
(stores K * N bits of information)N Multi-bit Register
(each stores K bits of information)K 1-bit Register
(each stores 1 bit of information)Mux + D Flip Flop
As implemented using HDL in project 3.