Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] trimming of wanted (useful) signals in XILINX board what is the problem of my code?

Status
Not open for further replies.

corin.otesteanu

Newbie level 5
Joined
Apr 22, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,344
I'm implementing a finite state machine to count some events.

The pre-synthesis simulations works fine, but the post synthesis doesn't. Im sure it's because of the trimming:
FF/Latch <pr_state_FSM_FFd3> has a constant value of 0 in block <fsm_moving_object>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1896 - Due to other FF/Latch trimming, FF/Latch <pr_state_FSM_FFd1> has a constant value of 0 in block <fsm_moving_object>. This FF/Latch will be trimmed during the optimization process.​

Any help would be appreciated.
Code:
entity fsm_moving_object is
    Port ( CLK : in  STD_LOGIC;
           A : in  STD_LOGIC;
           B : in  STD_LOGIC;
           res : in  STD_LOGIC;
	  output: out STD_LOGIC_vector(3 downto 0));
 end fsm_moving_object;

architecture Behavioral of fsm_moving_object is

type states is (state0, stateA, state_inc, stateB, state_dec);
  signal pr_state, next_state: states;
  signal index: integer range 0 to 9:=0;
	signal A_prev: std_logic :='0';
	signal B_prev: std_logic:='0';
 
begin

process (res, clk,index)
begin
  if (res='1') then
      pr_state <= state0; 
  elsif (clk'event and clk = '1') then
      pr_state <= next_state;
      output<=Conv_Std_Logic_Vector(index,4);
  end if;
end process;

process (pr_state,A,B,res)
variable inc: integer range 0 to 1;
variable dec: integer range 0 to 1;
begin
    inc:=0;
    dec:=0;
    case pr_state is
    when state0 =>
		if (A='0' and A_prev='1') then  
			next_state<= stateA;
		elsif (B='0' and B_prev='1') then 
			next_state<=stateB;   
		else next_state<=state0;
		end if;
	
    when stateA =>
      		if (B='0' and B_prev='1') then next_state<= state_inc;
		elsif (A='0' and A_prev='1') then next_state<= state0; 
		else next_state<=stateA;
		end if;
		
    when state_inc=>
		inc:=1;
		next_state<=state0;	
	
    when stateB =>
		if (B='0' and B_prev='1' ) then next_state<= state0;
		elsif (A='0' and A_prev='1' ) then next_state<= state_dec;
		else next_state<=stateB;
		end if;
			 
    when state_dec=>
		dec:=1;
		next_state<=state0;
    end case;
	
    if (res='1') then	
		A_prev<='0';
		B_prev<='0';
		index<=0;
    else
		A_prev<=A;
		B_prev<=B;
		index<=index+inc-dec;
    end if;
end process;	
end Behavioral;
 

mrflibble

Advanced Member level 5
Joined
Apr 19, 2010
Messages
2,724
Helped
679
Reputation
1,360
Reaction score
651
Trophy points
1,393
Activity points
19,551
You can put a "S" (SAVE) attribute on the instance to prevent trimming...

So a .ucf file entry might be something like:

INST "*/fsm_moving_object/pr_state*" " S = "TRUE";

You may also want to check out the XST manual for the specifics on this attribute.
 

corin.otesteanu

Newbie level 5
Joined
Apr 22, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,344
You can put a "S" (SAVE) attribute on the instance to prevent trimming...

So a .ucf file entry might be something like:

INST "*/fsm_moving_object/pr_state*" " S = "TRUE";

You may also want to check out the XST manual for the specifics on this attribute.

Thank you for your reply. I would also be interested why does the synthesizer "optimize" my code in such a way. Maybe I'm writing my code somehow wrong.
Could anyone point some parts in my code that need improoving or revision?
 

mrflibble

Advanced Member level 5
Joined
Apr 19, 2010
Messages
2,724
Helped
679
Reputation
1,360
Reaction score
651
Trophy points
1,393
Activity points
19,551
I would also be interested why does the synthesizer "optimize" my code in such a way.

Actually the warning says it all...

FF/Latch <pr_state_FSM_FFd3> has a constant value of 0 in block <fsm_moving_object>. This FF/Latch will be trimmed during the optimization process.

That one has a predictable constant value of 0, so no logic resources are needed to figure that out. So the synthesis tool removes the entire piece of logic that was needed to get to that constant 0 result.

Also, maybe this paper on FSM's is of interest:

https://www.sunburst-design.com/papers/CummingsICU2002_FSMFundamentals.pdf

It is focused on verilog, but the same principles apply to vhdl.
 
  • Like
Reactions: blooz

    blooz

    Points: 2
    Helpful Answer Positive Rating

permute

Advanced Member level 3
Joined
Jul 16, 2010
Messages
923
Helped
295
Reputation
590
Reaction score
268
Trophy points
1,343
Activity points
8,543
Code:
process (pr_state,A,B,res)
if (B='0' and B_prev='1')
B_prev<=B;
simulations will work, but synthesis will not. The synthesizer ignores the sensitivity list and just assumes you left "B_prev" out. thus B = '0' and B_Prev = '1' will never be true in the synthesized design. Same for A and A_Prev. As a result, state0 will only transition to state0. there is no need to use any registers for the state, as it cannot change. index is also always 0 for the same reason. B_Prev and A_Prev need to be in the clocked process.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top