簡體   English   中英

帶有 d_flip flop 的櫃台笑臉

[英]smiley face of counter with d_flip flop

我正在嘗試使用 VHDL 為笑臉計數器編寫代碼,使用觸發器,但我遇到了一些關於“寬度不匹配”的錯誤,我不知道到底是什么問題。


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity Smiley_Faces is
    Port ( Clk, Reset : in STD_LOGIC;
           Q : out STD_LOGIC_VECTOR (3 downto 0));
end Smiley_Faces;

architecture Behavioral of Smiley_Faces is
signal NS, PS:std_logic_vector(5 downto 0):= (others => '0');
begin
--- Memory Component
D_ff:process(reset,clk)
begin
if(reset='1') then
ps <= "0000";
elsif(rising_edge(clk)) then
ps<=nS;
end if;
end process;
-- Combination Logic
NS <= "010000" when ps="000000" else
     "000110" when ps="010000" else
     "010110" when ps="000110" else
     "001111" when ps="010110" else
     "011111" when ps="001111" else
     "101111" when ps="011111" else
     "111111" when ps="101111" else
     "000000" when ps="111111" else
     "000000";
Q <= PS;
     
end Behavioral;

附上關於state笑臉機器的圖片

多個東西

  1. 您將 PS 的位寬設置為 6,但您的重置語句僅為其分配了 4 位

    if(reset='1') then ps <= "0000";`
  2. 您正在為 Q 分配 PS 的值,但它們的位寬不同。 您需要將 Q 更新為 6 位或將代碼編輯為:

     Q <= PS(3 downto 0);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM