# Digital Component Types¶

Read time: 21 minutes (5459 words)

Before we get serious about building our simulator, there is one important aspect of basic digital components we need to discuss.

Some parts in a digital system act as a simple function, mapping a set of inputs directly into a set of outputs. These components react immediately to any change on an input and after a short period of time, a new set of outputs will appear.

These components are called combinational, and they obey George Boole’s algebraic rules. In fact, we can use Boolean Algebra to derive the internal structure of these components.

We still need to activate the simulated combinational components in order to calculate the current set of outputs leaving that component. But this activation is not really driven by the master system clock. It is driven by the changes that arrive from other components. We will need to consider this when we set up the real simulator control system.

A good example of a combinational component is the ALU. This device does not need a clock. Instead, it simply reacts to the incoming signals, and produces the desired outputs. The is no memory of the action that occurred. In our simulator, we need to activate this part, but that activation is not really dependent on the system clock.

## Sequential Components¶

The second class of digital components are activated by a clock signal, and what they do depends on their internal structure and the set of input signals available. We call these components sequential and these components maintain internal data, which can be used to alter the outputs by including that internal data with the new signal values.

### Registers¶

The simplest sequential component is called a register. This component has a single data input signal, and a single data output signal. When the clock arrives, the output is updated with the current input value. No change will occur on that output until the next clock signal arrives. The register “holds” a value for the period of one clock. Such devices can be used to delay a signal so it arrives at another point in the system when we need it there, not before!

### Menory Components¶

We can collect a group of registers in an array and store more than one value in the resulting component. We will need to add additional input signals to decide which register is to receive the new input data when the clock arrives, We can decide whether to update the internal store based on one input signal, .

These sequential components may deliver different outputs, even when no changes are seen on an input signal. A simple counter is an example of this. Counters need a way to “reset” their internal store to a known (zero) value. At all other times, when a clock signal arrives, the output increments to the next value. Devices of this sort do not need to count sequentially, they could be designed using a look-up table, and return any value desired. In that case, we probably should not call the resulting component a “counter”, but rather, some kind of simple “state machine”.

Some memory elements cannot be altered while the system is running. The instruction memory should act like this, so the program cannot be altered.

Note

In the “old days” it was fairly common for programs to alter themselves. This kind of tricky programming is not used these days. YMMV!

Obviously, in a modern machine, we need to provide a way to “load” the program, usually from a file. However, once loaded, that memory will not provide a way to modify the contents.

Other memory elements can be updated. Here an incoming data signal, combined with an address signal will specify the single memory cell to be updated. The clock will cause that data item to be stored. We need to provide a special signal that tells the memory component to either deliver the memory stored at a specified address, or to write the provided data item at the specified address.

### attiny85 Memory¶

The attiny85 has several internal memory components and they are very different in design.

The most important memory area is the register file This memory component is divided into several functional areas.

#### Internal Registers¶

The The heart of the system is the set of internal registers, named R0 to R31. Each of these registers is 8-bits wide. THe register memory is special in that it supports reading two separate memory cells at the same time. This is valuable, since these two data paths are routed to the ALU for processing. THat means that this memory component needs two input paths, and two output paths. Normally, only one data path is used for writing.

#### I/O Registers¶

A large number of locations in the memory unit are associated with I/O operations. There are a number of special locations in this bank of memory locations where individual buts connect to hardware devices that do a variety of tasks. This kind on functionality is called “Memory-Mapped I/O”. The memory locations can be “read” and “written” to as anoy other location, but what happens in each case depends on the hardware connected to that location.

#### User Memory¶

Normal User Memory is just a bank of 8-bit memory locations. The programmer can use these for program control as needed.

#### Stack Memory¶

The AVR family supports using part of the user memory to hold the system stack. This is a vital area, usually placed at the highest address in available memory. “Push” operations will cause the stack to grow downward, to lower addresses, and “Pop” operations, shrink the stack towards the top.

Warning

Uncontrolled use of the stack can lead to a crash. This occurs when the stack grows large enough to step on user data. Managing the stack is an important part of programming!