Forum Discussion
Altera_Forum
Honored Contributor
9 years agoI don't see how else I would do it. The ROM isn't really a rom anymore. I converted it into the code below.
entity char_display is
generic(
text_length: integer := 1;
addrWidth: integer := 11;
dataWidth: integer := 8
);
port(
text_to_be_displayed : in string(1 to text_length) := (others => NUL);
origin_x : in integer;
origin_y : in integer;
current_x : in integer;
current_y : in integer;
this_px_is_text : out boolean;
this_px_is_text_bg : out boolean
);
end char_display;
architecture Behavioral of char_display is
type rom_type is array (0 to 2**addrWidth-1) of std_logic_vector(dataWidth-1 downto 0);
-- ROM definition
signal ROM: rom_type := ( -- 2^11-by-8
-- NUL: code x00
"00000000", -- 0
"00000000", -- 1
"00000000", -- 2
"00000000", -- 3
"00000000", -- 4
"00000000", -- 5
"00000000", -- 6
"00000000", -- 7
"00000000", -- 8
"00000000", -- 9
"00000000", -- a
"00000000", -- b
"00000000", -- c
"00000000", -- d
"00000000", -- e
"00000000", -- f
-- SOH: code x01
"00000000", -- 0
"00000000", -- 1
"01111110", -- 2 ******
"10000001", -- 3 * *
"10100101", -- 4 * * * *
"10000001", -- 5 * *
"10000001", -- 6 * *
"10111101", -- 7 * **** *
"10011001", -- 8 * ** *
"10000001", -- 9 * *
"10000001", -- a * *
"01111110", -- b ******
"00000000", -- c
"00000000", -- d
"00000000", -- e
"00000000", -- f
-- STX: code x02
"00000000", -- 0
"00000000", -- 1
"01111110", -- 2 ******
"11111111", -- 3 ********
"11011011", -- 4 ** ** **
"11111111", -- 5 ********
"11111111", -- 6 ********
"11000011", -- 7 ** **
"11100111", -- 8 *** ***
"11111111", -- 9 ********
"11111111", -- a ********
"01111110", -- b ******
"00000000", -- c
"00000000", -- d
"00000000", -- e
"00000000", -- f
.
.
.
);
begin
process (text_to_be_displayed, origin_x, origin_y, current_x, current_y)
(variables...)
begin
(combinational logic...)
end process;
end Behavioral; It was originally this: https://github.com/madlittlemods/fp-v-ga-text but in my opinion it was super over-engineered. I reduced that mess down to the one entity shown above which is working great. My question is, if the way I'm doing it is so backwards, how would you describe a process that is equally code-minimal, easy to read, and efficient?