Lothar M. wrote:
> Ed H. wrote:
>> error: "width mismatch in assignment, target has 8-bits, source has
>> 4-bits."
> Thats correct.
>
> data is a std_logic_vector ( 7 downto 0), the RAM is a array "of
> std_logic_vector (3 downto 0)".
> So, what 4 bits of data do you want to store in the memory?
>
> With this you won't get errors:
> mem(conv_integer(address)) <= data(3 downto 0);
> data <= "0000" & mem(conv_integer(address));
> Wether thats OK to do it that way or not is up to you...
So I just changed the array to hold 8-bits as shown below, but now I get
an error that states "pin data[0]....[7] has multiple drivers."
1 | library ieee;
|
2 | use ieee.std_logic_1164.all;
|
3 | use ieee.std_logic_unsigned.all;
|
4 | entity ram is
|
5 | port (
|
6 | address :in std_logic_vector ( 3 downto 0);
|
7 | data :inout std_logic_vector ( 7 downto 0);
|
8 | cs :in std_logic;
|
9 | we :in std_logic;
|
10 | oe :in std_logic
|
11 | );
|
12 | end ram;
|
13 | architecture beh_ram of ram is
|
14 | type memory is array (0 to 15)of std_logic_vector (7 downto 0);
|
15 | signal mem : memory ;
|
16 | begin
|
17 | MEM_WRITE:
|
18 | process (address, data, cs, we)
|
19 | begin
|
20 | if (cs = '1' and we = '1') then
|
21 | mem(conv_integer(address)) <= data;
|
22 | end if;
|
23 | end process;
|
24 | MEM_READ:
|
25 | process (address, cs, we, oe, mem) begin
|
26 | if (cs = '1' and we = '0' and oe = '1') then
|
27 | data <= mem(conv_integer(address));
|
28 | else
|
29 | data <= (others => 'Z' );
|
30 | end if;
|
31 | end process;
|
32 | end beh_ram;
|