EmbDev.net

Forum: FPGA, VHDL & Verilog How to output ROM data that is loaded from an MIF file on GTKwave?


von Mahmoud R. (mahmoud899)


Rate this post
useful
not useful
I am writing a ROM vhdl code and I loaded the ROM with an MIF file. I 
wrote a testbench for the ROM and I ran it on GTKWave and there was no 
output when specific ROM addresses were selected.

ROM Code (rom.vhdl):
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
5
entity rom is
6
7
generic(
8
    addr_width  : integer := 16;
9
    addr_bits   : integer := 4;
10
    data_width  : integer := 8  
11
);
12
13
port(
14
    address     : in std_logic_vector(addr_bits-1 downto 0);
15
    dataout     : out std_logic_vector(data_width-1 downto 0)
16
);
17
18
end rom;
19
20
architecture behavioral of rom is
21
22
    type rom_type is array (0 to addr_width-1) of std_logic_vector(data_width-1 downto 0);
23
24
    signal my_rom : rom_type;
25
26
    -- note that 'ram_init_file' is not the user-defined-name (it is attribute name)
27
    attribute ram_init_file : string;
28
29
    -- "seven_seg_data.mif" is saved in the folder "ROM", then use "ROM/seven_seg_data.mif"
30
    attribute ram_init_file of my_rom : signal is "romdata.mif";
31
32
33
 begin
34
35
    dataout <= my_rom(to_integer(unsigned(address)));
36
37
 end behavioral;

ROM Testbench Code (rom_tb.vhdl):
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
5
entity rom_tb is
6
end entity;
7
8
architecture behavioral of rom_tb is
9
component rom
10
port(
11
    address     : in std_logic_vector(3 downto 0);
12
    dataout     : out std_logic_vector(7 downto 0)
13
);
14
end component;
15
16
signal address  : std_logic_vector(3 downto 0);
17
signal dataout  : std_logic_vector(7 downto 0);
18
19
begin
20
    U0 : rom port map (address, dataout);
21
22
    stim_process : process
23
    begin
24
        address <= "0000";
25
        wait for 10 ns;
26
    
27
        address <= "0001";
28
        wait for 10 ns;
29
    
30
        address <= "0010";
31
        wait for 10 ns;
32
    
33
        address <= "0011";
34
        wait for 10 ns;
35
    
36
        address <= "0100";
37
        wait for 10 ns;
38
    
39
        assert false report "Reached end of test";
40
        wait;
41
    
42
    end process;
43
end behavioral;

MIF File (romdata.mif):
1
% romdata.mif %
2
% ROM data    %
3
4
% data width and total data %
5
width=7;    % number of bits in each data
6
depth=16;   % total number of data (i.e. total address) %
7
8
%
9
    format of the data and address stored in this file
10
    uns : unsigned, dec : decimal, hex : hexadecimal
11
    bin : binary, oct : octal
12
%
13
14
address_radix=uns;  % address is unsigned-type %
15
data_radix=bin; % data is binary-type %
16
17
% ROM data %
18
content begin
19
    [0..15] : 0000000;
20
    0 : 00000000;
21
    1 : 00000001;
22
    2 : 00000010;
23
    3 : 00000011;
24
    4 : 00000100;
25
    5 : 00000101;
26
    6 : 00000110;
27
    7 : 00000111;
28
    8 : 00001000;
29
    9 : 00001001;
30
    10 : 00001010;
31
    11 : 00001011;
32
    12 : 00001100;
33
    13 : 00001101;
34
    14 : 00001110;
35
    15 : 00001111;
36
37
end;

What is wrong with the code and what do I need to do to be able to 
output what is stored in the memory addresses?

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.