Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as VHDL by hbr ( 12 years ago )
-- LED matrix is 8 by 16 wide with 2 colors.
-- This signal is sent to the LED matrix to be displayed.
signal maze: DISPLAY := ( -- Left is red; right green
"0000000000000000" & "0000000000000001",
"0000000000000000" & "0000000000000000",
"0000000000000000" & "0000000000000000",
"0000000000000000" & "0000000000000000",
"0000000000000000" & "0000000000000000",
"0000000000000000" & "0000000000000000",
"0000000000000000" & "0000000000000000",
"0000000000000000" & "0000000000000000"
);
-- Access a position in the map
signal x: INTEGER := 0; -- 0 to 15 (width)
signal y: INTEGER := 7; -- 0 to 7 (height)
-- Random direction (up, down, left, right)
signal random: STD_LOGIC_VECTOR(1 downto 0); -- 0 to 3
-- SNIP...
-- In the architecture:
make_maze: process(clk)
begin
if falling_edge(clk) then
-- Choose a random direction to walk in (up, down, left, right)
case random is
when "00" =>
x <= x + 1;
when "01" =>
y <= y + 1;
when "10" =>
x <= x - 1;
when "11" =>
y <= y - 1;
when others => null;
end case
-- Light up that position in the maze
maze(y)(x) <= '1';
maze(y)(x + 16) <= '1';
end if;
end process;
Revise this Paste