0

[Yosys 0.8]

我的一位同事向 Yosys 扔了一些随机的verilog 代码,看看它是如何反应的。

这里是:

module top(input clk, input led, output led2, output to_port1,output [24:0] to_port2);


reg ctr = 0;
reg[24:0] counter = 2;
always@(posedge clk) begin
    if (ctr == 1) begin
        ctr <= 0;
        counter <= counter + 1;
    end
    else
        ctr <= 1;
end

assign led2 = ctr;
assign to_port1 = led;
assign to_port2 = counter;
endmodule

和 Yosys,带有命令yosys -o synth.v x.v抛出:

module top(clk, led, led2, to_port1, to_port2);

  reg [24:0] _0_;
  reg _1_;
  reg [24:0] _2_;
  reg _3_;
  wire [31:0] _4_;
  wire _5_;
  input clk;
  reg [24:0] counter;
  reg ctr;
  input led;
  output led2;
  output to_port1;
  output [24:0] to_port2;

  assign _4_ = counter + 32'd1;
  assign _5_ = ctr == 32'd1;
  always @* begin
    _3_ = 1'h0;
  end
  always @* begin
  end
  always @({  }) begin
      ctr <= _3_;
  end
  always @* begin
    _2_ = 25'h0000002;
  end
  always @* begin
  end
  always @({  }) begin
      counter <= _2_;
  end
  always @* begin
    _1_ = ctr;
    _0_ = counter;
    casez (_5_)
      1'h1:
        begin
          _1_ = 1'h0;
          _0_ = _4_[24:0];
        end
      default:
          _1_ = 1'h1;
    endcase
  end
  always @(posedge clk) begin
      ctr <= _1_;
      counter <= _0_;
  end
  assign led2 = ctr;
  assign to_port1 = led;
  assign to_port2 = counter;
endmodule

一些结构最终变得复杂。上面的这个结果代码不能被最近的verilog编译器编译,而原来的代码可以。

为什么always @({ }) begin构造和空always @* begin?有没有我们错过的选项?

谢谢

4

1 回答 1

0

通常,由于 Yosys 对读入的 Verilog 的内部表示的性质,您应该始终在读取和写入 Verilog 之间运行 proc (-p proc)

于 2019-05-14T10:55:18.880 回答