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

结果正确:

相关推荐
丝斯201121 小时前
AI学习笔记整理(22)—— AI核心技术(深度学习6)
人工智能·笔记·学习
koo36421 小时前
pytorch深度学习笔记1
pytorch·笔记·深度学习
jimmyleeee1 天前
人工智能基础知识笔记二十一:Function Calling
人工智能·笔记
丝斯20111 天前
AI学习笔记整理(21)—— AI核心技术(深度学习5)
人工智能·笔记·学习
szxinmai主板定制专家1 天前
柔宇柔性显示屏+x86、arm显示解决方案,还有库存
arm开发·人工智能·fpga开发
风123456789~1 天前
【健康管理】第5章 流行病学、医学统计学 1/2
笔记·考证·健康管理
CHY_1281 天前
JESD204B 协议解析(5)ILA序列
fpga开发·jesd204
closejudge1 天前
部署siyuan笔记docker问题记录
笔记
摇滚侠1 天前
零基础小白自学Git_Github教程,GitHubDeskTop安装,笔记10
笔记·git·github
摇滚侠1 天前
零基础小白自学 Git_Github 教程,GitHub 是如何工作的,笔记08
笔记·git·github