Skip to content

Commit

Permalink
small cleanup: gather common functions and remove unused module
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Mar 21, 2021
1 parent 03f57ca commit 18c9361
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 128 deletions.
6 changes: 4 additions & 2 deletions src/util/adder_tree.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ library ieee;
use ieee.numeric_std.all;
use ieee.math_real.all;

library util;
use util.array_pkg.all;

entity adder_tree is
generic (
C_INPUT_COUNT : integer := 4;
Expand Down Expand Up @@ -50,8 +53,7 @@ architecture rtl of adder_tree is

for i in 0 to C_INPUT_COUNT - 1 loop

-- TODO: use get_slice
v_input_datum := input_vector((i + 1) * C_INPUT_BITWIDTH - 1 downto i * C_INPUT_BITWIDTH);
v_input_datum := get_slice(input_vector, i, C_INPUT_BITWIDTH);

if (C_UNSIGNED = 1) then
-- Pad a zero (sign) bit in case of unsigned input.
Expand Down
18 changes: 18 additions & 0 deletions src/util/array_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ package array_pkg is

function array_to_slv (array_in : t_kernel_array) return std_logic_vector;

function get_slice (vector: std_logic_vector; int_byte_index : natural; int_slice_size : natural) return std_logic_vector;

function get_fastest_increment (vector: std_logic_vector; int_index : natural; int_slice_size : natural) return std_logic_vector;

end package array_pkg;

package body array_pkg is
Expand Down Expand Up @@ -51,4 +55,18 @@ package body array_pkg is
return slv_out;
end function;

function get_slice (vector: std_logic_vector; int_byte_index : natural; int_slice_size : natural) return std_logic_vector is
begin
return vector((int_byte_index + 1) * int_slice_size - 1 downto int_byte_index * int_slice_size);
end function;

function get_fastest_increment (vector: std_logic_vector; int_index : natural; int_slice_size : natural) return std_logic_vector is
variable vector_out : std_logic_vector(vector'length / int_slice_size - 1 downto 0);
begin
for i in 0 to vector'length / int_slice_size - 1 loop
vector_out(i) := vector(int_index + i * int_slice_size);
end loop;
return vector_out;
end function;

end package body array_pkg;
107 changes: 0 additions & 107 deletions src/util/output_buffer.vhd

This file was deleted.

8 changes: 3 additions & 5 deletions src/util/serializer.vhd
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
library ieee;
use ieee.std_logic_1164.all;

library util;
use util.array_pkg.all;

entity serializer is
generic (
C_DATA_COUNT : integer := 4;
Expand All @@ -23,11 +26,6 @@ architecture rtl of serializer is

signal int_output_valid_cycles : integer range 0 to C_DATA_COUNT;

function get_slice (vector: std_logic_vector; int_byte_index : natural; int_slice_size : natural) return std_logic_vector is
begin
return vector((int_byte_index + 1) * int_slice_size - 1 downto int_byte_index * int_slice_size);
end function;

begin

proc_serializer : process (isl_clk) is
Expand Down
15 changes: 1 addition & 14 deletions src/window_convolution_activation.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ library ieee;
library cnn_lib;

library util;
use util.array_pkg.all;
use util.math_pkg.all;

library window_ctrl_lib;
Expand Down Expand Up @@ -58,20 +59,6 @@ architecture behavioral of window_convolution_activation is
signal a_weights : t_slv_array_1d(0 to C_OUTPUT_CHANNEL - 1)(C_KERNEL_SIZE * C_KERNEL_SIZE * C_INPUT_CHANNEL - 1 downto 0);
signal a_threshold : t_slv_array_1d(0 to C_OUTPUT_CHANNEL - 1)(C_POST_CONVOLUTION_BITWIDTH - 1 downto 0);

function get_slice (vector: std_logic_vector; int_byte_index : natural; int_slice_size : natural) return std_logic_vector is
begin
return vector((int_byte_index + 1) * int_slice_size - 1 downto int_byte_index * int_slice_size);
end function;

function get_fastest_increment (vector: std_logic_vector; int_index : natural; int_slice_size : natural) return std_logic_vector is
variable vector_out : std_logic_vector(vector'length / int_slice_size - 1 downto 0);
begin
for i in 0 to vector'length / int_slice_size - 1 loop
vector_out(i) := vector(int_index + i * int_slice_size);
end loop;
return vector_out;
end function;

begin

i_window_ctrl : entity window_ctrl_lib.window_ctrl
Expand Down

0 comments on commit 18c9361

Please sign in to comment.