D
Dave Wilson
Guest
Hello all,
I'm trying to convert some VHDL code to Verilog and have a few syntax
problems. Can anyone see what I'm doing wrong in this code ?
// 18-06-04
module sync_compare_verilog(clk,aclr,enable,out,get_ready_pulse
,main_sync,sync_polarity,missing_sync,sync_valid,sync_out);
input clk,aclr,enable,get_ready_pulse,main_sync,sync_polarity,missing_sync;
output sync_valid,sync_out;
reg sync_valid;
reg sync_out;
reg state;
parameter zero=0, one=1;
always @(state)
begin
case (state)
zero:
out = 1'b0;
one:
out = 1'b1;
default:
out = 1'b0;
endcase
end
always @(posedge clk or posedge aclr)
begin
if (aclr)
sync_valid = 1'b0;
sync_out = 1'b0;
state = zero;
else
case (state)
zero: // ----------------------------- STATE 0
if (enable == 1'b1) // wait for enable
if (get_ready_pulse == 1'b1)
if (main_sync == 1'b1) and (sync_polarity = 1'b0) // check which
way ..
sync_valid = 1'b1;
// sync_out = main_sync; -- = 1
state = one;
else if (main_sync == 1'b0) and (sync_polarity == 1'b1)
sync_valid = 1'b1;
// sync_out = main_sync; -- = '0'
state = one;
else
sync_valid = 1'b0;
// sync_out = main_sync; -- = '0'
state = zero; // wait for the start conditions ..
end;
else
sync_valid = 1'b0;
//sync_out = main_sync; -- = '0'
state = zero; // wait for the start conditions ..
end;
else
state = zero;
end;
one: // ---------------------------------------- STATE 1
if (missing_sync == 1'b1)
sync_valid = 1'b0;
state = zero;
else
state = one;
//sync_out = main_sync;
end;
endcase
end;
endmodule
I'm trying to convert some VHDL code to Verilog and have a few syntax
problems. Can anyone see what I'm doing wrong in this code ?
// 18-06-04
module sync_compare_verilog(clk,aclr,enable,out,get_ready_pulse
,main_sync,sync_polarity,missing_sync,sync_valid,sync_out);
input clk,aclr,enable,get_ready_pulse,main_sync,sync_polarity,missing_sync;
output sync_valid,sync_out;
reg sync_valid;
reg sync_out;
reg state;
parameter zero=0, one=1;
always @(state)
begin
case (state)
zero:
out = 1'b0;
one:
out = 1'b1;
default:
out = 1'b0;
endcase
end
always @(posedge clk or posedge aclr)
begin
if (aclr)
sync_valid = 1'b0;
sync_out = 1'b0;
state = zero;
else
case (state)
zero: // ----------------------------- STATE 0
if (enable == 1'b1) // wait for enable
if (get_ready_pulse == 1'b1)
if (main_sync == 1'b1) and (sync_polarity = 1'b0) // check which
way ..
sync_valid = 1'b1;
// sync_out = main_sync; -- = 1
state = one;
else if (main_sync == 1'b0) and (sync_polarity == 1'b1)
sync_valid = 1'b1;
// sync_out = main_sync; -- = '0'
state = one;
else
sync_valid = 1'b0;
// sync_out = main_sync; -- = '0'
state = zero; // wait for the start conditions ..
end;
else
sync_valid = 1'b0;
//sync_out = main_sync; -- = '0'
state = zero; // wait for the start conditions ..
end;
else
state = zero;
end;
one: // ---------------------------------------- STATE 1
if (missing_sync == 1'b1)
sync_valid = 1'b0;
state = zero;
else
state = one;
//sync_out = main_sync;
end;
endcase
end;
endmodule