如何将多个VHDL代码组合成一个系统
How combine multiple VHDL codes to make one system
我有多个来自不同来源的 VHDL 代码,我想将它们组合成一个系统。
我的理解是,我必须从每个代码中提取我感兴趣的实体和架构,然后我创建一个将它们组合在一起的新实体,架构也是如此。
我错过了如何在此过程中使用这些的后续步骤。
如果能从你们那里得到一些关于如何正确执行并避免像我这样的 VHDL 新手可能会犯的错误的提示和技巧,那就太好了。
图中总结了我所拥有的和我所需要的
Multiple VHDL to one
此致
这个例子可以是如果你有两个模块,mdl_sub
子模块:
library ieee;
use ieee.std_logic_1164.all;
entity mdl_sub is
generic(
A_L : natural;
Z_L : natural);
port(
clk_i : in std_logic;
rst_i : in std_logic;
a_i : in std_logic_vector(A_L - 1 downto 0);
z_o : out std_logic_vector(Z_L - 1 downto 0));
end entity;
library ieee;
use ieee.numeric_std.all;
architecture syn of mdl_sub is
signal z : std_logic_vector(z_o'range);
begin
process (clk_i, rst_i) is
begin
-- Clock
if rising_edge(clk_i) then
z <= std_logic_vector(unsigned(z) + unsigned(a_i));
end if;
-- Reset
if rst_i = '1' then
z <= (others => '0');
end if;
end process;
-- Drive output
z_o <= z;
end architecture;
和 mdl_top
顶级模块:
library ieee;
use ieee.std_logic_1164.all;
entity mdl_top is
generic(
M0_A_L : natural := 8;
M0_Z_L : natural := 8;
M1_A_L : natural := 4;
M1_Z_L : natural := 4);
port(
clk_i : in std_logic;
rst_i : in std_logic;
m0_a_i : in std_logic_vector(M0_A_L - 1 downto 0);
m0_z_o : out std_logic_vector(M0_Z_L - 1 downto 0);
m1_a_i : in std_logic_vector(M1_A_L - 1 downto 0);
m1_z_o : out std_logic_vector(M1_Z_L - 1 downto 0));
end entity;
library ieee;
use ieee.numeric_std.all;
architecture syn of mdl_top is
begin
-- Sub-module 0
mdl_sub_0 : entity work.mdl_sub
generic map(
A_L => M0_A_L,
Z_L => M0_Z_L)
port map(
clk_i => clk_i,
rst_i => rst_i,
a_i => m0_a_i,
z_o => m0_z_o);
-- Sub-module 1
mdl_sub_1 : entity work.mdl_sub
generic map(
A_L => M1_A_L,
Z_L => M1_Z_L)
port map(
clk_i => clk_i,
rst_i => rst_i,
a_i => m1_a_i,
z_o => m1_z_o);
end architecture;
然后可以单独编译带有模块的两个文件,然后将 mdl_sub
集成到 mdl_top
,如 Brian Drummond 所述。
抱歉,模块较长,但我有现成的示例;-)
我有多个来自不同来源的 VHDL 代码,我想将它们组合成一个系统。
我的理解是,我必须从每个代码中提取我感兴趣的实体和架构,然后我创建一个将它们组合在一起的新实体,架构也是如此。
我错过了如何在此过程中使用这些的后续步骤。
如果能从你们那里得到一些关于如何正确执行并避免像我这样的 VHDL 新手可能会犯的错误的提示和技巧,那就太好了。
图中总结了我所拥有的和我所需要的
Multiple VHDL to one
此致
这个例子可以是如果你有两个模块,mdl_sub
子模块:
library ieee;
use ieee.std_logic_1164.all;
entity mdl_sub is
generic(
A_L : natural;
Z_L : natural);
port(
clk_i : in std_logic;
rst_i : in std_logic;
a_i : in std_logic_vector(A_L - 1 downto 0);
z_o : out std_logic_vector(Z_L - 1 downto 0));
end entity;
library ieee;
use ieee.numeric_std.all;
architecture syn of mdl_sub is
signal z : std_logic_vector(z_o'range);
begin
process (clk_i, rst_i) is
begin
-- Clock
if rising_edge(clk_i) then
z <= std_logic_vector(unsigned(z) + unsigned(a_i));
end if;
-- Reset
if rst_i = '1' then
z <= (others => '0');
end if;
end process;
-- Drive output
z_o <= z;
end architecture;
和 mdl_top
顶级模块:
library ieee;
use ieee.std_logic_1164.all;
entity mdl_top is
generic(
M0_A_L : natural := 8;
M0_Z_L : natural := 8;
M1_A_L : natural := 4;
M1_Z_L : natural := 4);
port(
clk_i : in std_logic;
rst_i : in std_logic;
m0_a_i : in std_logic_vector(M0_A_L - 1 downto 0);
m0_z_o : out std_logic_vector(M0_Z_L - 1 downto 0);
m1_a_i : in std_logic_vector(M1_A_L - 1 downto 0);
m1_z_o : out std_logic_vector(M1_Z_L - 1 downto 0));
end entity;
library ieee;
use ieee.numeric_std.all;
architecture syn of mdl_top is
begin
-- Sub-module 0
mdl_sub_0 : entity work.mdl_sub
generic map(
A_L => M0_A_L,
Z_L => M0_Z_L)
port map(
clk_i => clk_i,
rst_i => rst_i,
a_i => m0_a_i,
z_o => m0_z_o);
-- Sub-module 1
mdl_sub_1 : entity work.mdl_sub
generic map(
A_L => M1_A_L,
Z_L => M1_Z_L)
port map(
clk_i => clk_i,
rst_i => rst_i,
a_i => m1_a_i,
z_o => m1_z_o);
end architecture;
然后可以单独编译带有模块的两个文件,然后将 mdl_sub
集成到 mdl_top
,如 Brian Drummond 所述。
抱歉,模块较长,但我有现成的示例;-)