mjuneja
Advanced Member level 4
- Joined
- Aug 28, 2016
- Messages
- 105
- Helped
- 12
- Reputation
- 24
- Reaction score
- 10
- Trophy points
- 18
- Location
- Bangalore, India
- Activity points
- 674
-- subtype state_type is std_logic_vector(4 downto 0);
-- constant RESET : state_type := "00000";
-- constant WAIT4_FIFO_RDY : state_type := "00001";
.
.
.
-- signal state : state_type;
In order to debug the issue, I want to track the state register of FSM written, in the wave window. But I cannot see that state register in object window of Modelsim.
The synthesis report also shows the fsm encoding. There is also a synthesis attribute to specify an encoding. The state might have a weird name though, especially if global optimization or retiming was used.
It is bit tricky to do something like that in VHDL.
For such purposes fixed encoding for the states can be used.
-- subtype state_type is std_logic_vector(4 downto 0);
-- constant RESET : state_type := "00000";
-- constant WAIT4_FIFO_RDY : state_type := "00001";
.
.
.
-- signal state : state_type;
Then you can view the "state" in Modelsim.
If I will use these constants in coding my FSM next state and output logic , will I be able to see the same code (assigned in declaration) for signal state in the post layout simulation.
INFO:Xst:2117 - HDL ADVISOR - Mux Selector <state_now> of Case statement line 362 was re-encoded using one-hot encoding. The case statement will be optimized (default statement optimization), but this optimization may lead to design initialization problems. To ensure the design works safely, you can:
- add an 'INIT' attribute on signal <state_now> (optimization is then done without any risk)
- use the attribute 'signal_encoding user' to avoid onehot optimization
- use the attribute 'safe_implementation yes' to force XST to perform a safe (but less efficient) optimization
Actually in the synthesis report I didn't find any fsm encoding, instead I got following info.
while synthesizing in XST.
Finally I got the fsm encoding done.
Actually in my case statement I had put a case of "when others =>", that's why it was not realizing that part of code as FSM.
That should not affect the implementation of an FSM.
I'm not sure about XST, but in Synplify you have to enable "preserve and decode unreachable states" (i.e., WHEN OTHERS) for it to synthesize the WHEN OTHERS clause.
--state_reg------------------------------------------------------------comm
process(clk,rst_n,state_next)
begin
if(rst_n = '0') then
state_now <= INIT;
elsif(rising_edge(clk)) then
state_now <= state_next;
end if;
end process;
--FSM------------------------------------------------------------------comm
process(state_now,addr,Data_valid,Data,addr,fram_add_c,fram_siz_1,cntr_px)
begin
case state_now is
when INIT =>
NWEi <= '1';
NOEi <= '1';
addr_en <= "01";
addr_up <= '0';
addr_rst <= "10";
dir <= '0';
DR <= "11";
mem_act <= '0';
if(Data_valid = '1') then
state_next <= WRIT1;
else
state_next <= INIT;
end if;
when WRIT1 =>
NWEi <= '1';
NOEi <= '1';
addr_en <= "01";
addr_up <= '1';
addr_rst <= "11";
dir <= '1';
DR <= "11";
mem_act <= '1';
state_next <= WRIT2;
when WRIT2 =>
NWEi <= '1';
NOEi <= '1';
addr_en <= "01";
addr_up <= '0';
addr_rst <= "11";
dir <= '1';
DR <= "11";
mem_act <= '1';
state_next <= WRIT7;
when WRIT7 =>
NWEi <= '1';
NOEi <= '1';
addr_en <= "01";
addr_up <= '0';
addr_rst <= "11";
dir <= '1';
DR <= "11";
mem_act <= '1';
state_next <= WRIT8;
when WRIT8 =>
NWEi <= '0';
NOEi <= '1';
addr_en <= "01";
addr_up <= '0';
dir <= '1';
DR <= "11";
mem_act <= '1';
if(cntr_px = 2*fram_siz_1) then
state_next <= ADD_RST;
addr_rst <= "00";
else
state_next <= WRIT1;
addr_rst <= "11";
end if;
when ADD_RST =>
NWEi <= '1';
NOEi <= '1';
addr_en <= "01";
addr_up <= '1';
addr_rst <= "11";
dir <= '1';
DR <= "11";
mem_act <= '1';
state_next <= RD2;
when RD2 =>
NWEi <= '1';
NOEi <= '0';
addr_en <= "01";
addr_up <= '0';
addr_rst <= "11";
dir <= '0';
DR <= "00";
mem_act <= '1';
state_next <= RD4;
when RD4 =>
NWEi <= '1';
NOEi <= '0';
addr_en <= "10";
addr_up <= '0';
addr_rst <= "11";
dir <= '0';
DR <= "01";
mem_act <= '1';
state_next <= RD6;
when RD6 =>
NWEi <= '1';
NOEi <= '0';
addr_en <= "11";
addr_rst <= "11";
dir <= '0';
DR <= "10";
mem_act <= '1';
if(unsigned(addr) = fram_add_c) then
state_next <= INIT;
addr_up <= '0';
else
state_next <= RD2;
addr_up <= '1';
end if;
-- when others =>
end case;
end process;
Yes, your RTL should include the "when others".when I comment the "when others => " it infers it as FSM otherwise message in post #8 comes.
There can be 2 reasons. Either you couldn't find it in the synth report else your FSM was not extracted properly by the synth tool.Actually in the synthesis report I didn't find any fsm encoding, instead I got following info.
---------------------------------------------------------------------------------------------------
State | New Encoding | Previous Encoding
---------------------------------------------------------------------------------------------------
addr_wait | 000 | 000
read_state | 001 | 001
read_resp_state | 010 | 011
write_state | 011 | 010
write_resp_state | 100 | 100
---------------------------------------------------------------------------------------------------
Yes, your RTL should include the "when others".
Correct. I did not give a proper explanation.When others => is only required when you dont explicitly cover all of your enumerated states in all of the other states.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?