Serial sequential adder  v.1.0
Example documentation project, author Vladimir Petrović
shiftreg.vhd
Go to the documentation of this file.
1 
17 
18 
19 library ieee;
20 
21 use ieee.std_logic_1164.all;
22 use ieee.numeric_std.all;
23 
32 entity shiftreg is
33  generic (
34  reg_width : integer := 8
35  );
36  port (
37  clk : in std_logic;
38  reset : in std_logic;
39  load, do_shift : in std_logic;
40  sin : in std_logic;
41  sout : out std_logic;
42  pin : in std_logic_vector(reg_width - 1 downto 0);
43  pout : out std_logic_vector(reg_width - 1 downto 0)
44  );
45 end shiftreg;
46 
52 architecture shr_behav_arch of shiftreg is
53 
54 signal reg_state : std_logic_vector(reg_width - 1 downto 0);
55 
56 begin
57 
58  shift_reg_process : process (clk, reset)
59  begin
60  if reset = '1' then
61  sout <= '0';
62  reg_state <= (others => '0');
63  elsif rising_edge(clk) then
64  if load = '1' then
65  reg_state <= pin;
66  sout <= pin(0);
67  elsif do_shift = '1' then
68  sout <= reg_state(1);
69  reg_state <= sin & reg_state(reg_width - 1 downto 1);
70  end if;
71  end if;
72 
73  end process;
74 
75  pout <= reg_state;
76 
77 end shr_behav_arch;
in clkstd_logic
Definition: shiftreg.vhd:37
Entitiy declaration for shiftreg.
Definition: shiftreg.vhd:32
in loadstd_logic
Definition: shiftreg.vhd:39
std_logic_vector( reg_width- 1 downto 0) reg_state
Definition: shiftreg.vhd:54
in resetstd_logic
Definition: shiftreg.vhd:38
out soutstd_logic
Definition: shiftreg.vhd:41
reg_widthinteger := 8
Definition: shiftreg.vhd:35
in do_shiftstd_logic
Definition: shiftreg.vhd:39
in pinstd_logic_vector( reg_width- 1 downto 0)
Definition: shiftreg.vhd:42
_library_ ieeeieee
out poutstd_logic_vector( reg_width- 1 downto 0)
Definition: shiftreg.vhd:44
in sinstd_logic
Definition: shiftreg.vhd:40