下面的代码在 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;