[Part 1] Unit 3.3 - Memory Units

MakkuZjAileron
16 Jan 201825:41

Summary

TLDRThis lecture delves into the fundamentals of computer memory, focusing on the Von Neumann architecture and the role of memory in computing. It explains the distinction between main memory, including RAM and secondary memory, and the concepts of volatile and non-volatile memory. The lecturer discusses the logical and physical aspects of memory, highlighting the importance of RAM in storing data and program instructions. The script also covers the construction of memory using basic building blocks like registers and demonstrates how to manipulate these through a hardware simulator. The course aims to build a series of 16-bit RAM chips, illustrating the process of reading from and writing to memory units and emphasizing the unique capability of RAM for rapid, random access to any register.

Takeaways

  • 💾 The script discusses building memory units for a computer, starting with revisiting the Von Neumann architecture and emphasizing the role of memory.
  • 🔍 It differentiates between main memory, secondary memory, and the concepts of volatile and non-volatile memory, highlighting RAM as a primary component.
  • 🌐 The RAM's function is to store both data and program instructions, and the importance of its role in the computer architecture is underscored.
  • 🔑 The script introduces the concept of a register as a fundamental building block of memory, explaining its state and how it can be read and written to.
  • 📏 It explains the abstraction of registers into a wider memory unit, using the width parameter 'w', which is set to 16 for the purpose of building a 16-bit computer.
  • 🔄 The process of changing the state of a register via the load bit and the significance of the clock cycle in stabilizing the new state is described.
  • 🛠️ A demonstration using a hardware simulator is provided to illustrate the operation of a register chip, showing how to manually advance the clock and update register values.
  • 📦 The script outlines the architecture of RAM, describing it as a sequence of addressable registers and explaining how addresses are used to select specific registers for read/write operations.
  • 🔢 The necessity of using a certain number of address bits based on the log of the number of registers in the RAM unit is clarified.
  • 🔄 Similar to registers, RAM units are sequential and clocked, with the ability to update the state of the selected register on the next cycle if the load bit is asserted.
  • 🚀 The script concludes with an overview of the different RAM chips that will be built during the course, ranging from RAM8 to RAM16K, each serving a specific purpose in constructing the Hack computer platform.
  • 🎯 The unique feature of RAM, allowing random access to any register regardless of the total number of registers with uniform access time, is highlighted as a remarkable capability.

Q & A

  • What is the Von Neumann architecture and why is memory a major player in it?

    -The Von Neumann architecture is a model of computer organization where the CPU executes instructions and processes data stored in the same read/write memory. Memory is a major player because it holds both the data on which programs operate and the instructions that are the building blocks of the programs themselves.

  • What are the different categories of memory mentioned in the script?

    -The script mentions main memory, which includes RAM (Random Access Memory), and secondary memory like hard-disks and memory sticks. It also distinguishes between volatile memory, such as RAM which is erased when power is lost, and non-volatile memory, which retains data even without power.

  • What is the difference between volatile and non-volatile memory?

    -Volatile memory, like RAM, loses its data when the power supply is interrupted, whereas non-volatile memory, such as hard disks and flash drives, retains data even in the absence of power.

  • What is RAM used for in a computer system?

    -RAM is used to store both the data on which programs operate and the instructions that constitute the programs. It is a crucial component of a computer's main memory.

  • What is the significance of the term 'state' in the context of a register?

    -In the context of a register, 'state' refers to the value currently stored or being expressed by the internal circuits of the register. It represents the data that the register is holding at a particular time.

  • How does a register read its value?

    -A register reads its value by probing the output, which at any given time emits the state of the register, thus revealing the value currently stored inside.

  • What is the process of writing a new value into a register?

    -To write a new value into a register, you set the input to the new value and assert the load bit by setting it to 1. From the next cycle, the register state and output will start emitting this new value.

  • Can you explain the concept of a '16-bit register' as mentioned in the script?

    -A '16-bit register' is a register that can store a number or a sequence of bits up to 16 bits wide. The width of the register, denoted as 'w' in the script, is a parameter that can vary, but for the purposes of the script's example, it is set to 16.

  • What is the purpose of the load bit in a register?

    -The load bit is used to control when a new value is written into a register. When the load bit is asserted (set to 1), the register updates its state to the new value provided at the input.

  • How does the RAM device differ from a single register in terms of functionality?

    -A RAM device is an array of addressable registers, allowing for the storage and retrieval of data in any of the registers independently. Unlike a single register, RAM provides the ability to access multiple locations for reading or writing data based on their addresses.

  • What is the role of the address input in a RAM device?

    -The address input in a RAM device is used to select a specific register within the device. It determines which register's data will be read from or written to, allowing access to any register irrespective of the total number of registers in the device.

  • Why is RAM called 'Random Access Memory'?

    -RAM is called 'Random Access Memory' because it allows any memory location to be accessed directly and randomly, without the need to follow a sequence. This means that the time to read or write any location is the same, regardless of the size of the memory.

  • What is the significance of the clock input in a RAM or register chip?

    -The clock input in a RAM or register chip is crucial for simulating the progression of time within the computer. It dictates the timing of operations, ensuring that data is read, written, or changed in sync with the computer's operation cycles.

  • How does the RAM8 chip demonstrated in the script work?

    -The RAM8 chip, as demonstrated, is a built-in chip with a GUI that allows for the manual input of values into its registers. It can be manipulated to read and write values to specific registers using the address and load inputs, with the state of the selected register being output after a clock cycle.

Outlines

00:00

💾 Introduction to Memory Units and Von Neumann Architecture

The script begins with an introduction to the theory of sequential logic and time, leading into a discussion about memory units essential for computer construction. It revisits the Von Neumann architecture, emphasizing the role of memory in computer hardware. The explanation covers various types of memory, including main memory, RAM (Random Access Memory), secondary memory, and the distinction between volatile and non-volatile memory. The importance of RAM in storing data and program instructions is highlighted, along with a brief mention of the physical and logical aspects of memory, focusing on the logical organization and the RAM unit's significance in computer architecture.

05:04

🔍 Exploring Registers and their Functionality

This paragraph delves into the elementary building blocks of memory, specifically registers. It explains how multiple one-bit registers can be combined to form a register capable of representing larger numbers, such as a 16-bit register. The concept of 'state' is introduced, referring to the value stored within a register. The process of reading from and writing to a register is described, including the use of an output to read the current state and the necessity of a 'load' operation to update the register's state with a new value. The paragraph also mentions the use of a hardware simulator to demonstrate the functionality of a register chip.

10:06

🕹️ Register Chip Demonstration using a Hardware Simulator

The script provides a practical demonstration of a register chip using a hardware simulator. It details the process of loading a built-in register chip, explaining the hardware description language (HDL) code and the clock mechanism that simulates time progression. The built-in chip's GUI feature is utilized to visually represent the register's state. The demonstration includes changing the register's state to a specific value, such as 17, by setting the input and asserting the load bit, followed by advancing the clock to update the state and output.

15:08

📚 Building Memory Units from Registers

The paragraph discusses the construction of memory units from basic registers. It introduces the concept of RAM as a sequence of addressable registers, each identifiable by an address. The importance of selecting a single register for operation at any given time is emphasized, and the method for selecting a register using an address input is explained. The paragraph also touches on the calculation of address bits needed based on the number of registers and the fixed width of the register, which is set to 16 bits for the purpose of building a 16-bit computer.

20:11

🔄 Understanding RAM Operations and its Abstraction

This section explains the operations of RAM, including how to read and write values using the RAM device. It describes the process of setting an address to select a specific register and the use of a load bit to initiate a write operation. The paragraph also discusses the sequential nature of RAM, which depends on a clock input to define its behavior. The functionality of RAM is demonstrated through a hardware simulator, showing how values in registers change over time and how to manipulate these values using the simulator's GUI and clock mechanism.

25:12

🛠️ Constructing a Family of 16-bit RAM Chips

The script outlines the plan to build a family of 16-bit RAM chips with varying sizes, starting from RAM8 with 8 registers to RAM16K for the Hack computer platform. Each chip will share a common architecture but differ in the number of registers and address bits required. The paragraph also addresses the question of why RAM is called 'random access memory,' highlighting its unique capability to access any register randomly in constant time, irrespective of the chip's size. The importance and remarkable nature of this functionality are emphasized, setting the stage for building this feature using HDL in a future unit.

🔢 Introducing Counters and Accounting Operations

The final paragraph introduces the concept of counters, which are essential for implementing accounting operations in computer systems. It indicates that counters will be the focus of the next unit, suggesting a progression from understanding basic memory operations to more complex functionalities that involve keeping track of values and operations within a computer system.

Mindmap

Keywords

💡Sequential Logic

Sequential logic is a fundamental concept in digital electronics that deals with the design of circuits whose outputs depend not only on the current inputs but also on the past history of inputs. In the context of the video, sequential logic is foundational to understanding how memory units operate over time, as it is integral to the functioning of registers and memory devices.

💡Von Neumann Architecture

The Von Neumann architecture refers to a computer organization where the instruction and data are stored in the same read/write memory. The video revisits this architecture to emphasize the importance of memory in computing systems. It is the basis for the discussion on different types of memory and their roles within a computer system.

💡Memory

Memory in computer hardware encompasses various types of storage used by a computer to hold information. The script discusses main memory, which includes RAM (Random Access Memory), and secondary memory like hard disks. Memory is central to the video's theme, as it is essential for storing data and instructions that a computer operates on.

💡RAM (Random Access Memory)

RAM stands for Random Access Memory and is a type of computer memory that can be read from and written to in any order, hence the term 'random access.' It is volatile memory, meaning it loses its contents when power is removed. The script uses RAM as an example of how data and instructions are stored and accessed in a computer.

💡Volatile Memory

Volatile memory is a type of computer memory that requires power to maintain its data. The script mentions that when the computer's power is turned off, RAM is erased, illustrating the concept of volatility in the context of computer memory.

💡Non-Volatile Memory

Non-volatile memory retains stored information even when not powered. The video contrasts this with volatile memory, noting that information on disks and flash memory persists without a power supply, highlighting the importance of non-volatility for long-term data storage.

💡Register

A register is a small and fast storage location within a processor or a memory unit. The script describes registers as the basic building blocks of memory, capable of holding binary values and being manipulated through operations like loading new values.

💡State

In the context of the video, 'state' refers to the value currently stored in a register. The script explains that the state is what the internal circuits of the register express at any given time, creating an illusion of storage.

💡Load Bit

The load bit is a control signal used in registers to initiate the process of loading a new value into the register. The script demonstrates how asserting the load bit (setting it to 1) allows a new value to be written into the register, which is central to the operation of memory units.

💡Address

An address is a unique identifier for a location in memory. The script explains that in a RAM device, an address is used to select a specific register for reading or writing operations, illustrating the concept of addressing in the context of memory access.

💡RAM8, RAM64, RAM4K, RAM16K

These terms refer to different sizes of RAM chips that the video script mentions will be built during the course. RAM8 has 8 registers, RAM64 has 64, and RAM4K and RAM16K have 4,096 and 16,384 registers, respectively. These chips are part of the progression towards building a larger memory system for the Hack computer platform.

Highlights

Introduction to building memory units for a computer, starting with revisiting the Von Neumann architecture and emphasizing the role of memory.

Explanation of different types of memory in computer hardware, including main memory, secondary memory, and the distinction between volatile and non-volatile memory.

Description of RAM (Random Access Memory) as the primary storage for data and program instructions in a computer.

Introduction to the concept of memory from both a physical perspective of building memory and a logical perspective of its organization.

Focus on the logical considerations of RAM as the most important element of a computer's main memory.

Discussion of the elementary building blocks of memory, starting with the function of a single bit register.

Concept of a register's state and how it represents the current value stored within the register.

Demonstration of how to read the value of a register by probing the output.

Process of writing a new value into a register by setting the input value and asserting the load bit.

Introduction to the hardware simulator and a practical example of a register chip in action.

Explanation of the clock input's role in simulating the progression of time within a computer.

Demonstration of changing the contents of a register using the hardware simulator.

Transition to building memory units by stacking registers to create an abstraction of a multi-bit number.

Description of RAM as a sequence of addressable registers and the importance of selecting a specific register for operation.

Explanation of how many bits are needed to select a register from a set using binary code, based on the logarithm of the number of registers.

Introduction to the RAM unit's functionality, including reading and writing values using address inputs and the load bit.

Demonstration of a RAM chip in action, showing how values of registers change over time using the hardware simulator.

Overview of the different RAM chips that will be built, including RAM8, RAM64, and larger chips up to RAM16K, tailored for the Hack computer platform.

Discussion on the significance of RAM as random access memory, highlighting its ability to access any register in constant time regardless of size.

Anticipation of building the RAM functionality using HDL in the following lessons.

Introduction to the next unit, which will cover the chip that implements counting operations, known as counters.

Transcripts

play00:04

So now that we went through the theory of sequential logic and time, we can go ahead

play00:09

and begin building the memory units that we need in order to build our computer.

play00:15

Before we do that, let's revisit the Von Neumann architecture.

play00:20

And observe that one of the major players of this architecture

play00:23

is something called memory.

play00:25

Now, when we say memory in computer hardware, we mean many different things.

play00:31

First of all there is main memory,

play00:33

which consists of the memory that resides actually inside the computer and

play00:37

hard-wired into the computer's motherboard.

play00:42

And this main memory also divides into several different categories of memories.

play00:48

The most famous one is called RAM or the Random Access Memory.

play00:52

And then there's secondary memory like hard-disks and

play00:56

memory sticks and and so on.

play00:59

And then there's also the distinction between volatile and non-volatile memory.

play01:04

For example, when you pull out the plug of the computer,

play01:08

the RAM is effectively erased.

play01:11

At the same time the information which is stored on the disks and on, on,

play01:16

flash memory and so

play01:17

on, persists even when the computer is not connected to a power supply.

play01:22

So, we have this distinction.

play01:25

The RAM is used to store both the data on which our programs operate as well as

play01:32

the instructions, which are the building blocks of the programs themselves.

play01:37

And we will talk about this duality later on in the course

play01:41

when we talk about the overall computer architecture.

play01:45

And finally, another comment that I want to make before we actually start

play01:49

this unit, is that like anything else when we talk about memory.

play01:53

We can talk about it from a physical perspective,

play01:55

how we actually build the memory, what kind of the technology do we, do we,

play02:00

do we use in order to realize the memory.

play02:04

And we can also talk about the logical organization of the memory.

play02:09

Now, in this unit, and in this course,

play02:11

in general, we always focus on logical considerations.

play02:16

And we focus in particular on the RAM unit, which is once again,

play02:20

the most important element of the computer's main memory.

play02:25

All right.

play02:26

Now, before we actually talk about the RAM, we have to step back and

play02:30

talk about the elementary building blocks from which memory is designed.

play02:36

So, the previous unit ended up with a description of how

play02:40

a single bit register works.

play02:43

And it doesn't take a big stretch of imagination to understand that you

play02:47

can take several such one bit register and put them one next to the other.

play02:52

And by doing this, you can create an abstraction of a 16-bit number.

play02:58

And we call this abstraction register.

play03:00

The width of the register, in general, is, is, is a parameter.

play03:06

We call it w.

play03:08

And in some computers it's 16-bit,

play03:10

in other computers it may be 32-bits or 64-bit.

play03:13

It turns out that its not a terribly interesting parameter because everything

play03:18

that they say in this lecture works for any width of,

play03:22

of memory that you might encounter.

play03:24

But from now on I'm going to use w equals 16 because we are building

play03:29

a 16-bit computer so we do this without loss of generality.

play03:35

Another thing that I'd like to say is that I'm going to use a lot the term

play03:39

register's state.

play03:40

And in fact, this term was introduced in the previous unit as well.

play03:45

State is the value which is currently stored,

play03:49

quote unquote, inside the register.

play03:52

To say it more precisely, this is the value which is currently

play03:57

being expressed by the internal circuits of, of, the register.

play04:02

This is a more, I think, accurate description of what's going on.

play04:05

It creates an illusion of, of storage if you will.

play04:10

All right, so here's the register.

play04:13

And let's take a user's perspective of this of this device.

play04:18

How do we read the value of this register?

play04:21

Well, it turns out that all we have to do is probe the out, output.

play04:27

Why?

play04:28

Because at any given point of time, the out,

play04:30

output simply emits the state of the register.

play04:34

So if we just look up the value that comes out from out,

play04:37

we know what is stored inside the register in this particular time cycle.

play04:43

Now let us talk about how we write a new value into the register.

play04:49

So, you know,

play04:50

we want to we want the register to remember the number 17 from now on.

play04:56

What do we do?

play04:57

Well, we set in to this new value, let's say 17, and we assert the load bit.

play05:04

When I say assert the load bit, I mean we set the load bit to 1.

play05:08

So here's what will happen.

play05:10

The register state becomes v.

play05:13

And from the next cycle onward,

play05:16

the output of the register will also start emitting this value v.

play05:21

So from the next cycle onward,

play05:24

the register will effectively store the new value 17.

play05:29

And it will keep on storing this value forever until we decide to change

play05:33

this value in the very same manner that I just described.

play05:38

All right, so we are now ready to give you an example of a register chip in action.

play05:44

And in order to do this, we will fire up the hardware simulator and

play05:49

show you how register chip works.

play05:52

So to get started I, I am going to load one of my built-in register chips.

play05:58

And in order to do it, I will select the nand2tetris folder.

play06:06

And within it I'm going to tools, and within tools I'm going to builtinChips.

play06:13

And by the way, everything that I do, you can do also on your computer.

play06:17

You know, all these folders are available to you also if

play06:21

of course if you have downloaded the nand2tetris suite to your computer.

play06:26

So I'm selecting the builtinChips directory and opening it.

play06:31

And I see that they have all sorts of built in chips available to me.

play06:37

And all these chips are part of the hack chip set.

play06:40

You know, these are chips that will come to play when we

play06:43

piece together the computer architecture.

play06:46

In one of these chips is called DRegister.

play06:50

So let us load the DRegister built in chip into the simulator.

play06:55

And if I look at the HDL code,

play06:58

I see that the HDL code is a little bit strange because it's a built in chip.

play07:03

You don't have to worry about it,

play07:04

because you don't have to build built in chips in, in this course.

play07:08

You have to build them in plain HDL.

play07:11

But this code here says that this chip is actually implemented by a Java class

play07:16

called DRegister which delivers the functionality of, of a 16-bit register.

play07:24

So it also says that this chip is clocked.

play07:28

Because, you know, it's, it's a register chip so it receives a clock input.

play07:33

And because the HDL includes the magical word clocked,

play07:39

we see that a clock icon has opened up in

play07:44

the control panel of the of the simulator.

play07:50

And this clock is used to simulate the progression of time within the computer,

play07:56

or more accurately, it simulates, it can be used to simulate a train.

play08:01

Of cycles.

play08:03

So each time I click this clock icon, I move one phase in the cycle.

play08:10

So, you know, this was a tick, this is a tock.

play08:13

Tick, tock, tick, tock, tick, tock.

play08:19

So I'm progressing the clock manually.

play08:24

And of course I can also write a test script that includes a command like

play08:29

while true, tick tock, which will cause the clock to to tick and tock forever.

play08:36

Or I can say something like repeat 10,000, tick tocks and so on.

play08:43

So but now we're going to do everything manually.

play08:46

And that's what you normally do when you build a chip and, and test it for

play08:49

the first time.

play08:50

So because this chip is implemented by a Java class, we, we

play08:56

added to the to these Java implementations all sorts of nice features.

play09:01

For example the D register has a GUI that

play09:07

it's a GUI side effect that shows what is the current state,

play09:12

or the current contents of this register.

play09:15

Happens to be 0, because this is the default.

play09:18

So let's go ahead and

play09:21

change the the contents of this register to something else.

play09:26

In particular, let's change the register to 17,

play09:32

my favorite number.

play09:36

So I'm changing the in input, which is a 16-bit value, into 17.

play09:43

And I will run the clock forward,

play09:47

and I see that actually, nothing seems to happen.

play09:52

The contents of the register remains 0, and so is the output of the register.

play09:58

Well, nothing happens because I forgot to assert the load bit.

play10:01

So let's go to the load bit and turn it into 1.

play10:05

And then we go back to the clock.

play10:07

We do a tick.

play10:10

And we see that the contents of the register changed to 17,

play10:14

which is very nice.

play10:15

But the output of the register is still 0.

play10:18

And that's because, you know, it takes a complete cycle for

play10:22

the register to actually stabilize and begin to emit the new state.

play10:29

So let's do a tock.

play10:31

And indeed,

play10:31

I see that once I move to the next cycle, the output of the register is also 17.

play10:36

And from now on the register is in a stable state, and the state is 17.

play10:43

And it will remain 17 until a point of time

play10:48

in which I will decide to change it into something else.

play10:52

Now, you know, one thing which I may want to do is set the the load bit to 0.

play10:59

And this will serve as a safety so that if inadvertently,

play11:04

you know, someone changes the value of this register

play11:08

nothing will happen until the load bit will be asserted.

play11:11

So, so let's go ahead and, and change the value of the register which is

play11:16

presently 17 to let's say 23, which is another one of my favorite numbers.

play11:23

So 23, and I set the load bit to 1.

play11:29

I do a tick.

play11:31

And I see that now the register is kind of an inconsistent state

play11:36

because the state of the register is 23, but the output is still 17.

play11:41

Once again, I have to complete the cycle in order to to get to the,

play11:46

the register into a stable state.

play11:47

So I do a tock.

play11:49

And now the register is 23.

play11:51

But both the state, the internal state of the register is 23.

play11:56

And also the, the register is itself has committed to this new value, and

play12:00

it emits the value 23 as well.

play12:04

So now I continue to click the clock, and the value of, of the register became 23.

play12:11

So, you know, this has been a demo of the typical behavior of the register.

play12:18

And let's continue with the lecture.

play12:21

So now that we understand how the basic building blocks of memory work, registers,

play12:26

we can begin to stack them together and build actual memory units.

play12:32

And the general architecture of of these units looks as follows.

play12:38

In fact, I can talk about it in, in terms of abstraction.

play12:42

The RAM abstraction, or the way we are used to think about memories,

play12:47

is we think about them as a sequence of addressable registers.

play12:51

It's as if every register has an address that ranges from 0 to

play12:56

n minus 1 in case of a, of a RAM device that consists of, of n registers.

play13:03

Now, there's one thing which is very important to emphasize, which makes this

play13:08

whole notion of RAM much easier to, to understand and to to comprehend.

play13:13

And this is the fact that irrespective of how many registers you have in this

play13:19

RAM unit, and it may well have millions of such registers, at any given point of

play13:24

time, only one register is selected and only one register is interesting.

play13:31

All the other registers don't take any part in the game, so to speak.

play13:36

So at any given point of time,

play13:38

we have to say which is the register on which we want to operate.

play13:42

Which is the register that we want to read, or

play13:44

which is the register whose value we want to change.

play13:49

So we have to make a selection.

play13:51

We have to determine this the address of this register.

play13:54

And we do it using an input, which we call address.

play13:58

So think about it.

play13:59

If we have to select one out of n possible registers using

play14:06

some sort of a binary code, how many bits do we need in order to create such a code?

play14:11

Well, it turns out that we need log of n such bits.

play14:16

For example, if we have eight registers we need three bits, right?

play14:21

Log of 8 in base 2 is 3.

play14:24

So register number 0 will be represented with a code 000.

play14:29

Repre, register number 7 will be represented with a code 111.

play14:33

And then we have all the possibilities in the middle.

play14:38

So the length of the address input, which we call k in this diagram

play14:44

equals log of n, the number of registers in this particular RAM device.

play14:50

And finally, we have this w, which as I said before is not terribly interesting.

play14:55

w, in our computer, happens to be 16.

play14:57

But if you want you, we can make this w equal some other number like 64.

play15:03

And everything that we say from now,

play15:05

now until the end of the unit would be just the same.

play15:08

So without loss of generality, w equals 16.

play15:12

Finally, I want to I want us all to remember that this is a sequential chip.

play15:19

It depends on a clock input,

play15:22

and that's why we have this little triangle in the diagram.

play15:26

And this means that it has a clocked behavior.

play15:29

And the behavior is defined as follows.

play15:33

If we use the label M to stand for the state of the selected register,

play15:39

then if load equals 1 M becomes in.

play15:43

And from the next cycle onward, the output of this register become M as well.

play15:49

And if load is not 1,

play15:51

the output of this register will be exactly as it was before, okay?

play15:56

So this is the basic functionality of of this RAM unit.

play16:02

Let us say a few words about how we read and write values using this RAM device.

play16:08

So, to read a particular register, we do two things.

play16:13

First of all, we set the address of the RAM unit to the desired register number or

play16:19

address, you know, register number five or something like this.

play16:23

And then we probe the out of the register we probe the out of the RAM unit.

play16:30

And the out of the RAM unit is built in such a way.

play16:33

I mean, the, the internal circuitry is built in such a way that the out

play16:37

always emits the state of the selected register.

play16:42

So in this case, it will emit the state of register number i.

play16:48

So that's how we read one register out of the millions of registers

play16:53

that may be present in this RAM device.

play16:56

What about writing?

play16:57

Well writing is slightly more involved.

play17:00

If we want to write something into

play17:03

register number five using the same example, we set the address to five.

play17:07

We set in to 17 for example.

play17:11

We assert the load bit and here is what will happen.

play17:15

The state of register number 5 will become 17.

play17:19

And from the next cycle onward, the RAM will start to output this value as well.

play17:25

And from now until further notice register number 5 will contain the value 17.

play17:34

Until we, we change it again using precisely the same procedure.

play17:39

So we know how to read and

play17:40

write individual registers from the given RAM device.

play17:47

Okay I would now to give you an example of a RAM chip in action.

play17:52

So once again, we're going to fire up the hardware simulator and

play17:56

we'll see some examples of, of how the values of the registers change over time.

play18:04

In this demo, we're going to illustrate how a RAM device operates

play18:09

using the how to simulator.

play18:11

So let's open our built in chip directory and

play18:16

look for some RAM device.

play18:19

We have several RAM devices in the hex chip set.

play18:23

Let's select the RAM8.

play18:24

So I load the chip and this is a built in chip.

play18:28

It comes a nice GUI side effect which we see here on the right-hand side.

play18:36

And I can use this GUI in order to put some values inside the RAM so let's do it.

play18:43

So I'm just putting some you know,

play18:47

random numbers really inside some of the registers.

play18:53

And we can leave some registers as zero.

play18:59

I'm just entering values.

play19:04

You know, nothing interesting here.

play19:06

And, and that's it.

play19:09

Now it should be understood that what I did here is is kind of cheating.

play19:14

That's not how you manipulate a RAM device in a low level fashion.

play19:20

So, so, so let's, let's go ahead and do it the right way so to speak.

play19:24

Let's decide that we want to read say, register number 5.

play19:29

How do I read the contents of register number 5?

play19:33

Well I go to the address input of the RAM device and

play19:38

I put the number 5 there, and then nothing seems to happen.

play19:43

But if I run the clock, I see that the out output

play19:48

of the RAM device begins to emit the value 8373,

play19:53

which happens to be the contents of the selected register or register number 5.

play19:58

If I want read another register, let's say register number 1.

play20:03

Well I change the address to number 1, I run the clock and

play20:07

I see that I get the contents of register number 1.

play20:11

What about changing the contents of some of these registers?

play20:14

Let's say they want to set the contents of register number 4 to 12.

play20:21

So I go to this address here to, to,

play20:24

I'm sorry I go to the address input of the RAM.

play20:28

I set the address to 4.

play20:32

I assert the load bit to enable the right operation.

play20:38

I set the value of the in input to the desired value which we

play20:43

decided is 12 and then I run the clock.

play20:48

So in the first tick,

play20:51

I see that the internal state of register number 4 became a 12.

play20:56

But the output of the RAM device is still something else.

play21:01

In order to commit the RAM to the new value, I have to complete the cycle.

play21:06

So I do it, and I see that now the RAM device is also emitting

play21:13

the value of the selected register which happens to be register number 4.

play21:17

So let's say that I want to change another register.

play21:20

Say register number 2.

play21:23

Let us set register number 2 to the number 17.

play21:28

So, I go to to the address input.

play21:33

I set it to 2.

play21:34

I go to the input.

play21:37

To the in input, I change it to 17.

play21:40

I run the clock.

play21:43

And I see that the register number 2 indeed changed to 17.

play21:49

And the out output of the RAM is now emitting this value as well.

play21:55

So, this has been a demonstration of how a RAM unit operates.

play22:01

Now, in this particular course,

play22:04

we are going to build a family of 16-bit RAM chips.

play22:10

All of them are going to have exactly the same generic architecture.

play22:15

But the details are going to be slightly different.

play22:20

So, here are the chips that we are actually going to build.

play22:24

We'll build a RAM8 consisting of 8 registers, and

play22:28

the length of the address bit is going to be log of 8, which is 3.

play22:34

Log to the base to 2 of 8.

play22:37

RAM64 contains 64 registers and 6 address bits.

play22:43

Then we'll create a RAM whose size is half k of registers and

play22:48

then we'll continue with a RAM4K and RAM16K.

play22:54

Which is what we finally need for our hack computer platform.

play23:00

So these are the five chips that we are going to build and the construction of

play23:05

these chips is going to be surprisingly simple as you will see in the next unit.

play23:12

Now a sensible question is why do we need these these five particular chips?

play23:18

And the answer is quite simply because that's what we need

play23:22

in order to build our Hack computer.

play23:25

And another interesting question that I side stepped until now is,

play23:29

why is this thing called RAM?

play23:32

To begin with.

play23:33

Well, RAM stands for random access memory.

play23:39

And I would like to note at the end of this unit, that

play23:45

maybe we didn't give this this chip the, the respect that, it actually deserves.

play23:52

Because something really remarkable happens with this chip, and

play23:56

here's what actually happens.

play23:58

Irrespective of the size of this chip, irre,

play24:01

irrespective of whether it has 8 registers or 8 million registers,

play24:07

I can select every register from this chip and apply an operation on

play24:12

it in exactly the same axis time which is truly remarkable.

play24:18

All I have to do is enter the address of this register

play24:23

into the address input and boom, this register is going to be selected and

play24:28

all the other registers are going to be ignored.

play24:31

Okay now there is no boom in reality, I'm doing it for dramatic effect.

play24:36

But actually it's quite dramatic because once again if I now want to select

play24:41

the register number of 5,000, all I have to do is enter 5,000 and boom,

play24:46

this register becomes irrelevant and register number 5,000 becomes active and,

play24:52

and it, it it kind of opens up for business.

play24:55

And it doesn't matter if I have 8 million registers or 8 billion registers.

play25:01

I have this basic ability to select at random any register

play25:06

in this configuration and either read it or write it in the same access time.

play25:11

So this is truly a remarkable functionality and later on in this week,

play25:15

you will actually build this functionality using HDL.

play25:20

But before we do so, we have one more chip that we need to describe.

play25:26

And this is the chip that implements accounting operation.

play25:30

And the chip is called counters.

play25:32

And counter, in singular, and this will be the subject of our next unit.

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
Computer MemoryVon NeumannRAM ArchitectureRandom AccessMain MemoryData StorageInstruction SetSequential LogicHardware SimulationNand2Tetris
¿Necesitas un resumen en inglés?