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

Subversion Repositories present

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

powered by: WebSVN 2.1.0

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