Vhdl 我的程序是生成一个用于计算4点fft的代码
我已经将代码分为三部分。第一部分包含加法、减法和求反等函数。第二部分是蝴蝶结构。第三部分是fft4 我发现蝴蝶部分有一些错误,请帮忙解决 程序如下所示。在fft_pkg中,我使用了否定函数,而不是-j的乘法Vhdl 我的程序是生成一个用于计算4点fft的代码,vhdl,Vhdl,我已经将代码分为三部分。第一部分包含加法、减法和求反等函数。第二部分是蝴蝶结构。第三部分是fft4 我发现蝴蝶部分有一些错误,请帮忙解决 程序如下所示。在fft_pkg中,我使用了否定函数,而不是-j的乘法 -- Design Name: -- Module Name: butterfly - Behavioral -- Project Name: -- Target Devices: -- Tool versions: -- Description: -- -- Depend
-- Design Name:
-- Module Name: butterfly - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-------------------------------------------------------------
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
library work;
use work.fft_pkg.all;
entity butterfly is
port (
s1,s2 : in complex;
stage : in std_logic; -- inputs
-- w : in complex -- phase factor
g1,g2 : out complex -- outputs
);
end butterfly;
architecture Behavioral of butterfly is
begin
--butterfly equations.
if ( stage ='0') then
g1 <= add(s1,s2);
g2 <= sub(s1,s2);
elsif (stage ='1') then
g1 <= add(s1,negate(s2));
g2 <= sub(s1,negate(s2));
end if;
end Behavioral;
--butterfly structure(in it instead of multiplication negate func is used)
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
library work;
use work.fft_pkg.all;
entity butterfly is
port (
s1,s2 : in complex;
stage : in std_logic; -- inputs
-- w : in complex; -- phase factor
g1,g2 :out complex -- outputs
);
end butterfly;
architecture Behavioral of butterfly is
begin
--butterfly equations.
if ( stage ='0') then
g1 <= add(s1,s2);
g2 <= sub(s1,s2);
elsif (stage ='1') then
g1 <= add(s1,negate(s2));
g2 <= sub(s1,negate(s2));
end if;
end Behavioral;
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.fft_pkg.all;
entity fft4 is
port (
s: in comp_array;
y : out comp_array
);
end fft4;
architecture rtl of fft4 is
component butterfly is
port (
s1,s2 : in complex; -- inputs
-- w : in complex; -- phase factor
g1,g2 : out complex -- outputs
);
end component;
signal g1,g2: comp_array; -- :=(others=>(0000,0000));
-- signal w:comp_array2 :=(("0000","0001"),("0000","1111"));
begin
--first stage of butterfly
bf11 : butterfly port map(s(0),s(2),'0',g1(0),g1(1));
bf12 : butterfly port map(s(1),s(3),'0',g1(2),g1(3));
--second stage of butterfly's.
bf21 : butterfly port map(g1(0),g1(2),'0',g2(0),g2(2));
bf22 : butterfly port map(g1(1),g1(3),'1',g2(1),g2(3));
end rtl;
我避免了1和-j的乘法,并使用了加法和求反函数
-- Design Name:
-- Module Name: butterfly - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-------------------------------------------------------------
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
library work;
use work.fft_pkg.all;
entity butterfly is
port (
s1,s2 : in complex;
stage : in std_logic; -- inputs
-- w : in complex -- phase factor
g1,g2 : out complex -- outputs
);
end butterfly;
architecture Behavioral of butterfly is
begin
--butterfly equations.
if ( stage ='0') then
g1 <= add(s1,s2);
g2 <= sub(s1,s2);
elsif (stage ='1') then
g1 <= add(s1,negate(s2));
g2 <= sub(s1,negate(s2));
end if;
end Behavioral;
--butterfly structure(in it instead of multiplication negate func is used)
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
library work;
use work.fft_pkg.all;
entity butterfly is
port (
s1,s2 : in complex;
stage : in std_logic; -- inputs
-- w : in complex; -- phase factor
g1,g2 :out complex -- outputs
);
end butterfly;
architecture Behavioral of butterfly is
begin
--butterfly equations.
if ( stage ='0') then
g1 <= add(s1,s2);
g2 <= sub(s1,s2);
elsif (stage ='1') then
g1 <= add(s1,negate(s2));
g2 <= sub(s1,negate(s2));
end if;
end Behavioral;
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.fft_pkg.all;
entity fft4 is
port (
s: in comp_array;
y : out comp_array
);
end fft4;
architecture rtl of fft4 is
component butterfly is
port (
s1,s2 : in complex; -- inputs
-- w : in complex; -- phase factor
g1,g2 : out complex -- outputs
);
end component;
signal g1,g2: comp_array; -- :=(others=>(0000,0000));
-- signal w:comp_array2 :=(("0000","0001"),("0000","1111"));
begin
--first stage of butterfly
bf11 : butterfly port map(s(0),s(2),'0',g1(0),g1(1));
bf12 : butterfly port map(s(1),s(3),'0',g1(2),g1(3));
--second stage of butterfly's.
bf21 : butterfly port map(g1(0),g1(2),'0',g2(0),g2(2));
bf22 : butterfly port map(g1(1),g1(3),'1',g2(1),g2(3));
end rtl;
错误是
错误:HDLCompiler:806-C:\Users\RObin\fftfinal\butterfly.vhd第36行:if附近的语法错误。
错误:HDLCompiler:806-C:\Users\RObin\fftfinal\butterfly.vhd第39行:elsif附近的语法错误。
错误:HDLCompiler:806-C:\Users\RObin\fftfinal\butterfly.vhd第42行:if附近的语法错误。
错误:HDLCompiler:854-C:\Users\RObin\fftfinal\butterfly.vhd第31行:由于以前的错误,单元被忽略
尝试将if语句放入进程中:
architecture behavioral of butterfly is
begin
--butterfly equations.
process (s1, s2)
begin
if ( stage ='0') then
g1 <= add(s1,s2);
g2 <= sub(s1,s2);
elsif (stage ='1') then
g1 <= add(s1,negate(s2));
g2 <= sub(s1,negate(s2));
end if;
end process;
end behavioral;
在没有包fft_pkg或编写包的情况下,不可能验证代码,这似乎需要确定复杂的类型
请注意,尽管Nicolas也评论说可以使用并发条件赋值语句,但所有并发语句都具有等效的进程语句或进程和块语句,这就是VHDL在精化后模拟和合成的方式
您还可以注释掉或删除实体butterfly及其行为体系结构的两个副本之一。如果需要使用同一接口的两种不同表示,可以更改连续不同体系结构的体系结构名称
默认情况下,将使用最后一个分析的。重新分析同一命名实体和体系结构的效果是替换第一次出现的实体和体系结构,同时仍然需要这两个实体和体系结构都是有效的VHDL。If测试必须包含在流程中。相反,您可以这样做:g1您实际上没有显示代码的所有三部分。这些错误还与体系结构主体中的if语句有关。If语句是顺序语句,在本例中属于进程语句。一旦你修正了你的if语句,可能会有其他错误。补充你的问题,不要替换它。