zoukankan      html  css  js  c++  java
  • 在systemverilog中正确使用“禁用fork”

    我有类似于跟随伪代码的东西:
    for (lets say 10 iterations)
    begin
    // Do some configuration changes
        fork
            begin
            ///apply input to design
            end
            begin
            while (1)
            /// at particular point update expected status / values
            end
            begin
            while (1)
            /// read status and verify with expected values
            end
        join_any
    end

    从代码:只有输入的应用程序可以打破fork,因为其他2个线程在while(1)下工作
     我希望在每次迭代之间禁用所有线程,即一旦应用了输入流 – 禁用所有生成的线程,直到下一次迭代开始(使用新配置)

    所以我修改了上面的代码

     ....
     join_any
     disable_fork
     end

    然而,这似乎也禁用了循环以及类似的东西,我不明白,但效果是测试被挂起.
    有人可以解释一下原因和解决方案吗?

    最佳答案
    “disable fork”不仅会杀死fork … join_any启动的进程,还会杀死执行disable-fork的同一进程的后代的任何其他进程.如果您在此过程的生命周期的早期启动了任何其他进程(例如,使用fork … join_none),那么其他进程也将被终止.

    您可以通过使您的fork … join_any及其后来的disable-fork在其自己的新子进程中运行来轻松地防止这种情况发生.这限制了disable-fork的效果,因此它只会影响您关注的新启动的进程,并且保证不会产生其他不需要的影响.

    通过将整个混乱包含在“fork begin … end join”中这样做:

    fork begin // isolate the following code as a single child process
      fork  // launch the processes you wish to manage
        apply_input();
        update_status();
        verify_status();
      join_any // kill off the *_status threads when apply_input terminates
      disable fork;
    end join // end of child process isolation

    这是fork … join_any和fork … join_none的一个众所周知的问题.最近在Verification Guild论坛上进行了讨论,并在Sutherland和Mills的书“Verilog and SystemVerilog Gotchas”的第79和80节中进行了描述.

  • 相关阅读:
    Android Activity的事件分发机制-源码解析
    Android ViewGroup的事件分发机制-源码分析
    Android View的事件分发机制-源码解析
    Activity中的setContentView(R.layout.xxx)源码分析
    android 6.0动态权限的申请
    java 回行矩阵的打印
    Masonry解析ios屏幕适配
    CollectionsUtil 类
    Request.url请求路径的一些属性
    .net中HttpCookie使用
  • 原文地址:https://www.cnblogs.com/verification/p/11537120.html
Copyright © 2011-2022 走看看