Hi,
I'm a newbie in VHDL and i'm trying to get a RS232 connection working with my XUP virtex-II Pro FPGA board.
I used the following code below (which i made myself based with help of internet (FPGA4fun)) and it works fine in the behaverioul simulation. But when i try the post-route simulation, i do not get the results i wanted. I don't know how to check whats going wrong. Prolly timing issues or obvious things i don't know cuz lack of experience. I used clock high = 15 ns = clock low, input setup time = 1 ns = output valid delay. The generation of the baud_ticks works fine. I think it's the case-thingie that forms problems
------------------------------------------------------------
entity Main is
Port ( clk_fpga : in STD_LOGIC;
TxD : out STD_LOGIC := '1';
TxD_busy : out STD_LOGIC;
baud_tick_out : out STD_LOGIC);
end Main;
architecture Behavioral of Main is
signal baud_tick : STD_LOGIC;
signal nextstate : integer := 0;
signal busy : STD_LOGIC := '0';
signal TxD_data : STD_LOGIC_VECTOR(7 downto 0) := "10010101";
signal TxD_start : STD_LOGIC := '1';
COMPONENT Baud_generator_asyn
Port( clk : in std_logic;
enable : in std_logic;
baud_tick : out std_logic);
END COMPONENT;
begin
baud_gen_asyn: Baud_generator_asyn PORT MAP(
clk => clk_fpga,
enable => '1',
baud_tick => baud_tick
);
process(Txd_start,baud_tick,TxD_data)
begin
case nextstate is
when 0 => if TxD_start = '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 <= '1'; end if;
end case;
end process;
process(busy)
begin
TxD_busy <= busy after 5 ns;
end process;
process(baud_tick)
begin
baud_tick_out <= baud_tick after 5 ns;
end process;
end Behavioral;
--------------------------------------------
entity Baud_generator_asyn is
Port ( clk : in STD_LOGIC; --CLOCK MUST BE 32 MHZ
enable : in STD_LOGIC := '0';
baud_tick : out STD_LOGIC
);
end Baud_generator_asyn;
architecture Behavioral of Baud_generator_asyn is
begin
process(clk,enable)
variable baud_acc : STD_LOGIC_VECTOR (15 downto 0) := "0000000000000000";
begin
if rising_edge(clk) then
if enable = '1' then
baud_acc := ("0" & baud_acc(14 downto 0)) + ( "0000000001110110");
else
baud_acc := "0000000000000000";
end if;
end if;
baud_tick <= baud_acc(15);
end process;
end Behavioral;
----------------------------------------
If you want me to show simulation pictures or something. You can always ask
. I've looked in a lot of VHDL tutorials and that is a popular way to do sequential code. But it just doenst work beyond behaverioul simulation :S
Thx in advance
I'm a newbie in VHDL and i'm trying to get a RS232 connection working with my XUP virtex-II Pro FPGA board.
I used the following code below (which i made myself based with help of internet (FPGA4fun)) and it works fine in the behaverioul simulation. But when i try the post-route simulation, i do not get the results i wanted. I don't know how to check whats going wrong. Prolly timing issues or obvious things i don't know cuz lack of experience. I used clock high = 15 ns = clock low, input setup time = 1 ns = output valid delay. The generation of the baud_ticks works fine. I think it's the case-thingie that forms problems
------------------------------------------------------------
entity Main is
Port ( clk_fpga : in STD_LOGIC;
TxD : out STD_LOGIC := '1';
TxD_busy : out STD_LOGIC;
baud_tick_out : out STD_LOGIC);
end Main;
architecture Behavioral of Main is
signal baud_tick : STD_LOGIC;
signal nextstate : integer := 0;
signal busy : STD_LOGIC := '0';
signal TxD_data : STD_LOGIC_VECTOR(7 downto 0) := "10010101";
signal TxD_start : STD_LOGIC := '1';
COMPONENT Baud_generator_asyn
Port( clk : in std_logic;
enable : in std_logic;
baud_tick : out std_logic);
END COMPONENT;
begin
baud_gen_asyn: Baud_generator_asyn PORT MAP(
clk => clk_fpga,
enable => '1',
baud_tick => baud_tick
);
process(Txd_start,baud_tick,TxD_data)
begin
case nextstate is
when 0 => if TxD_start = '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 <= '1'; end if;
end case;
end process;
process(busy)
begin
TxD_busy <= busy after 5 ns;
end process;
process(baud_tick)
begin
baud_tick_out <= baud_tick after 5 ns;
end process;
end Behavioral;
--------------------------------------------
entity Baud_generator_asyn is
Port ( clk : in STD_LOGIC; --CLOCK MUST BE 32 MHZ
enable : in STD_LOGIC := '0';
baud_tick : out STD_LOGIC
);
end Baud_generator_asyn;
architecture Behavioral of Baud_generator_asyn is
begin
process(clk,enable)
variable baud_acc : STD_LOGIC_VECTOR (15 downto 0) := "0000000000000000";
begin
if rising_edge(clk) then
if enable = '1' then
baud_acc := ("0" & baud_acc(14 downto 0)) + ( "0000000001110110");
else
baud_acc := "0000000000000000";
end if;
end if;
baud_tick <= baud_acc(15);
end process;
end Behavioral;
----------------------------------------
If you want me to show simulation pictures or something. You can always ask
Thx in advance
Last edited: