joe2moon
Full Member level 5
I try the X-HDL 3.2.21 release from x-tek (h**p://www.x-tekc0rp.c0m),
and get the following result.
Test: VHDL to Verilog translation
Input: D flip-flop entity (DFF.vhd)
Ouput: D flip-flop module (DFF_D.v)
-- Input: DFF.vhd --
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity DFF is
generic(N : integer := 8);
port(CLK : in std_logic;
RSTB : in std_logic;
D : in std_logic_vector(N-1 downto 0);
Q : out std_logic_vector(N-1 downto 0));
end DFF;
architecture DFF_A1 of DFF is
begin
dff_procrocess(RSTB, CLK)
begin
if(RSTB='0') then
Q <= (others=>'0');
elsif(CLK'event and CLK='1') then
Q <= D;
end if;
end process dff_proc;
end DFF_A1;
// output: DFF_D.v
module DFF (CLK, RSTB, D, Q);
parameter N = 8;
input CLK;
input RSTB;
input[N - 1:0] D;
output[N - 1:0] Q;
reg[N - 1:0] Q;
always @(RSTB or CLK)
begin : dff_proc
if (RSTB == 1'b0)
begin
Q <= {1{1'b0}} ;
end
else if (CLK == 1'b1)
begin
Q <= D ;
end
end
endmodule
// Expected result
module DFF(D, CLK, RSTB, Q);
parameter N=8;
input [N-1:0] D;
input CLK, RSTB;
output [N-1:0] Q;
reg [N-1:0] Q;
always @(posedge CLK or negedge RSTB)
begin
if(!RSTB) Q <= 0;
else Q <= D;
end
endmodule // DFF
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Since D flip-flop is a sequential logic, and inside the
sensitivity list should have "posedge CLK" & "negedge RSTB".
NOT only CLK or RSTB, which will be synthesized into the
combinational logic !
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I don't understand why XHDL translate in this way.
(Maybe I should follow some rules to get the desired result ?)
Any suggestion ?
and get the following result.
Test: VHDL to Verilog translation
Input: D flip-flop entity (DFF.vhd)
Ouput: D flip-flop module (DFF_D.v)
-- Input: DFF.vhd --
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity DFF is
generic(N : integer := 8);
port(CLK : in std_logic;
RSTB : in std_logic;
D : in std_logic_vector(N-1 downto 0);
Q : out std_logic_vector(N-1 downto 0));
end DFF;
architecture DFF_A1 of DFF is
begin
dff_procrocess(RSTB, CLK)
begin
if(RSTB='0') then
Q <= (others=>'0');
elsif(CLK'event and CLK='1') then
Q <= D;
end if;
end process dff_proc;
end DFF_A1;
// output: DFF_D.v
module DFF (CLK, RSTB, D, Q);
parameter N = 8;
input CLK;
input RSTB;
input[N - 1:0] D;
output[N - 1:0] Q;
reg[N - 1:0] Q;
always @(RSTB or CLK)
begin : dff_proc
if (RSTB == 1'b0)
begin
Q <= {1{1'b0}} ;
end
else if (CLK == 1'b1)
begin
Q <= D ;
end
end
endmodule
// Expected result
module DFF(D, CLK, RSTB, Q);
parameter N=8;
input [N-1:0] D;
input CLK, RSTB;
output [N-1:0] Q;
reg [N-1:0] Q;
always @(posedge CLK or negedge RSTB)
begin
if(!RSTB) Q <= 0;
else Q <= D;
end
endmodule // DFF
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Since D flip-flop is a sequential logic, and inside the
sensitivity list should have "posedge CLK" & "negedge RSTB".
NOT only CLK or RSTB, which will be synthesized into the
combinational logic !
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I don't understand why XHDL translate in this way.
(Maybe I should follow some rules to get the desired result ?)
Any suggestion ?