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

结果正确:

相关推荐
晓梦林10 小时前
BUUCTF findKey-学习笔记
笔记·学习
x173880627313 小时前
XXE外部实体注入
xml·笔记
库玛西17 小时前
C++ 运行时多态 :核心总结与原理图解
c语言·c++·笔记
魔力女仆19 小时前
语言开发笔记3
笔记
x173880627319 小时前
文件包含漏洞介绍
笔记
一只小菜鸡..21 小时前
南京大学 操作系统 (JYY) 学习笔记:CPU 的局限、GPU 与 AI 时代的算力革命
人工智能·笔记·学习
所愿ღ1 天前
SSM框架-Spring3
java·开发语言·笔记·spring
影视飓风TIM1 天前
C++ STL 完整入门笔记[8]:deque 底层原理深度剖析
开发语言·c++·笔记
辰丁电子1 天前
PCB设计:EMMC设计规范
fpga开发·pcb设计·pcb工艺·layout·pcb layout
优化Henry1 天前
5G站点软件错误告警与资源激活超时两类典型告警分析与处理
网络·笔记·学习·5g·信息与通信