Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17268 Discussions

Function to_unsigned returns only zeros

Altera_Forum
Honored Contributor II
1,928 Views

Hello, 

 

I'm programming a FIR Filter in VHDL and I want to insert stuck on errors in the taps.. so, I did this: 

 

SIGNAL tap0, tap1, tap2, tap3 : INTEGER :=0 ; SIGNAL error : INTEGER :=0; -- other problem if I don't initialize them with "0", the test bench won't run. SIGNAL tap3std : std_logic_vector(to_unsigned(tap3, 8)); SIGNAL tap_error : to_integer(unsigned(std_logic_vector(to_unsigned(error, 8)) or tap3std)); p1 : process begin --here I put the equations for the FIR Filter, it works perfectly if I don't try to put any errors. end process;  

 

In the test bench I change the values in the taps and everything, but when I look the results, the tap3 signal works properly... but the tap3std is only zeros. :confused: 

 

Does anyone know how to fix this? 

 

Thank you, 

 

Helder. :)
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
704 Views

 

--- Quote Start ---  

 

SIGNAL tap3std : std_logic_vector(to_unsigned(tap3, 8)); 

--- Quote End ---  

 

 

In the declaration you should give the size of the vector, not the initial value: 

 

SIGNAL tap3std : std_logic_vector(15 downto 0); 

 

In this example tap3std has 16 bits. You can give an initial value to a signal that is a register. 

The only exception are the testbenches where you can do that. This initial value is assigned in the reset condition: 

 

process(clk) 

begin 

if( rst = '1' ) then 

tap3std <= std_logic_vector(to_unsigned(.... 

elsif( clk'event and ....
0 Kudos
Altera_Forum
Honored Contributor II
704 Views

instead of posting just a snippet, which is riddled with errors, why not post the real code?

0 Kudos
Altera_Forum
Honored Contributor II
704 Views

Oh, hi! 

 

I solved the problem! You're right, Tricky, I'm sorry for that. My problem was that I declared the "tap_error" signal outside of the architecture, not only out of the process. It made the signal work as a constant. Now that I changed it, it works. 

 

Thank you, guys!
0 Kudos
Reply