N
Nemesis
Guest
On Jan 5, 9:56 am, Nemesis <gnemesis2...@gmail.com> wrote:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity top_reg is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
d : in STD_LOGIC_VECTOR (23 downto 0);
load : in std_logic;
q1 : out STD_LOGIC_VECTOR (23 downto 0)
);
end top_reg;
architecture Behavioral of top_reg is
signal not_reset : std_logic;
attribute INIT : string;
signal q_int_1 : std_logic_vector(23 downto 0) :"101010101010101010101010";
attribute INIT of q_int_1 : signal is "101010101010101010101010";
component LE_REG
generic (N_bit : integer);
port(CLK : in std_logic;
D : in std_logic_vector(N_bit-1 downto 0);
Q : out std_logic_vector (N_bit-1 downto 0);
ENABLE : in std_logic;
LOAD : in std_logic;
RESET : in std_logic
);
end component;
begin
not_reset <= not reset;
reg_1: LE_REG
generic map (N_bit => 24)
port map(
CLK => CLK,
RESET => RESET,
ENABLE => not_reset,
LOAD => load,
D => D,
Q => q_int_1
);
q1 <= q_int_1;
end Behavioral;
where LE_REG is:
library ieee;
use ieee.std_logic_1164.all;
entity LE_REG is
generic (N_bit : integer);
port(CLK : in std_logic;
D : in std_logic_vector(N_bit-1 downto 0);
Q : out std_logic_vector (N_bit-1 downto 0);
ENABLE : in std_logic;
LOAD : in std_logic;
RESET : in std_logic
);
end entity LE_REG;
architecture BEHAVIORAL of LE_REG is
-- attribute keep_hierarchy : string;
-- attribute keep_hierarchy of BEHAVIORAL : architecture is
"yes";
begin
process (clk, reset)
begin
if (reset='1') then
Q <= (others => '0');
elsif clk='1' and clk'event then
if (enable='1') then
if (load='1') then
Q <= D;
end if;
end if;
end if;
end process;
end architecture BEHAVIORAL;
.... no I'm wrong it's not working even in simulation, that's the code:I missed the attribute INIT (it is Xilinx specific right?).
Now it is working in simulation, I hope to test it on the board today.
Thanks.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity top_reg is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
d : in STD_LOGIC_VECTOR (23 downto 0);
load : in std_logic;
q1 : out STD_LOGIC_VECTOR (23 downto 0)
);
end top_reg;
architecture Behavioral of top_reg is
signal not_reset : std_logic;
attribute INIT : string;
signal q_int_1 : std_logic_vector(23 downto 0) :"101010101010101010101010";
attribute INIT of q_int_1 : signal is "101010101010101010101010";
component LE_REG
generic (N_bit : integer);
port(CLK : in std_logic;
D : in std_logic_vector(N_bit-1 downto 0);
Q : out std_logic_vector (N_bit-1 downto 0);
ENABLE : in std_logic;
LOAD : in std_logic;
RESET : in std_logic
);
end component;
begin
not_reset <= not reset;
reg_1: LE_REG
generic map (N_bit => 24)
port map(
CLK => CLK,
RESET => RESET,
ENABLE => not_reset,
LOAD => load,
D => D,
Q => q_int_1
);
q1 <= q_int_1;
end Behavioral;
where LE_REG is:
library ieee;
use ieee.std_logic_1164.all;
entity LE_REG is
generic (N_bit : integer);
port(CLK : in std_logic;
D : in std_logic_vector(N_bit-1 downto 0);
Q : out std_logic_vector (N_bit-1 downto 0);
ENABLE : in std_logic;
LOAD : in std_logic;
RESET : in std_logic
);
end entity LE_REG;
architecture BEHAVIORAL of LE_REG is
-- attribute keep_hierarchy : string;
-- attribute keep_hierarchy of BEHAVIORAL : architecture is
"yes";
begin
process (clk, reset)
begin
if (reset='1') then
Q <= (others => '0');
elsif clk='1' and clk'event then
if (enable='1') then
if (load='1') then
Q <= D;
end if;
end if;
end if;
end process;
end architecture BEHAVIORAL;