Verilog刷题笔记17

题目:

For hardware synthesis, there are two types of always blocks that are relevant:

Combinational: always @(*)

Clocked: always @(posedge clk)

Clocked always blocks create a blob of combinational logic just like combinational always blocks, but also creates a set of flip-flops (or "registers") at the output of the blob of combinational logic. Instead of the outputs of the blob of logic being visible immediately, the outputs are visible only immediately after the next (posedge clk).

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.

A bit of practice

Build an XOR gate three ways, using an assign statement, a combinational always block, and a clocked always block. Note that the clocked always block produces a different circuit from the other two: There is a flip-flop so the output is delayed.

我的解法:

bash 复制代码
// 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

结果正确:

相关推荐
做cv的小昊27 分钟前
科研论文PPT绘图技巧:绘制任意曲线三角形(胖三角形)并制作效果对比图
经验分享·笔记·学习·微软·ai绘画·数据可视化
霖001 小时前
ZYNQ——ultra scale+ IP 核详解与配置
服务器·开发语言·网络·笔记·网络协议·tcp/ip
谅望者2 小时前
数据分析笔记10:数据容器
笔记·数据挖掘·数据分析
谅望者2 小时前
数据分析笔记05:区间估计
笔记·数据挖掘·数据分析
@游子2 小时前
内网渗透笔记-Day2
笔记
河铃旅鹿2 小时前
Android开发-java版:SQLite数据库
android·数据库·笔记·学习·sqlite
嵌入式软硬件攻城狮2 小时前
2.FPGA板卡通过电脑映射连接上网
fpga开发·电脑
optimistic_chen4 小时前
【Java EE进阶 --- SpringBoot】AOP原理
spring boot·笔记·后端·java-ee·开源·aop
brave and determined4 小时前
可编程逻辑器件学习(day22):“让ARM穿上FPGA的马甲“:赛灵思Zynq的命名哲学与技术革命
arm开发·嵌入式硬件·fpga开发·zynq·fpga设计·嵌入式设计·fpga开发流程
AA陈超5 小时前
UE5笔记:OnComponentBeginOverlap
c++·笔记·学习·ue5·虚幻引擎