Altera_Forum
Honored Contributor
11 years agobasic type conversion STD_LOGIC_VECTOR to INTEGER
Hi,
When I set up a new component under QSYS, under "Files" -> "Synthesis Files" I import my file delay_ctrl.vhd; when I run "Analyze Synthesis Files", I obtain the following message: --- Quote Start --- type of "writedata" does not agree with its usage as "integer" type --- Quote End --- I defined the input "writedata" as STD_LOGIC_VECTOR, but then later on I like to init an INTEGER by the content of writedata (which gives the actual error). If I define writedata already as INTEGER input signal, it won't be recongnized at all by QSYS, i.e. then does not show up in the "Signals" tab of "new component" in QSYS. Questions: How to convert or add, respectively, a STD_LOGIC_VECTOR to an INTEGER? Or, which type to take correctly instead of STD_LOGIC_VECTOR? How to deal with this situation and what would be the best approach in my situation? My code:LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
ENTITY delay_ctrl IS
PORT (
clk : IN STD_LOGIC;
pos : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) := "0010";
-- avalon interface inputs
write : IN STD_LOGIC := '0';
-- FIXME: writedata does not appear in signals (QSYS)
writedata : IN STD_LOGIC_VECTOR(3 DOWNTO 0) := "0000");
END delay_ctrl;
ARCHITECTURE delay_ctrl_arch OF delay_ctrl IS
(...)
SIGNAL tmp_delay: INTEGER := 0;
BEGIN
clock_proc : PROCESS(clk)
BEGIN
IF rising_edge(clk) THEN
-- get delay from HPS, is updated only in the NEXT round
IF (write = '1') THEN
-- FIXME: writedata:STD_VECTOR_TYPE and tmp_delay:INTEGER are of different types
tmp_delay <= tmp_delay + writedata;
END IF;
(...)