OpenCores
URL https://opencores.org/ocsvn/present/present/trunk

Subversion Repositories present

[/] [present/] [trunk/] [DecodeTesting/] [rtl/] [vhdl/] [PresentStateMachine.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 gajos
-----------------------------------------------------------------------
2
----                                                               ----
3
---- Present - a lightweight block cipher project                  ----
4
----                                                               ----
5
---- This file is part of the Present - a lightweight block        ----
6
---- cipher project                                                ----
7
---- http://www.http://opencores.org/project,present               ----
8
----                                                               ----
9
---- Description:                                                  ----
10
----     State machine for Present encoder. For more informations  ----
11
---- see below.                                                    ----
12
---- To Do:                                                        ----
13
----                                                               ----
14
---- Author(s):                                                    ----
15
---- - Krzysztof Gajewski, gajos@opencores.org                     ----
16
----                       k.gajewski@gmail.com                    ----
17
----                                                               ----
18
-----------------------------------------------------------------------
19
----                                                               ----
20
---- Copyright (C) 2013 Authors and OPENCORES.ORG                  ----
21
----                                                               ----
22
---- This source file may be used and distributed without          ----
23
---- restriction provided that this copyright statement is not     ----
24
---- removed from the file and that any derivative work contains   ----
25
---- the original copyright notice and the associated disclaimer.  ----
26
----                                                               ----
27
---- This source file is free software; you can redistribute it    ----
28
---- and-or modify it under the terms of the GNU Lesser General    ----
29
---- Public License as published by the Free Software Foundation;  ----
30
---- either version 2.1 of the License, or (at your option) any    ----
31
---- later version.                                                ----
32
----                                                               ----
33
---- This source is distributed in the hope that it will be        ----
34
---- useful, but WITHOUT ANY WARRANTY; without even the implied    ----
35
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       ----
36
---- PURPOSE. See the GNU Lesser General Public License for more   ----
37
---- details.                                                      ----
38
----                                                               ----
39
---- You should have received a copy of the GNU Lesser General     ----
40
---- Public License along with this source; if not, download it    ----
41
---- from http://www.opencores.org/lgpl.shtml                      ----
42
----                                                               ----
43
-----------------------------------------------------------------------
44 3 gajos
library IEEE;
45
use IEEE.STD_LOGIC_1164.ALL;
46
use IEEE.STD_LOGIC_ARITH.ALL;
47
use IEEE.STD_LOGIC_UNSIGNED.ALL;
48
use IEEE.NUMERIC_STD.ALL;
49
use work.kody.ALL;
50
 
51
entity PresentStateMachine is
52
        generic (
53
                w_5 : integer := 5
54
        );
55
        port (
56
                clk, reset, start : in std_logic;
57
                ready, cnt_res, ctrl_mux, RegEn: out std_logic;
58
                num : in std_logic_vector (w_5-1 downto 0)
59
        );
60
end PresentStateMachine;
61
 
62
architecture Behavioral of PresentStateMachine is
63
 
64
        signal state : stany;
65
        signal next_state : stany;
66
 
67
        begin
68
                States : process(state, start, num)
69
                        begin
70
                                case state is
71 4 gajos
                                    ---- Waiting for start
72 3 gajos
                                        when NOP =>
73
                                                ready <= '0';
74
                                                cnt_res <= '0';
75
                                                ctrl_mux <= '0';
76
                                                RegEn <= '0';
77
                                                if (start = '1') then
78
                                                        next_state <= SM_START;
79
                                                else
80
                                                        next_state <= NOP;
81
                                                end if;
82 4 gajos
                                        -- Decoding
83 3 gajos
                                        when SM_START =>
84
                                                ready <= '0';
85
                                                RegEn <= '1';
86
                                                cnt_res <= '1';
87
                                                if (start = '1') then
88 4 gajos
                                                    -- control during first start
89 3 gajos
                                                        if (num = "00000") then
90
                                                                ctrl_mux <= '0';
91
                                                                next_state <= SM_START;
92 4 gajos
                                                        -- last iteration
93 3 gajos
                                                        elsif (num = "11111") then
94
                                                                ctrl_mux <= '1';
95
                                                                next_state <= SM_READY;
96 4 gajos
                                                        -- rest iterations
97 3 gajos
                                                        else
98
                                                                ctrl_mux <= '1';
99
                                                                next_state <= SM_START;
100
                                                        end if;
101
                                                else
102
                                                        ctrl_mux <= '0';
103
                                                        next_state <= NOP;
104
                                                end if;
105 4 gajos
                                        -- Decoding end
106 3 gajos
                                        when SM_READY =>
107
                                                cnt_res <= '0';
108
                                                RegEn <= '0';
109
                                                ready <= '1';
110
                                                if (start = '1') then
111
                                                        ctrl_mux <= '1';
112
                                                        next_state <= SM_READY;
113
                                                else
114
                                                        ctrl_mux <= '0';
115
                                                        next_state <= NOP;
116
                                                end if;
117
                                end case;
118
                end process States;
119
 
120
                SM : process (clk, reset)
121
                        begin
122
                                if (reset = '1') then
123
                                        state <= NOP;
124
                                elsif (clk'Event and clk = '1') then
125
                                        state <= next_state;
126
                                end if;
127
                        end process SM;
128
 
129
        end Behavioral;
130
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.