URL
https://opencores.org/ocsvn/vhdl_wavefiles/vhdl_wavefiles/trunk
Subversion Repositories vhdl_wavefiles
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 1 to Rev 2
- ↔ Reverse comparison
Rev 1 → Rev 2
/trunk/src/Testbench-ea.vhd
0,0 → 1,113
------------------------------------------------------------------------------- |
-- Project : VHDL WAVE files |
------------------------------------------------------------------------------- |
-- File : Testbench-ea.vhd |
-- Author : Alexander Lindert <alexander.lindert@fh-hagenberg.at> |
-- Created : 2008-08-20 |
-- Last update: 2008-08-23 |
-- Platform : |
------------------------------------------------------------------------------- |
-- Description: |
------------------------------------------------------------------------------- |
-- Copyright (c) 2008 |
------------------------------------------------------------------------------- |
-- Revisions : |
-- Date Version |
-- 2008-08-20 1.0 |
------------------------------------------------------------------------------- |
|
library ieee; |
use ieee.std_logic_1164.all; |
use ieee.numeric_std.all; |
use work.WaveFiles.all; |
|
entity Testbench is |
end entity; |
|
architecture bhv of Testbench is |
|
-- signal iMono : signed(7 downto 0); |
-- type aPCM16 is array(natural range<>) of signed(15 downto 0); |
-- signal iStereo : aPCM16(0 to 1); |
-- signal i10 : aPCM16(0 to 9); |
signal ts : time; |
signal ReaderInfo : aWaveFileInfo; |
signal WriteData, ReadData : integer; |
signal Mono : integer; |
signal Stereo : aIntArray(0 to 1); |
signal Ch10 : aIntArray(0 to 9); |
|
begin |
|
Read : process |
file Reader : aFileHandle; |
file Writer : aFileHandle; |
variable vReaderInfo : aWaveFileInfo; |
variable vFileName : string(1 to 11); |
variable vMono : integer; |
variable vStereo : aIntArray(0 to 1); |
variable vCh10 : aIntArray(0 to 9); |
variable vWriteData, vReadData : integer; |
begin |
for i in 0 to 3 loop |
case i is |
when 0 => vFileName := "iMono.wav "; |
when 1 => vFileName := "iStereo.wav"; |
when 2 => vFileName := "iCh10.wav "; |
when 3 => vFileName := "iBit32.wav "; |
when others => null; |
end case; |
OpenWaveFileRead(vFileName, Reader, vReaderInfo); |
case i is |
when 0 => vFileName := "oMono.wav "; |
when 1 => vFileName := "oStereo.wav"; |
when 2 => vFileName := "oCh10.wav "; |
when 3 => vFileName := "oBit32.wav "; |
when others => null; |
end case; |
OpenWaveFileWrite(vFileName, Writer, vReaderInfo); |
ReaderInfo <= vReaderInfo; |
vReadData := vReaderInfo.DataSize; |
vWriteData := vReaderInfo.DataSize; |
ts <= 1 sec /(vReaderInfo.SamplingRate); |
wait for 0 ns; |
wait for ts; |
|
while vReadData > 0 loop |
case vReaderInfo.Channels is |
when 1 => |
ReadSample(Reader, vMono, |
vReadData, vReaderInfo.DataTyp); |
Mono <= vMono; |
WriteSample(Writer, vMono, |
vWriteData, vReaderInfo.DataTyp); |
when 2 => |
ReadSamples(Reader, vStereo, vReadData, |
vReaderInfo.Channels, vReaderInfo.DataTyp); |
Stereo <= vStereo; |
WriteSamples(Writer, vStereo, vWriteData, |
vReaderInfo.Channels, vReaderInfo.DataTyp); |
when 10 => |
ReadSamples(Reader, vCh10, vReadData, |
vReaderInfo.Channels, vReaderInfo.DataTyp); |
Ch10 <= vCh10; |
WriteSamples(Writer, vCh10, vWriteData, |
vReaderInfo.Channels, vReaderInfo.DataTyp); |
when others => |
report "Untestet" severity note; |
vReaderInfo.DataSize := 0; |
end case; |
ReadData <= vReadData; |
WriteData <= vReadData; |
wait for ts; |
end loop; |
file_close(Reader); |
file_close(Writer); |
end loop; |
|
wait; |
end process; |
|
end architecture; |
|
|
/trunk/src/Wavefiles-p.vhd
0,0 → 1,324
------------------------------------------------------------------------------- |
-- Project : VHDL WAVE files |
------------------------------------------------------------------------------- |
-- File : Wavefiles-p.vhd |
-- Author : Alexander Lindert <alexander_lindert at gmx.at> |
-- Created : 2008-08-19 |
-- Last update: 2008-08-23 |
-- Platform : |
------------------------------------------------------------------------------- |
-- Description: This package can read or write VHDL signals from or to wave files. |
-- There are no restriction for the numbers of channels and the sampling |
-- frequences because Octave and Matlab can read them in every configuration. |
-- Format used from this link: |
-- http://www.lightlink.com/tjweber/StripWav/Canon.html |
------------------------------------------------------------------------------- |
-- GNU Lesser General Public License Version 3 |
-- ============================================= |
-- Copyright 2005 by Sun Microsystems, Inc. |
-- 901 San Antonio Road, Palo Alto, CA 94303, USA |
-- |
-- This library is free software; you can redistribute it and/or |
-- modify it under the terms of the GNU Lesser General Public |
-- License version 3, as published by the Free Software Foundation. |
-- |
-- This library is distributed in the hope that it will be useful, |
-- but WITHOUT ANY WARRANTY; without even the implied warranty of |
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
-- Lesser General Public License for more details. |
-- |
-- You should have received a copy of the GNU Lesser General Public |
-- License along with this library; if not, write to the Free Software |
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
-- MA 02111-1307 USA |
------------------------------------------------------------------------------- |
-- Revisions : |
-- Date Version |
-- 2008-08-19 1.0 |
------------------------------------------------------------------------------- |
|
package WaveFiles is |
|
type aFileHandle is file of character; |
type aWaveDataTyp is (PCM8, PCM16LE, PCM32LE); |
type aIntArray is array (natural range<>) of integer; |
|
type aWaveFileInfo is record |
-- Handle : aFileHandle; |
Channels : natural; |
Datatyp : aWaveDataTyp; |
DataSize : integer; |
SamplingRate : natural; |
end record; |
|
procedure OpenWaveFileRead(constant FileName : string; |
file WaveFileHandle : aFileHandle; |
variable FileInfo : out aWaveFileInfo); |
|
|
procedure ReadSample(file WaveFileHandle : aFileHandle; |
variable Sample : out integer; |
variable RemainingData : inout natural; |
constant DataTyp : aWaveDataTyp); |
|
procedure ReadSamples(file WaveFileHandle : aFileHandle; |
variable Samples : out aIntArray; |
variable RemainingData : inout natural; |
constant Channels : natural; |
constant DataTyp : aWaveDataTyp); |
|
procedure OpenWaveFileWrite(constant FileName : string; |
file WaveFileHandle : aFileHandle; |
variable WaveFile : inout aWaveFileInfo); |
|
procedure WriteSample(file WaveFileHandle : aFileHandle; |
constant Sample : integer; |
variable RemainingData : inout natural; |
constant DataTyp : aWaveDataTyp); |
|
procedure WriteSamples(file WaveFileHandle : aFileHandle; |
constant Samples : aIntArray; |
variable RemainingData : inout natural; |
constant Channels : natural; |
constant DataTyp : aWaveDataTyp); |
end; |
|
package body WaveFiles is |
|
function ReadString(file WaveFileHandle : aFileHandle; |
constant Name : string) return boolean is |
variable Ret : boolean := true; |
variable ch : character; |
begin |
for i in Name'range loop |
read(WaveFileHandle, ch); |
if ch /= Name(i) then |
Ret := false; |
end if; |
end loop; |
return Ret; |
end; |
|
function ReadDword(file WaveFileHandle : aFileHandle) return integer is |
variable Ret : integer := 0; |
variable temp : natural := 0; |
variable ch : character; |
begin |
for i in 0 to 3 loop |
read(WaveFileHandle, ch); |
temp := natural(character'pos(ch)); |
Ret := Ret + temp*2**(8*i); |
end loop; |
return Ret; |
end; |
|
function ReadWord(file WaveFileHandle : aFileHandle) return integer is |
variable Ret : integer := 0; |
variable ch : character; |
begin |
for i in 0 to 1 loop |
read(WaveFileHandle, ch); |
Ret := Ret + character'pos(ch)*2**(8*i); |
end loop; |
return Ret; |
end; |
|
procedure OpenWaveFileRead(constant FileName : string; |
file WaveFileHandle : aFileHandle; |
variable FileInfo : out aWaveFileInfo) is |
variable ch : character; |
variable Dummy : integer; |
variable FileSize : natural; |
variable FileStatus : file_open_status; |
begin |
file_open(FileStatus, WaveFileHandle, FileName, read_mode); |
assert(FileStatus = open_ok) |
report "Cannot open file " & FileName & "!" severity failure; |
assert(ReadString(WaveFileHandle, "RIFF")) |
report "The file " & FileName & " is not a wave file!" severity failure; |
FileSize := ReadDWord(WaveFileHandle) +8; -- wrong dummy access!!! |
assert(ReadString(WaveFileHandle, "WAVE")) |
report "The file " & FileName & " is not a wave file!" severity failure; |
assert(ReadString(WaveFileHandle, "fmt ")) |
report "The file " & FileName & " is not a wave file!" severity failure; |
assert(ReadDWord(WaveFileHandle) = 16) |
report "Uncommon header length, data will be corrupted!" severity failure; |
assert(ReadWord(WaveFileHandle) = 1) |
report "Cannot Handle any compressed file format" severity warning; |
FileInfo.Channels := ReadWord(WaveFileHandle); |
FileInfo.SamplingRate := ReadDword(WaveFileHandle); |
Dummy := ReadDword(WaveFileHandle); -- bytes/second |
Dummy := ReadWord(WaveFileHandle); -- block align |
case ReadWord(WaveFileHandle) is |
when 8 => FileInfo.DataTyp := PCM8; |
when 16 => FileInfo.DataTyp := PCM16LE; |
when 32 => FileInfo.DataTyp := PCM32LE; |
when others => |
report "Not Implemented!" severity failure; |
end case; |
assert(ReadString(WaveFileHandle, "data")) |
report "The file " & FileName & " is not a wave file!" severity failure; |
FileInfo.DataSize := ReadDword(WaveFileHandle); |
end; |
|
procedure ReadSample(file WaveFileHandle : aFileHandle; |
variable Sample : out integer; |
variable RemainingData : inout natural; |
constant DataTyp : aWaveDataTyp) is |
variable Ret : integer := 0; |
variable ch : character; |
begin |
if endfile(WaveFileHandle) = true then |
if RemainingData < 0 then |
report "Unexpected end of file!" severity error; |
else |
report "End of file reached!" severity note; |
end if; |
else |
case DataTyp is |
when PCM8 => |
read(WaveFileHandle, ch); |
Ret := character'pos(ch); |
RemainingData := RemainingData-1; |
when PCM16LE => |
Ret := ReadWord(WaveFileHandle); |
RemainingData := RemainingData-2; |
when PCM32LE => |
Ret := ReadDword(WaveFileHandle); |
RemainingData := RemainingData-4; |
end case; |
end if; |
Sample := Ret; |
end; |
|
|
procedure ReadSamples(file WaveFileHandle : aFileHandle; |
variable Samples : out aIntArray; |
variable RemainingData : inout natural; |
constant Channels : natural; |
constant DataTyp : aWaveDataTyp) is |
variable Ret : aIntArray(0 to Channels-1); |
begin |
for i in 0 to Channels-1 loop |
ReadSample(WaveFileHandle, Ret(i), RemainingData, DataTyp); |
end loop; |
Samples := Ret; |
end; |
|
procedure WriteString(file WaveFileHandle : aFileHandle; |
constant Name : string) is |
begin |
for i in Name'range loop |
write(WaveFileHandle, Name(i)); |
end loop; |
end; |
|
procedure WriteChar(file WaveFileHandle : aFileHandle; |
constant Value : integer) is |
variable ch : character; |
variable to_ch : integer; |
begin |
to_ch := Value; |
if to_ch < 0 then |
to_ch := 2**8 + to_ch; |
end if; |
ch := character'val(to_ch); |
write(WaveFileHandle, ch); |
end; |
|
procedure WriteDword(file WaveFileHandle : aFileHandle; |
constant Value : integer) is |
variable temp : integer := 0; |
variable to_ch : integer := 0; |
begin |
temp := Value; |
for i in 0 to 3 loop |
to_ch := temp mod 2**8; |
WriteChar(WaveFileHandle, to_ch); |
temp := (temp-to_ch)/2**8; |
end loop; |
end; |
|
procedure WriteWord(file WaveFileHandle : aFileHandle; |
constant Value : integer) is |
variable temp : integer := 0; |
variable to_ch : integer := 0; |
begin |
temp := Value; |
for i in 0 to 1 loop |
to_ch := temp mod 2**8; |
WriteChar(WaveFileHandle, to_ch); |
temp := (temp-to_ch)/2**8; |
end loop; |
end; |
|
|
procedure OpenWaveFileWrite(constant FileName : string; |
file WaveFileHandle : aFileHandle; |
variable WaveFile : inout aWaveFileInfo) is |
variable ch : character; |
variable Size : integer; |
variable FileStatus : file_open_status; |
begin |
file_open(FileStatus, WaveFileHandle, FileName, write_mode); |
assert(FileStatus = open_ok) |
report "Cannot open file " & FileName & "!" severity failure; |
WriteString(WaveFileHandle, "RIFF"); -- 4 |
Size := WaveFile.DataSize + 44 -8; |
WriteDword(WaveFileHandle, Size); -- 8 |
WriteString(WaveFileHandle, "WAVE"); -- 12 |
WriteString(WaveFileHandle, "fmt "); -- 16 |
Size := 16; |
WriteDWord(WaveFileHandle, Size); -- 20 size of format tag |
Size := 1; |
WriteWord(WaveFileHandle, Size); -- 22 PCM stream |
WriteWord(WaveFileHandle, WaveFile.Channels); -- 24 |
WriteDWord(WaveFileHandle, WaveFile.SamplingRate); -- 28 |
case WaveFile.DataTyp is |
when PCM8 => Size := 8; |
when PCM16LE => Size := 16; |
when PCM32LE => Size := 32; |
end case; |
WriteDWord(WaveFileHandle, WaveFile.SamplingRate*WaveFile.Channels*Size/8); -- bytes/second |
WriteWord(WaveFileHandle, WaveFile.Channels*Size/8); -- block align |
WriteWord(WaveFileHandle, Size); |
WriteString(WaveFileHandle, "data"); |
WriteDWord(WaveFileHandle, WaveFile.DataSize); |
end; |
|
procedure WriteSample(file WaveFileHandle : aFileHandle; |
constant Sample : integer; |
variable RemainingData : inout natural; |
constant DataTyp : aWaveDataTyp) is |
variable ch : character; |
begin |
if RemainingData > 0 then |
case DataTyp is |
when PCM8 => |
WriteChar(WaveFileHandle, Sample); |
RemainingData := RemainingData -1; |
when PCM16LE => |
WriteWord(WaveFileHandle, Sample); |
RemainingData := RemainingData -2; |
when PCM32LE => |
WriteDword(WaveFileHandle, Sample); |
RemainingData := RemainingData -4; |
end case; |
else |
report "Wave file is full, have you forgotten to set the data size for OpenWaveFileWrite!" severity error; |
end if; |
end; |
|
procedure WriteSamples(file WaveFileHandle : aFileHandle; |
constant Samples : aIntArray; |
variable RemainingData : inout natural; |
constant Channels : natural; |
constant DataTyp : aWaveDataTyp) is |
begin |
for i in 0 to Channels-1 loop |
WriteSample(WaveFileHandle, Samples(i), RemainingData, DataTyp); |
end loop; |
end; |
|
end; |
|
/trunk/src/LGPL.txt
0,0 → 1,166
GNU LESSER GENERAL PUBLIC LICENSE |
Version 3, 29 June 2007 |
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
Everyone is permitted to copy and distribute verbatim copies |
of this license document, but changing it is not allowed. |
|
|
This version of the GNU Lesser General Public License incorporates |
the terms and conditions of version 3 of the GNU General Public |
License, supplemented by the additional permissions listed below. |
|
0. Additional Definitions. |
|
As used herein, "this License" refers to version 3 of the GNU Lesser |
General Public License, and the "GNU GPL" refers to version 3 of the GNU |
General Public License. |
|
"The Library" refers to a covered work governed by this License, |
other than an Application or a Combined Work as defined below. |
|
An "Application" is any work that makes use of an interface provided |
by the Library, but which is not otherwise based on the Library. |
Defining a subclass of a class defined by the Library is deemed a mode |
of using an interface provided by the Library. |
|
A "Combined Work" is a work produced by combining or linking an |
Application with the Library. The particular version of the Library |
with which the Combined Work was made is also called the "Linked |
Version". |
|
The "Minimal Corresponding Source" for a Combined Work means the |
Corresponding Source for the Combined Work, excluding any source code |
for portions of the Combined Work that, considered in isolation, are |
based on the Application, and not on the Linked Version. |
|
The "Corresponding Application Code" for a Combined Work means the |
object code and/or source code for the Application, including any data |
and utility programs needed for reproducing the Combined Work from the |
Application, but excluding the System Libraries of the Combined Work. |
|
1. Exception to Section 3 of the GNU GPL. |
|
You may convey a covered work under sections 3 and 4 of this License |
without being bound by section 3 of the GNU GPL. |
|
2. Conveying Modified Versions. |
|
If you modify a copy of the Library, and, in your modifications, a |
facility refers to a function or data to be supplied by an Application |
that uses the facility (other than as an argument passed when the |
facility is invoked), then you may convey a copy of the modified |
version: |
|
a) under this License, provided that you make a good faith effort to |
ensure that, in the event an Application does not supply the |
function or data, the facility still operates, and performs |
whatever part of its purpose remains meaningful, or |
|
b) under the GNU GPL, with none of the additional permissions of |
this License applicable to that copy. |
|
3. Object Code Incorporating Material from Library Header Files. |
|
The object code form of an Application may incorporate material from |
a header file that is part of the Library. You may convey such object |
code under terms of your choice, provided that, if the incorporated |
material is not limited to numerical parameters, data structure |
layouts and accessors, or small macros, inline functions and templates |
(ten or fewer lines in length), you do both of the following: |
|
a) Give prominent notice with each copy of the object code that the |
Library is used in it and that the Library and its use are |
covered by this License. |
|
b) Accompany the object code with a copy of the GNU GPL and this license |
document. |
|
4. Combined Works. |
|
You may convey a Combined Work under terms of your choice that, |
taken together, effectively do not restrict modification of the |
portions of the Library contained in the Combined Work and reverse |
engineering for debugging such modifications, if you also do each of |
the following: |
|
a) Give prominent notice with each copy of the Combined Work that |
the Library is used in it and that the Library and its use are |
covered by this License. |
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license |
document. |
|
c) For a Combined Work that displays copyright notices during |
execution, include the copyright notice for the Library among |
these notices, as well as a reference directing the user to the |
copies of the GNU GPL and this license document. |
|
d) Do one of the following: |
|
0) Convey the Minimal Corresponding Source under the terms of this |
License, and the Corresponding Application Code in a form |
suitable for, and under terms that permit, the user to |
recombine or relink the Application with a modified version of |
the Linked Version to produce a modified Combined Work, in the |
manner specified by section 6 of the GNU GPL for conveying |
Corresponding Source. |
|
1) Use a suitable shared library mechanism for linking with the |
Library. A suitable mechanism is one that (a) uses at run time |
a copy of the Library already present on the user's computer |
system, and (b) will operate properly with a modified version |
of the Library that is interface-compatible with the Linked |
Version. |
|
e) Provide Installation Information, but only if you would otherwise |
be required to provide such information under section 6 of the |
GNU GPL, and only to the extent that such information is |
necessary to install and execute a modified version of the |
Combined Work produced by recombining or relinking the |
Application with a modified version of the Linked Version. (If |
you use option 4d0, the Installation Information must accompany |
the Minimal Corresponding Source and Corresponding Application |
Code. If you use option 4d1, you must provide the Installation |
Information in the manner specified by section 6 of the GNU GPL |
for conveying Corresponding Source.) |
|
5. Combined Libraries. |
|
You may place library facilities that are a work based on the |
Library side by side in a single library together with other library |
facilities that are not Applications and are not covered by this |
License, and convey such a combined library under terms of your |
choice, if you do both of the following: |
|
a) Accompany the combined library with a copy of the same work based |
on the Library, uncombined with any other library facilities, |
conveyed under the terms of this License. |
|
b) Give prominent notice with the combined library that part of it |
is a work based on the Library, and explaining where to find the |
accompanying uncombined form of the same work. |
|
6. Revised Versions of the GNU Lesser General Public License. |
|
The Free Software Foundation may publish revised and/or new versions |
of the GNU Lesser General Public License from time to time. Such new |
versions will be similar in spirit to the present version, but may |
differ in detail to address new problems or concerns. |
|
Each version is given a distinguishing version number. If the |
Library as you received it specifies that a certain numbered version |
of the GNU Lesser General Public License "or any later version" |
applies to it, you have the option of following the terms and |
conditions either of that published version or of any later version |
published by the Free Software Foundation. If the Library as you |
received it does not specify a version number of the GNU Lesser |
General Public License, you may choose any version of the GNU Lesser |
General Public License ever published by the Free Software Foundation. |
|
If the Library as you received it specifies that a proxy can decide |
whether future versions of the GNU Lesser General Public License shall |
apply, that proxy's public statement of acceptance of any version is |
permanent authorization for you to choose that version for the |
Library. |
|
/trunk/sim/CompareWave.m
0,0 → 1,36
|
[M fs] = wavread('oMono.wav'); |
Monox = sum(M-Mono); |
figure |
hold on |
plot(Mono); |
plot(M); |
plot(M-Mono); |
hold off |
|
[S fs] = wavread('oStereo.wav'); |
Stereox = sum(sum(S-Stereo)); |
figure |
hold on |
plot(Stereo(:,2)); |
plot(S(:,2)); |
plot(S(:,2)-Stereo(:,2)); |
hold off |
|
[C fs] = wavread('oCh10.wav'); |
Ch10x = sum(sum(C-Ch10)); |
figure |
hold on |
plot(Ch10(:,9)); |
plot(C(:,9)); |
plot(C(:,10)-Ch10(:,10)); |
hold off |
|
[B fs] = wavread('oBit32.wav'); |
Bit32x = sum(sum(C-Ch10)); |
figure |
hold on |
plot(Stereo(:,2)); |
plot(B(:,2)); |
plot(B(:,2)-Stereo(:,2)); |
hold off |
/trunk/sim/GenerateWave.m
0,0 → 1,30
clear all; |
close all; |
|
fs = 1e9; |
% frequence, amplitude |
Sinus = [6e6, 0.6]; |
lf = [1e6, 0.8]; |
noise = 0.2; |
bits = 9; |
t = 2e-6; |
|
LF = SinGen(fs,t, lf); |
S = SinGen(fs,t, Sinus); |
|
InputValues = [LF S]'; |
Mono = InputValues/(max(InputValues)+0.02); |
|
wavwrite(Mono,1e6,8,'iMono.wav'); |
|
Stereo = [Mono Mono]; |
wavwrite(Stereo, 44100,16,'iStereo.wav'); |
|
z = rand(length(InputValues(:,1)),8); |
Ch10 = [z Stereo]; |
wavwrite(Ch10, 1e9,16,'iCh10.wav'); |
plot(InputValues(:,1)); |
|
wavwrite(Stereo, 1e5,32,'iBit32.wav'); |
plot(InputValues(:,1)); |
|
/trunk/sim/CreatePackage.m
0,0 → 1,62
function [ success ] = CreatePackage( type, name, vector) |
% creates a VHDL package with a constat array from a vector |
% Author: Alexander Lindert |
% type ... VHDL typ |
% name ... array name |
% vector ... single dimensional array |
% TODO ... more dimensions |
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
% GNU Lesser General Public License Version 3 |
% ============================================= |
% Copyright 2005 by Sun Microsystems, Inc. |
% 901 San Antonio Road, Palo Alto, CA 94303, USA |
% |
% This library is free software; you can redistribute it and/or |
% modify it under the terms of the GNU Lesser General Public |
% License version 3, as published by the Free Software Foundation. |
% |
% This library is distributed in the hope that it will be useful, |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
% Lesser General Public License for more details. |
% |
% You should have received a copy of the GNU Lesser General Public |
% License along with this library; if not, write to the Free Software |
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
% MA 02111-1307 USA |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
filename = sprintf('%s-p.vhd',name); |
system(sprintf('rm %s', filename)); |
hFile = fopen(filename,'w'); |
|
fprintf(hFile,'------------------------------------------------------------------------\n'); |
fprintf(hFile,'-- Script created table file\n'); |
fprintf(hFile,'------------------------------------------------------------------------\n'); |
fprintf(hFile,'library ieee;\n'); |
fprintf(hFile,'use ieee.std_logic_1164.all;\n'); |
fprintf(hFile,'use ieee.numeric_std.all;\n'); |
%fprintf(hFile,'use work.Fractional.all;\n'); |
%fprintf(hFile,'use work.Global.all;\n\n'); |
fprintf(hFile,'package p%s is\n',name); |
fprintf(hFile,'constant c%s : %s',name,type); |
VectorSize = length(vector); |
Dimension = length(VectorSize); |
VectorPos = ones(1,VectorSize); |
|
if Dimension == 1 |
fprintf(hFile,'(0 to %d-1) := (',VectorSize); |
for i = 1:VectorSize |
fprintf(hFile,' %d',round(vector(i))); |
if i ~= VectorSize |
fprintf(hFile,','); |
end |
end |
fprintf(hFile,')'); |
end |
fprintf(hFile,';\nend;\n'); |
fclose(hFile); |
|
|
|
/trunk/sim/sim.bat
0,0 → 1,5
ghdl -a ../src/Wavefiles-p.vhd |
ghdl -a ../src/Testbench-ea.vhd |
|
del test.log |
ghdl -r Testbench --vcd=test.vcd 2> test.log |
/trunk/sim/SinGen.m
0,0 → 1,11
function [ vector ] = SinGen(fs, t, Table) |
% fs ... sampling frequence |
% t ... sampling time |
% Table ... [ sin frequence, amplitude; sin frequence, amplitude; ...] |
|
T = [1:(fs*t)]*2*pi/fs; |
vector = zeros(1,length(T)); |
|
for i = 1:length(Table(:,1)) |
vector = vector + sin(T*Table(i,1))*Table(i,2); |
end |