【问题标题】:Verilog contention with next signalVerilog 与下一个信号的争用
【发布时间】:2012-10-30 06:52:30
【问题描述】:

我正在尝试实现以下代码:

reg [7:0] next_busy;

always @* begin
    next_busy = busy; //default assignment

    if (condition determined by module input) begin
        next_busy[0]= 1'b1;
    end
end //always @*

always @(posedge clock) begin
    if (reset) begin
        busy <= 8'b0;
    end else begin
        busy <= next_busy;
    end
end //always @(posedge clock)

这在模拟中运行良好,但在合成中似乎存在对 next_busy 信号的某种争用。也就是说,如果busy 不是1(比如前一个周期有一个复位),那么它输出一个x(如果满足输入条件)。但是,如果busy 已经为1(并且满足输入条件),则next_busy 被正确分配为1。所以我只是想知道是否有一种正确的方法来做我想做的事情,以便它也可以在合成中工作?

【问题讨论】:

  • 您的代码对我来说看起来不错。在门级仿真中,您在哪里看到了争用?您是否在该模块中的其他任何地方分配给next_busy?综合日志中是否有提及该信号的警告消息。

标签: simulation verilog synthesis mismatch contention


【解决方案1】:

您通常将复位包含在触发器的敏感度列表中。对于低电平有效复位always @(posedge clock or negedge reset)

在提供的示例中,busy 没有定义,假设它是reg [7:0] busy;

我会按照以下方式实施:

reg [7:0] busy;

always @(posedge clock or negedge reset) begin
    if (reset == 1'b0) begin
        busy    <= 8'b0;
    end
    else if (condition determined by module input) begin
        busy[0] <= 1'b1; // busy <= 8'b1;
    end
    else begin
        busy    <= next_busy;
    end
end //always @(posedge clock)

【讨论】:

  • 操作可能需要同步重置?
  • 他们可能会,但我总是会包含一个用于初始化的重置。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-20
  • 2018-05-23
  • 2021-12-01
  • 2017-02-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多