Altera_Forum
Honored Contributor
13 years agoReduce total logic elements?
Hi all, at first, sorry for my bad english.
I'm currently working on Bomberman project. I have some problems and huge total logic elements is the worst. For example, i would like to display a static map, consist of stone, brick, wall and grass (RGB 12bit), and this map uses 21% total logic elements of DE1. So how can i reduce this number to 10% or smaller? Below is my VHDL code:Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;
Entity display_map1 is
Port ( clk : in std_logic;
video_on : in std_logic;
brick_on : in std_logic;
p_row, p_col : in std_logic_vector(9 downto 0);
stone_on_out : out std_logic;
rgb : out std_logic_vector(11 downto 0));
End display_map1;
Architecture Behave of display_map1 is
Type ROM_type is array (0 to 31, 0 to 31) of std_logic_vector(11 downto 0);
Constant Stone_ROM: ROM_type :=
(
-- 32x32x12 bit ROM for Stone image
);
Constant Grass_ROM: ROM_type :=
(
-- 32x32x12 bit ROM for Grass image
);
Constant Wall_ROM: ROM_type :=
(
-- 32x32x12 bit ROM for Wall image
);
Constant Brick_ROM: ROM_type :=
(
-- 32x32x12 bit ROM for Brick image
);
Signal wall_on, stone_on, grass_on, inner_map : std_logic;
Signal wall_rgb, stone_rgb, grass_rgb : std_logic_vector(11 downto 0);
Signal x, i, j, x_1, y_1, i_1, j_1 : integer;
Signal rgb_reg : std_logic_vector(11 downto 0);
Signal p_row_o, p_col_o : unsigned(9 downto 0);
Begin
x <= to_integer(unsigned(p_col(9 downto 5)));
i <= to_integer(unsigned(p_col(4 downto 0)));
j <= to_integer(unsigned(p_row(4 downto 0)));
p_col_o <= unsigned(p_col) - "0001100000" when (p_col >= "0001100000") else
"1111011111";
p_row_o <= unsigned(p_row) - "0000010000" when (p_row >= "0000010000") else
"1111011111";
x_1 <= to_integer(p_col_o(9 downto 5));
y_1 <= to_integer(p_row_o(9 downto 5));
i_1 <= to_integer(p_col_o(4 downto 0));
j_1 <= to_integer(p_row_o(4 downto 0));
-- Inner map
inner_map <= '1' when (x_1 < 11) and (y_1 < 19) else
'0';
-- Display stone
stone_on <= '1' when (inner_map = '1') and (p_col_o(5) = '1') and (p_row_o(5) = '1') else
'0';
stone_on_out <= stone_on;
stone_rgb <= Stone_ROM(i_1, j_1);
-- Display wall
wall_on <= '1' when (inner_map = '0') and (x > 1) else
'0';
wall_rgb <= Wall_ROM(i, j);
-- Display grass when don't have wall or stone
grass_on <= '1' when (inner_map = '1') and (stone_on = '0') else
'0';
grass_rgb <= Grass_ROM(i_1, j_1);
-- Display color when video_on = '1'
rgb <= rgb_reg when (video_on = '1') else
(others => '0');
rgb_reg <= wall_rgb when (wall_on = '1') else
Brick_ROM(i_1, j_1) when (brick_on = '1') else
stone_rgb when (stone_on = '1') else
grass_rgb when (grass_on = '1') else
(others => '1');
End Behave; I think the worst part of this code is rgb_reg <= wall_rgb when (wall_on = '1') else
Brick_ROM(i_1, j_1) when (brick_on = '1') else
stone_rgb when (stone_on = '1') else
grass_rgb when (grass_on = '1') else
(others => '1');
This part create a lot of MUX.