# Project 3 Combinational Circuits

## Introduction

This project requires several circuit designs that are slightly more involved. They are presented with higher-level, natural-worded descriptions, and your job is to create circuits that behave according to the descriptions.

When starting circuit designs from higher-level, purely behavioral descriptions like those presented below, it’s a good idea to identify and follow a set of good design practices. In general, good design practices follow several steps: first, be sure you clearly understand the design intent, and exactly what is being asked; second, cast the worded description into a formalism (like a block diagram and truth table showing all inputs & outputs, and their functional relationships); third, capture a circuit based on the formalisms (that is, write a Verilog description); and fourth, implement the circuit and verify its performance. Each of the requirements below present problems that are involved enough that all of these steps should be followed.

#### Before you begin, you should:

• Have a working knowledge of Vivado and a functioning Blackboard;
• Be comfortable working with logic equations and logic circuits;
• Be able to describe logic circuits in Verilog;
• Know how to implement logic circuits on the Blackboard.

#### After you’re done, you should:

• Be able to write more complex Verilog descriptions;
• Be able to analyze more complex descriptions, and design circuits to implement the behavior;
• Know how to find a minimum expression for any given logic requirement.

## Background

Each of the problems in this project describe a two-state output (either on or off, true or false, 1 or 0, etc.) that is a logic function of some number of two-state (or binary) inputs. It follows that each of these problems can be represented using a truth table, and the truth table forms the specification for a circuit. The truth table exactly specifies the behavior of a circuit, but not the structure. Before a physical circuit can be constructed, its structure must be defined.

For any given behavior description, any number of physical/structural circuits could be built to implement the same behavior. Of all the possible circuits that could be constructed, our goal is to find the most efficient one. (Note: “efficiency” could imply several end goals – the most efficient circuit could use the fewest number of transistors, or it could use the least amount of power, or it could run the fastest. All of these end-points could result in different circuits. For the most part, we will look for the circuit that uses the fewest number of transistors). Several methods have evolved to find the most efficient circuit, and they are discussed in the topic documents.

To solve these problems, you should cast the described behavior in a truth table, then analyze/process that truth table to find a minimal circuit (using the methods described in the topic documents), then capture the circuit in the Vivado design tool, and then implement and verify your design.

## Requirements

#### 1. Design a five-way light switch

A room has five doors with a light switch next to each door, and one light in the center of the room. Design a circuit that allows any light switch to change the state of the light (that is, if the light is currently off, any switch can turn it on, and vice-versa). Use five switches and one LED on your Blackboard to build and demonstrate your circuit.

Note that each of the five inputs can be on or off (a ‘1’ or a ‘0’), so you can represent all possible combinations of inputs in a truth table. The first row (all 0’s) represents a state where the light is OFF. From there, if any input toggles to a “1”, the light toggles ON. When the output is on, any new input toggle will set the light OFF again, and then any additional toggle will turn the light back ON, etc. You must cast this behavior into a truth table, and then use that truth table to capture a circuit.

#### 2. Design a majority-of-five circuit

A majority-of-five circuit has five inputs, and one output that is asserted whenever any three or more inputs are asserted. Design a minimized circuit using K-maps, and implement your circuit on the Blackboard by writing Verilog code for your equations. For full credit, you must thoroughly simulate your circuit as well. The tutorial document can help guide your efforts on this problem.

#### 3. Design a temperature indicator

A digital thermometer produces a continuously varying voltage signal between 0V and 5V, where 0V represents 0 degrees and 5V represents 100 degrees. This signal is digitized using an Analog-to-Digital converter that produces an 8-bit binary number proportional to temperature, where 00000000 represents 0 degrees and 11111111 represents 100 degrees (so each binary number represents a multiple of 100/256 degrees).

Design a logic circuit that outputs a logic high signal whenever the temperature is greater than 62.5 degrees but less than 72.5 degrees. Use K-maps to define the circuit, then create and simulate a Verilog description (you will need to create a test bench), and then program the Blackboard with your circuit. On the Blackboard, use the eight slide switches to emulate the thermometer output, and an LED to indicate when the temperature is within the desired range.

Hint: You can make an excel spreadsheet with 0-255 in one column, scaled numbers in the next column (by multiplying the first column by 100/254, and rounding to 1 digit after the decimal point), and binary numbers in the third column (by using excel’s DEC2BIN function on the first column of decimal numbers). Then you can identify the numbers in the required range, and devise a circuit to detect only those numbers.

Example: Binary 10110000 would convert to 68.75 degrees (68.8 degrees after rounding), which is within the desired range, and so would cause the output signal to run high.

## Challenges

#### 1. Design an odd number detector (and an even number detector)

Implement a circuit that illuminates an LED when an odd number of the eight slide switches are set to “1”, and illuminates a second LED when an even number of slide switches are set to “1”.

#### 2. Enhance the odd number detector with pushbutton inputs

Illuminate a second LED when the odd LED in the circuit above is illuminated, and 0, 2, or all 4 of the pushbuttons are pressed.