相当于'VHDL和Verilog事件 - 可合成的

时间:2014-10-28 00:09:24

标签: vhdl verilog

我需要使用Verilog等效的VHDL事件。

这是一个从VHDL转换为Verilog的示例(注意:我需要在同一个porcess中使用posedge和negedge):

process (CLK, I) begin

 if (I'event and I = 1) then  //posedge
   x <= x + 1;
 elsif (I'event and I = 0)  //negedge
   x <= c + 2;
 end if;

 if (CLK'event and CLK = 1) // posedge
  a <= b + 1;
 end if;

结束过程;

1 个答案:

答案 0 :(得分:1)

我只是试着重写代码。

看来你在这里有两件不同的事情。你有一个分配和x的分配。 a的分配基于时钟,x的分配基于I。

always @(clk) begin
    if (posedge clk)
        a <= b + 1;
end

always @(in_i) begin
    if (posedge in_i)
        x <= x + 1;
    else if (negedge in_i)
        x <= c + 2;
end