|
From: Brian K. <bri...@so...> - 2018-01-05 23:21:05
|
I'm attaching the image as a .png since I'm not sure online images are
supported...
On Fri, Jan 5, 2018 at 11:50 PM, Brian Kaczynski <bri...@so...>
wrote:
> Hello,
>
> I am having weird problems reading the header of a .wav file in 32-bit
> words. The following code should read the whole header 32 bits at a time
> and store then in the 32-bit by 11-entry memory wavheader:
>
> integer ofile, i, r;
> reg [31:0] wavheader [10:0];
> reg [31:0] ifile, rdata;
> ifile = $fopen("input.wav","rb");
> for( i = 0; i < 11; i = i + 1 ) begin
> #10 r = $fgets(rdata, ifile);
> wavheader[i] = rdata;
> end
>
> Here are the first 32 bytes of the .wav file:
> 52 49 46 46 FC B6 3C 00 57 41 56 45 66 6D 74 20 10 00 00 00 01 00 01 00 80
> BB 00 00 80 32 02 00
>
> And here is a screen shot from gtkwave of what rdata[31:0] is assigned on
> each iteration:
> [image: Inline image 1]
>
> The first 32-bit word is correct, but the second one is getting messed up
> somehow (FCB63C00 is turning into 00FCB63C).
> The next two words are correct and then the fifth word is being read as
> little-endian (which is actually correct but I'm not sure how iverilog
> knows to do this)!
> The sixth word is a complete mystery to me -- it's 01000100 in the file
> and iverilog turns it into 00000001 -- again maybe reading it as
> little-endian but why is it dropping the "01" in the second little-endian
> byte?
> These errors continue...
>
> Can anyone explain why and even better, give some tips on how to read this
> .wav file correctly?
>
> Many thanks in advance!
>
> --
> Brian Kaczynski, CTO
> Sonicsmith B. Kaczynski N. Lavi s.c.
> Ul. Bernardyńska 9/2
> 31-069 Kraków, Poland
> cell: +48 501 793 691 <+48%20501%20793%20691>
> web: www.sonicsmith.com
> FB: www.facebook.com/sonicsmithsynths
> Instagram: www.instagram.com/sonicsmithsynths/
> --
>
--
Brian Kaczynski, CTO
Sonicsmith B. Kaczynski N. Lavi s.c.
Ul. Bernardyńska 9/2
31-069 Kraków, Poland
cell: +48 501 793 691
web: www.sonicsmith.com
FB: www.facebook.com/sonicsmithsynths
Instagram: www.instagram.com/sonicsmithsynths/
--
|