OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.communication/] [hibi_pe_dma/] [1.0/] [tb/] [blocks/] [tb_n2h2_pkg.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Package for block-level testing of Nios-to-HIBI
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : tb_n2h2_pkg.vhd
6
-- Author     : Ari Kulmala
7
-- Company    : 
8
-- Created    : 2005-03-22
9
-- Last update: 2011-11-11
10
-- Platform   : 
11
-- Standard   : VHDL'87
12
-------------------------------------------------------------------------------
13
-- Description: 
14
-------------------------------------------------------------------------------
15
-- Revisions  :
16
-- Date        Version  Author  Description
17
-- 2005-03-22  1.0      AK      Created
18
-------------------------------------------------------------------------------
19
-------------------------------------------------------------------------------
20
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
21
--
22
-- This file is part of HIBI
23
--
24
-- This source file may be used and distributed without
25
-- restriction provided that this copyright statement is not
26
-- removed from the file and that any derivative work contains
27
-- the original copyright notice and the associated disclaimer.
28
--
29
-- This source file is free software; you can redistribute it
30
-- and/or modify it under the terms of the GNU Lesser General
31
-- Public License as published by the Free Software Foundation;
32
-- either version 2.1 of the License, or (at your option) any
33
-- later version.
34
--
35
-- This source is distributed in the hope that it will be
36
-- useful, but WITHOUT ANY WARRANTY; without even the implied
37
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
38
-- PURPOSE.  See the GNU Lesser General Public License for more
39
-- details.
40
--
41
-- You should have received a copy of the GNU Lesser General
42
-- Public License along with this source; if not, download it
43
-- from http://www.opencores.org/lgpl.shtml
44
-------------------------------------------------------------------------------
45
 
46
library ieee;
47
use ieee.std_logic_1164.all;
48
use ieee.std_logic_arith.all;
49
use ieee.std_logic_unsigned.all;
50
use std.textio.all;
51
use ieee.std_logic_textio.all;
52
 
53
package tb_n2h2_pkg is
54
 
55
  type     addr_array is array (0 to 7) of integer;
56
 
57
  -- Noc addresses (HIBI addresses). These identify the active reception channel of the N2H DMA block
58
  constant addresses_c     : addr_array := (200, 250, 300, 444, 555, 666, 777, 888);
59
 
60
  -- Addresses on the avalon bus to the memory = memory addresses of reception buffer
61
  -- arrays 
62
  constant ava_addresses_c : addr_array := (1000, 3333, 5555, 7000000, 9000000, 11000000, 13000000, 15000000);
63
 
64
 
65
 
66
  --  constant addresses_c : addr_array := (16#1000000#, 16#3000000#, 16#5000000#, 16#7000000#, 16#9000000#, 16#b000000#, 16#d000000#, 16#f000000#);
67
  --  constant ava_addresses_c : addr_array := (1000000, 3000000, 5000000, 7000000, 9000000, 11000000, 13000000, 15000000);
68
 
69
  constant conf_bits_c    : integer := 4;  -- number of configuration bits in CPU
70
 
71
 
72
  procedure read_conf_file (
73
    mem_addr      : out integer;
74
    dst_addr      : out integer;
75
    irq_amount    : out integer;
76
    --    max_amount    : out integer;
77
    file file_txt :     text);
78
 
79
 
80
  function log2 (
81
    constant x         : integer)
82
    return integer;
83
 
84
 
85
  --  -- This has become obsolete (2011-11-11)
86
  --  procedure read_data_file (
87
  --    data          : out integer;
88
  --    file file_txt :     text);
89
 
90
 
91
end tb_n2h2_pkg;
92
 
93
package body tb_n2h2_pkg is
94
 
95
 
96
  -- Reads ASCII file that stores info how to confgiure N2H DMA
97
  procedure read_conf_file (
98
    mem_addr      : out integer;
99
    dst_addr      : out integer;
100
    irq_amount    : out integer;
101
    file file_txt :     text) is
102
 
103
    variable file_row        : line;
104
    --variable file_sample     : integer;
105
    -- variable file_sample_hex : std_logic_vector(31 downto 0);
106
    variable sample_ok            : boolean := FALSE;
107
  begin
108
 
109
    -- Loop until finding a line that is not a comment
110
    while sample_ok = false and not(endfile(file_txt)) loop
111
      readline(file_txt, file_row);
112
      read (file_row, mem_addr, sample_ok);
113
 
114
      if sample_ok = FALSE then
115
        --Reading of the delay value failed
116
        --=> assume that this line is comment or empty, and skip other it
117
        -- assert false report "Skipped a line" severity note;
118
        next;                           -- start new loop interation
119
      end if;
120
 
121
 
122
      read(file_row, dst_addr); --file_sample);
123
      --dst_addr   := file_sample;
124
      read(file_row, irq_amount); -- file_sample);
125
      --irq_amount := file_sample;
126
    end loop;
127
 
128
 
129
 
130
    --    readline(file_txt, file_row);
131
    --    --    hread(file_row, file_sample_hex);
132
    --    --    mem_addr   := conv_integer(file_sample_hex);
133
    --    --    hread(file_row, file_sample_hex);
134
    --    --    dst_addr     := conv_integer(file_sample_hex);
135
    --    read(file_row, file_sample, sample_ok);
136
    --    if sample_ok = true then
137
    --    assert sample_ok report "ei oo hyvä" severity note;
138
    --    mem_addr   := file_sample;
139
    --    read(file_row, file_sample);
140
    --    dst_addr   := file_sample;
141
    --    read(file_row, file_sample);
142
    --    irq_amount := file_sample;
143
    --    end if;
144
  end read_conf_file;
145
 
146
 
147
  -- Logarithm with base=2
148
  function log2 (
149
    constant x : integer)
150
    return integer is
151
 
152
    variable tmp_v : integer := 1;
153
    --variable i_v   : integer := 0;
154
  begin  -- log2
155
    --report "log2(x):x is " &  integer'image(x);
156
 
157
    for i in 0 to 31 loop
158
      if tmp_v >= x then
159
        -- report "ceil(log2(x)) is " &  integer'image(i);
160
        return i;
161
      end if;
162
      tmp_v := tmp_v * 2;
163
    end loop;  -- i
164
 
165
    -- We should not ever come here, let's return a definitely illegal value
166
    assert false report "Error in function log2(x)" severity warning;
167
    return -1;
168
 
169
  end log2;
170
 
171
 
172
 
173
--  procedure read_data_file (
174
--    data          : out integer;
175
--    file file_txt :     text) is
176
 
177
--    variable file_row    : line;
178
--    variable file_sample : integer;
179
--  begin  -- read_data_file
180
--    readline(file_txt, file_row);
181
--    read(file_row, file_sample);
182
--    data := file_sample;
183
--  end read_data_file;
184
 
185
 
186
 
187
end tb_n2h2_pkg;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.