原创 【博客大赛】分享一个老外写的DDS(VHDL)的例子,很经典

2012-4-7 20:27 2322 18 20 分类: FPGA/CPLD

一个老外写的DDS(VHDL)的例子,很经典

-- DDFS.vhd
-------------------------------------
-- Direct Digital Freq. Synthesis --
-------------------------------------
-- (c) Bert Cuzeau, ALSE - info@alse-fr.com
-- May be reproduced provided that copyright above remains.
-- We use one of the symetries in the sine function,
-- so the lookup table is re-used twice (128 entries table)
-- The Sine Table is built by a C program...
-------------------------------------
-- Design IOs :
-- Clk : Global Clock input
-- Rst : Global Reset input
-- Freq_data : 8-bit frequency control vector
-- from DIP switches on the board.
-- Dout : is signed 8-bit output to the DAC.
-- -----------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
-- -----------------------------------------------
Entity DDFS is
-- -----------------------------------------------
Port ( CLK : in std_logic;
RST : in std_logic;
Freq_Data : in std_logic_vector (7 downto 0);
Dout : out std_logic_vector (7 downto 0)
);
end DDFS;
-- -----------------------------------------------
Architecture RTL of DDFS is
-- -----------------------------------------------
signal Address : unsigned (6 downto 0);
signal Result : std_logic_vector (7 downto 0);
signal Accum : unsigned (28 downto 0); -- we want very low Frequencies !
signal Sign : std_logic;
begin
-- Signed Accumulator
-- ------------------
Acc: process (CLK,RST)
begin
if RST='1' then
Accum '0');
elsif rising_edge(CLK) then
Accum <= Accum + unsigned(Freq_Data);
end if;
END process acc;
Sign <= Accum(Accum'high); -- MSB
-- Lookup Table Index calculation
-- ------------------------------
Address <= unsigned(Accum(Accum'high-1 downto Accum'high-Address'length));
-- SINE Look-Up TABLE
-- -------------------
-- Inference of an Asynchronous Rom.
-- A synchronous one would be better, but we register the output.
-- This table has been built by GENVEC.exe (C program)
-- We use only positive values ! (sign comes from quadrant info)
-- This could be further optimized by coding only one quadrant...
lookup: process (Address)
subtype SLV8 is std_logic_vector (7 downto 0);
type Rom128x8 is array (0 to 127) of SLV8; -- 0 to 2**Address'length - 1
constant Sinus_Rom : Rom128x8 := (
x"00", x"03", x"06", x"09", x"0c", x"0f", x"12", x"15",
x"18", x"1b", x"1e", x"21", x"24", x"27", x"2a", x"2d",
x"30", x"33", x"36", x"39", x"3b", x"3e", x"41", x"43",
x"46", x"49", x"4b", x"4e", x"50", x"52", x"55", x"57",
x"59", x"5b", x"5e", x"60", x"62", x"64", x"66", x"67",
x"69", x"6b", x"6c", x"6e", x"70", x"71", x"72", x"74",
x"75", x"76", x"77", x"78", x"79", x"7a", x"7b", x"7b",
x"7c", x"7d", x"7d", x"7e", x"7e", x"7e", x"7e", x"7e",
x"7f", x"7e", x"7e", x"7e", x"7e", x"7e", x"7d", x"7d",
x"7c", x"7b", x"7b", x"7a", x"79", x"78", x"77", x"76",
x"75", x"74", x"72", x"71", x"70", x"6e", x"6c", x"6b",
x"69", x"67", x"66", x"64", x"62", x"60", x"5e", x"5b",
x"59", x"57", x"55", x"52", x"50", x"4e", x"4b", x"49",
x"46", x"43", x"41", x"3e", x"3b", x"39", x"36", x"33",
x"30", x"2d", x"2a", x"27", x"24", x"21", x"1e", x"1b",
x"18", x"15", x"12", x"0f", x"0c", x"09", x"06", x"03" );
begin
Result '0');
elsif rising_edge(CLK) then
if Sign='1' then
Dout <= Result;
else
Dout <= std_logic_vector (- signed(Result));
end if;
end if;
end process outreg;
end RTL;

 

文章评论2条评论)

登录后参与讨论

用户1612775 2012-9-14 16:17

欢迎大家交流

用户1632198 2012-6-21 21:24

楼猪应该说明这个用来干嘛的 给我们扫盲

用户377235 2012-4-27 15:13

经典
相关推荐阅读
用户1647968 2013-03-12 22:27
[博客大赛]TI官网上的WEBENCH® Power Designer 设计工具厉害啊
您指掌之间完成电源设计! WEBENCH设计环境为您提供了创建电源或直流/直流转换器所需的全面设计和原型建立工具,能够有效地满足您的设计要求。WEBENCH工具让设计者在建...
用户1647968 2013-03-12 21:53
【博客大赛】【原创】基于ALTER 数字信号传输性能分析仪
...
用户1647968 2012-11-22 12:20
【TI博客大赛】基于TMS320LF2407A的PMSM矢量控制电流环的设计
三相永磁同步电动机的转矩方程为 (4-1) 上式说明了转矩由两项组成,括号中的第一项是由三相旋转磁场和永磁磁场相互作用所产生的电磁转矩;第二项是由凸极效应引起的磁阻转矩。 对于嵌入式转子,Ld,电磁转...
用户1647968 2012-11-22 12:18
【TI博客大赛】基于DSP28027的SVPWM简易变频器
SVPWM技术的原理 2.1 基本电压空间矢量 图1示出电动游览车的逆变器主电路。规定当上桥臂的一个开关管导通时,开关状态为1。此时,相应的下桥臂开关管关断;反之亦然,开关状态为0。3个桥...
用户1647968 2012-08-25 22:37
【TI博客大赛】TI电源管理芯片BQ20Z75DBT 设计高稳定笔记本电池移动电源
时间岁月飞快啊,一转眼俺做电源工程师之路也有10年了,一直做移动笔记本电池电源设计,使用过不少笔记本电源设计应用解决方案。说起使用稳定性,也很纠结啊,笔记本电源安全性一直各品牌生产厂家最关注问题,经过...
用户1647968 2012-08-25 22:34
【TI博客大赛】基于TI DSP的数字化三相变频电源的研制
    随着电力电子技术的飞速发展,正弦波输出变频电源已被广泛应用在各个领域中,与此同时对变频电源的输出电压波形质量也提出了越来越高的要求。在实验室和工业部门,三相正弦波变频电源常用于各种测量和控...
我要评论
2
18
关闭 站长推荐上一条 /2 下一条