【HDLbits刷题笔记】Given the finite state machine circuit as shown, assume that the D flip-flops are initi

Given the finite state machine circuit as shown, assume that the D flip-flops are initially reset to zero before the machine begins.

Build this circuit.)

在这里插入图片描述
HDLbits上的一道题,用实例化做的:

module top_module (
    input clk,
    input x,
    output z
); 
    
    wire d1,d2,d3,d4,d5,d6;
    wire q2,q3;
 
    
    assign d1 =  d4 ^ x ;
    assign d2 = ~d5 & x ;
    assign d3 = ~d6 | x ;
    
    D_D DD1(.d(d1), .q(d4), .clk(clk)  );
    D_D DD2(.d(d2), .q(d5), .clk(clk)  );
    D_D DD3(.d(d3), .q(d6), .clk(clk)  );
    
    assign z = ~( d4 | d5 | d6 );
    

endmodule

module D_D(
	input d,
    input clk,
    output q
);
    
    always@(posedge clk)begin
    	q  <= d;
    end
       
endmodule

编译通过了,这里我最开始把D触发器的~q端也定义为一个output,后来编译不通过,如下:

module D_D(
	input d,
    input clk,
    output q,
    output q1
);
    
    always@(posedge clk)begin
    	q  <= d;
        q1 <= ~ q;
    end
       
endmodule

在这里插入图片描述

省略这个输出端口反而对了,以后的D触发器对于反向端是不必要定义的啊,记录一下。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值