我已经写了三个部分的代码。第一部分包含加法、减法和否定句等函数。第二部分是蝴蝶结构。第三部分是fft4。
我在蝴蝶部分发现了一些错误,请帮助解决这些问题。
程序如下所示。在fft_pkg中,我没有使用-j乘法,而是使用了否定函数。
我避免了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行:由于先前的错误而忽略了单元。
发布于 2015-04-12 19:23:57
尝试将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,或者编写一个包complex,就不可能验证您的代码,这似乎需要确定complex的类型。
注意,尽管Nicolas还评论说您可以使用并发条件赋值语句,但所有并发语句都有等效的流程语句或进程语句和块语句,这就是VHDL在精化之后模拟和合成的方式。
您还可以注释掉或删除实体蝴蝶的两个副本之一,以及它的架构行为。如果需要具有相同接口的两种不同表示形式,则可以更改连续不同体系结构的体系结构名称。
默认情况下,将使用最后一个分析结果。再次对同一命名实体和体系结构进行分析,可以替代第一次出现,但仍然需要两者都是有效的VHDL。
https://stackoverflow.com/questions/29591938
复制相似问题