Docsity

Lab report for COE 203, Lab Reports of Logistics

Toggle sidebar
bg1
Exp# 12 Title: Traffic Light Controller (TLC) Date: 11/24/2020
1.Objectives:
Discover how to write a Verilog model for a given finite state machine (FSM).
Learn about Mealy and Moore finite state machines.
Create and execute a traffic light controller as an example of FSM.
Complete an uncomplicated experimental design.
2.Procedure:
Task 1: (Complete the State Table)
1. We create a table, and we list all the four states.
2. We list all the possible inputs with the states.
3. We list the next state that depends on the current state and the input.
4. We depend on the three rules to fill the next state which are No Traffic: Always state 0, Traffic
on one road only: Always that state, and Traffic on more than one road: Apply the rule: Go to
next available in the order 1 -> 2-> 3-> 1.
5. We list the outputs which they only depend on the state and the change if the input changes.
Task 2: (Implement the State Machine of the traffic light controller.)
1. We create a new HDL project source and named it exp12.
2. We create a new Verilog source and named it tlc.
3. We modified the given code of tcl by adding the contents of the three states.
4. We made STATE1 to be s1 = 1;
if ({x3,x2,x1} == 3'b000) next_state = STATE0;
else if ({x3,x2,x1} == 3'b001) next_state = STATE1;
else if ({x3,x2} == 2'b10) next_state = STATE3;
else next_state = STATE2;
5. We made STATE2 to be s2=1;
if ({x3,x2,x1} == 3'b000) next_state = STATE0;
else if ({x3,x1} == 2'b01) next_state = STATE1;
else if ({x3,x2,x1} == 3'b010) next_state = STATE2;
else next_state = STATE3;
pf3
pf4
pf5

Partial preview of the text

Download Lab report for COE 203 and more Lab Reports Logistics in PDF only on Docsity!

1.Objectives:  Discover how to write a Verilog model for a given finite state machine (FSM).  Learn about Mealy and Moore finite state machines.  Create and execute a traffic light controller as an example of FSM.  Complete an uncomplicated experimental design. 2.Procedure: Task 1: (Complete the State Table)

  1. We create a table, and we list all the four states.
  2. We list all the possible inputs with the states.
  3. We list the next state that depends on the current state and the input.
  4. We depend on the three rules to fill the next state which are No Traffic: Always state 0, Traffic on one road only: Always that state, and Traffic on more than one road: Apply the rule: Go to next available in the order 1 -> 2-> 3-> 1.
  5. We list the outputs which they only depend on the state and the change if the input changes. Task 2: (Implement the State Machine of the traffic light controller.)
  6. We create a new HDL project source and named it exp12.
  7. We create a new Verilog source and named it tlc.
  8. We modified the given code of tcl by adding the contents of the three states.
  9. We made STATE1 to be s1 = 1; if ({x3,x2,x1} == 3'b000) next_state = STATE0; else if ({x3,x2,x1} == 3'b001) next_state = STATE1; else if ({x3,x2} == 2'b10) next_state = STATE3; else next_state = STATE2;
  10. We made STATE2 to be s2=1; if ({x3,x2,x1} == 3'b000) next_state = STATE0; else if ({x3,x1} == 2'b01) next_state = STATE1; else if ({x3,x2,x1} == 3'b010) next_state = STATE2; else next_state = STATE3;
  1. We made STATE3 to be s3=1; if ({x3,x2,x1} == 3'b000) next_state = STATE0; else if ({x3,x2,x1} == 3'b100) next_state = STATE3; else if ({x2,x1} == 2'b10) next_state = STATE2; else next_state = STATE1;
  2. We went into simulation and Force Clocked clk to 1ns, x1 2ns, x2 4ns, x3 8ns, Force Constant reset to 1 (cancel after Time Offset 1ns), Force Constant EN to 1 (don’t cancel), Change the Radix of the state and next_state to Unsigned Decimal.
  3. We create a new Verilog source and named it tlc_test.
  4. We add the given code of tlc_test to do the I/0 planning on it
  5. We went to User constraints and did I/0 planning to the circuit and ordered the input reset to a push button, clk to V10, x3 x2 x1 to 3 level switches ,and the output s1 s2 s3, state0, and state0 all to separate LED outputs. 3.Problems Faced: No problem faced. 4.Work Distribution: 5.Answer to the questions: Curren t State input Next State Output X3 X2 X1 S3 S2 S

STATE2 1 1 1 STATE

STATE3 0 0 0 STATE

STATE3 0 0 1 STATE

STATE3 0 1 0 STATE

STATE3 0 1 1 STATE

STATE3 1 0 0 STATE

STATE3 1 0 1 STATE

STATE3 1 1 0 STATE

STATE3 1 1 1 STATE

Figure.1: State Table. Figure.2: Simulation of tlc. Input (X 3 , X 2 , X 1 ) Output (S 3 , S 2 , S 1 ) Reset 001(state0) 010 010(state2) 100 100(state3) 100 100(state3) 111 001(state1) 110 010(state2) 011 001(state1) Figure.3: Simple Experimental Design.

Figure.4: Verilog module for tlc part1. Figure.5: Verilog module for tlc part2. Figure.6: Verilog module for tlc part3.