2014-10-28 56 views
0

我需要使用Verilog的VHDL事件等價物。等效於Verilog上的VHDL事件 - 可合成

這是一個例子,從VHDL轉換爲Verilog的(注:我需要既posedge和negedge在同一porcess):

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

要在同一個過程中擁有posedge和negedge看起來像是一個奇怪的要求。它絕對不能用Verilog或VHDL進行綜合,你的例子當然不需要它在一個進程中。然而,Verilog沒有'事件屬性,而是依賴於你真正的功能,是實現類似行爲的方式。 SystemVerilog可能有更多的幫助你(.triggered方法),但仍然希望看到更多的解釋。 – 2014-10-28 05:53:03

+0

您可以使用always塊,並將您要查找的信號放入靈敏度列表中嗎? – Russell 2014-10-28 11:54:58

回答

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