说清楚

Posted yinhuachen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了说清楚相关的知识,希望对你有一定的参考价值。

https://zhuanlan.zhihu.com/p/359330607

三种情况:

  • valid先发起请求

  • ready先发起请求

  • 同时发起请求

 

 

 

 

 

仔细观察上述3幅时序图,我们了解valid-ready握手机制需要注意三件事:

  1. valid与ready不可过度依赖,比如valid不可以等待ready到达再拉高(为了防止死锁TODO: 有没有具体点的例子?说明后果),但是在axi协议中的握手信号,ready是可以等待valid拉高再拉高的,valid不可依赖ready的原因是防止死锁(deadlock),本文的代码他俩彼此可以互相独立发出请求拉高;
  2. valid拉高时与有效数据同步,时钟要对齐;(valid与有效数据拉高的时钟要对齐,提高效率)
  3. 当数据计算好后,valid可以拉高等待ready拉高,但是每当握手成功之后,数据需要更新,如果此时没有新的有效数据,valid要拉低。

 

通过一个Ready信号告诉自己前面的模块暂停数据传输的方法被称之为‘反压’。

 

握手与反压

当入口流量大于出口流量,这时候就需要反压,或者,当后级未准备好时,如果本级进行数据传递,那么它就需要反压前级,所以此时前级需要将数据保持不动,直到握手成功才能更新数据。而反压在多级流水线中就变得稍显复杂,原因在于,比如我们采用三级流水设计,如果我们收到后级反压信号,我们理所当然想反压本级输出信号的寄存器,但是如果只反压最后一级寄存器,那么会面临一个问题,就是最后一级寄存器数据会被前两级流水冲毁,导致数据丢失,引出数据安全问题,所以我们此时需要考虑反压设计。

 

script标签的asyncdefer属性傻傻分不清楚?来一次说清楚

Normal Execution

Before looking into the effect of the two attributes, we must first look at what occurs in their absence. By default, as mentioned above, JavaScript files will interrupt the parsing of the HTML document in order for them to be fetched (if not inline) and executed.

Take, for example, this script element located somewhere in the middle of the page -

<html>
<head> ... </head>
<body>
    ...
    <script src="script.js">
    ....
</body>
</html>

As the document parser goes through the page, this is what occurs -

Normal JavaScript Execution. HTML Parsing paused for script fetching and execution

The HTML parsing is paused for the script to be fetched and executed, thereby extending the amount of time it takes to get to first paint.

The async Attribute

The async attribute is used to indicate to the browser that the script file can be executed asynchronously. The HTML parser does not need to pause at the point it reaches the script tag to fetch and execute, the execution can happen whenever the script becomes ready after being fetched in parallel with the document parsing.

<script async src="script.js">

This attribute is only available for externally located script files. When an external script has this attribute, the file can be downloaded while the HTML document is still parsing. Once it has been downloaded, the parsing is paused for the script to be executed.

Asynchronous JavaScript Execution. HTML parsing is paused only for the script execution

The defer Attribute

The defer attribute tells the browser to only execute the script file once the HTML document has been fully parsed.

<script defer src="script.js">

Like an asynchronously loaded script, the file can be downloaded while the HTML document is still parsing. However, even if the file is fully downloaded long before the document is finished parsing, the script is not executed until the parsing is complete.

Deferred JavaScript Execution. HTML parsing is never paused. Script execution happens after parsing is complete.

Asynchronous, Deferred or Normal Execution?

So, when should we use asynchronous, deferred, or normal JavaScript execution? As always, it depends on the situation, and there are a few questions to consider.

Where is the

Asynchronous and deferred execution of scripts are more important when the

Is the script self-contained?

For script files that are not dependent on other files and/or do not have any dependencies themselves, the async attribute is particularly useful. Since we do not care exactly at which point the file is executed, asynchronous loading is the most suitable option.

Does the script rely on a fully parsed DOM?

In many cases, the script file contains functionality that requires interaction with the DOM. Or, it may have a dependency on another file included on the page. In these cases, the DOM must be fully parsed before the script should be executed. Typically, such a file will be placed at the bottom of the page to ensure everything before it has been parsed. However, in situation where, for whatever reason, the file in question needs to be placed elsewhere, the defer attribute can be used.

Is the script a (small) dependency?

Finally, if the script is relatively small, and/or is depended on by other files, it may be more useful to have it defined inline. Although having it inline will block the parsing of the HTML document, it should not be a significant interference if it’s a small size. Additionally, if it is depended on by other files, the minor blocking may be necessary.

以上是关于说清楚的主要内容,如果未能解决你的问题,请参考以下文章

极大似然说清楚?

HMM说清楚?

CRF说清楚?

说清楚

[转帖]浅谈IOC--说清楚IOC是什么

云原生是什么?你真的能说清楚吗?