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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [trunk/] [rtl/] [vhdl/] [core/] [x_shift_reg.vhd] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 JonasDC
----------------------------------------------------------------------  
2
----  x_shift_reg                                                 ---- 
3
----                                                              ---- 
4
----  This file is part of the                                    ----
5
----    Modular Simultaneous Exponentiation Core project          ---- 
6
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
7
----                                                              ---- 
8
----  Description                                                 ---- 
9
----    1536 bit shift register with lsb output                   ----
10
----                                                              ---- 
11
----  Dependencies: none                                          ----
12
----                                                              ----
13
----  Authors:                                                    ----
14
----      - Geoffrey Ottoy, DraMCo research group                 ----
15
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
16
----                                                              ---- 
17
---------------------------------------------------------------------- 
18
----                                                              ---- 
19
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
20
----                                                              ---- 
21
---- This source file may be used and distributed without         ---- 
22
---- restriction provided that this copyright statement is not    ---- 
23
---- removed from the file and that any derivative work contains  ---- 
24
---- the original copyright notice and the associated disclaimer. ---- 
25
----                                                              ---- 
26
---- This source file is free software; you can redistribute it   ---- 
27
---- and/or modify it under the terms of the GNU Lesser General   ---- 
28
---- Public License as published by the Free Software Foundation; ---- 
29
---- either version 2.1 of the License, or (at your option) any   ---- 
30
---- later version.                                               ---- 
31
----                                                              ---- 
32
---- This source is distributed in the hope that it will be       ---- 
33
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
34
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
35
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
36
---- details.                                                     ---- 
37
----                                                              ---- 
38
---- You should have received a copy of the GNU Lesser General    ---- 
39
---- Public License along with this source; if not, download it   ---- 
40
---- from http://www.opencores.org/lgpl.shtml                     ---- 
41
----                                                              ---- 
42
----------------------------------------------------------------------
43 2 JonasDC
 
44 3 JonasDC
library ieee;
45
use ieee.std_logic_1164.all;
46
use ieee.std_logic_arith.all;
47
use ieee.std_logic_unsigned.all;
48 2 JonasDC
 
49 3 JonasDC
 
50 2 JonasDC
entity x_shift_reg is
51 3 JonasDC
  generic(
52
    n  : integer := 1536;
53
    t  : integer := 48;
54
    tl : integer := 16
55
  );
56
  port(
57
    clk    : in  std_logic;
58
    reset  : in  std_logic;
59
    x_in   : in  std_logic_vector((n-1) downto 0);
60
    load_x : in  std_logic;
61
    next_x : in  std_logic;
62
    p_sel  : in  std_logic_vector(1 downto 0);
63
    x_i    : out std_logic
64
  );
65 2 JonasDC
end x_shift_reg;
66
 
67 3 JonasDC
 
68 2 JonasDC
architecture Behavioral of x_shift_reg is
69 3 JonasDC
  signal x_reg_i  : std_logic_vector((n-1) downto 0); -- register
70
  constant s      : integer := n/t;   -- nr of stages
71
  constant offset : integer := s*tl;  -- calculate startbit pos of higher part of pipeline
72 2 JonasDC
begin
73 3 JonasDC
 
74 2 JonasDC
        REG_PROC: process(reset, clk)
75
        begin
76
                if reset = '1' then -- Reset, clear the register
77
                        x_reg_i <= (others => '0');
78
                elsif rising_edge(clk) then
79
                        if load_x = '1' then -- Load_x, load the register with x_in
80
                                x_reg_i <= x_in;
81
                        elsif next_x = '1' then  -- next_x, shift to right. LSbit gets lost and zero's are shifted in
82
                                x_reg_i((n-2) downto 0) <= x_reg_i((n-1) downto 1);
83
                        else -- else remember state
84
                                x_reg_i <= x_reg_i;
85
                        end if;
86
                end if;
87
        end process;
88
 
89
        with p_sel select  -- pipeline select
90 3 JonasDC
                x_i <= x_reg_i(offset) when "10", -- use bit at offset for high part of pipeline
91
                                   x_reg_i(0) when others;    -- use LS bit for lower part of pipeline
92 2 JonasDC
 
93
end Behavioral;

powered by: WebSVN 2.1.0

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