EECS 270: Lab 3

Designing combinational circuits

See lab schedule for due dates.
Total value: 150 points

  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.

    This lab has two in-labs due in successive lab periods. In the first period you will demonstrate your solution to the first design problem, and in the second, you will demonstrate your solution to the more complex problem.

  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 only consist 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 just uses 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.

      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 the Verilog design the inputs should be the same, but you outputs will be different. Instead of using red LED #0 and #1, you will instead use the seven-segment displays. 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.

      For the Verilog design, you must use the following module declaration as your top-level module (which should be named robbie.v):

      module robbie(ls,fs,rs,lwd,rwd);
        input ls,fs,rs;
        output [6:0]lwd,rwd;
      

      Further, you must make a second module (it can be in the same file) which handles the display of a "S" or "F" to hex display. It should take one input, which indicates if it is to display an S or an F, and should generate a bus of 7 wires as output. You can then instantiate that module twice, once for each hex digit. See the Verilog combinational reference for examples of doing this.

    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 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 more sophisticated sensors in place of Robbie's three sensors. The one on the front is removed. The 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 on the front, left, right and back. 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 backwards as well as stopping. She can now do the following actions:
        ActionLeft WheelRight Wheel
        Forward FF
        Left SF
        Right FS
        Stop SS
        Hard Left RF
        Hard Right FR
        Left Back SR
        Right Back RS
        Reverse RR

        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 which indicates it has the strongest signal. If both signals are zero Renee should stop. If the two signals are the same, 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:

      Implementation details


      For the Verilog design, you must use the following module declaration as your top-level module (which should be 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:
      SensorsBoard inputs
      Right beacon sensorSW2-SW0 (SW2 is MSB)
      Left beacon sensorSW6-SW4 (SW6 is MSB)
      Left bumper sensorKey3
      Front bumper sensorKey2
      Back bumper sensorKey1
      Right bumper sensorKey0

      Table 2: Mapping of sensors to switches for Renee.

      Notes:

  8. Design Notes and Hints
  9. Deliverables
    1. Pre-Lab (55 points)
      1. Draw a truth table for how Robbie's three inputs correspond to each of the two outputs (don't worry about the HEX displays, just the simple on/off of the LEDs). Then use a Karnaugh map to find the minimal sum-of-products for each of the two outputs. Show your work. (10 points)
      2. Turn in a printout of the schematic and qsf file for your schematic solution to the Robbie problem. (10 points)
      3. Turn in a printout of the Verilog and qsf file for your Verilog solution to the Robbie problem (including the display on the HEX digits). (10 points)
      4. Create and print a functional simulation which goes through all possible input combinations for Robbie (hints: #1 there are only 8 combinations, #2 use the clock input option with different periods). Have the simulation list the inputs and output in this order: left sensor, forward sensor, right sensor, left wheel (high if going forward), and lastly right wheel (high if going forward) and run it on your schematic version of Robbie. (10 points)
      5. We have provided an input test vector for you to use on your Renee model. Download it and load it into the simulator (as a text file it is pretty meaningless). This is what a good test should look like. You should be viewing it using the waveform viewer, that thing you've used to generate simulation test cases!

        Now, using our test as a model, write a test, using the waveform viewer (that thing you used to do tests in simulation) which tests the following cases. Provide a printout of the input waveform. (15 points)

        lsrsfb lbrbbb
        0010100 000
        0010010 000
        1011011 001

    2. In-Lab (60 points)
      The in-lab is turned in on two different days. On the first day of in-lab the two Robbie simulations are to be demonstrated on the DE2 board. (20 points) On the second day of in-lab, the Renee simulation is to be demonstrated on the DE2 board. (40 points)

    3. Post-lab (35 points)
      1. Prepare your lab report as described in the EECS270 Laboratory Overview handout. Make sure you complete and include all parts of the report including the Cover Sheet and the Design Documentation section. Include your Verilog code and qsf file for Renee only.(10 points)
      2. Print the results of your Renee model on the test vector we supplied (in the pre-lab) as well as the test vector you wrote for the pre-lab. (10 points)
      3. 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 hit some barrier between herself and the beacon (with 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?