Why is my state machine output being synthesized away?

  • Thread starter Thread starter keith03
  • Start date Start date
  • Tags Tags
    Machine State
Click For Summary

Discussion Overview

The discussion revolves around a VHDL implementation of a state machine, specifically addressing issues related to output synthesis being optimized away by simulation tools. Participants explore the implications of input handling, state transitions, and the proper assignment of outputs within the context of a Moore machine.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant notes that the simulation tool indicates the output is being synthesized away and expresses uncertainty about how to resolve this issue.
  • Another participant mentions a warning about input x not driving logic, questioning whether this could be a compiler issue.
  • A participant with a Verilog background raises concerns about the use of comparison operators in VHDL, suggesting that the code may not align with the intended state diagram.
  • There is a discussion about the necessity of assigning values to output q based on the current state to avoid optimization issues.
  • One participant suggests separating register assignments from continuous assignments to influence the compiler's state machine implementation.
  • Another participant admits to posting the wrong version of the code, which contributed to discrepancies with the state diagram.
  • A later reply indicates that switching compilers resolved the synthesis issue, suggesting that compiler behavior may vary.

Areas of Agreement / Disagreement

Participants express differing views on the correct handling of state transitions and output assignments, with no consensus reached on the best approach to resolve the synthesis issue. Some participants agree on the need for proper output assignments, while others question the interpretation of the VHDL code.

Contextual Notes

Limitations include potential misunderstandings of VHDL syntax by participants with a Verilog background, as well as unresolved issues related to compiler behavior and code correctness.

keith03
Messages
31
Reaction score
0
This is my first state machine that has an input large than one bit. The simulation tool says that I synthesize my output away. I think I understand why, but don't really know how to fix it.

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--
entity trimoore is
port
(
clk : in std_logic;
x : in std_logic_vector (1 downto 0);
------ mode : in std_logic_vector (2 downto 0);
q : out std_logic_vector(2 downto 0)
);
end trimoore;
--
architecture behave of trimoore is

type state_type is (A, B, C);
signal state: state_type;
begin
process (clk)
begin

if (clk'event and clk ='1') then
case state is
when A =>
if x<="11" then state <= A;
else state <= B;
end if;
when B =>
if x <= "11" then state <= A;
elsif x <= "00" then state <= B;
else state <= C;
end if;
when C =>
if x <= "00" then state <= B;
elsif x <= "01" then state <= C;
else state <= A;
end if;
end case;
end if;
end process;

with state select
q <= "000" when A,
"001" when B,
"110" when C;
 
Engineering news on Phys.org
keith03 said:
This is my first state machine that has an input large than one bit. The simulation tool says that I synthesize my output away. I think I understand why, but don't really know how to fix it.

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--
entity trimoore is
port
(
clk : in std_logic;
x : in std_logic_vector (1 downto 0);
------ mode : in std_logic_vector (2 downto 0);
q : out std_logic_vector(2 downto 0)
);
end trimoore;
--
architecture behave of trimoore is

type state_type is (A, B, C);
signal state: state_type;
begin
process (clk)
begin

if (clk'event and clk ='1') then
case state is
when A =>
if x<="11" then state <= A;
else state <= B;
end if;
when B =>
if x <= "11" then state <= A;
elsif x <= "00" then state <= B;
else state <= C;
end if;
when C =>
if x <= "00" then state <= B;
elsif x <= "01" then state <= C;
else state <= A;
end if;
end case;
end if;
end process;

with state select
q <= "000" when A,
"001" when B,
"110" when C;


Can you post a state diagram that goes with the code? That would make it easier to try to see what is getting optimized out.
 
10 is a don't care input. I have attached a pdf of the state diagram. Also, I want three separate iterations of this to be selected from a three bit input. Could I do case statements for entire state machines? thanks ahead of time. actual output is wrong...sorry. the real problem is that the states don't change in simulation.
 

Attachments

I also get a warning stating that input x does not drive logic. the code is correct to my understanding. Could this maybe be the compiler?
 
OK, I'm more of Verilog person and might be wrong, but let me tell you what I observe.

1. you use "if x<=00 then ...". Isn't <= for assignment ?(Again I'm not VHDL person, so forgive me).
2. What does the following mean ?

when A =>
if x<="11" then state <= A;
else state <= B;

Does it mean when you are in state A and X=11, it stays in A, otherwise goes to B ? if so, it doesn't match the state diagram you posted. The same for B and C too.

3. Regarding stating all the possible states, it probably depends on the compiler. In Verilog, it is always recommended to put all the possible states(even with default statement) to avoid the latch inference.

4. Your output is q. You didn't assign anything to q in the code so the tool thinks it can optimize it away. Assuming from the name, you're trying to make a Moore machine. You need to assign the value to q based on the current state.
 
Last edited:
About the only advice I could give (I'm a verilog person as well) is that I normally will separate the actual register assignments , (the clocked state memory) from the continuous assignments or the next state logic. This will also help or force the compiler to choose a one hot state machine or not. L
 
sorry for the delayed replies.

I used a different compiler, and everything came out fine. I would like to addres the questions that were asked though.

I made a horrible mistake of posting the wrong version of the code, and that is why is does not match the state diagram.

To lostinxlation: you are correct in your interpretation of the VHDL for the states, but the q is assigned values through the select statements at the end of the code.

To lifeattthesha: i had tried to separate them before, but I was getting errors. Turns out that the Quartus free edition that I had been using from school, needed a vouple of updates. I used the trial of Xilinx ISE and everyhting worked fine.

Thanks for the input from both!
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
Replies
5
Views
11K
Replies
1
Views
9K
Replies
4
Views
1K
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
12K
  • · Replies 1 ·
Replies
1
Views
15K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
28K