多个触发器设备

问题描述

我正在尝试编写一个表示图像图的 VHDL 代码。我是 VHDL 的新手,所以我使用了很多条件来让它工作。但是,我在使用预设和清除输入时遇到问题,我使用 ifelsif 来了解哪个预设或清除有效,但我一直收到此错误

Asynchronous Preset equation not allowed error for Q

我的代码是:

library ieee;
USE ieee.std_logic_1164.all;

entity FF is
    port(
            clk: in std_logic;
            ctrl : in std_logic_vector(1 downto 0);
            R,S,D,J,K,T,PS,CL: in std_logic;
            Q,QN : out std_logic);
    end FF;
    
architecture FF_arq of FF is
     signal tmp:std_logic;
 begin
    process(clk,ctrl,CL)
        begin
            if PS='0' then
                tmp<='1';
            elsif CL='0' then
                tmp<='0';
            elsif (rising_edge(clk))then
                if ctrl="00" then
                    if R='0' and S='0' then
                        tmp<=tmp;
                    else if R='1' and S='0' then
                        tmp<='0';
                    else if R='0' and S='1' then
                        tmp<='1';
                    else
                        tmp<='-';
                    end if;
                    end if;
                    end if;
                else if ctrl="01" then
                    if D='0' then
                        tmp<='0';
                    else if D='1' then
                        tmp<='1';
                    else
                        tmp<='-';
                    end if;
                    end if;
                else if ctrl="10" then
                    if J='0' and K='0'then
                        tmp<=tmp;
                    else if J='1' and K='1' then
                        tmp<= not tmp;
                    else if J='1' and K='0' then
                        tmp<='1';
                    else
                        tmp<='0';
                    end if;
                    end if;
                    end if;
                else
                    if T='0' then
                        tmp<=tmp;
                    else 
                        tmp<= not tmp;
                    end if;
                end if;
                end if;
                end if;
            end if;                 
    end process;
    Q<= tmp;
    QN<= not tmp;
end FF_arq;

这是示意图:

enter image description here

解决方法

试图缩短一些事情,也许有一些更好的解决方案。

library ieee;
USE ieee.std_logic_1164.all;

entity FF is
    port(
            clk: in std_logic;
            ctrl : in std_logic_vector(1 downto 0);
            R,S,D,J,K,T,PS,CL: in std_logic;
            Q,QN : out std_logic);
    end FF;
    
architecture FF_arq of FF is
    signal tmp : std_logic := '0';
    signal RS : std_logic_vector(1 downto 0) := (others => '0');
    signal JK : std_logic_vector(1 downto 0) := (others => '0');
 begin
 
    Q <= tmp;
    QN <= not(tmp);
 
    process(clk,CL)
        begin
            if PS='0' then
                tmp<='1';
            elsif CL='0' then
                tmp<='0';
            elsif (rising_edge(clk))then
            
                RS(1) <= R;
                RS(0) <= S;
                JK(1) <= J;
                JK(0) <= K;
            
                case ctrl is
                    when "00" => case RS is
                                    when "00" => tmp <= tmp;
                                    when "10" => tmp <= '0';
                                    when "01" => tmp <= '1';
                                    when others => tmp <= '-';
                                 end case;
                    when "01" => tmp <= D;
                    when "10" => case JK is
                                    when "00" => tmp <= tmp;
                                    when "11" => tmp <= not(tmp);
                                    when "10" => tmp <= '1';
                                    when others => tmp <= '0';
                                 end case;
                    when others =>  if T='0' then
                                        tmp <= tmp;
                                    else
                                        tmp <= not(tmp);
                                    end if;
                end case;
            end if;                 
    end process;
end FF_arq;

@我无法检查代码的那一刻,所以也许有一些不需要的功能......

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...