Verilog刷题笔记32

题目:
A heating/cooling thermostat controls both a heater (during winter) and an air conditioner (during summer). Implement a circuit that will turn on and off the heater, air conditioning, and blower fan as appropriate.

The thermostat can be in one of two modes: heating () and cooling (). In heating mode, turn the heater on when it is too cold () but do not use the air conditioner. In cooling mode, turn the air conditioner on when it is too hot (), but do not turn on the heater. When the heater or air conditioner are on, also turn on the fan to circulate the air. In addition, the user can also request the fan to turn on (), even if the heater and air conditioner are off. mode = 1mode = 0too_cold = 1too_hot = 1fan_on = 1

Try to use only statements, to see whether you can translate a problem description into a collection of logic gates. assign
在这里插入图片描述
解题:

module top_module (
    input too_cold,
    input too_hot,
    input mode,
    input fan_on,
    output heater,
    output aircon,
    output fan
); 

    assign heater=mode&too_cold;
    assign aircon=(~mode)&too_hot;
    assign fan=heater|aircon|fan_on;
endmodule

结果正确:
在这里插入图片描述
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值