📄 wteam.vhd
字号:
------------------------------------------------------ Library----------------------------------------------------library IEEE;use IEEE.std_logic_1164.all ;use IEEE.std_logic_arith.all ;use IEEE.std_logic_unsigned.all ;------------------------------------------------------ entity----------------------------------------------------entity wteam is port (RST : in std_logic; CLK : in std_logic; A : in std_logic; B : in std_logic_vector (3 downto 0); CH:out std_logic_vector (3 downto 0); CL:out std_logic_vector (3 downto 0); DH:out std_logic_vector (3 downto 0); DL:out std_logic_vector (3 downto 0); FH:out std_logic_vector (3 downto 0); FL:out std_logic_vector (3 downto 0); E: out std_logic_vector (3 downto 0));end wteam;------------------------------------------------------ Architecture----------------------------------------------------architecture RTL of wteam is -- ** Internal signal declarations ** -- signal s_guest_cnt_high : std_logic_vector(3 downto 0); signal s_guest_cnt_low : std_logic_vector(3 downto 0); signal s_sevice_cnt_high : std_logic_vector(3 downto 0); signal s_sevice_cnt_low : std_logic_vector(3 downto 0); signal n_wait_guest_high : std_logic_vector(3 downto 0); signal n_wait_guest_low : std_logic_vector(3 downto 0); beginp_function_cnt : process (RST, clk)begin if (RST = '0') then s_guest_cnt_low <= "0000"; s_guest_cnt_high <= "0000"; elsif (clk'event and clk = '1') then if (A = '1') then if (s_guest_cnt_low = "1001") then s_guest_cnt_low <= "0000"; if (s_guest_cnt_high < "1001") then s_guest_cnt_high <= s_guest_cnt_high + 1; else s_guest_cnt_high <= "0000"; end if; elsif (s_guest_cnt_low < "1001") then s_guest_cnt_low <= s_guest_cnt_low + 1; elsif (s_guest_cnt_high > "1001") then s_guest_cnt_high <= "0000"; else s_guest_cnt_low <= "0000"; end if; end if; end if;end process;p_sevice_cnt : process (RST, s_guest_cnt_low, s_guest_cnt_high, clk)begin if ((RST = '0') or ((s_guest_cnt_low = "0000") and (s_guest_cnt_high = "0000")) or (s_guest_cnt_high < s_sevice_cnt_high)) then s_sevice_cnt_low <= "0000"; s_sevice_cnt_high <= "0000"; elsif (clk'event and clk = '1') then if (B > "0000") then if (s_sevice_cnt_low = "1001") then s_sevice_cnt_low <= "0000"; if (s_sevice_cnt_high < "1001") then s_sevice_cnt_high <= s_sevice_cnt_high + 1; else s_sevice_cnt_high <= "0000"; end if; elsif (s_sevice_cnt_low < "1001") then s_sevice_cnt_low <= s_sevice_cnt_low + 1; elsif (s_sevice_cnt_high > "1001") then s_sevice_cnt_high <= "0000"; end if; end if; end if;end process;p_wait_guest : process (s_guest_cnt_low, s_guest_cnt_high, s_sevice_cnt_low, s_sevice_cnt_high)begin if ((s_guest_cnt_low = "0000") and (s_guest_cnt_high = "0000")) then n_wait_guest_high <= "0000"; n_wait_guest_low <= "0000"; elsif (s_guest_cnt_low > s_sevice_cnt_low) then n_wait_guest_high <= s_guest_cnt_high - s_sevice_cnt_high; n_wait_guest_low <= s_guest_cnt_low - s_sevice_cnt_low - 1; elsif ((n_wait_guest_high > 1) and (s_guest_cnt_low < s_sevice_cnt_low)) then n_wait_guest_high <= s_guest_cnt_high - s_sevice_cnt_high - 1; n_wait_guest_low <= 10 - s_sevice_cnt_low - 1; else n_wait_guest_high <= "0000"; n_wait_guest_low <= "0000"; end if;end process;------------------------------------------------------ OUTPUT---------------------------------------------------- CH<= s_guest_cnt_high; CL<= s_guest_cnt_low; DH<= n_wait_guest_high; DL<= n_wait_guest_low; FH<= s_sevice_cnt_high; FL<= s_sevice_cnt_low; E <= not B;end RTL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -