EECS 270: Lab 3

Designing Combinational Circuits

See lab schedule for due dates.
Total value: 150 points
Revised 9/25/16

  1. Overview
  2. In this lab you will learn how to translate word descriptions or specifications into a working logic design. You will be presented with two design problems. The first will be fairly simple and you will implement it in both schematic and HDL (Hardware Description Language) forms. The second is significantly more complex and is to be done solely in the HDL.

    There are two parts to the In-Lab assignment: a simpler version (Robbie) to be done in schematic and HDL form as well as a more complex version (Renee) to be done only in HDL (the schematic version would be very complex).

  3. Preparation
  4. Verilog issues
  5. For this lab you will be creating three different designs, two of which will be in a Hardware Description Language (HDL) named Verilog. In this lab we will be using a small subset of the language. Specifically your modules may consist only of: The purpose of these rules is to keep things at a level where you could easily replace your Verilog code with a schematic that uses just standard gates.

  6. Design Specification
  7. For this lab there are two different design specifications. In both cases, you will be designing control logic for a robot which is trying to drive to a beacon and stop.

    1. Robbie the Robot
    2. Robbie is the simpler robot which is attempting to drive to the beacon and stop. Robbie has three sensors and two independently controlled wheels. The sensors are mounted on the front, front-right and front-left of the robot, as seen in Figure 1. These sensors detect if the beacon is in a certain area (the cones indicated in Figure 1). If the sensor does detect the beacon it outputs a "1", otherwise it will output a "0".

      The two wheels are driven independently. If a "1" is sent to the wheel it turns forward, but if a "0" is sent to the the wheel it doesn't turn. Robbie will go straight if both wheels are turning forward, and will stop if both wheels are stopped. In addition, Robbie turns right if the left wheel is going forward while the right wheel isn't turning, and would turn left in the symmetric case (the left wheel stooped and the right wheel going forward).

      Robbie should follow the following rules:


      Figure 1: Robbie the robot, with sensors and wheels.

      Implementation details

      You are to implement Robbie twice: once using the schematic editor, and once using Verilog. Be sure to use a separate Quartus project for each implementation!

      Schematic version

      For your schematic design, you are to use dip switches 2, 1 and 0 as the left, forward, and right sensor inputs respectively. You are to turn on the red LED #1 to indicate that the left wheel is going forward, and turn on red LED #0 if the right wheel is going forward. Otherwise those LEDs should be off.

      Verilog version
      For this part of the assignment, you will implement Robbie entirely in Verilog. As with schematic based projects (i.e. the ripple carry adder of lab2), you can have a top-level-component and several sub-level-components. In Verilog we will refer to the components as top-level-modules and submodules. For a detailed explanation and example of Verilog modules, the hierarchical relations and connection, see the combinational Verilog reference listed with this lab (pages 1-2), which shows how a full adder is implemented in verilog with submodules.

      For this part of the assignment, you will use the HEX display instead of the LEDs for your output. You should display a capital "F" on HEX0 if the right wheel is going forward, and a capital "S" if the right wheel is stopped. You should do the same on HEX1 for the left wheel. Recall that the HEX segments are active low.

      Your Verilog design should be organized into a top-level-module and submodules. The top-level-module will contain Robbie's control logic, and the submodules will be used to generate the "S" and "F" patterns from the wheel control signals. The HEX display submodules should be controlled by a single bit control. For example, control bit on means display "F", control bit off means display "S". You may use the same submodule more than once if necessary. The top-level-module and submodules will have the general form:

      module robbie(ls,fs,rs,lwd,rwd); //top level module declaration
      input ls,fs,rs; //input declarations
      output [6:0]lwd,rwd; //output declarations. The notation [6:0]lwd, rwd means lwd and rwd consist of a set of
      //7 connections, 6 thru 0. Each connection can be refered to individually or as a set. For example,
      //assign lwd[6] = 0 sets this connection to logical 0. assign lwd = 7'h11 sets lwd[0] to logical 1,
      //lwd[4] to logical 1, and all other bits to logical 0.
      //For more on this, see the combinational verilog reference.

      //Robbie's control logic goes here
      outputSF sf1(inputs to submodule, outputs from submodule); //submodule instantiation

      endmodule

      module outputSF(inputs, outputs); //submodule declaration
      //submodule's input and output declarations go here
      //HEX display logic goes here
      endmodule
      As with schematic-based projects, the top-level-module must have the same name as the project. Also, the file name should have the same name as the top-level-module. The top-level-module and submodules may be placed in the same file, in this case robbie.v. FPGA pin assignments are made to the top-level-module's input and output names.

    3. Renee the Robot
    4. Renee is similar to Robbie, but there are some significant differences. First, she has only two beacon sensors (left and right), but those sensors provide information about distance. Secondly, she has four bumper sensors (which tell her if she has hit something). Lastly, her wheels can go in reverse in addition to going forward. These changes are detailed below:

      1. Beacon sensors:
        Renee uses two sophisticated sensors in place of Robbie's three simple sensors. The two sensors are aimed at Renee's left and right (in the same places as Robbie's left and right sensors). Unlike Robbie's sensors, however, Renee's sensors provide information about how strong of a signal they are getting from the beacon. The sensors return a 3-bit unsigned number. The closer the beacon (and more toward the center of the cone of a given sensor) the higher the value they return.
      2. Bumper sensors:
        Renee has four of these: one each on the front, left, right and back. They are active low: they return a "0" if Renee has bumped into something in that direction, and a "1" if she has not.
      3. Wheels:
        Renee's wheels can go forward and backward, as well as stop. She can now perform the following actions (though you may not need to do all these actions...):
        Action Left Wheel Right Wheel
        Forward F F
        Left S F
        Right F S
        Stop S S
        Left Back S R
        Right Back R S
        Reverse R R

        Table 1: How Renee uses her wheels to perform her actions.
      Renee's interactions with the world
      Renee should head in the direction of the sensor that indicates it has the strongest signal. If both signals are zero, Renee should stop. If the two signals are the same but not zero, Renee should go forward. However, the beacon senors are ignored if Renee has hit something: in that case her first priority is to move away from the thing she hit. If any of her bumpers detect a collision, she should follow the these rules:
      1. If her front bumper sensor is the only one detecting a collision, she should move in reverse.
      2. If her back bumper sensor is the only one detecting a collision, she should move forward.
      3. If her left bumper sensor is the only one detecting a collision, she should move right back.
      4. If her left and front bumper sensors are the only ones detecting a collision, she should move right back.
      5. If her right bumper sensor is the only one detecting a collision, she should move left back.
      6. If her right and front bumper sensors are the only ones detecting a collision, she should move left back.
      7. If her left and back bumper sensors are the only ones detecting a collision, she should move right.
      8. If her right and back bumper sensors are the only ones detecting a collision, she should move left.
      9. If any two bumper sensors on opposite sides are detecting a collision (front and back or left and right), she should stop.

      Implementation details


      For the Verilog design, you must use the following module declaration as your top-level module (which should be in a file named renee.v):
      module renee(ls,rs,fb,rb,lb,bb,lwd,rwd);
      input [2:0] ls,rs; //Beacon sensors
      input fb, rb, lb, bb; //Bumper sensors
      output [6:0]lwd,rwd; //wheel outputs
      You should use the DE2 board inputs as follows:
      Sensors Board inputs
      Right beacon sensor SW2-SW0 (SW2 is MSB)
      Left beacon sensor SW6-SW4 (SW6 is MSB)
      Left bumper sensor Key3 (SW17 Labsland)
      Front bumper sensor Key2 (SW16 Labsland)
      Back bumper sensor Key1 (SW15 Labsland)
      Right bumper sensor Key0 (Sw14 Labsland)

      Table 2: Mapping of sensors to switches for Renee.

      Notes:

  8. Design Notes and Hints
  9. Deliverables
  1. Pre-Lab (30 points)
      1. Submit a truth table for how Robbie's three sensor inputs correspond to each of the two one-bit wheel drive output signals (don't worry about the HEX displays, just the simple on/off of the LEDs).  (10 points)
      2. Submit the schematic image and qsf listing for your schematic solution to the Robbie problem. (10 points)
      3. Submit a functional simulation of the Robbie schematic version. Note,  there are only 8 input combinations. Order the ports in your testbench like this: left sensor, forward sensor, right sensor, left wheel (high if going forward), and lastly right wheel (high if going forward). All signal names and values must be clearly displayed on the waveform. (10 points)
    1. In-Lab (65 points)

    2. The In-Lab consists of 2 parts. Part 1 requires demonstrating the Robbie Verilog version on the DE2 board (25 points), while Part 2 is a demonstration of Renee (40 points). These can be signed off separately by the lab instructor.
       
    3. Post-lab (55 points)
      1. Perform a functional simulaiton for the Robie Verilog that tests all input combinations. Order the ports in your testbench like this: left sensor, forward sensor, right sensor, left wheel (display as a bus), and lastly right wheel (display as a bus). All signal names and values must be clearly displayed. Displaying a signal on the waveform as a bus means that the waveform should show all the segments as one multi-bit unit. As long as you declared the variable as a set in Verilog, ModelSim will do this automatically. (15 points)
      2. Perform a functional simulation for Renee using the following test cases. A logical 1 for the bumpers means the switch is NOT activated or pressed.  All signal names and values must be clearly displayed on the waveform. The wheels must be displayed as a bus.  (15 points)
      3. ls rs fb lb rb bb
        001 010 1
        1
        1
        1
        001 001 1
        1
        1
        1
        101 101 0
        1
        1
        0
        Table 3: Simulation test cases for Renee.

      4. Provide your Verilog code for Robbie and Renee. (10 points)
      5. Consider what would happen if Renee detected the beacon in front of herself (so left and right are equal) and was thus moving forward, and then she hit some barrier between herself and the beacon (activating her front bumper). Answer the following questions: (15 points)
        1. What would an observer see her do (over time)?
        2. Would she ever reach the beacon? Why or why not?
        3. Renee, as described, maintains no state. That is, she only reacts to the current situation without any memory of the past. How could having state help in this case?