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

Subversion Repositories vhdl_wavefiles

[/] [vhdl_wavefiles/] [trunk/] [sim/] [CreatePackage.m] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alex008
function [ success ] = CreatePackage( type, name, vector)
2
% creates a VHDL package with a constat array from a vector
3
% Author: Alexander Lindert
4
%  type       ... VHDL typ
5
%  name       ... array name
6
%  vector     ... single dimensional array
7
% TODO        ... more dimensions
8
 
9
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10
 %    GNU Lesser General Public License Version 3
11
 %    =============================================
12
 %    Copyright 2005 by Sun Microsystems, Inc.
13
 %    901 San Antonio Road, Palo Alto, CA 94303, USA
14
 %
15
 %    This library is free software; you can redistribute it and/or
16
 %    modify it under the terms of the GNU Lesser General Public
17
 %    License version 3, as published by the Free Software Foundation.
18
 %
19
 %    This library is distributed in the hope that it will be useful,
20
 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
 %    Lesser General Public License for more details.
23
 %
24
 %    You should have received a copy of the GNU Lesser General Public
25
 %    License along with this library; if not, write to the Free Software
26
 %    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27
 %    MA  02111-1307  USA
28
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29
 
30
filename = sprintf('%s-p.vhd',name);
31
system(sprintf('rm %s', filename));
32
hFile = fopen(filename,'w');
33
 
34
fprintf(hFile,'------------------------------------------------------------------------\n');
35
fprintf(hFile,'-- Script created table file\n');
36
fprintf(hFile,'------------------------------------------------------------------------\n');
37
fprintf(hFile,'library ieee;\n');
38
fprintf(hFile,'use ieee.std_logic_1164.all;\n');
39
fprintf(hFile,'use ieee.numeric_std.all;\n');
40
%fprintf(hFile,'use work.Fractional.all;\n');
41
%fprintf(hFile,'use work.Global.all;\n\n');
42
fprintf(hFile,'package p%s is\n',name);
43
fprintf(hFile,'constant c%s : %s',name,type);
44
VectorSize = length(vector);
45
Dimension = length(VectorSize);
46
VectorPos = ones(1,VectorSize);
47
 
48
if Dimension == 1
49
    fprintf(hFile,'(0 to %d-1) := (',VectorSize);
50
    for i = 1:VectorSize
51
        fprintf(hFile,' %d',round(vector(i)));
52
        if i ~= VectorSize
53
            fprintf(hFile,',');
54
        end
55
    end
56
    fprintf(hFile,')');
57
end
58
fprintf(hFile,';\nend;\n');
59
fclose(hFile);
60
 
61
 
62
 

powered by: WebSVN 2.1.0

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