Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   VHDL (http://www.velocityreviews.com/forums/f18-vhdl.html)
-   -   reading hex file-URGENTTT !! (http://www.velocityreviews.com/forums/t747820-reading-hex-file-urgenttt.html)

housam 05-05-2011 06:25 PM

reading hex file-URGENTTT !!
 
Hey, Im not familiar with vhdl code and need an immediate help.
i need to build a test bench that reads a combined victor of two bits and hex numbers, here's an example:
reading the victor: 0 0 F0A...3C 0BB...D1 FFF...0F AA0...A0
that is:

|Reset (single bit)
|
| --- |EN (single bit)
| --- |
| --- | - |Ms(128 hex digits)
| --- | - | ------------ |Hs(64 hex digits)
| --- | - | ------------ | ------------ |Ss(32 hex digits)
| --- | - | ------------ | ------------ | ----------- |Ts (16 hex digits)
0 - 0 - F0A...3C - 0BB...D1 - FFF...0F - AA0...A0

i heard about library textio but still don't know hoe to use its functions and what parameters
I will really appreciate if some one can write me a relevant code or help me with that, this is urgent for my project in the university
(sorry about my bad english level)
THANKS IN ADVANCE

slimbobaggins 05-06-2011 10:31 PM

4 Attachment(s)
Sorry, I don't have time to write code custom to your project cuz I'm struggling through my own code atm, but I have some stuff that can help you...



Quote:

library IEEE;
library std;
use std.textio.all;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;

entity filereader_tb is
generic(inleft : string := "left25.hex";
inright : string := "right25.hex";
outfile : string := "output.hex");
end filereader_tb;

architecture behavioral of filereader_tb is
begin
P1 : process
variable fstatus : file_open_status := status_error;
variable l : line;
variable r : line;
file in_lft : text;
file in_rgt : text;
file out_fd : text;
variable sample : string(8 downto 1);

begin
file_open(fstatus,in_lft,inleft,read_mode);
if(fstatus /= open_ok)then
assert false;
report "Your left input can go to hell"
severity failure;
end if;

file_open(fstatus,in_rgt,inright,read_mode);
if(fstatus /= open_ok)then
assert false;
report "Your right input can go to hell"
severity failure;
end if;

file_open(fstatus,out_fd,outfile,write_mode);
if(fstatus /= open_ok)then
assert false;
report "Your output can go to hell"
severity failure;
end if;

while(not endfile(in_lft)) loop
wait for 5 ns;
readline(in_lft,l);
read(l,sample(8 downto 5));
readline(in_rgt,r);
read(r,sample(4 downto 1));
report "Value Read from file"
severity note;
write(l,sample);
writeline(output,l);
write(l,sample);
writeline(out_fd,l);
end loop;
report "Left and Right channels concatenated together, and outputted"
severity note;
file_close(out_fd);
wait;
end process P1;
end behavioral;

slimbobaggins 05-06-2011 10:31 PM

jeez, of course the tabbed formatting gets all screwed up

not sure why my most recent comment disappeared, but change the file extension on the test bench to .vhd, and the others to .hex. this code reads in a 16-bit hex number from each right and left files (represents right and left audio), combines them using a string, and spits them out into output.hex.

note that each read/write takes 5ns, so set your clock and execution time according.

slimbobaggins 05-06-2011 10:40 PM

okay. i had to upload everything as text files because it doesn't all .vhd files. so, after you download the files, change filereader_tb to .vhd extension, and change the other three files to .hex extension.

what this code does is open up two seperate text files containing 16-bit hex values, combines them into 1 string (32 bits), and spits it out into output.hex. note that each read/write in my test bench requires 5ns, so make sure you run it for the appropriate amount of time.

http://www.cs.sfu.ca/~ggbaker/reference/std_logic/

is a website with good reference for textio and other vhdl in general

slimbobaggins 05-09-2011 12:47 PM

urgent, but no response?


All times are GMT. The time now is 06:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.