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 2

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

Line No. Rev Author Line
1 2 JonasDC
------------------------------------------------------------------------------------ 
2
--                      
3
-- Geoffrey Ottoy - DraMCo research group
4
--
5
-- Module Name: x_shift_reg.vhd / entity x_shift_reg
6
-- 
7
-- Last Modified:       18/06/2012 
8
-- 
9
-- Description:         n-bit shift register with lsb output
10
--
11
--
12
-- Dependencies:        none
13
--
14
-- Revision:
15
--      Revision 1.00 - Architecture
16
--      Revision 0.01 - File Created
17
--
18
--
19
------------------------------------------------------------------------------------
20
--
21
-- NOTICE:
22
--
23
-- Copyright DraMCo research group. 2011. This code may be contain portions patented
24
-- by other third parties!
25
--
26
------------------------------------------------------------------------------------
27
library IEEE;
28
use IEEE.STD_LOGIC_1164.ALL;
29
use IEEE.STD_LOGIC_ARITH.ALL;
30
use IEEE.STD_LOGIC_UNSIGNED.ALL;
31
 
32
---- Uncomment the following library declaration if instantiating
33
---- any Xilinx primitives in this code.
34
--library UNISIM;
35
--use UNISIM.VComponents.all;
36
 
37
entity x_shift_reg is
38
        generic(  n : integer := 1536;
39
                       t : integer := 48;
40
                                tl : integer := 16
41
        );
42
        port(   clk : in  STD_LOGIC;
43
         reset : in  STD_LOGIC;
44
          x_in : in  STD_LOGIC_VECTOR((n-1) downto 0);
45
        load_x : in  STD_LOGIC;
46
        next_x : in  STD_LOGIC;
47
                   p_sel : in  STD_LOGIC_VECTOR(1 downto 0);
48
           x_i : out  STD_LOGIC
49
        );
50
end x_shift_reg;
51
 
52
architecture Behavioral of x_shift_reg is
53
        signal x_reg_i : std_logic_vector((n-1) downto 0); -- register
54
        constant s : integer := n/t;   -- nr of stages
55
        constant offset : integer := s*tl; -- calculate startbit pos of higher part of pipeline
56
begin
57
 
58
        REG_PROC: process(reset, clk)
59
        begin
60
                if reset = '1' then -- Reset, clear the register
61
                        x_reg_i <= (others => '0');
62
                elsif rising_edge(clk) then
63
                        if load_x = '1' then -- Load_x, load the register with x_in
64
                                x_reg_i <= x_in;
65
                        elsif next_x = '1' then  -- next_x, shift to right. LSbit gets lost and zero's are shifted in
66
                                x_reg_i((n-2) downto 0) <= x_reg_i((n-1) downto 1);
67
                        else -- else remember state
68
                                x_reg_i <= x_reg_i;
69
                        end if;
70
                end if;
71
        end process;
72
 
73
        with p_sel select  -- pipeline select
74
                x_i <= x_reg_i(offset) when "10",   -- use bit at offset for high part of pipeline
75
                                 x_reg_i(0) when others;    -- use LS bit for lower part of pipeline
76
 
77
end Behavioral;
78
 

powered by: WebSVN 2.1.0

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