maturainfankam
Newbie level 4
- Joined
- Aug 5, 2014
- Messages
- 7
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Location
- Bremen
- Activity points
- 90
Hello everybody,
i have some problem to use the pointer in VHDl.
to begin a have contruct a linked list with three element 10 => 12 => 14. Nun a want to add the value 13 on the List ( between 12 and 14) so that i get always a sorted list.
But that not work:
you can see the code in appendex.
Thanks for answers.
Jean
i have some problem to use the pointer in VHDl.
to begin a have contruct a linked list with three element 10 => 12 => 14. Nun a want to add the value 13 on the List ( between 12 and 14) so that i get always a sorted list.
But that not work:
you can see the code in appendex.
Thanks for answers.
Jean
Code:
syntax=vhdl
library ieee;
use ieee.std_logic_1164.all; -- biblio for std_logic
entity pointer is
port (
rst : in std_logic;
clk : in std_logic;
re : in std_logic);
end pointer;
architecture arch of pointer is
type CELL;
type LINK is access CELL;
type CELL is record
value : natural;
NEXTP : LINK;
end record CELL;
shared variable HEAD, current, previous : LINK; --Zeiger auf CELL
shared variable tests : boolean := false;
signal output : natural;
begin -- architecture
MAKE_LL : process
variable tempptr, temp : LINK;
variable find : boolean := false;
begin -- process
HEAD := new CELL'(14, HEAD);
HEAD := new CELL'(12, HEAD);
HEAD := new CELL'(10, HEAD);
current := HEAD;
while current /= null and find = false loop
if current.value > 13 then
find := true;
else
previous := current;
current := current.NEXTP;
end if;
end loop;
if previous = null then
HEAD := new CELL'(13, HEAD);
elsif current = null then
tempptr := new CELL'(13, null);
previous.NEXTP := tempptr;
else
tempptr := new CELL'(13, tempptr);
temp := tempptr;
tempptr := current;
previous.NEXTP := tempptr;
-- current := previous.NEXTP;
-- previous.NEXTP := temp;
-- current := temp;
report "previous and current don't point of null" severity note;
--deallocate(tempptr);
-- deallocate(temp);
end if;
tests := true;
wait;
end process;
LESEN_LL : process
variable testnew : LINK;
begin -- process
testnew := HEAD;
if tests then
while testnew /= null loop
output <= testnew.value;
wait for 20 ns;
testnew := testnew.NEXTP;
if testnew = null then
wait;
end if;
end loop;
end if;
wait for 10 ns;
end process;
end arch;