Build a simple module which "renders" "pixels" from data stored in a ROM. The input to your module is a row and column of the virtual screen; the output is a single bit indicating whether or not to color the pixel at that location. The ROM packs the pixels into 8-bit words, stored in row-major order. The first (leftmost) bit is bit 7 (the MSB), as shown below:
[byte 0] [byte 1] [byte 2] ...
[bytes 0-7 ] 76543210 76543210 76543210 ...
[bytes 8-15] ... ... ...
Your task is simply to read the correct row of the ROM and pick out the bit corresponding to the pixel being rendered.
You may find the to_integer
function helpful if you need to use an unsigned value where you'd normally use an integer (e.g., as an index).
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity bitrender is
port(
clk : in std_logic;
row : in unsigned(2 downto 0); -- vertical position, 0 to 7
col : in unsigned(5 downto 0); -- horizontal position, 0 to 63
pixel : out std_logic
);
end;
architecture synth of bitrender is
component rom is
port(
clk : in std_logic;
addr : in std_logic_vector(5 downto 0); -- 64 words total
data : out std_logic_vector(7 downto 0) -- 8-bit words
);
end component;
signal addr : std_logic_vector(5 downto 0);
signal data : std_logic_vector(7 downto 0); -- Memory has 8-bit words
begin
end;
Are you confident about this change? (select one to recompile)