palettememory.vhd

来自「描述:LED示范、按钮及开关、视频输出、键入、含Xilinx PicoBlaze」· VHDL 代码 · 共 55 行

VHD
55
字号
--Dual port memory for the palette. Each entry is 6 bits long in the form of
--RRGGBB. 
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity PaletteMemory is
    Port ( RESET : in std_logic;
	        READ_INDEX_A : in std_logic_vector(2 downto 0);
           READ_VALUE_A : out std_logic_vector(7 downto 0);
	        READ_INDEX_B : in std_logic_vector(2 downto 0);
           READ_VALUE_B : out std_logic_vector(7 downto 0);
           WRITE_INDEX : in std_logic_vector(2 downto 0);
           WRITE_VALUE : in std_logic_vector(7 downto 0);
           WRITE_STROBE : in std_logic);
end PaletteMemory;

architecture Behavioral of PaletteMemory is
	type buff_array_type is array (15 downto 0) of std_logic_vector (5 downto 0);
	signal PaletteMemory: buff_array_type; 
begin
	--The two read ports
	READ_VALUE_A <= "00" & PaletteMemory(conv_integer(UNSIGNED(READ_INDEX_A)));
	READ_VALUE_B <= "00" & PaletteMemory(conv_integer(UNSIGNED(READ_INDEX_B)));

	--The reset / write part
	process (RESET, WRITE_STROBE)
	begin
		if RESET = '0' then
			if (WRITE_STROBE'event) and (WRITE_STROBE = '1') then
				PaletteMemory(conv_integer(UNSIGNED(WRITE_INDEX)))	<= WRITE_VALUE(5 downto 0);			
			end if;
		else
			--intialize the palette upon reset
			PaletteMemory(0)  <= "000000";	-- black
			PaletteMemory(1)  <= "000011"; -- blue
			PaletteMemory(2)  <= "001100"; -- green
			PaletteMemory(3)  <= "001111"; -- cyan
			PaletteMemory(4)  <= "110000"; -- red
			PaletteMemory(5)  <= "110011"; -- mangenta
			PaletteMemory(6)  <= "101000";	-- brown
			PaletteMemory(7)  <= "101010"; -- light grey
			PaletteMemory(8)  <= "010101";	-- dark grey
			PaletteMemory(9)  <= "100101";	-- some more random colors :)
			PaletteMemory(10) <= "011010";
			PaletteMemory(11) <= "010101";
			PaletteMemory(12) <= "010110";
			PaletteMemory(13) <= "100101";
			PaletteMemory(14) <= "010101";
			PaletteMemory(15) <= "111111";	-- white
		end if;
	end process;
end Behavioral;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?