Write a behavrioral verilog description of the state machine

Write a behavrioral verilog description of the state machine above. (Assume the state changes occur on the falling edge,). Represent the state table with arrays.

Solution

// Copyright (C) 1991-2014 Altera Corporation. All rights reserved.
// Your use of Altera Corporation\'s design tools, logic functions
// and other software and tools, and its AMPP partner logic
// functions, and any output files from any of the foregoing
// (including device programming or simulation files), and any
// associated documentation or information are expressly subject
// to the terms and conditions of the Altera Program License
// Subscription Agreement, the Altera Quartus II License Agreement,
// the Altera MegaCore Function License Agreement, or other
// applicable license agreement, including, without limitation,
// that your use is for the sole purpose of programming logic
// devices manufactured by Altera and sold by Altera or its
// authorized distributors. Please refer to the applicable
// agreement for further details.

// Generated by Quartus II Version 14.0.0 Build 200 06/17/2014 SJ Web Edition
// Created on Wed Oct 12 07:41:57 2016

// synthesis message_off 10175

`timescale 1ns/1ns

module fsm1 (
clock,X,
Y[1:0]);

input clock;
input reset;
input X;
tri0 reset;
tri0 X;
output [1:0] Y;
reg [1:0] Y;
reg [5:0] fstate;
reg [5:0] reg_fstate;
parameter S0=0,S1=1,S2=2,S3=3,S4=4,S5=5;

always @(posedge clock)
begin
if (clock) begin
fstate <= reg_fstate;
end
end

always @(fstate or X)
begin
  

case (fstate)
S0: begin
reg_fstate <= S1;

if (~(X))
Y <= 2\'b00;
else if (X)
Y <= 2\'b10;
// Inserting \'else\' block to prevent latch inference
else
Y <= 2\'b00;
end
S1: begin
if (~(X))
reg_fstate <= S2;
else if (X)
reg_fstate <= S4;
// Inserting \'else\' block to prevent latch inference
else
reg_fstate <= S1;

if (~(X))
Y <= 2\'b10;
else if (X)
Y <= 2\'b00;
// Inserting \'else\' block to prevent latch inference
else
Y <= 2\'b00;
end
S2: begin
reg_fstate <= S3;

if (~(X))
Y <= 2\'b00;
else if (X)
Y <= 2\'b10;
// Inserting \'else\' block to prevent latch inference
else
Y <= 2\'b00;
end
S3: begin
reg_fstate <= S0;

if (~(X))
Y <= 2\'b00;
else if (X)
Y <= 2\'b10;
// Inserting \'else\' block to prevent latch inference
else
Y <= 2\'b00;
end
S4: begin
if (~(X))
reg_fstate <= S3;
else if (X)
reg_fstate <= S5;
// Inserting \'else\' block to prevent latch inference
else
reg_fstate <= S4;

if (~(X))
Y <= 2\'b10;
else if (X)
Y <= 2\'b00;
// Inserting \'else\' block to prevent latch inference
else
Y <= 2\'b00;
end
S5: begin
reg_fstate <= S0;

if (~(X))
Y <= 2\'b10;
else if (X)
Y <= 2\'b01;
// Inserting \'else\' block to prevent latch inference
else
Y <= 2\'b00;
end
default: begin
Y <= 2\'bxx;
$display (\"Reach undefined state\");
end
endcase
end
end
endmodule // fsm1

Write a behavrioral verilog description of the state machine above. (Assume the state changes occur on the falling edge,). Represent the state table with arrays
Write a behavrioral verilog description of the state machine above. (Assume the state changes occur on the falling edge,). Represent the state table with arrays
Write a behavrioral verilog description of the state machine above. (Assume the state changes occur on the falling edge,). Represent the state table with arrays

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site