aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/arr01/arr04.vhdl
blob: 813f366c9ffcdbf8b805c01338d80fb539e1e16c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
library ieee;
use ieee.std_logic_1164.all;

entity arr04 is
  port (clk : in std_logic;
        rst : std_logic;
        sel_i : std_logic;
        sel_o : std_logic;
        v : std_logic;
        res : out std_logic);
end arr04;

architecture behav of arr04 is
  signal reg : std_logic_vector (0 to 1);
begin
  --  Reader
  process(clk)
  begin
    if rising_edge (clk) then
      if sel_o = '0' then
        res <= reg (0);
      else
        res <= reg (1);
      end if;
    end if;
  end process;

  -- Writer
  process(clk)
  begin
    if rising_edge(clk) then
      if rst = '1' then
        reg <= "00";
      else
        if sel_i = '0' then
          reg (0) <= v;
        else
          reg (1) <= v;
        end if;
      end if;
    end if;
  end process;
end behav;