Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16662 Discussions

how to define a function in quatus?

Altera_Forum
Honored Contributor II
1,902 Views

I created a file named user_defs.vhl, the contents as below: 

 

LIBRARY ieee; 

USE ieee.std_logic_1164.all; 

PACKAGE user_defs IS 

Type Clock is (int, ext); 

Type Trig is (manual, auto); 

 

function spi_adc_wr_rd(input_dat: bit_vector(15 downto 0); input_clk: std_logic) return bit_vector(15 downto 0); 

END user_defs; 

 

PACKAGE BODY user_defs IS 

Function SPI_ADC_wr_RD(Input_dat: bit_vector(15 downto 0); Input_clk: std_LOGIC) return bit_vector(15 downto 0) is 

variable tmp: bit_vector(Input_dat'rang); 

begin 

tmp <= Input_dat; 

return tmp; 

end; 

 

END user_defs; 

 

 

I want to invole this function of SPI_ADC_wr_RD in another VHDL file, 

... 

USE work.user_defs.all 

... 

 

but when I compile this project, 

it always displays error as below, even I do not invole this function. 

10479 VHDL error at user_defs(9): indexed name type is used but not declared. 

 

I am using 32-bit Quartus 13.1, 

please give me support. 

 

thanks! 

Br 

jjl3
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
800 Views

Is that the full code? it has a typo in it: 

 

you need input_dat'range not rang 

 

Also, what are you expecting this function to do? currently. it does nothing except return the input. And the clock parameter does nothing.
0 Kudos
Altera_Forum
Honored Contributor II
800 Views

Hi, 

 

Apart from the typo (rang -> range) and also tmp being assigned as a signal rather than a variable, the source of the error message given by Quartus is probably that you define the return type as a bit_vector(15 downto 0). This is interpreted as an array of bit_vectors (thus the mentioning of indexed name type). If you remove (15 downto 0) from the return clauses this compilation error should be cleared. That is: 

... 

Function SPI_ADC_wr_RD(Input_dat: bit_vector(15 downto 0); Input_clk: std_LOGIC) return bit_vector; 

END user_defs; 

 

PACKAGE BODY user_defs IS 

Function SPI_ADC_wr_RD(Input_dat: bit_vector(15 downto 0); Input_clk: std_LOGIC) return bit_vector is 

... 

 

/J
0 Kudos
Altera_Forum
Honored Contributor II
800 Views

 

--- Quote Start ---  

Hi, 

 

Apart from the typo (rang -> range) and also tmp being assigned as a signal rather than a variable, the source of the error message given by Quartus is probably that you define the return type as a bit_vector(15 downto 0). This is interpreted as an array of bit_vectors (thus the mentioning of indexed name type). If you remove (15 downto 0) from the return clauses this compilation error should be cleared. That is: 

... 

Function SPI_ADC_wr_RD(Input_dat: bit_vector(15 downto 0); Input_clk: std_LOGIC) return bit_vector; 

END user_defs; 

 

PACKAGE BODY user_defs IS 

 

 

Function SPI_ADC_wr_RD(Input_dat: bit_vector(15 downto 0); Input_clk: std_LOGIC) return bit_vector is 

... 

 

/J 

--- Quote End ---  

 

 

 

Thanks! you are right!
0 Kudos
Reply