Forum Discussion
Altera_Forum
Honored Contributor
14 years agoHello Carlhermann,
First of all I want to thank you for your comments and suggestions :o. I was able to solve this issue, part of it was make changes like you suggested before. --- Quote Start --- ...Additionally you should synchronize the process for concatenating the command to sysclk rather using the outputflag of the UART process for stringent clock synchronous design... --- Quote End --- Also I built a FSM for handling the "commands", the code I sure could be improved a lot in order to be more "compact" or efficient; but at least it is working now. Here's the code
...
-- Commands FSM
process(sysrst, sysclk, txEnable, rxData)
begin
if sysrst = '0' then
txEnable <= '0';
txData <= (others => '0');
cmd_ctr <= 0;
cmd_state <= IDLE;
commands <= (others => '0');
elsif sysclk'event and sysclk = '1' then
case cmd_state is
when IDLE =>
txEnable <= '0';
txData <= (others => '0');
if rxReady = '1' then
cmd_state <= START_CMD;
else
cmd_state <= IDLE;
cmd_rdy <= '0';
cmd_ctr <= 0;
commands <= (others => '0');
end if;
when START_CMD =>
case cmd_ctr is
when 0 =>
commands <= commands(23 downto 0) & rxData;
cmd_ctr <= 1;
cmd_state <= START_CMD;
when 1 =>
if rxReady = '1' then
commands <= commands(23 downto 0) & rxData;
cmd_ctr <= 2;
cmd_state <= START_CMD;
end if;
when 2 =>
if rxReady = '1' then
commands <= commands(23 downto 0) & rxData;
cmd_ctr <= 3;
cmd_state <= START_CMD;
end if;
when 3 =>
if rxReady = '1' then
commands <= commands(23 downto 0) & rxData;
cmd_ctr <= 0;
cmd_state <= WHICH_CMD;
end if;
end case;
when WHICH_CMD =>
...
Thanks again for your support. Regards, Efel