在线上“期待一个声明”:“总是@(negedge in2)开始”

时间:2014-05-08 21:49:32

标签: verilog

我一直收到错误:

...,NOTSTT (lab1.v,31|6): expecting a statement [9(IEEE)]

我不能在不是clk的信号上使用negedge吗? 我可以在clk上使用poseedge和在in2上使用negedge吗? 完整的代码是:

module ex1 (in1, in2 ,clk , out1 , out2, bus);

//input&outputs
//==============
input  in1, in2, clk;
output out1,out2,bus;

//reg
//====
reg out1= 1'b0, out2=1'b0, y=1'b0 ;//y = previous state
reg [2:0] bus=3'b000;

//on clk pose edge
//=================
always @(posedge clk) begin 
    if ((in1==1)&&(y==0))
      out1 = 1;
    else if ((in1==0)&&(y==1))
      out2 = 1;
    else 
    begin
      out1 = 0;
      out2 = 0;
    end

    if (in1 == 1)
      y = 1'b1;
    else if (in1 == 0)
      y = 1'b0;

    always @(negedge in2) begin
      if(in1==1)
        bus = 3'b001;
      else if (in1==0)
        bus = 0;
      else
        bus <= bus + 1;
    end

endmodule

1 个答案:

答案 0 :(得分:2)

您错过了第一个end的{​​{1}}。它需要放在begin之前。每个always @(negedge in2)必须有相应的begin

此外,对同步逻辑使用非阻塞(end)分配。

我建议您将常用块合并为一个<=。它将消除always @(posedge clock)上的噪声变化,从而产生意外行为。使用in2in2示例转换为与您类似的新翻牌。