Verilog刷题笔记41

题目:Create 8 D flip-flops with active high asynchronous reset. All DFFs should be triggered by the positive edge of clk.
在这里插入图片描述
解题:

module top_module (
    input clk,
    input areset,   // active high asynchronous reset
    input [7:0] d,
    output [7:0] q
);
    always@(posedge clk,posedge areset)
    if(areset)
        q<=8'h0;
    else
        q<=d;
       
endmodule

结果正确
在这里插入图片描述
官方答案:

module top_module(
	input clk,
	input [7:0] d,
	input areset,
	output reg [7:0] q);
	
	// The only difference in code compared to synchronous reset is in the sensitivity list.
	always @(posedge clk, posedge areset)
		if (areset)
			q <= 0;
		else
			q <= d;


	// In Verilog, the sensitivity list looks strange. The FF's reset is sensitive to the
	// *level* of areset, so why does using "posedge areset" work?
	// To see why it works, consider the truth table for all events that change the input 
	// signals, assuming clk and areset do not switch at precisely the same time:
	
	//  clk		areset		output
	//   x		 0->1		q <= 0; (because areset = 1)
	//   x		 1->0		no change (always block not triggered)
	//  0->1	   0		q <= d; (not resetting)
	//  0->1	   1		q <= 0; (still resetting, q was 0 before too)
	//  1->0	   x		no change (always block not triggered)
	
endmodule

注意点:
与同步复位相比,异步复位代码的唯一区别在于灵敏度列表

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-03-22 07:28:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-22 07:28:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-22 07:28:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-22 07:28:02       18 阅读

热门阅读

  1. 2024.3.21 ARM

    2024-03-22 07:28:02       18 阅读
  2. C++ 函数指针与回调函数

    2024-03-22 07:28:02       22 阅读
  3. 全球化战略中的技术纵深

    2024-03-22 07:28:02       17 阅读
  4. android11 系统的启动流程 的面试题目

    2024-03-22 07:28:02       20 阅读
  5. Python 机器学习 前向后向算法评估观察序列概率

    2024-03-22 07:28:02       19 阅读
  6. ChatGPT为您的论文写作提供无限可能

    2024-03-22 07:28:02       19 阅读
  7. Play on Words(UVA 10129)

    2024-03-22 07:28:02       15 阅读