Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

ASIC/FPGA Design and Verification Out Source Services

A VHDL example implementing list (is access record).



  1. This examples demonstrates how to create lists in VHDL. This may be useful in implementing a FIFO quickly in a test-bench.
    I used list style coding to read an unknown number of bytes, during simulation at time 0, from a file. The data is to be later driven to a DUT. read from file into a list.

  2. The list item has two fields, data to be driven to DUT and a next item pointer for list manipulation.

  3. The simulation is ended using an assert error statement. The code has been tested using ghdl. The code and compilation script is shown below:

  4. #!/bin/bash

    if [ -d "work" ] ; then
      rm -fr work
    fi
    mkdir work

    ghdl -i --std=93c --workdir=work tb_is_access.vhd
    ghdl -m --work=work --workdir=work --ieee=synopsys tb_is_access

    ./tb_is_access --assert-level=error



    1. LIBRARY ieee;
    2. USE ieee.std_logic_1164.ALL;
    3. use STD.textio.all;
    4. use IEEE.std_logic_textio.all;
    5. use ieee.numeric_std.all;
    6. use ieee.STD_LOGIC_UNSIGNED.conv_integer;
    7. ENTITY tb_is_access IS
    8. END tb_is_access;
    9. ARCHITECTURE beha OF tb_is_access IS
    10. type fifo_item; -- the item
    11. type fifo_item_ptr is access fifo_item; -- pointer to item
    12. type fifo_item is record -- full definition of item
    13. data : std_logic_vector(7 downto 0);
    14. next_rec : fifo_item_ptr;
    15. end record;
    16. BEGIN
    17. --Read process
    18. process
    19. variable j : integer;
    20. variable v : std_logic_vector(7 downto 0);
    21. variable new_pkt : fifo_item_ptr;
    22. variable tmp_ptr : fifo_item_ptr;
    23. variable fifo_ptr: fifo_item_ptr := null;
    24. variable my_line : line;
    25. begin
    26.   v := (others => '0');
    27.   for j in 0 to 8 loop
    28.     if(j = 0) then
    29.       new_pkt := new fifo_item;
    30.       new_pkt.data := v;
    31.       new_pkt.next_rec := null;
    32.       fifo_ptr := new_pkt;
    33.     else
    34.       new_pkt := new fifo_item;
    35.       new_pkt.data := v;
    36.       new_pkt.next_rec := null;
    37.       tmp_ptr := fifo_ptr;
    38.       
    39.       --write(my_line, string'("dbg "));
    40.       --hwrite(my_line, new_pkt.data);
    41.       --writeline(output, my_line);
    42.       
    43.       while(tmp_ptr.next_rec /= null) loop --find last
    44.         tmp_ptr := tmp_ptr.next_rec;
    45.       end loop;
    46.       tmp_ptr.next_rec := new_pkt;
    47.     end if;
    48.     v := std_logic_vector(unsigned(v) + "00000001");
    49.   end loop;
    50.   wait for 10 ns;
    51.   tmp_ptr := fifo_ptr;
    52.   while(tmp_ptr.next_rec /= null) loop
    53.     write(my_line, string'("dbg "));
    54.     hwrite(my_line, tmp_ptr.data);
    55.     write(my_line, string'(" time "));
    56.     write(my_line, now);
    57.     writeline(output, my_line);
    58.     
    59.     tmp_ptr := tmp_ptr.next_rec;
    60.   end loop;
    61.   
    62.   assert false report "end of test" severity error;
    63. end process;
    64. end beha;


Search This Site


Feedback This Site




new pages on this site