Project 4 Combinational Building Blocks

Basic Combinational Blocks

21478

Introduction

This project presents the design of four logic circuits are often 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 Blackboard 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 can use them in several designs.

Requirements

With the tutorial above and the previous experience you’ve gained writing test benches and completing simulations, you should be able to complete the design requirements below. If you create multiple testbenches, and they are all listed in your project, then before running the simulation you must select which testbench file is active. Before clicking Run Behavioral Simulation, right click on the simulation source file you want to simulate and select Set as Top.

1. Multiplexor Part 1

Simulate an 8:1 1-bit multiplexor, and then implement it on the Blackboard. Use three push buttons as select inputs, eight slide switches as data input signals, and connect the output to a green LED. Verify the circuit works correctly.

2. Multiplexor Part 2

Implement a 4:1 3-bit bus multiplexor on your Blackboard. Use 12 switches as data inputs, 2 buttons as select inputs, and three LEDs as the output.

Simulate an 8:1 8-bit bus multiplexor (yes, 64 data inputs). Verify that it works correctly.

Hint: instead of simulating every single possible input, assign an arbitary value to each data input. Then just show that the select signals change the output appropriately.

reg [7:0] I0 = 8'h01;
reg [7:0] I1 = 8'h23;
...
reg [7:0] I7 = 8'hEF;

3. 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.

4. 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.

5. 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 Blackboard, 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. 12:1 Multiplexor

Implement a 12:1 1-bit multiplexor on your Blackboard. The output should be connected to a green LED. The mux should turn on a red LED if the select input is out of range. (Hint: your module will need two outputs).

2. 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).