【问题标题】:How to break a loop if "break" is inside fork-join?如果“break”在fork-join内,如何打破循环?
【发布时间】:2018-07-16 16:12:00
【问题描述】:

我需要打破repeat 循环,其break 决定是在fork-join 块内做出的,但我的模拟器没有编译具有以下结构的代码。

repeat (10) begin
    fork
        begin
            // do something
        end
        begin
            #(100ms);
            break; // compile error
        end
    join_any
    disable fork;
end

我也尝试了disable 命令。我能够编译,但它没有打破循环。

repeat (10)
begin : repeat10_loop
    fork
        begin
            // do something
        end
        begin
            #(100ms);
            disable repeat10_loop; // try
        end
    join_any
    disable fork;
end : repeat10_loop

有没有办法在 fork-join 中使用 breakdisable

【问题讨论】:

    标签: system-verilog


    【解决方案1】:

    breakcontinue 语句必须与循环语句位于同一进程中。您禁用的问题是您错误地标记了循环。试试:

    repeat10_loop: repeat (10)
       begin
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-16
      • 1970-01-01
      • 2021-12-01
      • 1970-01-01
      • 2012-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多