Guest
Hi, i'm having quite a few problems with writing/simulating a RS232
send module. For example this code:
process(baud_tick)
variable state, nextstate : integer := 0;
begin
case state is
when 0 => if TxD_start = '1' and baud_tick = '1' then nextstate := 1;
busy <= '1'; end if;
when 1 => if baud_tick = '1' then nextstate := 2; TxD <= '0'; end if;
--start
when 2 => if baud_tick = '1' then nextstate := 3; TxD <= TxD_data(0);
end if; --bit0
when 3 => if baud_tick = '1' then nextstate := 4; TxD <= TxD_data(1);
end if; --bit1
when 4 => if baud_tick = '1' then nextstate := 5; TxD <= TxD_data(2);
end if; --bit2
when 5 => if baud_tick = '1' then nextstate := 6; TxD <= TxD_data(3);
end if; --bit3
when 6 => if baud_tick = '1' then nextstate := 7; TxD <= TxD_data(4);
end if; --bit4
when 7 => if baud_tick = '1' then nextstate := 8; TxD <= TxD_data(5);
end if; --bit5
when 8 => if baud_tick = '1' then nextstate := 9; TxD <= TxD_data(6);
end if; --bit6
when 9 => if baud_tick = '1' then nextstate := 10; TxD <= TxD_data(7);
end if; --bit7
when 10 => if baud_tick = '1' then nextstate := 11; TxD <= '1'; end
if; --stopbit1
when 11 => if baud_tick = '1' then nextstate := 12; TxD <= '1'; end
if; --busy <= '0'; end if; --stopbit2
when 12 => if baud_tick = '1' then nextstate := 0; busy <= '0'; end
if;
when others => if baud_tick = '1' then nextstate := 0; TxD <= '0'; end
if; --(***)
end case;
if baud_tick = '0' then
state := nextstate;
end if;
end process;
The baudticks are small pulses that operate at a 115200 Hz frequency.
The behaverioul simulation works fine, but post-route doesnt. I mean
even when you change the TxD to <= '1' at (***), then the simulation
result changes. But it is made that you never get to 'when others'. So
is there something wrong with my declarations of nextstate or so?
I also tried a different approach:
process
begin
wait until rising_edge(TxD_start); busy <= '1;
wait until rising_edge(baud_tick); TxD <= '0'; --start
wait until rising_edge(baud_tick); TxD <= TxD_data(0); --bit0
wait until rising_edge(baud_tick); TxD <= TxD_data(1); --bit1
wait until rising_edge(baud_tick); TxD <= TxD_data(2); --bit2
wait until rising_edge(baud_tick); TxD <= TxD_data(3); --bit3
wait until rising_edge(baud_tick); TxD <= TxD_data(4); --bit4
wait until rising_edge(baud_tick); TxD <= TxD_data(5); --bit5
wait until rising_edge(baud_tick); TxD <= TxD_data(6); --bit6
wait until rising_edge(baud_tick); TxD <= TxD_data(7); --bit7
wait until rising_edge(baud_tick); TxD <= '1'; --stopbit1
wait until rising_edge(baud_tick); TxD <= '1'; --stopbit2
wait until rising_edge(clk_fpga); busy <= '0';
end process;
But it gives the error: line 63: Same wait conditions expected in all
Multiple Waits.
Is that normal? I find it weird that there would be such a restriction.
send module. For example this code:
process(baud_tick)
variable state, nextstate : integer := 0;
begin
case state is
when 0 => if TxD_start = '1' and baud_tick = '1' then nextstate := 1;
busy <= '1'; end if;
when 1 => if baud_tick = '1' then nextstate := 2; TxD <= '0'; end if;
--start
when 2 => if baud_tick = '1' then nextstate := 3; TxD <= TxD_data(0);
end if; --bit0
when 3 => if baud_tick = '1' then nextstate := 4; TxD <= TxD_data(1);
end if; --bit1
when 4 => if baud_tick = '1' then nextstate := 5; TxD <= TxD_data(2);
end if; --bit2
when 5 => if baud_tick = '1' then nextstate := 6; TxD <= TxD_data(3);
end if; --bit3
when 6 => if baud_tick = '1' then nextstate := 7; TxD <= TxD_data(4);
end if; --bit4
when 7 => if baud_tick = '1' then nextstate := 8; TxD <= TxD_data(5);
end if; --bit5
when 8 => if baud_tick = '1' then nextstate := 9; TxD <= TxD_data(6);
end if; --bit6
when 9 => if baud_tick = '1' then nextstate := 10; TxD <= TxD_data(7);
end if; --bit7
when 10 => if baud_tick = '1' then nextstate := 11; TxD <= '1'; end
if; --stopbit1
when 11 => if baud_tick = '1' then nextstate := 12; TxD <= '1'; end
if; --busy <= '0'; end if; --stopbit2
when 12 => if baud_tick = '1' then nextstate := 0; busy <= '0'; end
if;
when others => if baud_tick = '1' then nextstate := 0; TxD <= '0'; end
if; --(***)
end case;
if baud_tick = '0' then
state := nextstate;
end if;
end process;
The baudticks are small pulses that operate at a 115200 Hz frequency.
The behaverioul simulation works fine, but post-route doesnt. I mean
even when you change the TxD to <= '1' at (***), then the simulation
result changes. But it is made that you never get to 'when others'. So
is there something wrong with my declarations of nextstate or so?
I also tried a different approach:
process
begin
wait until rising_edge(TxD_start); busy <= '1;
wait until rising_edge(baud_tick); TxD <= '0'; --start
wait until rising_edge(baud_tick); TxD <= TxD_data(0); --bit0
wait until rising_edge(baud_tick); TxD <= TxD_data(1); --bit1
wait until rising_edge(baud_tick); TxD <= TxD_data(2); --bit2
wait until rising_edge(baud_tick); TxD <= TxD_data(3); --bit3
wait until rising_edge(baud_tick); TxD <= TxD_data(4); --bit4
wait until rising_edge(baud_tick); TxD <= TxD_data(5); --bit5
wait until rising_edge(baud_tick); TxD <= TxD_data(6); --bit6
wait until rising_edge(baud_tick); TxD <= TxD_data(7); --bit7
wait until rising_edge(baud_tick); TxD <= '1'; --stopbit1
wait until rising_edge(baud_tick); TxD <= '1'; --stopbit2
wait until rising_edge(clk_fpga); busy <= '0';
end process;
But it gives the error: line 63: Same wait conditions expected in all
Multiple Waits.
Is that normal? I find it weird that there would be such a restriction.