【问题标题】:Delta-sigma DAC from Verilog to VHDL从 Verilog 到 VHDL 的 Delta-sigma DAC
【发布时间】:2010-12-31 09:28:25
【问题描述】:

下面的代码在 Verilog 中实现了一个 Delta-sigma DAC,来自 Xilinx 应用笔记,我想编写等效的 VHDL 代码。我对 Verilog 一无所知,而且我是 VHDL 的初学者,所以我不得不做出很多猜测,并且可能是初学者的错误(下面的代码)。我不确定翻译是否正确,有人可以帮忙吗?

原版 Verilog

`timescale 100 ps / 10 ps
`define MSBI 7

module dac(DACout, DACin, Clk, Reset);
output DACout;
reg DACout;
input [`MSBI:0] DACin;
input Clk;
input Reset;

reg [`MSBI+2:0] DeltaAdder;
reg [`MSBI+2:0] SigmaAdder;
reg [`MSBI+2:0] SigmaLatch;
reg [`MSBI+2:0] DeltaB;

always @(SigmaLatch) DeltaB = {SigmaLatch[`MSBI+2], SigmaLatch[`MSBI+2]} << (`MSBI+1);
always @(DACin or DeltaB) DeltaAdder = DACin + DeltaB;
always @(DeltaAdder or SigmaLatch) SigmaAdder = DeltaAdder + SigmaLatch;
always @(posedge Clk or posedge Reset)
begin
    if(Reset)
    begin
        SigmaLatch <= #1 1'bl << (`MSBI+1);
        DACout <= #1 1'b0;
    end
    else
    begin
        SigmaLatch <== #1 SigmaAdder;
        DACout <= #1 SigmaLatch[`MSBI+2];
    end
end
endmodule

我在 VHDL 中的尝试:

entity audio is
    generic(
        width  : integer := 8
    );
    port(
        reset  : in    std_logic;
        clock  : in    std_logic;
        dacin  : in    std_logic_vector(width-1 downto 0);
        dacout : out   std_logic
    );
end entity;

architecture behavioral of audio is
    signal deltaadder    : std_logic_vector(width+2 downto 0);
    signal sigmaadder    : std_logic_vector(width+2 downto 0);
    signal sigmalatch    : std_logic_vector(width+2 downto 0);
    signal deltafeedback : std_logic_vector(width+2 downto 0);
begin
    deltafeedback <= (sigmalatch(width+2), sigmalatch(width+2), others => '0');
    deltaadder <= dacin + deltafeedback;
    sigmaadder <= deltaadder + sigmalatch;

    process(clock, reset)
    begin
        if (reset = '1') then
            sigmalatch <= ('1', others => '0');
            dacout <= '0';
        elsif rising_edge(clock) then
            sigmalatch <= sigmaadder;
            dacout <= sigmalatch(width+2);
        end if;
    end process;
end architecture;

【问题讨论】:

  • 您是否尝试过同时模拟 Verilog 和 VHDL 并检查输出?

标签: audio vhdl verilog dac


【解决方案1】:

您似乎正在使用 ieee.std_logic_unsigned(或 _arith)或两者兼有。

Please don't do that。请改用ieee.numeric_std.all

我的 Verilog 几乎不存在,所以我忘记了 Verilog 是否默认使用有符号或无符号算术......但无论是哪种,都将所有数字信号转换为 signedunsigned 类型以匹配。

您的 reset 子句可能希望读取如下内容:

sigmalatch <= (width+1 => '1', others => '0');

增量反馈更新类似于:

deltafeedback(width+2 downto width+1) <= sigmalatch(width+2) & sigmalatch(width+2);
deltafeedback(width downto 0) <= (others => '0');

最后,为了匹配 Verilog,我认为您的 width 泛型应称为 MSBI 并设置为 7,(或将您所有的 width+2s 更改为 width+1s 以匹配您对 @987654331 的意图@通用)

【讨论】:

  • Verilog 算术默认是无符号的,这实际上与它应该是相反的:-)
【解决方案2】:

如果您只是对 VHDL 中的 Delta-sigma DAC 感兴趣,您可以查看我发布到 alt.sources 的实现(请选择“原始消息”,保存到文件并在其上运行“unshar”以获取资源)。

沃伊泰克

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多