在可移植VHDL中使用特定于供应商的原语

在可移植VHDL中使用特定于供应商的原语,vhdl,Vhdl,我的项目是用可移植的VHDL编写的(主要是用GHDL开发的),但我想利用供应商特定的原语(例如乘法器),如果它们可用的话 例如,在C/C++中,您可以使用#ifdef根据CPU体系结构或编译器供应商等情况有条件地选择不同的代码段 您是否可以在VHDL中使用类似的语言,例如区分Xilinx或Altera/Intel目标?您可以使用生成语句和特定于供应商的实体+体系结构。大量使用此技术来创建 例如,看看PoC的片上存储器(ocram)抽象层: 这里,它为Altera设备实例化了一个特殊实体。对于其他

我的项目是用可移植的VHDL编写的(主要是用GHDL开发的),但我想利用供应商特定的原语(例如乘法器),如果它们可用的话

例如,在C/C++中,您可以使用#ifdef根据CPU体系结构或编译器供应商等情况有条件地选择不同的代码段


您是否可以在VHDL中使用类似的语言,例如区分Xilinx或Altera/Intel目标?

您可以使用
生成
语句和特定于供应商的实体+体系结构。大量使用此技术来创建

例如,看看PoC的片上存储器(ocram)抽象层:


这里,它为Altera设备实例化了一个特殊实体。对于其他设备(Xilinx、Lattice),使用通用VHDL实现。此外,还使用特殊模型进行模拟,因为供应商原语不会模拟FPGA设备文档(例如内存指南)中记录的实际行为。

您可以编写一个可移植实体,并使用配置声明从多个供应商特定的体系结构中选择一个。
gAltera: if not SIMULATION and (VENDOR = VENDOR_ALTERA) generate
    component ocram_tdp_altera
        generic (
            A_BITS      : positive;
            D_BITS      : positive;
            FILENAME    : string        := ""
        );
        port (
            clk1 : in   std_logic;
            clk2 : in   std_logic;
            ce1 : in    std_logic;
            ce2 : in    std_logic;
            we1 : in    std_logic;
            we2 : in    std_logic;
            a1   : in   unsigned(A_BITS-1 downto 0);
            a2   : in   unsigned(A_BITS-1 downto 0);
            d1   : in   std_logic_vector(D_BITS-1 downto 0);
            d2   : in   std_logic_vector(D_BITS-1 downto 0);
            q1   : out std_logic_vector(D_BITS-1 downto 0);
            q2   : out std_logic_vector(D_BITS-1 downto 0)
        );
    end component;
begin
    -- Direct instantiation of altsyncram (including component
    -- declaration above) is not sufficient for ModelSim.
    -- That requires also usage of altera_mf library.

    ram_altera: ocram_tdp_altera
        generic map (
            A_BITS      => A_BITS,
            D_BITS      => D_BITS,
            FILENAME    => FILENAME
        )
        port map (
            clk1    => clk1,
            clk2    => clk2,
            ce1     => ce1,
            ce2     => ce2,
            we1     => we1,
            we2     => we2,
            a1      => a1,
            a2      => a2,
            d1      => d1,
            d2      => d2,
            q1      => q1,
            q2      => q2
        );
end generate gAltera;