Forum Discussion
48 Replies
- Altera_Forum
Honored Contributor
Find some example code in this previous thread http://www.alteraforum.com/forum/showthread.php?t=1902
The general option is to calculate a sine table with an external tool, e.g. a spreasheet calculator like MS Excel and export it as *.hex or *.mif file, that can be imported by a ROM MegaFunction. - Altera_Forum
Honored Contributor
you see the problem is i'm completely new and I don't know how to do that. plus I have quartus-ii web edition.. do you know where I can get and hdl file that's already been done? I just want to implement as soon as possible
- Altera_Forum
Honored Contributor
Sounds like you didn't read the link or at least didn't try to understand the code example. In this case, I can't help.
- Altera_Forum
Honored Contributor
no no i did read it.. i think your examples were great but it's just that I'm new and I don't know much about vhdl. I would like to use this code posted by you:
LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all; USE ieee.math_real.all; TYPE ROM IS ARRAY(0 TO 511) OF UNSIGNED(8 DOWNTO 0); FUNCTION INIT_ROM RETURN ROM IS VARIABLE romvar: ROM; begin --for .. loop -- romvar() := --end loop return romvar; end; CONSTANT rom1: ROM := INIT_ROM; And from what I understand I have to use some sort of generated values for the for loop. can you please help me, I would really appreciate it. - Altera_Forum
Honored Contributor
Attached a direct LUT in vhdl
The input theta_in is the address, you can increment it as you wish to skip samples e.g. increment by 1 to use full table or by 2 to use half table or by 4 to use quarter table and so on. - Altera_Forum
Honored Contributor
you are a genius! thank you so much!!!
- Altera_Forum
Honored Contributor
this was really helpful
thanks - Altera_Forum
Honored Contributor
Hm, I have used the "kaz" code, converting DAC_input <= std_logic_vector(sin_data), basically converting signed to SLV and increasing the theta from 0 to 4095. The output is like this: http://i.imgur.com/G4l1d.jpg
Where did I miss the MSB inversion? - Altera_Forum
Honored Contributor
--- Quote Start --- Where did I miss the MSB inversion? --- Quote End --- It's your decision where to place it. Obviously the DAC data representation isn't signed. - Altera_Forum
Honored Contributor
If its not signed, you need to add an offset to the data.