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

结果正确:

相关推荐
IOT.FIVE.NO.110 分钟前
Linux实操笔记2 Ubuntu安装Nginx的不同方法
linux·笔记·ubuntu
akbar&44 分钟前
计算机三级 - 数据库技术 - 第十三章 大规模数据库架构 笔记
数据库·笔记
sixteenyy1 小时前
学习笔记(一)
笔记·学习
邹莉斯2 小时前
FPGA基本结构和简单原理
fpga开发·硬件工程
悲喜自渡7212 小时前
易灵思FPGA开发(一)——软件安装
fpga开发
吃什么芹菜卷2 小时前
2024.9最新:CUDA安装,pytorch库安装
人工智能·pytorch·笔记·python·深度学习
云边有个稻草人2 小时前
【刷题】Day5--数字在升序数组中出现的次数
开发语言·笔记·算法
月夕花晨3742 小时前
C++学习笔记(26)
c++·笔记·学习
ZxsLoves3 小时前
【【通信协议ARP的verilog实现】】
fpga开发
zhangrelay4 小时前
Arduino IDE离线配置第三方库文件-ESP32开发板
笔记·学习·持续学习