Transmit on UART from FSMBaud Rate Clock VHDL — floating point exception error and/or style issuesVHDL FSM not changing statesVHDL - FSM not starting (JUST in timing simulation)vhdl fsm counter conditionsUsing If condition to do “something” once every 10 clock cycles. what if “something” takes more than 1 clock cycle?block ram (BRAM) read and write using different clocksIteration limit reached - simple counter in VHDL FSMQ: VHDL Implementation of 2 simple funcitonsMy VHDL flag needs to terminateVHDL reset during execution

What to do as a player when ranger animal companion dies

Minimize taxes now that I earn more

How does one calculate the distribution of the Matt Colville way of rolling stats?

Simulate a 1D Game-of-Life-ish Model

How could artificial intelligence harm us?

As an employer, can I compel my employees to vote?

Which museums have artworks of all four ninja turtles' namesakes?

What are sources for Magic Items that are not adventure-specific?

Is it possible to get a pointer to one subobject via a pointer to a different, unreleated subobject?

Quick Kurodoko Puzzle: Threes and Triples

Why would a fighter use the afterburner and air brakes at the same time?

Flying pigs arrive

Why do we need to use transistors when building an OR gate?

Weapon class firing logic in JavaScript

Borrowing observations for prior probability in Bayesian Inference

How to ask a man to not take up more than one seat on public transport while avoiding conflict?

Tips for remembering the order of parameters for ln?

What is the maximum viable speed for a projectile within earth's atmosphere?

Did HaShem ever command a Navi (Prophet) to break a law?

How do rulers get rich from war?

Is a global DNS record a security risk for phpMyAdmin?

How should errors be reported in scientific libraries?

Why is the stock market so unpredictable?

Can I separate garlic into cloves for storage?



Transmit on UART from FSM


Baud Rate Clock VHDL — floating point exception error and/or style issuesVHDL FSM not changing statesVHDL - FSM not starting (JUST in timing simulation)vhdl fsm counter conditionsUsing If condition to do “something” once every 10 clock cycles. what if “something” takes more than 1 clock cycle?block ram (BRAM) read and write using different clocksIteration limit reached - simple counter in VHDL FSMQ: VHDL Implementation of 2 simple funcitonsMy VHDL flag needs to terminateVHDL reset during execution






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have created a FSM and I would that, for each state of FSM, to transmit a char (8 bit) from my UART.
The UART transmitter is defined as:



library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity UART_TX is
generic (
g_CLKS_PER_BIT : integer := 139 -- Needs to be set correctly
);
port (
i_Clk : in std_logic;
i_TX_DV : in std_logic;
i_TX_Byte : in std_logic_vector(7 downto 0);
o_TX_Active : out std_logic;
o_TX_Serial : out std_logic;
o_TX_Done : out std_logic
);
end UART_TX;


architecture RTL of UART_TX is

type t_SM_Main is (s_Idle, s_TX_Start_Bit, s_TX_Data_Bits,
s_TX_Stop_Bit, s_Cleanup);
signal r_SM_Main : t_SM_Main := s_Idle;

signal r_Clk_Count : integer range 0 to g_CLKS_PER_BIT-1 := 0;
signal r_Bit_Index : integer range 0 to 7 := 0; -- 8 Bits Total
signal r_TX_Data : std_logic_vector(7 downto 0) := (others => '0');
signal r_TX_Done : std_logic := '0';

begin


p_UART_TX : process (i_Clk)
begin
if rising_edge(i_Clk) then

case r_SM_Main is

when s_Idle =>
o_TX_Active <= '0';
o_TX_Serial <= '1'; -- Drive Line High for Idle
r_TX_Done <= '0';
r_Clk_Count <= 0;
r_Bit_Index <= 0;

if i_TX_DV = '1' then
r_TX_Data <= i_TX_Byte;
r_SM_Main <= s_TX_Start_Bit;
else
r_SM_Main <= s_Idle;
end if;


-- Send out Start Bit. Start bit = 0
when s_TX_Start_Bit =>
o_TX_Active <= '1';
o_TX_Serial <= '0';

-- Wait g_CLKS_PER_BIT-1 clock cycles for start bit to finish
if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Start_Bit;
else
r_Clk_Count <= 0;
r_SM_Main <= s_TX_Data_Bits;
end if;


-- Wait g_CLKS_PER_BIT-1 clock cycles for data bits to finish
when s_TX_Data_Bits =>
o_TX_Serial <= r_TX_Data(r_Bit_Index);

if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Data_Bits;
else
r_Clk_Count <= 0;

-- Check if we have sent out all bits
if r_Bit_Index < 7 then
r_Bit_Index <= r_Bit_Index + 1;
r_SM_Main <= s_TX_Data_Bits;
else
r_Bit_Index <= 0;
r_SM_Main <= s_TX_Stop_Bit;
end if;
end if;


-- Send out Stop bit. Stop bit = 1
when s_TX_Stop_Bit =>
o_TX_Serial <= '1';

-- Wait g_CLKS_PER_BIT-1 clock cycles for Stop bit to finish
if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Stop_Bit;
else
r_TX_Done <= '1';
r_Clk_Count <= 0;
r_SM_Main <= s_Cleanup;
end if;


-- Stay here 1 clock
when s_Cleanup =>
o_TX_Active <= '0';
r_TX_Done <= '1';
r_SM_Main <= s_Idle;


when others =>
r_SM_Main <= s_Idle;

end case;
end if;
end process p_UART_TX;

o_TX_Done <= r_TX_Done;

end RTL;


It work well for only one character.
This VHDL code, wait for DV signal (DataValid) when it transm the r_TX_Data byte. Finally, it set the o_TX_Done signal.



I need to send various char (byte) trough my transmitter.for this reason I use this code:



---[cut]
type t_SM_serial is (s_Start, s_COMMAND, s_BA, s_BB, s_BC);
signal next_state : t_SM_Serial;
signal r_SM_serial : t_SM_serial := s_Start;


-- Low-level byte-write---------------------------------------------------------------
procedure UART_WRITE_BYTE ( i_data_in : in std_logic_vector(7 downto 0) ) is
begin
r_TX_BYTE <= i_data_in;
r_TX_DV <= '1';
end UART_WRITE_BYTE;
--------------------------------------------------------------------------------------





begin --------------architecture begin


-- Instantiate UART transmitter
UART_TX_INST : uart_tx
generic map (
g_CLKS_PER_BIT => 139 --c_CLKS_PER_BIT
)
port map (
i_clk => Clk,
i_tx_dv => r_TX_DV,
i_tx_byte => r_TX_BYTE,
o_tx_active => open,
o_tx_serial => out_serial_memory,
o_tx_done => w_TX_DONE
);



st: process (r_SM_serial,w_TX_DONE)
begin
case r_SM_Serial is
when s_COMMAND =>
if (w_TX_Done = '1' ) then
next_state <= S_BA;
end if;

when s_BA =>
if (w_TX_Done = '1' ) then
next_state <= S_BB;
end if;
when s_BB =>
if (w_TX_Done = '1' ) then
next_state <= S_start;
end if;
when others =>
next_state <= s_Start;
end case;
end process;



----------------------------------------
-- Output Logic
----------------------------------------
OUT_LOGIC: process (r_SM_Serial)
begin
case r_SM_Serial is
when s_Command =>
UART_WRITE_BYTE(X"41");
when s_BA =>
UART_WRITE_BYTE(X"42");
when s_BB =>
UART_WRITE_BYTE(X"43");
when s_Start =>
r_TX_DV <= '0';
when others =>
r_TX_DV <= '0';
end case;
end process OUT_LOGIC;


process (Clk,reset)
begin
if reset = '1' then
r_SM_serial <= s_command;

elsif (CLK'event and CLK = '1') then
r_SM_Serial <= NEXT_STATE;
end if;
end process;



This does not work.
The transmitter continuously sends the first character (status s_Command) and never stops.



Apparently, the w_TX_Done signal is set, but there are no correct timing.
I obtain this output:



PuTTY Output



Where am I wrong?



And… the trasmission never end










share|improve this question


























  • I might have missed something, but I don't see when you actually write a different value to the 'r_TX_BYTE' signal. Do you change the value of this signal after the first command?

    – Jan Snoeijs
    Mar 28 at 14:24











  • In the code I have only one state. But it send continuously the first character.

    – Claudio La Rosa
    Mar 28 at 15:09











  • What I don't understand is that you write a constant value to your transmitter :UART_WRITE_BYTE(X"41"); so how do you expect it to change

    – Jan Snoeijs
    Mar 28 at 15:30












  • In my code, in this case, I have only one state. But the problem is the same: The trasmission of character does not stop

    – Claudio La Rosa
    Mar 28 at 15:54











  • OK, it is hard to understand your problem and what you actually want to achieve. Have you checked that your FSM is not stuck in s_COMMAND( (because of w_tx_done not being set to '1' properly)?

    – Jan Snoeijs
    Mar 28 at 16:26


















0















I have created a FSM and I would that, for each state of FSM, to transmit a char (8 bit) from my UART.
The UART transmitter is defined as:



library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity UART_TX is
generic (
g_CLKS_PER_BIT : integer := 139 -- Needs to be set correctly
);
port (
i_Clk : in std_logic;
i_TX_DV : in std_logic;
i_TX_Byte : in std_logic_vector(7 downto 0);
o_TX_Active : out std_logic;
o_TX_Serial : out std_logic;
o_TX_Done : out std_logic
);
end UART_TX;


architecture RTL of UART_TX is

type t_SM_Main is (s_Idle, s_TX_Start_Bit, s_TX_Data_Bits,
s_TX_Stop_Bit, s_Cleanup);
signal r_SM_Main : t_SM_Main := s_Idle;

signal r_Clk_Count : integer range 0 to g_CLKS_PER_BIT-1 := 0;
signal r_Bit_Index : integer range 0 to 7 := 0; -- 8 Bits Total
signal r_TX_Data : std_logic_vector(7 downto 0) := (others => '0');
signal r_TX_Done : std_logic := '0';

begin


p_UART_TX : process (i_Clk)
begin
if rising_edge(i_Clk) then

case r_SM_Main is

when s_Idle =>
o_TX_Active <= '0';
o_TX_Serial <= '1'; -- Drive Line High for Idle
r_TX_Done <= '0';
r_Clk_Count <= 0;
r_Bit_Index <= 0;

if i_TX_DV = '1' then
r_TX_Data <= i_TX_Byte;
r_SM_Main <= s_TX_Start_Bit;
else
r_SM_Main <= s_Idle;
end if;


-- Send out Start Bit. Start bit = 0
when s_TX_Start_Bit =>
o_TX_Active <= '1';
o_TX_Serial <= '0';

-- Wait g_CLKS_PER_BIT-1 clock cycles for start bit to finish
if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Start_Bit;
else
r_Clk_Count <= 0;
r_SM_Main <= s_TX_Data_Bits;
end if;


-- Wait g_CLKS_PER_BIT-1 clock cycles for data bits to finish
when s_TX_Data_Bits =>
o_TX_Serial <= r_TX_Data(r_Bit_Index);

if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Data_Bits;
else
r_Clk_Count <= 0;

-- Check if we have sent out all bits
if r_Bit_Index < 7 then
r_Bit_Index <= r_Bit_Index + 1;
r_SM_Main <= s_TX_Data_Bits;
else
r_Bit_Index <= 0;
r_SM_Main <= s_TX_Stop_Bit;
end if;
end if;


-- Send out Stop bit. Stop bit = 1
when s_TX_Stop_Bit =>
o_TX_Serial <= '1';

-- Wait g_CLKS_PER_BIT-1 clock cycles for Stop bit to finish
if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Stop_Bit;
else
r_TX_Done <= '1';
r_Clk_Count <= 0;
r_SM_Main <= s_Cleanup;
end if;


-- Stay here 1 clock
when s_Cleanup =>
o_TX_Active <= '0';
r_TX_Done <= '1';
r_SM_Main <= s_Idle;


when others =>
r_SM_Main <= s_Idle;

end case;
end if;
end process p_UART_TX;

o_TX_Done <= r_TX_Done;

end RTL;


It work well for only one character.
This VHDL code, wait for DV signal (DataValid) when it transm the r_TX_Data byte. Finally, it set the o_TX_Done signal.



I need to send various char (byte) trough my transmitter.for this reason I use this code:



---[cut]
type t_SM_serial is (s_Start, s_COMMAND, s_BA, s_BB, s_BC);
signal next_state : t_SM_Serial;
signal r_SM_serial : t_SM_serial := s_Start;


-- Low-level byte-write---------------------------------------------------------------
procedure UART_WRITE_BYTE ( i_data_in : in std_logic_vector(7 downto 0) ) is
begin
r_TX_BYTE <= i_data_in;
r_TX_DV <= '1';
end UART_WRITE_BYTE;
--------------------------------------------------------------------------------------





begin --------------architecture begin


-- Instantiate UART transmitter
UART_TX_INST : uart_tx
generic map (
g_CLKS_PER_BIT => 139 --c_CLKS_PER_BIT
)
port map (
i_clk => Clk,
i_tx_dv => r_TX_DV,
i_tx_byte => r_TX_BYTE,
o_tx_active => open,
o_tx_serial => out_serial_memory,
o_tx_done => w_TX_DONE
);



st: process (r_SM_serial,w_TX_DONE)
begin
case r_SM_Serial is
when s_COMMAND =>
if (w_TX_Done = '1' ) then
next_state <= S_BA;
end if;

when s_BA =>
if (w_TX_Done = '1' ) then
next_state <= S_BB;
end if;
when s_BB =>
if (w_TX_Done = '1' ) then
next_state <= S_start;
end if;
when others =>
next_state <= s_Start;
end case;
end process;



----------------------------------------
-- Output Logic
----------------------------------------
OUT_LOGIC: process (r_SM_Serial)
begin
case r_SM_Serial is
when s_Command =>
UART_WRITE_BYTE(X"41");
when s_BA =>
UART_WRITE_BYTE(X"42");
when s_BB =>
UART_WRITE_BYTE(X"43");
when s_Start =>
r_TX_DV <= '0';
when others =>
r_TX_DV <= '0';
end case;
end process OUT_LOGIC;


process (Clk,reset)
begin
if reset = '1' then
r_SM_serial <= s_command;

elsif (CLK'event and CLK = '1') then
r_SM_Serial <= NEXT_STATE;
end if;
end process;



This does not work.
The transmitter continuously sends the first character (status s_Command) and never stops.



Apparently, the w_TX_Done signal is set, but there are no correct timing.
I obtain this output:



PuTTY Output



Where am I wrong?



And… the trasmission never end










share|improve this question


























  • I might have missed something, but I don't see when you actually write a different value to the 'r_TX_BYTE' signal. Do you change the value of this signal after the first command?

    – Jan Snoeijs
    Mar 28 at 14:24











  • In the code I have only one state. But it send continuously the first character.

    – Claudio La Rosa
    Mar 28 at 15:09











  • What I don't understand is that you write a constant value to your transmitter :UART_WRITE_BYTE(X"41"); so how do you expect it to change

    – Jan Snoeijs
    Mar 28 at 15:30












  • In my code, in this case, I have only one state. But the problem is the same: The trasmission of character does not stop

    – Claudio La Rosa
    Mar 28 at 15:54











  • OK, it is hard to understand your problem and what you actually want to achieve. Have you checked that your FSM is not stuck in s_COMMAND( (because of w_tx_done not being set to '1' properly)?

    – Jan Snoeijs
    Mar 28 at 16:26














0












0








0








I have created a FSM and I would that, for each state of FSM, to transmit a char (8 bit) from my UART.
The UART transmitter is defined as:



library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity UART_TX is
generic (
g_CLKS_PER_BIT : integer := 139 -- Needs to be set correctly
);
port (
i_Clk : in std_logic;
i_TX_DV : in std_logic;
i_TX_Byte : in std_logic_vector(7 downto 0);
o_TX_Active : out std_logic;
o_TX_Serial : out std_logic;
o_TX_Done : out std_logic
);
end UART_TX;


architecture RTL of UART_TX is

type t_SM_Main is (s_Idle, s_TX_Start_Bit, s_TX_Data_Bits,
s_TX_Stop_Bit, s_Cleanup);
signal r_SM_Main : t_SM_Main := s_Idle;

signal r_Clk_Count : integer range 0 to g_CLKS_PER_BIT-1 := 0;
signal r_Bit_Index : integer range 0 to 7 := 0; -- 8 Bits Total
signal r_TX_Data : std_logic_vector(7 downto 0) := (others => '0');
signal r_TX_Done : std_logic := '0';

begin


p_UART_TX : process (i_Clk)
begin
if rising_edge(i_Clk) then

case r_SM_Main is

when s_Idle =>
o_TX_Active <= '0';
o_TX_Serial <= '1'; -- Drive Line High for Idle
r_TX_Done <= '0';
r_Clk_Count <= 0;
r_Bit_Index <= 0;

if i_TX_DV = '1' then
r_TX_Data <= i_TX_Byte;
r_SM_Main <= s_TX_Start_Bit;
else
r_SM_Main <= s_Idle;
end if;


-- Send out Start Bit. Start bit = 0
when s_TX_Start_Bit =>
o_TX_Active <= '1';
o_TX_Serial <= '0';

-- Wait g_CLKS_PER_BIT-1 clock cycles for start bit to finish
if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Start_Bit;
else
r_Clk_Count <= 0;
r_SM_Main <= s_TX_Data_Bits;
end if;


-- Wait g_CLKS_PER_BIT-1 clock cycles for data bits to finish
when s_TX_Data_Bits =>
o_TX_Serial <= r_TX_Data(r_Bit_Index);

if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Data_Bits;
else
r_Clk_Count <= 0;

-- Check if we have sent out all bits
if r_Bit_Index < 7 then
r_Bit_Index <= r_Bit_Index + 1;
r_SM_Main <= s_TX_Data_Bits;
else
r_Bit_Index <= 0;
r_SM_Main <= s_TX_Stop_Bit;
end if;
end if;


-- Send out Stop bit. Stop bit = 1
when s_TX_Stop_Bit =>
o_TX_Serial <= '1';

-- Wait g_CLKS_PER_BIT-1 clock cycles for Stop bit to finish
if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Stop_Bit;
else
r_TX_Done <= '1';
r_Clk_Count <= 0;
r_SM_Main <= s_Cleanup;
end if;


-- Stay here 1 clock
when s_Cleanup =>
o_TX_Active <= '0';
r_TX_Done <= '1';
r_SM_Main <= s_Idle;


when others =>
r_SM_Main <= s_Idle;

end case;
end if;
end process p_UART_TX;

o_TX_Done <= r_TX_Done;

end RTL;


It work well for only one character.
This VHDL code, wait for DV signal (DataValid) when it transm the r_TX_Data byte. Finally, it set the o_TX_Done signal.



I need to send various char (byte) trough my transmitter.for this reason I use this code:



---[cut]
type t_SM_serial is (s_Start, s_COMMAND, s_BA, s_BB, s_BC);
signal next_state : t_SM_Serial;
signal r_SM_serial : t_SM_serial := s_Start;


-- Low-level byte-write---------------------------------------------------------------
procedure UART_WRITE_BYTE ( i_data_in : in std_logic_vector(7 downto 0) ) is
begin
r_TX_BYTE <= i_data_in;
r_TX_DV <= '1';
end UART_WRITE_BYTE;
--------------------------------------------------------------------------------------





begin --------------architecture begin


-- Instantiate UART transmitter
UART_TX_INST : uart_tx
generic map (
g_CLKS_PER_BIT => 139 --c_CLKS_PER_BIT
)
port map (
i_clk => Clk,
i_tx_dv => r_TX_DV,
i_tx_byte => r_TX_BYTE,
o_tx_active => open,
o_tx_serial => out_serial_memory,
o_tx_done => w_TX_DONE
);



st: process (r_SM_serial,w_TX_DONE)
begin
case r_SM_Serial is
when s_COMMAND =>
if (w_TX_Done = '1' ) then
next_state <= S_BA;
end if;

when s_BA =>
if (w_TX_Done = '1' ) then
next_state <= S_BB;
end if;
when s_BB =>
if (w_TX_Done = '1' ) then
next_state <= S_start;
end if;
when others =>
next_state <= s_Start;
end case;
end process;



----------------------------------------
-- Output Logic
----------------------------------------
OUT_LOGIC: process (r_SM_Serial)
begin
case r_SM_Serial is
when s_Command =>
UART_WRITE_BYTE(X"41");
when s_BA =>
UART_WRITE_BYTE(X"42");
when s_BB =>
UART_WRITE_BYTE(X"43");
when s_Start =>
r_TX_DV <= '0';
when others =>
r_TX_DV <= '0';
end case;
end process OUT_LOGIC;


process (Clk,reset)
begin
if reset = '1' then
r_SM_serial <= s_command;

elsif (CLK'event and CLK = '1') then
r_SM_Serial <= NEXT_STATE;
end if;
end process;



This does not work.
The transmitter continuously sends the first character (status s_Command) and never stops.



Apparently, the w_TX_Done signal is set, but there are no correct timing.
I obtain this output:



PuTTY Output



Where am I wrong?



And… the trasmission never end










share|improve this question
















I have created a FSM and I would that, for each state of FSM, to transmit a char (8 bit) from my UART.
The UART transmitter is defined as:



library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity UART_TX is
generic (
g_CLKS_PER_BIT : integer := 139 -- Needs to be set correctly
);
port (
i_Clk : in std_logic;
i_TX_DV : in std_logic;
i_TX_Byte : in std_logic_vector(7 downto 0);
o_TX_Active : out std_logic;
o_TX_Serial : out std_logic;
o_TX_Done : out std_logic
);
end UART_TX;


architecture RTL of UART_TX is

type t_SM_Main is (s_Idle, s_TX_Start_Bit, s_TX_Data_Bits,
s_TX_Stop_Bit, s_Cleanup);
signal r_SM_Main : t_SM_Main := s_Idle;

signal r_Clk_Count : integer range 0 to g_CLKS_PER_BIT-1 := 0;
signal r_Bit_Index : integer range 0 to 7 := 0; -- 8 Bits Total
signal r_TX_Data : std_logic_vector(7 downto 0) := (others => '0');
signal r_TX_Done : std_logic := '0';

begin


p_UART_TX : process (i_Clk)
begin
if rising_edge(i_Clk) then

case r_SM_Main is

when s_Idle =>
o_TX_Active <= '0';
o_TX_Serial <= '1'; -- Drive Line High for Idle
r_TX_Done <= '0';
r_Clk_Count <= 0;
r_Bit_Index <= 0;

if i_TX_DV = '1' then
r_TX_Data <= i_TX_Byte;
r_SM_Main <= s_TX_Start_Bit;
else
r_SM_Main <= s_Idle;
end if;


-- Send out Start Bit. Start bit = 0
when s_TX_Start_Bit =>
o_TX_Active <= '1';
o_TX_Serial <= '0';

-- Wait g_CLKS_PER_BIT-1 clock cycles for start bit to finish
if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Start_Bit;
else
r_Clk_Count <= 0;
r_SM_Main <= s_TX_Data_Bits;
end if;


-- Wait g_CLKS_PER_BIT-1 clock cycles for data bits to finish
when s_TX_Data_Bits =>
o_TX_Serial <= r_TX_Data(r_Bit_Index);

if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Data_Bits;
else
r_Clk_Count <= 0;

-- Check if we have sent out all bits
if r_Bit_Index < 7 then
r_Bit_Index <= r_Bit_Index + 1;
r_SM_Main <= s_TX_Data_Bits;
else
r_Bit_Index <= 0;
r_SM_Main <= s_TX_Stop_Bit;
end if;
end if;


-- Send out Stop bit. Stop bit = 1
when s_TX_Stop_Bit =>
o_TX_Serial <= '1';

-- Wait g_CLKS_PER_BIT-1 clock cycles for Stop bit to finish
if r_Clk_Count < g_CLKS_PER_BIT-1 then
r_Clk_Count <= r_Clk_Count + 1;
r_SM_Main <= s_TX_Stop_Bit;
else
r_TX_Done <= '1';
r_Clk_Count <= 0;
r_SM_Main <= s_Cleanup;
end if;


-- Stay here 1 clock
when s_Cleanup =>
o_TX_Active <= '0';
r_TX_Done <= '1';
r_SM_Main <= s_Idle;


when others =>
r_SM_Main <= s_Idle;

end case;
end if;
end process p_UART_TX;

o_TX_Done <= r_TX_Done;

end RTL;


It work well for only one character.
This VHDL code, wait for DV signal (DataValid) when it transm the r_TX_Data byte. Finally, it set the o_TX_Done signal.



I need to send various char (byte) trough my transmitter.for this reason I use this code:



---[cut]
type t_SM_serial is (s_Start, s_COMMAND, s_BA, s_BB, s_BC);
signal next_state : t_SM_Serial;
signal r_SM_serial : t_SM_serial := s_Start;


-- Low-level byte-write---------------------------------------------------------------
procedure UART_WRITE_BYTE ( i_data_in : in std_logic_vector(7 downto 0) ) is
begin
r_TX_BYTE <= i_data_in;
r_TX_DV <= '1';
end UART_WRITE_BYTE;
--------------------------------------------------------------------------------------





begin --------------architecture begin


-- Instantiate UART transmitter
UART_TX_INST : uart_tx
generic map (
g_CLKS_PER_BIT => 139 --c_CLKS_PER_BIT
)
port map (
i_clk => Clk,
i_tx_dv => r_TX_DV,
i_tx_byte => r_TX_BYTE,
o_tx_active => open,
o_tx_serial => out_serial_memory,
o_tx_done => w_TX_DONE
);



st: process (r_SM_serial,w_TX_DONE)
begin
case r_SM_Serial is
when s_COMMAND =>
if (w_TX_Done = '1' ) then
next_state <= S_BA;
end if;

when s_BA =>
if (w_TX_Done = '1' ) then
next_state <= S_BB;
end if;
when s_BB =>
if (w_TX_Done = '1' ) then
next_state <= S_start;
end if;
when others =>
next_state <= s_Start;
end case;
end process;



----------------------------------------
-- Output Logic
----------------------------------------
OUT_LOGIC: process (r_SM_Serial)
begin
case r_SM_Serial is
when s_Command =>
UART_WRITE_BYTE(X"41");
when s_BA =>
UART_WRITE_BYTE(X"42");
when s_BB =>
UART_WRITE_BYTE(X"43");
when s_Start =>
r_TX_DV <= '0';
when others =>
r_TX_DV <= '0';
end case;
end process OUT_LOGIC;


process (Clk,reset)
begin
if reset = '1' then
r_SM_serial <= s_command;

elsif (CLK'event and CLK = '1') then
r_SM_Serial <= NEXT_STATE;
end if;
end process;



This does not work.
The transmitter continuously sends the first character (status s_Command) and never stops.



Apparently, the w_TX_Done signal is set, but there are no correct timing.
I obtain this output:



PuTTY Output



Where am I wrong?



And… the trasmission never end







vhdl uart fsm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 29 at 15:02







Claudio La Rosa

















asked Mar 28 at 14:11









Claudio La RosaClaudio La Rosa

44 bronze badges




44 bronze badges















  • I might have missed something, but I don't see when you actually write a different value to the 'r_TX_BYTE' signal. Do you change the value of this signal after the first command?

    – Jan Snoeijs
    Mar 28 at 14:24











  • In the code I have only one state. But it send continuously the first character.

    – Claudio La Rosa
    Mar 28 at 15:09











  • What I don't understand is that you write a constant value to your transmitter :UART_WRITE_BYTE(X"41"); so how do you expect it to change

    – Jan Snoeijs
    Mar 28 at 15:30












  • In my code, in this case, I have only one state. But the problem is the same: The trasmission of character does not stop

    – Claudio La Rosa
    Mar 28 at 15:54











  • OK, it is hard to understand your problem and what you actually want to achieve. Have you checked that your FSM is not stuck in s_COMMAND( (because of w_tx_done not being set to '1' properly)?

    – Jan Snoeijs
    Mar 28 at 16:26


















  • I might have missed something, but I don't see when you actually write a different value to the 'r_TX_BYTE' signal. Do you change the value of this signal after the first command?

    – Jan Snoeijs
    Mar 28 at 14:24











  • In the code I have only one state. But it send continuously the first character.

    – Claudio La Rosa
    Mar 28 at 15:09











  • What I don't understand is that you write a constant value to your transmitter :UART_WRITE_BYTE(X"41"); so how do you expect it to change

    – Jan Snoeijs
    Mar 28 at 15:30












  • In my code, in this case, I have only one state. But the problem is the same: The trasmission of character does not stop

    – Claudio La Rosa
    Mar 28 at 15:54











  • OK, it is hard to understand your problem and what you actually want to achieve. Have you checked that your FSM is not stuck in s_COMMAND( (because of w_tx_done not being set to '1' properly)?

    – Jan Snoeijs
    Mar 28 at 16:26

















I might have missed something, but I don't see when you actually write a different value to the 'r_TX_BYTE' signal. Do you change the value of this signal after the first command?

– Jan Snoeijs
Mar 28 at 14:24





I might have missed something, but I don't see when you actually write a different value to the 'r_TX_BYTE' signal. Do you change the value of this signal after the first command?

– Jan Snoeijs
Mar 28 at 14:24













In the code I have only one state. But it send continuously the first character.

– Claudio La Rosa
Mar 28 at 15:09





In the code I have only one state. But it send continuously the first character.

– Claudio La Rosa
Mar 28 at 15:09













What I don't understand is that you write a constant value to your transmitter :UART_WRITE_BYTE(X"41"); so how do you expect it to change

– Jan Snoeijs
Mar 28 at 15:30






What I don't understand is that you write a constant value to your transmitter :UART_WRITE_BYTE(X"41"); so how do you expect it to change

– Jan Snoeijs
Mar 28 at 15:30














In my code, in this case, I have only one state. But the problem is the same: The trasmission of character does not stop

– Claudio La Rosa
Mar 28 at 15:54





In my code, in this case, I have only one state. But the problem is the same: The trasmission of character does not stop

– Claudio La Rosa
Mar 28 at 15:54













OK, it is hard to understand your problem and what you actually want to achieve. Have you checked that your FSM is not stuck in s_COMMAND( (because of w_tx_done not being set to '1' properly)?

– Jan Snoeijs
Mar 28 at 16:26






OK, it is hard to understand your problem and what you actually want to achieve. Have you checked that your FSM is not stuck in s_COMMAND( (because of w_tx_done not being set to '1' properly)?

– Jan Snoeijs
Mar 28 at 16:26













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399701%2ftransmit-on-uart-from-fsm%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399701%2ftransmit-on-uart-from-fsm%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript