> Welche verschiedenen Möglichkeiten gibt es das zu schreiben?
1) Du kannst eine FSM mit diesen 3 Zuständen bauen.
1 | signal state : std_logic_vector (2 downto 0) := "001";
|
2 | :
|
3 | process begin
|
4 | wait until rising_edge(clk);
|
5 | case state is
|
6 | when "001" => state <= "010";
|
7 | when "010" => state <= "100";
|
8 | when others => state <= "001";
|
9 | end case;
|
10 | end process;
|
11 |
|
12 | leds <= state;
|
2) Du kannst einen Zähler bauen, der ein RAM indiziert.
1 | type Rom is array (0 to 2) of std_logic_vector(2 downto 0);
|
2 | constant ledarray : Rom := ("001", "010", x"100");
|
3 | signal cnt : integer range 0 to 2 := 0;
|
4 | :
|
5 | process begin
|
6 | wait until rising_edge(clk);
|
7 | if (cnt<2) then
|
8 | cnt <= cnt+1;
|
9 | else
|
10 | cnt <= 0;
|
11 | end if;
|
12 | end process;
|
13 |
|
14 | leds <= ledarray(cnt);
|
3) Du kannst ein Schieberegister bauen.
1 | signal ledint: std_logic_vector(2 downto 0) := "001";
|
2 | :
|
3 | process begin
|
4 | wait until rising_edge(clk);
|
5 | ledint <= ledint(1 downto 0) & '0';
|
6 | if (ledint="100") then
|
7 | ledint<= "001";
|
8 | end if;
|
9 | end process;
|
10 |
|
11 | leds <= ledint;
|
Und dann gibts noch einige weitere Möglichkeiten...