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

结果正确:

相关推荐
unicrom_深圳市由你创科技13 小时前
如何做FPGA的功耗优化?动态功耗管理怎么实现?
fpga开发
不会武功的火柴13 小时前
SystemVerilog语法(9)-验证基础与简单Testbench
嵌入式硬件·fpga开发·fpga·systemverilog·硬件描述语言·rtl·uvm验证
June bug13 小时前
【AI赋能测试笔记】5基于文档用例生成系统及skills
笔记·功能测试·职场和发展·测试用例·学习方法
kaizq13 小时前
MuleRun助力MakerChip-FPGA在线编程模拟仿真操练
fpga开发·verilog·龙虾机器人·mulerun·makerchip·在线模拟仿真
c-u-r-ry3013 小时前
vivado处理硬件设计差分对布线极性翻转的问题
经验分享·fpga开发
XINVRY-FPGA13 小时前
XC7Z020-2CLG484I Xilinx Zynq-7000 SoC FPGA
嵌入式硬件·fpga开发·云计算·硬件工程·fpga
小眼睛FPGA13 小时前
【紫光HiYou开源入门轻量级PCIE开发板PG2L25G】实验例程2-基于紫光FPGA 的键控流水灯实验例程
fpga开发
XMAIPC_Robot13 小时前
电力设备RK3568/RK3576+FPGA,多系统混合部署Linux+RTOS RT-THREAD,强实时性
linux·运维·fpga开发
nnsix13 小时前
设计模式 - 原型模式 笔记
笔记·设计模式·原型模式
handler0114 小时前
【Linux 网络】一文读懂 HTTP 协议
linux·c语言·网络·c++·笔记·网络协议·http