Browse Source

add init() procedure to t_list_queue type to configure the maximal depth of the linked-list queue

pull/1/head
T. Meissner 10 years ago
parent
commit
500f41f4b7
5 changed files with 53 additions and 10 deletions
  1. +10
    -8
      sim/QueueP.vhd
  2. +12
    -2
      test/QueueT.vhd
  3. +8
    -0
      test/SimT.vhd
  4. +16
    -0
      test/SpiT.vhd
  5. +7
    -0
      test/WishBoneT.vhd

+ 10
- 8
sim/QueueP.vhd View File

@ -30,7 +30,7 @@ package QueueP is
procedure push (data : in std_logic_vector); procedure push (data : in std_logic_vector);
procedure pop (data : inout std_logic_vector); procedure pop (data : inout std_logic_vector);
procedure logging (logging : in boolean);
procedure init (depth : in natural; logging : in boolean := false);
impure function is_empty return boolean; impure function is_empty return boolean;
impure function is_full return boolean; impure function is_full return boolean;
impure function fillstate return natural; impure function fillstate return natural;
@ -112,7 +112,8 @@ package body QueueP is
-- linked liste queue implementation -- linked liste queue implementation
type t_list_queue is protected body type t_list_queue is protected body
constant C_QUEUE_DEPTH : natural := 64;
variable v_queue_depth : natural := 0;
constant C_QUEUE_WIDTH : natural := 8; constant C_QUEUE_WIDTH : natural := 8;
type t_entry; type t_entry;
@ -126,7 +127,7 @@ package body QueueP is
variable v_head : t_entry_ptr; variable v_head : t_entry_ptr;
variable v_tail : t_entry_ptr; variable v_tail : t_entry_ptr;
variable v_count : natural range 0 to C_QUEUE_DEPTH := 0;
variable v_count : natural := 0;
variable v_logging : boolean := false; variable v_logging : boolean := false;
-- write one entry into queue by -- write one entry into queue by
@ -167,10 +168,11 @@ package body QueueP is
end if; end if;
end procedure pop; end procedure pop;
procedure logging (logging : in boolean) is
procedure init (depth : in natural; logging : in boolean := false) is
begin begin
v_logging := logging;
end procedure logging;
v_queue_depth := depth;
v_logging := logging;
end procedure init;
-- returns true if queue is empty, false otherwise -- returns true if queue is empty, false otherwise
impure function is_empty return boolean is impure function is_empty return boolean is
@ -181,7 +183,7 @@ package body QueueP is
-- returns true if queue is full, false otherwise -- returns true if queue is full, false otherwise
impure function is_full return boolean is impure function is_full return boolean is
begin begin
return v_count = C_QUEUE_DEPTH;
return v_count = v_queue_depth;
end function is_full; end function is_full;
-- returns number of filled slots in queue -- returns number of filled slots in queue
@ -193,7 +195,7 @@ package body QueueP is
-- returns number of free slots in queue -- returns number of free slots in queue
impure function freeslots return natural is impure function freeslots return natural is
begin begin
return C_QUEUE_DEPTH - v_count;
return v_queue_depth - v_count;
end function freeslots; end function freeslots;
end protected body t_list_queue; end protected body t_list_queue;


+ 12
- 2
test/QueueT.vhd View File

@ -16,6 +16,8 @@ end entity QueueT;
architecture sim of QueueT is architecture sim of QueueT is
constant C_QUEUE_DEPTH : natural := 64;
shared variable sv_simple_queue : t_simple_queue; shared variable sv_simple_queue : t_simple_queue;
shared variable sv_list_queue : t_list_queue; shared variable sv_list_queue : t_list_queue;
@ -23,6 +25,14 @@ architecture sim of QueueT is
begin begin
QueueInitP : process is
begin
sv_list_queue.init(C_QUEUE_DEPTH);
wait;
end process QueueInitP;
SimpleQueueTestP : process is SimpleQueueTestP : process is
variable v_data : std_logic_vector(63 downto 0); variable v_data : std_logic_vector(63 downto 0);
begin begin
@ -50,13 +60,13 @@ begin
begin begin
-- check initial emptiness -- check initial emptiness
assert_true(sv_list_queue.is_empty, "Queue should be empty!"); assert_true(sv_list_queue.is_empty, "Queue should be empty!");
for i in 0 to 63 loop
for i in 0 to C_QUEUE_DEPTH-1 loop
sv_list_queue.push(std_logic_vector(to_unsigned(i, 8))); sv_list_queue.push(std_logic_vector(to_unsigned(i, 8)));
end loop; end loop;
-- check that it's full -- check that it's full
assert_true(sv_list_queue.is_full, "Queue should be full!"); assert_true(sv_list_queue.is_full, "Queue should be full!");
-- empty the queue -- empty the queue
for i in 0 to 63 loop
for i in 0 to C_QUEUE_DEPTH-1 loop
sv_list_queue.pop(v_data); sv_list_queue.pop(v_data);
assert_equal(v_data, std_logic_vector(to_unsigned(i, 8))); assert_equal(v_data, std_logic_vector(to_unsigned(i, 8)));
end loop; end loop;


+ 8
- 0
test/SimT.vhd View File

@ -53,6 +53,14 @@ begin
s_clk <= not(s_clk) after C_PERIOD when not(and_reduce(s_tests_done)) else '0'; s_clk <= not(s_clk) after C_PERIOD when not(and_reduce(s_tests_done)) else '0';
QueueInitP : process is
begin
sv_mosi_queue.init(32);
sv_miso_queue.init(32);
wait;
end process QueueInitP;
SimTestP : process is SimTestP : process is
variable v_time : time; variable v_time : time;
begin begin


+ 16
- 0
test/SpiT.vhd View File

@ -137,6 +137,14 @@ begin
begin begin
QueueInitP : process is
begin
sv_mosi_queue.init(32);
sv_miso_queue.init(32);
wait;
end process QueueInitP;
--* Stimuli generator and BFM for the valid-accept interface --* Stimuli generator and BFM for the valid-accept interface
--* on the local data input of the DUT --* on the local data input of the DUT
--* --*
@ -288,6 +296,14 @@ begin
begin begin
QueueInitP : process is
begin
sv_mosi_queue.init(32);
sv_miso_queue.init(32);
wait;
end process QueueInitP;
--* Unit test of spi master procedure, checks all combinations --* Unit test of spi master procedure, checks all combinations
--* of cpol & cpha against spi slave procedure --* of cpol & cpha against spi slave procedure
SpiMasterP : process is SpiMasterP : process is


+ 7
- 0
test/WishBoneT.vhd View File

@ -139,6 +139,13 @@ begin
s_wb_reset <= '0' after C_PERIOD * 5; s_wb_reset <= '0' after C_PERIOD * 5;
QueueInitP : process is
begin
sv_wishbone_queue.init(2**C_ADDRESS_WIDTH);
wait;
end process QueueInitP;
WbMasterLocalP : process is WbMasterLocalP : process is
variable v_random : RandomPType; variable v_random : RandomPType;
variable v_wbmaster_data : std_logic_vector(C_DATA_WIDTH-1 downto 0); variable v_wbmaster_data : std_logic_vector(C_DATA_WIDTH-1 downto 0);


Loading…
Cancel
Save