# Project 4 Basic Combinational Building Blocks

4100

## Introduction

This project presents the design of four logic circuits are commonly used as components in larger, more complex circuits. Although they can be used by themselves in simpler settings, these components are more typically thought of as basic building blocks in larger, more involved circuits.

The four circuits are described using structural methods based on logic operators and logic gates (i.e., AND, OR, and NOT functions). In the project design requirements, these same circuits are defined in behavioral Verilog. This is a typical “text book” approach – logic circuits are introduced and described using structural methods, but designed and implemented using behavioral methods. After an initial learning phase involving several design projects, structural descriptions will largely be abandoned in favor of purely behavioral descriptions (recall that behavioral descriptions only define a circuit’s input-output relationships, but say nothing about how a circuit might be implemented).

Although it is easier, simpler and more natural to define circuits behaviorally, any given circuit description must be translated into a detailed structural form before it can be implemented. For many years, the main job of a design engineer was translating loose behavioral descriptions into detailed structural specifications. In more recent times, logic synthesizer tools took over that task. Today, virtually all digital circuit designs use logic synthesizers, and all modern design tools (like Vivado) include synthesizers as essential components.

#### Before you begin, you should:

• Be able to find a minimum circuit for any given behavioral description;
• Understand the general design flow for designing any digital circuit;
• Be comfortable using Vivado and the Boolean board to define and implement designs.

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

• Understand the design and use of multiplexors, decoders, encoders and shifters;
• Be comfortable defining slightly larger circuits;
• Be comfortable using the simulator for routine circuits.

## Background

The four basic logic circuits examined in this project include a multiplexer, a decoder, an encoder, and a shifter. Each of these circuits are developed and discussed in the topic documents, and code examples are provided in the tutorial. After learning about these circuits and their applications, you will use them in several designs.

## Requirements

Each of the requirements below involves the design and simulation of an independent combinational circuit. If you have multiple source files and/or testbenches in a single project, you can select which one is “active” by right-clicking on the name and selecting “set as top” from the pull-down menu. Three small boxes in a triangle pattern next to a source file name indicates which source file is active. When you run a process like synthesis or simulation, the tools will use the currently active source file(s). Before clicking Run Behavioral Simulation, right click on the simulation source file you want to simulate and select Set as Top.

Note: The videos below are recorded on the Blackboard, but the behavior on the Boolean board is entirely similar.

#### 1. Multiplexor

Design and simulate a 4:1 multiplexor, and then implement it in the Boolean board. Use two slide switches to select the multiplexor input, connect the four pushbuttons to the multiplexor input signals, and connect the output to an LED. Verify the circuit works correctly.

Next, modify your code to create a 4:1 multiplexor where the inputs and output are four bits each. Connect the inputs of the four multiplexor channels to four unqiue slide swithces, connect the outputs to four LEDs, and control the select signals with two pushbuttons. Simulate the circuit to verify that it works correctly, and then program it into your Boolean board.

#### 2. Decoder

Implement a decoder circuit that can enable one of four LEDs to be turned on when a corresponding pushbutton is pressed. You will need a 2:4 decoder whose inputs are driven from two slide switches, and whose outputs are AND’ed with pushbutton inputs. The AND gate outputs should drive four LEDs. When the circuit is implemented, the four pushbuttons should turn on the LEDs, but only if the slide switches have been set to enable that channel.

#### 3. Encoder

Create a Verilog description of a 4:2 priority encoder and a test bench that checks for all possible input patterns. Simulate the encoder to verify that it works properly. You do not need to implement this circuit.

#### 4. Shifter

Create and simulate a Verilog description for an 8-bit shifter that can shift or rotate left or right by 0, 1, 2, or 3 bit positions. Implement the shifter on your board, using eight slide switches for shifter input, eight LEDs for outputs, and the four premaining slide switches to select shifter function. Two switches will be used for shift amount, one for direction, and one for shift/rotate selection. When shifting, use a pushbutton to define the fill input. Verify the shifter works correctly on your board.

## Challenges

#### 1. Minterm Multiplexor Circuit

Create a four input (SW0, SW1, SW2 and SW3), one output (LED0) Verilog circuit that uses a 4:1 behavioral multiplexor. Connect the multiplexor output to an LED, and connect the four inputs in such a way that minterms 3, 4, 6, 8, 9, 10 and 13 cause the LED to illuminate. (Hint: each input to the behavioral multiplexor will be driven by a simple logic function. Two of the slide switches will be inputs to these simple logic functions, and the other two will select the multiplexor channel).