|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我的程序如下,compile就会报错说无源,但我程序应该没问题啊,拜托帮忙看下 ~~~
LIBRARY IEEE;
USE IEEE .std_logic_1164.ALL;
USE IEEE .std_logic_arith.ALL;
ENTITY ureg IS
PORT (clk : IN std_logic;
reset: IN std_logic;
en : IN std_logic;
d : IN unsigned (3 downto 0);
q : BUFFER unsigned(3 downto 0));
END ureg;
ARCHITECTURE rtl OF ureg IS
BEGIN
PROCESS (clk,reset)
BEGIN
IF(reset='1') THEN
q <=( OTHERS =>'0');
ELSIF(clk'event AND clk='1') THEN
IF (en='1') THEN
q<=d;
ELSE
q<=q;
END IF;
END IF;
END PROCESS;
END rtl;
LIBRARY IEEE;
USE IEEE .std_logic_1164.ALL;
PACKAGE mnemonics IS
CONSTANT aq : std_logic_vector (2 downto 0) := "000";
CONSTANT ab : std_logic_vector (2 downto 0) := "001";
CONSTANT zq : std_logic_vector (2 downto 0) := "010";
CONSTANT zb : std_logic_vector (2 downto 0) := "011";
CONSTANT za : std_logic_vector (2 downto 0) := "100";
CONSTANT da : std_logic_vector (2 downto 0) := "101";
CONSTANT dq : std_logic_vector (2 downto 0) := "110";
CONSTANT dz : std_logic_vector (2 downto 0) := "111";
CONSTANT add : std_logic_vector (2 downto 0) := "000";
CONSTANT subr : std_logic_vector (2 downto 0) := "001";
CONSTANT subs : std_logic_vector (2 downto 0) := "010";
CONSTANT orrs : std_logic_vector (2 downto 0) := "011";
CONSTANT andrs : std_logic_vector (2 downto 0) := "100";
CONSTANT notrs : std_logic_vector (2 downto 0) := "101";
CONSTANT exor : std_logic_vector (2 downto 0) := "110";
CONSTANT exnor : std_logic_vector (2 downto 0) := "111";
CONSTANT qreg : std_logic_vector (2 downto 0) := "000";
CONSTANT nop : std_logic_vector (2 downto 0) := "001";
CONSTANT rama : std_logic_vector (2 downto 0) := "010";
CONSTANT ramf : std_logic_vector (2 downto 0) := "011";
CONSTANT ramqd : std_logic_vector (2 downto 0) := "100";
CONSTANT ramd : std_logic_vector (2 downto 0) := "101";
CONSTANT ramqu : std_logic_vector (2 downto 0) := "110";
CONSTANT ramu : std_logic_vector (2 downto 0) := "111";
END PACKAGE mnemonics;
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
USE IEEE.std_logic_arith.ALL;
USE WORK.mnemonics.ALL;
ENTITY ram_regs IS
PORT (clk : IN std_logic;
reset : IN std_logic;
a, b : IN unsigned (3 downto 0);
f : IN unsigned (3 downto 0);
dest_ctl : IN std_logic_vector (2 downto 0);
ram0,ram3: INOUT std_logic;
ad, bd : BUFFER unsigned (3 downto 0));
END ram_regs;
ARCHITECTURE ram_regs_arch OF ram_regs IS
COMPONENT ureg
GENERIC (size : integer:=4);
PORT (clk : IN std_logic;
reset: IN std_logic;
en : IN std_logic;
d : IN unsigned (size-1 downto 0);
q : BUFFER unsigned(size-1 downto 0));
END COMPONENT ureg;
SIGNAL ram_en : std_logic;
SIGNAL data :unsigned (3 downto 0);
SIGNAL en : std_logic_vector ( 15 downto 0);
TYPE ram_array IS ARRAY ( 15 downto 0) OF unsigned ( 3 downto 0);
SIGNAL ab_data : ram_array;
BEGIN
WITH dest_ctl SELECT
ram_en <= '0' WHEN qreg | nop,
'1'WHEN OTHERS;
enable_proc: PROCESS (b)
BEGIN
Decode:FOR I IN 0 TO 15 LOOP
IF (conv_integer (b) = i) THEN
En (i) <= ram_en;
ELSE
En (i) <= '0';
END IF;
END LOOP decode;
END PROCESS;
WITH dest_ctl SELECT
data <= (f (2 downto 0) & ram0 ) WHEN ramqu | ramu,
(ram3 & f(3 downto 1)) WHEN ramqd | ramd,
F WHEN rama | ramf,
"----" WHEN OTHERS;
register_generator: FOR I IN 15 downto 0 generate
Uregx : ureg
GENERIC MAP(4)
PORT MAP (clk,reset, en(i), data, ab_data(i));
END GENERATE register_generator;
ad <= ab_data (conv_integer(a));
bd <= ab_data (conv_integer(b));
Ram3 <= f(3) WHEN (dest_ctl =ramqu OR dest_ctl =ramu ) ELSE 'Z';
Ram0 <= f(0) WHEN (dest_ctl =ramqd OR dest_ctl =ramd ) ELSE 'Z';
END ram_regs_arch; |
|