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 |
|
|
---- Not "pure" registers. Main function of this component is ----
|
11 |
|
|
---- to convert 64 bit input to 32 bit output. For more 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 |
2 |
gajos |
library IEEE;
|
45 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
46 |
|
|
use work.kody.ALL;
|
47 |
|
|
|
48 |
|
|
-- Uncomment the following library declaration if using
|
49 |
|
|
-- arithmetic functions with Signed or Unsigned values
|
50 |
|
|
--use IEEE.NUMERIC_STD.ALL;
|
51 |
|
|
|
52 |
|
|
entity outputRegister is
|
53 |
|
|
generic (
|
54 |
|
|
w_2 : integer := 2;
|
55 |
|
|
w_32: integer := 32;
|
56 |
|
|
w_64: integer := 64
|
57 |
|
|
);
|
58 |
|
|
port(
|
59 |
|
|
rst, clk, rd : in std_logic;
|
60 |
|
|
ctrl : in std_logic_vector(w_2-1 downto 0);
|
61 |
|
|
input : in std_logic_vector(w_64-1 downto 0);
|
62 |
|
|
output : out std_logic_vector(w_32-1 downto 0);
|
63 |
|
|
ready : out std_logic
|
64 |
|
|
);
|
65 |
|
|
end outputRegister;
|
66 |
|
|
|
67 |
|
|
architecture Behavioral of outputRegister is
|
68 |
|
|
signal reg : std_logic_vector(w_64-1 downto 0);
|
69 |
|
|
begin
|
70 |
|
|
process( rst, clk, ctrl, input)
|
71 |
|
|
begin
|
72 |
|
|
if (rst = '1') then
|
73 |
|
|
output <= (others=>'Z');
|
74 |
4 |
gajos |
elsif(clk'event and clk = '1') then
|
75 |
|
|
-- loading internal signal
|
76 |
2 |
gajos |
if(ctrl = out_ld_reg) then
|
77 |
|
|
reg <= input;
|
78 |
|
|
output <= (others=>'Z');
|
79 |
4 |
gajos |
---- leas significant 32 bits to output
|
80 |
2 |
gajos |
elsif (ctrl = out_reg_L) then
|
81 |
|
|
output <= reg(w_32-1 downto 0);
|
82 |
4 |
gajos |
---- most significant 32 bits to output
|
83 |
2 |
gajos |
elsif (ctrl = out_reg_H) then
|
84 |
|
|
output <= reg(w_64-1 downto w_32);
|
85 |
4 |
gajos |
---- this should not happen
|
86 |
2 |
gajos |
else
|
87 |
|
|
output <= (others=>'Z');
|
88 |
|
|
end if;
|
89 |
|
|
end if;
|
90 |
|
|
end process;
|
91 |
|
|
ready <= rd;
|
92 |
|
|
end Behavioral;
|
93 |
|
|
|