Mandelbrot indexholders vhd

From Hamsterworks Wiki!

Revision as of 04:14, 16 May 2011 by User (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
----------------------------------------------------------------------------------
-- Project Name:    Mandelbrot
-- Author:         Mike Field <hamster@snap.net.nz>
--
-- Hold the index values used to look up constants
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity IndexHolders is
   Generic (depth : natural;
            width : natural;
            tap   : natural;
            tap2   : natural);

    Port ( clk :       in  STD_LOGIC;
           load :    in  STD_LOGIC;
           n_in:      in  STD_LOGIC_VECTOR(width-1 downto 0);
           tap_out:   out STD_LOGIC_VECTOR(width-1 downto 0);
           tap2_out:   out STD_LOGIC_VECTOR(width-1 downto 0);
           n_out:      out STD_LOGIC_VECTOR(width-1 downto 0)
         );
end IndexHolders;

architecture Behavioral of IndexHolders is
   signal r : STD_LOGIC_VECTOR(depth*width-1 downto 0);
   signal n : STD_LOGIC_VECTOR(depth*width-1 downto 0);
begin
   n_out <= r(depth*width-1 downto (depth-1)*width);
   tap_out <= r(tap*width-1 downto (tap-1)*width);
   tap2_out <= r(tap2*width-1 downto (tap2-1)*width);
   
   process(r,load,n_in)
   begin
      n(depth*width-1 downto width) <= r((depth-1)*width-1 downto 0);
      if load = '1' then
         n(width-1 downto 0) <= n_in;
      else
         n(width-1 downto 0) <= r(depth*width-1 downto (depth-1)*width);
      end if;
   end process;

   process(clk)
   begin
      if clk'event and clk = '1' then
         r <= n;
      end if;
   end process;
end Behavioral;

Personal tools