# CS 3330: 2330 Lite

This page does not represent the most current semester of this course; it is present merely as an archive.

# 1 Oversimplified Electronics

A wire is like a hose; voltage measures water pressure and current measures water flow.

In a chip we generalize the world into two kinds of wires: those that have high voltage (on or live or 1) and those that have low voltage (off or ground or 0).

We will mostly ignore current in this course, besides two observations:

• Current happens in a chip when we change wires between their high- and low-voltage states. There is also some (though less) current even when nothing is changing.
• Current × voltage = energy; energy creates heat and can make things not work right.

# 2 Transistors

A transistor is like a pressure-activated valve. There are three wires into it; if voltage is applied to one of them then current can flow between the other two.

There are many kinds of transistors, but they all behave like voltage-actuated current valves.

# 3 Larger Circuit Components

Transistors can be used to construct a variety of higher-level components often called gates. How this is done is discussed in ECE/CS 2330. For our purposes, you just need to know about the behavior of the following components.

Hpyerphysics has a summary of how gates and inverters are made from transistors if you are curious.

## 3.1 Boolean Gates

Boolean logic consists of the operators and, or, and not.

### 3.1.1 And

The expression `x & y` in programming languages is on if `x` and `y` are on, off if either `x` or `y` is off. In circuit diagrams we draw and as a D-shaped gate: . The output wire has high voltage only if both input wires have high voltage.

### 3.1.2 Or

The expression `x | y` in programming languages is on if either `x` or `y` is on, off if both `x` and `y` are off. In circuit diagrams we draw or as a spade-shaped gate: . The output wire has high voltage if either of the input wires has high voltage.

### 3.1.3 Not

The expression `~x` in programming languages is on if `x` is off, off is `x` is on. In circuit diagrams we draw not as little circle, often attached to other gates. If we need to draw it by itself, we put it on a triangle: . The output wire has high voltage if the input is low, low if the input is high.

### 3.1.4 Exclusive Or

The expression `x ^ y` in programming languages is on if `x | y` but not `x & y`. In circuit diagrams we draw exclusive-or or xor as a spade-shaped gate with an extra line over the inputs: . The output wire has high voltage if one input is high and the other is low.

### 3.1.5 Others

The not circle can be attached to any input or output of any other gate symbol to make a new symbol. Two of these, the nand and nor , are common enough to have their own name and own symbol, but do not have a standard operator representation in code (we’d have to use `~(x & y)` for nand and `~(x | y)` for nor).

## 3.2 Multiplexer

A multiplexer, or mux, selects one of a set of inputs to be the output. Given 2n inputs, it requires n selector inputs to decide which one to use. Multiplexers are typically drawn as trapezoids, though out textbook uses rounded boxes with the letters `MUX` in them instead.

Multiplexers are kind of like the hardware equivalent of an array. You can learn more at wikipedia.

## 3.3 Math

The ALU (Arithmetic Logic Unit) contains particular series of logic gates that can perform operations like addition and subtraction on groups of wires called words. We’ll basically ignore how these work in this class.

## 3.4 Register

A hardware register is made up of one or more flip-flops. The exact kind of flip-flop is not important for this course, though the D-type flip-flop has the behavior we most often discuss.

A register has an input, an output, and a clock input. Normally the output is constant, ignoring the input completely. However, on the rising edge of the clock input (that is, as the clock input transitions from low- to high-voltage) the register changes the output it is producing to match the current input. It will continue to produce that new output until the next rising clock edge.

This course will discuss several kinds of registers, including pipeline registers (which have gated input to simulate bubble and stall behaviors); program registers (which are addressable as operands in code); status registers (which impact program behavior but are not accessible as operands); and register files (which are muxed sets of program registers). All are made up of hardware registers under the hood.

# 4 Other sources

Prof. Kurmas from Grand Valley State University has a video you might find useful if you want another perspective on this.

Hyperphysics has a summary of how gates are made from transistors. Their discussion uses a different kind of transistor than is commonly used in microchips, but the ideas generally hold.