Skip to content
Snippets Groups Projects
Commit 6f8cfef7 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Added tb_common_log.vhd to print pow and log functions from common_pkg.vhd for range of values.

parent 026be57c
Branches
No related tags found
1 merge request!254Corrected c_block_size_w, by using +1 to ensure that g_block_size that is...
......@@ -148,6 +148,7 @@ synth_files =
tb/vhdl/tb_common_mem_pkg.vhd
test_bench_files =
tb/vhdl/tb_common_log.vhd
tb/vhdl/tb_common_acapture.vhd
tb/vhdl/tb_common_add_sub.vhd
tb/vhdl/tb_common_adder_tree.vhd
......
-- --------------------------------------------------------------------------
-- Copyright 2021
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- --------------------------------------------------------------------------
--
-- Author: E. Kooistra, 11 May 2022
-- Purpose: Show pow and log functions from common_pkg.vhd
-- Description:
-- Usage:
-- > run -all
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE work.common_pkg.ALL;
USE work.common_str_pkg.ALL;
ENTITY tb_common_log IS
END tb_common_log;
ARCHITECTURE tb OF tb_common_log IS
BEGIN
p_log : PROCESS
CONSTANT c_range : t_integer_arr := (99, 100, 101, 127, 128, 129);
VARIABLE vI : NATURAL;
BEGIN
print_str("I: pow2, ceil_pow2");
FOR I IN 1 TO 20 LOOP
print_str(int_to_str(I) & ": " &
int_to_str(pow2(I)) & ", " &
int_to_str(ceil_pow2(I)));
END LOOP;
print_str("");
print_str("I: ceil_log2, true_log2, true_log_pow2, is_pow2, floor_log10");
FOR I IN 1 TO 20 LOOP
print_str(int_to_str(I) & ": " &
int_to_str(ceil_log2(I)) & ", " &
int_to_str(true_log2(I)) & ", " &
int_to_str(true_log_pow2(I)) & ", " &
bool_to_str(is_pow2(I)) & ", " &
int_to_str(floor_log10(I)));
END LOOP;
print_str("");
print_str("I: ceil_log2, true_log2, true_log_pow2, is_pow2, floor_log10");
FOR I IN c_range'RANGE LOOP
vI := c_range(I);
print_str(int_to_str(vI) & ": " &
int_to_str(ceil_log2(vI)) & ", " &
int_to_str(true_log2(vI)) & ", " &
int_to_str(true_log_pow2(vI)) & ", " &
bool_to_str(is_pow2(vI)) & ", " &
int_to_str(floor_log10(vI)));
END LOOP;
WAIT;
END PROCESS;
END tb;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment