LUT for my vhdl code

K

kude

Guest
I have priority Queue vhdl code and I want to give this Code
(Character,freq)
shown at the end of the code ,so that I will have a huffman encoded ou
put.

pls help ,thanks

package commonConstants is
constant wordSize: integer := 23;
end package commonConstants;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use work.commonConstants.all;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity Huffman_Algo is
Port ( clk, reset : in std_logic;
insert, delete : in std_logic;
key, value : in std_logic_vector(wordSize-1 downto 0);
smallValue : out std_logic_vector(wordSize-1 downto 0);
busy, empty, full : out std_logic
);
end Huffman_Algo;
architecture arch1 of Huffman_Algo is
constant rowSize: integer := 23;
type pqElement is record
dp: std_logic;
key: std_logic_vector(wordSize-1 downto 0);
value: std_logic_vector(wordSize-1 downto 0);
end record pqElement;
type rowTyp is array(0 to rowSize-1) of pqElement;
signal top, bot: rowTyp;
type state_type is (ready, inserting, deleting);
signal state: state_type;
begin
process(clk) begin
if clk'event and clk = '1' then
if reset = '1' then
for i in 0 to rowSize-1 loop
top(i).dp <= '0'; bot(i).dp <= '0';
end loop;
state <= ready;
elsif state = ready and insert = '1' then
if top(rowSize-1).dp /= '1' then
for i in 1 to rowSize-1 loop
top(i) <= top(i-1);
end loop;
top(0) <= ('1',key,value);
state <= inserting;
end if;
elsif state = ready and delete = '1' then
if bot(0).dp /= '0' then
for i in 0 to rowSize-2 loop
bot(i) <= bot(i+1);
end loop;
bot(rowSize-1).dp <= '0'; state <= deleting;
end if;
elsif state = inserting or state = deleting then
for i in 0 to rowSize-1 loop
if top(i).dp = '1' and
(top(i).key < bot(i).key or bot(i).dp = '0') then
bot(i) <= top(i); top(i) <= bot(i);
end if;
end loop;
state <= ready;
end if;
end if;
end process;
smallValue <= bot(0).value when bot(0).dp = '1' else
(smallValue' range => '0');
empty <= not bot(0).dp;
full <= top(rowSize-1).dp;
busy <= '1' when state /= ready else '0';
end arch1;



---Characters with frequency

(s,32)
(a,17)
(u,9)
(h,9)
(f,18)
(e,42)
(m,10)
(y,5)
(z,1)
(.,2)
(q,3)
(n,21)
(o,23)
(t,13)
(l,13)
(r,26)
(space,56)
(c,16)
(i,15)
(d,14)
(g,7)
(b,4)
(p,3)


---------------------------------------
Posted through http://www.FPGARelated.com
 

Welcome to EDABoard.com

Sponsor

Back
Top