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

结果正确:

相关推荐
qeen8734 分钟前
【算法笔记】时间复杂度与空间复杂度
笔记
_李小白2 小时前
【OSG学习笔记】Day 50: Text与Font
笔记·学习
于慨2 小时前
flutter开发笔记
笔记
jimmyleeee2 小时前
人工智能基础知识笔记三十九:几个Skills的网站
人工智能·笔记·chatgpt
Hello_Embed2 小时前
嵌入式上位机开发入门(二十二):RTU/TCP 双协议互斥访问寄存器
笔记·网络协议·tcp/ip·嵌入式
碎碎思2 小时前
开源雷达做到20km?一个PLFM雷达项目的FPGA实现拆解
fpga开发
南宫萧幕3 小时前
自动控制原理|稳定性与劳斯判据 知识点+计算题+MATLAB实现全套笔记
笔记·matlab·控制
有个人神神叨叨3 小时前
Claude Managed Agents 快速入门笔记
人工智能·笔记
Saniffer_SH3 小时前
【市场洞察】一叶知秋 - 从2026年开年Quarch公司PCIe 6.0测试工具销售状况说起
服务器·人工智能·嵌入式硬件·测试工具·fpga开发·自动化·压力测试
yuyuyuliang003 小时前
python笔记1
开发语言·笔记·python