Daten werden geladen obwohl sw(0) nicht betätigt wurde für we.

Gast #3821708
Lesenswert?

Hallo, ich habe eine RAM-Compenente gebastelt.
Die Datenübergabe findet sofort statt, nachdem ich es in den DE1 geladen 
habe, ohne den Schiebeschalter SW(0) zu betätigen.

Woran liegt das bitte ?

Danke.

Gruss

Diese VHDL bindet die Sync_ram.vhdl ein:
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4

5
entity c_sync_ram is port(
6
  clock : in  std_logic;
7
  led_g : out STD_LOGIC_VECTOR(7 downto 0);
8
  sw    : in  STD_LOGIC_VECTOR(0 downto 0)
9
  ); 
10
end c_sync_ram; 
11
            
12
architecture Behavioral of c_sync_ram is
13

14
signal we      : STD_LOGIC;
15
signal address : std_logic_vector (7 downto 0);
16
signal datain  :   std_logic_vector (7 downto 0);
17
signal dataout :  std_logic_vector (7 downto 0);
18
signal read_address :  std_logic_vector(7 downto 0);
19

20
component sync_ram port(
21
  we      : in STD_LOGIC; 
22
  address : in std_logic_vector (7 downto 0);
23
  datain  : in std_logic_vector (7 downto 0);
24
  dataout : inout std_logic_vector (7 downto 0);
25
  clock   : in  std_logic;
26
  read_address : in std_logic_vector(7 downto 0)
27
 );
28
end component;
29

30
begin
31
io1 : sync_ram  port map(we,address,datain,dataout,clock,read_address);
32

33
process(clock)
34
begin
35
  if rising_edge(clock) then
36
    if sw(0)='1' then
37
      we <='1';
38
      address<="00001111";
39
      datain<="11000011";
40
    else
41
      we<='0'; 
42
      read_address<="00001111";       
43
    end if;    
44
  end if;
45
end process;  
46

47
led_g<=dataout;
48

49
end Behavioral;

sync_ram:
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.all;
3
use IEEE.Numeric_Std.all;
4

5
entity sync_ram is
6
  port (
7
    clock   : in  std_logic;
8
    we      : in  std_logic;
9
    address : in  std_logic_vector (7 downto 0);
10
    datain  : in  std_logic_vector (7 downto 0);
11
    dataout : out std_logic_vector (7 downto 0);
12
    read_address : in std_logic_vector(7 downto 0)
13
  );
14
end entity sync_ram;
15

16
architecture RTL of sync_ram is
17

18
  type ram_type is array (0 to 255) of std_logic_vector(datain'range);
19
  signal ram : ram_type;
20
  
21
begin
22

23
process(clock) is
24
begin
25
    if rising_edge(clock) then
26
      if we = '1' then
27
        ram(to_integer(unsigned(address))) <= datain;
28
      else
29
        dataout <= ram(to_integer(unsigned(read_address)));
30
      end if;  
31
    end if;
32
end process;
33

34
end architecture RTL;

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren