From 12bbdb42cdcf5e6e39832d75fbbd31e3781d550a Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Fri, 11 Apr 2014 19:29:53 +0200 Subject: Import fichiers projet Quartus --- FPGA/vhdl/rom_sinus.vhd | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 FPGA/vhdl/rom_sinus.vhd (limited to 'FPGA/vhdl/rom_sinus.vhd') diff --git a/FPGA/vhdl/rom_sinus.vhd b/FPGA/vhdl/rom_sinus.vhd new file mode 100644 index 0000000..7b3ce2c --- /dev/null +++ b/FPGA/vhdl/rom_sinus.vhd @@ -0,0 +1,75 @@ +---------------------------------------------------- +-- QUART de SINUS : SYNCHRONOUS ROM +---------------------------------------------------- +-- ESIEE +-- creation : A. Exertier, 06/2009 +-- modification : A. Exertier, 12/2011 +---------------------------------------------------- + + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use ieee.math_real.all; + +----------------------------------------------------- +-- GENERIC PARAMETER +----------------------------------------------------- +-- N_data : output data number of bits +-- N_adr_ROM : address number of bits +-- amplitude : sinus amplitude +-- should be < 2**N_data +----------------------------------------------------- +-- INPUTS +----------------------------------------------------- +-- clk : clock +-- address : ROM address +----------------------------------------------------- +-- OUTPUT +----------------------------------------------------- +-- data : output data +----------------------------------------------------- + +entity rom_sinus is + generic ( + N_data : natural := 14; + N_adr_ROM : natural := 8; + amplitude : natural := 1024 + ); + port ( + clk : in std_logic; + address : in std_logic_vector(N_adr_ROM-1 downto 0); + data : out std_logic_vector(N_data-2 downto 0)); + +end entity rom_sinus; + +architecture RTL of rom_sinus is + subtype DAC_data_type is std_logic_vector (N_data-2 downto 0); + type memory_type is array (0 to 2**N_adr_ROM-1) of DAC_data_type; + + function sinus_tabule return memory_type is + variable temp : memory_type; + variable sinus_real : real; + begin + for i in 0 to 2**N_adr_ROM-1 loop + sinus_real := real(amplitude)*(sin(math_pi_over_2 * real(i)/real(2**N_adr_ROM))); + if integer(sinus_real)= 2**(N_data-1) then + temp(i) := (others => '1'); + else + temp(i) := std_logic_vector(to_unsigned(integer(sinus_real), N_data-1)); + end if; + end loop; + return temp; + end sinus_tabule; + + constant memory_values : memory_type := sinus_tabule; + +begin + + process(clk) is + begin + if rising_edge(clk) then data<= memory_values(to_integer(unsigned(address))); + end if; + end process; + +end RTL; -- cgit v1.2.3