Gizmotoy
Newbie level 5
VHDL to Verilog Conversion Issue - Blocking vs. Non-blocking and Register Delays?
Hello. I have a good amount of experience in VHDL, but I'm trying to learn Verilog. I thought it might be worthwhile to hand-convert some of my VHDL designs into Verilog in order to learn the language. I have one procedure in particular that I can't get converted properly, as it is producing incorrect output. DATA and data_z are coincident on the same clock, and data_2z follows on the rising edge of the next clock.
What I'm looking for is like the VHDL produces: If DATA transitions low to high on clock cycle 1, then on the next clock rising edge data_z transitions, then data_2z on the rising edge after that.
Here's the VHDL that works:
And the "equivalent" Verilog that's not quite working right:
Why does the Verilog perform like this? I seem to be missing something. All signals are defined as Regs, but DATA is an input port for the module if that makes any difference.
Hello. I have a good amount of experience in VHDL, but I'm trying to learn Verilog. I thought it might be worthwhile to hand-convert some of my VHDL designs into Verilog in order to learn the language. I have one procedure in particular that I can't get converted properly, as it is producing incorrect output. DATA and data_z are coincident on the same clock, and data_2z follows on the rising edge of the next clock.
What I'm looking for is like the VHDL produces: If DATA transitions low to high on clock cycle 1, then on the next clock rising edge data_z transitions, then data_2z on the rising edge after that.
Here's the VHDL that works:
Code:
Reg_Data: process(CLOCK)
begin
if rising_edge(CLOCK) then
if (CLEAR = '1') then
data_z <= '0';
data_2z <= '0';
enable_z <= '0';
enable_2z <= '0';
gen_crc_z <= '0';
else
data_z <= DATA;
data_2z <= data_z;
enable_z <= ENABLE;
enable_2z <= enable_z;
gen_crc_z <= GEN_CRC;
end if;
end if;
end process Reg_Data;
And the "equivalent" Verilog that's not quite working right:
Code:
always @(posedge CLOCK)
begin
if (CLEAR == 1'b1) begin
data_z <= 1'b0;
data_2z <= 1'b0;
enable_z <= 1'b0;
enable_2z <= 1'b0;
gen_crc_z <= 1'b0;
end else begin
data_z <= DATA;
data_2z <= data_z;
enable_z <= ENABLE;
enable_2z <= enable_z;
gen_crc_z <= GEN_CRC;
end
end
Why does the Verilog perform like this? I seem to be missing something. All signals are defined as Regs, but DATA is an input port for the module if that makes any difference.
Last edited: