verilog理论刷题篇1 Alwaysblock1 2

news/2025/2/16 1:22:59/

总结:

using an assign statement,连续赋值给wire类型赋值assign
a combinational always block,组合逻辑 always 块给wire类型赋值always @(*)
and a clocked always block.时序逻辑always 块给reg类型赋值always @(posedge clk)

        组合逻辑:使用assign always @(*)

  时序逻辑:使用always @(posedge clk)

        不得不说,刷完题后,在开发板实战环节,代码编写及对verilog的理解有了一个质的提高。

verilog三种赋值的使用场景:下面这段话,五星重要

Blocking vs. Non-Blocking Assignment

There are three types of assignments in Verilog:

  • Continuous assignments (assign x = y;). Can only be used when not inside a procedure ("always block").
  • Procedural blocking assignment: (x = y;). Can only be used inside a procedure.
  • Procedural non-blocking assignment: (x <= y;). Can only be used inside a procedure.

In a combinational always block, use blocking assignments. In a clocked always block, use non-blocking assignments. A full understanding of why is not particularly useful for hardware design and requires a good understanding of how Verilog simulators keep track of events. Not following this rule results in extremely hard to find errors that are both non-deterministic and differ between simulation and synthesized hardware.

英文原汁原味,解释得特别清晰,

1.连续赋值assign x=y;不能放在always块里使用

2.阻塞赋值 x=y;只能用在组合always块always @(*) 的场景 

先执行x=1,再执行y=2,语句顺序执行,像C语言

x=1;

y=2;

3.非阻塞赋值  x<=y;只能用在时序always块always@(posedge clk) 的场景

两条语句同时执行,并行

x<=1;

y<=2;

一. always block (combinational)

连续赋值assign 与wire类型对应

always @(*)与 reg类型对应

// synthesis verilog_input_version verilog_2001
module top_module(input a, input b,output wire out_assign,output reg out_alwaysblock
);
assign out_assign = a & b;
always @(*) out_alwaysblock = a & b;    
endmodule

二. always block (clocked)

下面3条语句描述的电路功能是一样的

    assign out_assign = a^b;always @(*) out_always_comb = a^b;always @(posedge clk) out_always_ff = a^b;

完整代码

// synthesis verilog_input_version verilog_2001
module top_module(input clk,input a,input b,output wire out_assign,output reg out_always_comb,output reg out_always_ff   );assign out_assign = a^b;always @(*) out_always_comb = a^b;always @(posedge clk) out_always_ff = a^b;
endmodule


http://www.ppmy.cn/news/741284.html

相关文章

sqlserver2016无域alwayson搭建

前期准备&#xff1a; windows系统&#xff1a;window server 2016 数据库&#xff1a;sqlserver 2016 两台电脑 两个虚拟IP 1.安装windows 故障转移功能; 2.两节点添加相同名称的后缀DNS 3.访问 C:\Windows\System32\drivers\etc &#xff0c;修改host文件&#xff08…

ALE简介

ALE的全称&#xff1a;Application Level Events ALE的位置&#xff1a; ALE的优势&#xff1a;屏蔽了“获取EPC数据组件”、“过滤组件”、“应用程序”之间的联系&#xff0c;使得其中任意组件的改变都不会影响到其他组件。 ALE接口&#xff1a; 1. Reading API 2. Writing A…

AVL-Review

二叉树的删除 最值节点一定是叶节点&#xff0c;没有子树&#xff0c;所以在移动最值节点后删除的时候不用考虑最值节点下的节点移动问题。 完全二叉树和完美二叉树的区别&#xff1a; 完美二叉树&#xff1a;一个深度为k(>-1)且有2^(k1) - 1个结点的二叉树 ​ 深度&am…

alv

*&---------------------------------------------------------------------* *& REPORT ZMMR238 *& *&---------------------------------------------------------------------* *& 需求描述&#xff1a;設備進機明細系統化 *& 需求單號&#xff1a…

ALV小计

导语&#xff1a;最近开发程序的时候&#xff0c;用户方有需求为特定商品以月维度看每天的销售明细&#xff0c;然后还要在每个月最后一单下面显示出月汇总&#xff0c;这就属于分组汇总的意思了。标准的合计按钮只能合计一列的所有&#xff0c;下面说一下具体实现方式。 我一…

AWVS介绍

使用AWVS对域名进行全局分析&#xff0c;深入探索&#xff1a; 首先&#xff0c;介绍一下AWVS这个工具。 Acunetix Web Vulnerability Scanner&#xff08;简称AWVS&#xff09;是一款知名的网络漏洞扫描工具&#xff0c;它通过网络爬虫测试你的网站安全&#xff0c;检测流行安…

WADL 简介

WADL 越来越多的 依赖于Web的企业&#xff08;像Google, Yahoo, Amazon, Flickr等&#xff09;正在开发基于HTTP的应用&#xff08;通过XML访问其内部数据&#xff09;。用基于文本的协议描述和基于XMLSchema的数据格式描述来描述应用&#xff1b;为了使用这种基于HTTP的web应用…

AVL树

AVL树的性质 AVL树(Balanced Binary Tree or Height-Balanced Tree) AVL树或者是空二叉树&#xff0c;或者是具有如下性质的BST&#xff1a; 根结点的左、右子树高度之差的绝对值不超过1且根结点左子树和右子树仍然是AVL树。 结点的平衡因子BF&#xff08;Balanced Factor&a…