@(posege Clk); 之间的区别a<=1'b1;和 @(posege Clk) a<= 1'b1;

发布于 2024-12-27 18:23:31 字数 239 浏览 2 评论 0 原文

有什么区别

@(posedge Clk);
   a<= 1'b1;

@(posedge Clk)
   a<= 1'b1;

注意Clk后面的分号。当我浏览测试平台时,我遇到了类似的代码行。我做了一些简单的实验,在模拟过程中我找不到任何差异。由于分号的存在/不存在,这些行后面的代码的执行顺序是否会发生任何变化?

Is there any difference between

@(posedge Clk);
   a<= 1'b1;

and

@(posedge Clk)
   a<= 1'b1;

Note the semicolon after Clk. I came across similar lines of code when I was browsing through a testbench. I did some simple experiments and I could not find any differences during simulation. Will the sequence of execution for the code following these lines change in any way due to the presence/absence of the semicolon?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰魂雪魄 2025-01-03 18:23:31

任何过程语句的 BNF 语法本质上都是

statement_item := 
        {procedural_timing_control} statement;

这意味着您可以在任何语句前面有 0 个或多个时序控制。在您的示例中,@(thoughtge Clk) 是时序控制,a<= 1'b1; 是语句。

如果您的示例位于 fork/join 内,则会出现行为差异,因为前者是两个语句;后者是一种说法。

fork
  @(posedge Clk); a<=1'b1;
join

在这种情况下,这 2 个语句并行启动 - a 不会等待 posege 被分配。

The BNF syntax for any procedural statement is essentially

statement_item := 
        {procedural_timing_control} statement;

This means you can have 0 or more timing controls in front of any statement. In your example @(posedge Clk) is a timing control and a<= 1'b1; is the statement.

If your example were inside a fork/join, there would be a behavioral difference because the former is two statements; the later is one statement.

fork
  @(posedge Clk); a<=1'b1;
join

In this case, the 2 statements are started in parallel - a would not wait for the posedge to be assigned.

薄凉少年不暖心 2025-01-03 18:23:31

你是对的——没有行为差异。

分号版本是:等等。这样做。
非分号版本是:等待然后执行此操作。有时您会看到这种形式用于单行:

@(posedge Clk) a<= 1'b1;

You're correct -there's no behavioural difference.

The semicolon version is: Wait. Do this.
The non-semicolon version is: Wait then do this. You'll sometimes see this form used in one-liners:

@(posedge Clk) a<= 1'b1;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文