我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

本页主题: 硬件编程专题——一个老外写的DDS(VHDL)的例子 显示签名 | 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

gxuan1



性别: 帅哥 状态: 该用户目前不在线
等级: 荣誉会员
家族: 水族馆
发贴: 5200
威望: 3
浮云: 407
在线等级:
注册时间: 2006-02-20
最后登陆: 2007-12-02

5come5帮你背单词 [ shark /a:k/ n. 鲨鱼 ]


硬件编程专题——一个老外写的DDS(VHDL)的例子

一个老外写的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;
顶端 Posted: 2007-03-19 21:35 | [楼 主]
wesin



社区建设奖 年度之星奖 特殊贡献奖 爱心大使勋章
性别: 帅哥 状态: 该用户目前不在线
头衔: 幕后黑手
等级: 幕后精英
家族: 水族馆
发贴: 69325
威望: 12
浮云: 186283
在线等级:
注册时间: 2005-10-30
最后登陆: 2023-10-01

5come5帮你背单词 [ balance /'bæləns/ n. 均衡,平衡,收付平衡,收付余额,秤,天平;v. (使)保持平衡,(收支)相抵 ]


貌似这个学期就要做这些东西,LZ来帮我弄嘛
顶端 Posted: 2007-03-19 21:41 | [1 楼]
我来我网·5come5 Forum » 电子设计·数学建模

Total 0.011343(s) query 6, Time now is:06-15 00:03, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号