air_conditioner.txt

来自「空调温控电路有限状态自动机」· 文本 代码 · 共 33 行

TXT
33
字号
library ieee:
use ieee.std_logic_1164.all;
entity air_conditioner is
    port(clk:in std_ulogic;
              temp_high:in std_ulogic;
              temp_low:in std_ulogic;
               heat:out std_ulogic;
                cool:out std_ulogic);
    end air_conditioner;
achitecture style_b of air_conditioner is
type state_type is (just_right,too_cold,too_hot);
attribute sequential_encoding of state_type:type is "00 01 10";
signal stvar:state_type;
attribute state_vector:string;
arrribute state_vector of style_b:architecture is "stvar";
begin
controllerl:process
begin
wait until clk='1';
if(temp_low='1')then stvar<=too_cold;
elsif(temp_high='1')then stvar<=too_hot;
else stvar<=just_right;
end if;
case stvar is 
when just_right=>heat<='0';
                 cool<='0';
when too_cold=>heat<='1';
               cool<='0';
when too_hot=>heat<='0';
              cool<='1';
end case;
end process controllerl;
end style_b;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?