DesignStudies3 - Design Studies Part 3 Priority Queue VGA...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Jon Turner/David M. Zar Priority Queue VGA display buffer Design Studies – Part 3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Priority Queue Priority queue stores (key, value) pairs and always makes value with smallest key available. » operations – reset, insert new pair, delete pair with smallest key » inputs - clk, reset, insert, delete, key, value » outputs – smallValue, empty, full, busy (when high, new inputs ignored) Implement as two rows of cells. » each cell has data present bit (dp) plus (key, value) pair » keys in bottom row are sorted, keys in columns are sorted » occupied cells to left, occupied top cell must have occupied cell below it » to insert, • shift top to right • top-bottom swap » to delete • shift bottom left • top-bottom swap key val dp key val dp key val dp key val dp key val dp key val dp key val dp key val dp clk reset insert delete busy empty full key+value smallValue
Background image of page 2
3 VHDL for Priority Queue entity priQueue 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 priQueue; architecture arch1 of priQueue is constant rowSize: integer := 4; 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; define two rows of cells interface signals controller state
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 begin process(clk) begin if rising_edge(clk) 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; make all slots empty initially shift top row right and insert new value shift bottom row left
Background image of page 4
5 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;
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/06/2011.

Page1 / 20

DesignStudies3 - Design Studies Part 3 Priority Queue VGA...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online