L
Lenny
Guest
Hi all
I'm using Xilinx ISE 8.2 web edition toolsuite and writing the code in
vhdl language.
My question is: it's possible to declare an integer in port statement?
Reading a book (I'm a newbie in vhdl it seems to be legal, so I did
it, but the logic simulation ("Generate Expected Result" in Xilinx ISE
simulator) showed me an unknown state for this port; the vhdl list is:
-- NOT_OK code (simple counter)
entity Tmr1 is
port(clk, reset: IN std_logic;
seg1: OUT integer range 0 to 9);
end Tmr1;
architecture Behavioral of Tmr1 is
begin
process(clk, reset)
variable un: integer range 0 to 10;
begin
if (reset='1') then
un:=0;
elsif rising_edge(clk) then
un:=un+1;
if un=10 then un:=0;
end if;
end if;
seg1<=un;
end process;
end Behavioral;
-- end NOT_OK code
Behavioral simulation is OK, but logic simulation shows a strange
unknown in seg1. Here you could see the simulation:
http://img112.imageshack.us/my.php?image=simnotokgf8.png
Using std_logic_vector type intead of integer in port declaration solved
the problem:
--OK_CODE (simple counter)
library IEEE;
use ieee.std_logic_arith.all;
use IEEE.STD_LOGIC_1164.ALL;
entity Tmr1 is
port(clk, reset: IN std_logic;
seg1: OUT std_logic_vector(7 downto 0));
end Tmr1;
architecture Behavioral of Tmr1 is
begin
process(clk, reset)
variable un: integer range 0 to 10;
begin
if (reset='1') then
un:=0;
elsif rising_edge(clk) then
un:=un+1;
if un=10 then un:=0; end if;
end if;
seg1<=conv_std_logic_vector(un,8);
end process;
end Behavioral;
-- End OK_CODE
Any explaination? Dealing with integers in port statement is not allowed?!?
Lenny
I'm using Xilinx ISE 8.2 web edition toolsuite and writing the code in
vhdl language.
My question is: it's possible to declare an integer in port statement?
Reading a book (I'm a newbie in vhdl it seems to be legal, so I did
it, but the logic simulation ("Generate Expected Result" in Xilinx ISE
simulator) showed me an unknown state for this port; the vhdl list is:
-- NOT_OK code (simple counter)
entity Tmr1 is
port(clk, reset: IN std_logic;
seg1: OUT integer range 0 to 9);
end Tmr1;
architecture Behavioral of Tmr1 is
begin
process(clk, reset)
variable un: integer range 0 to 10;
begin
if (reset='1') then
un:=0;
elsif rising_edge(clk) then
un:=un+1;
if un=10 then un:=0;
end if;
end if;
seg1<=un;
end process;
end Behavioral;
-- end NOT_OK code
Behavioral simulation is OK, but logic simulation shows a strange
unknown in seg1. Here you could see the simulation:
http://img112.imageshack.us/my.php?image=simnotokgf8.png
Using std_logic_vector type intead of integer in port declaration solved
the problem:
--OK_CODE (simple counter)
library IEEE;
use ieee.std_logic_arith.all;
use IEEE.STD_LOGIC_1164.ALL;
entity Tmr1 is
port(clk, reset: IN std_logic;
seg1: OUT std_logic_vector(7 downto 0));
end Tmr1;
architecture Behavioral of Tmr1 is
begin
process(clk, reset)
variable un: integer range 0 to 10;
begin
if (reset='1') then
un:=0;
elsif rising_edge(clk) then
un:=un+1;
if un=10 then un:=0; end if;
end if;
seg1<=conv_std_logic_vector(un,8);
end process;
end Behavioral;
-- End OK_CODE
Any explaination? Dealing with integers in port statement is not allowed?!?
Lenny