VHDL code to read and write bots from a file in PC 
Author Message
 VHDL code to read and write bots from a file in PC

Can any one tell me how to write a VHDL code to read bits (1s and 0s) from a
file on the PC and another VHDL code to write output bits to a file on the
PC?
I am using both Altera and Xilinx platforms. Is it actually possible on
these platforms ?
Thanks in advance,
Avinash Maddy



Sat, 31 Aug 2002 03:00:00 GMT  
 VHDL code to read and write bots from a file in PC
Avinash;

Here is a process that will do the read. I adapted it from an example
included with Modelsim. I haven't done a write before (I usually just have
the simulator log its output), but hopefully this will get you started. The
reason it looks at entry(2) is that it happens to be the column where my 1's
and 0's are in the text file. Don't forget that when you read a line from a
file, even the non-printing characters become part of the vector. You may
need to experiment with your index a bit before figuring out where your data
actually is (as opposed to blanks, line feeds, etc.).

---------------------------
constant period : time := 20 ns;
signal data : std_logic := '0';

begin

sendpattern : process
file pattern_file : text is in "pattern.prn";
variable entry : line;
variable iteration : integer := 0;
variable updatetime : time;
begin
  while not endfile(pattern_file) loop
   readline(pattern_file, entry);
   updatetime := iteration * period;
   if (now < updatetime) then
    wait for updatetime - now;
   end if;
   case entry(2) is
    when '0' => data <= '0';
    when '1' => data <= '1';
    when others =>
     data <= '0';
     assert false
     report "Bad data in pattern file!"
     severity error;
   end case;
   iteration := iteration + 1;
  end loop;
 wait;
end process;
---------------------------

Cheers,
Jamie

P.S. - I propose that a group called comp.lang.vhdl.homework be created!


Quote:
> Can any one tell me how to write a VHDL code to read bits (1s and 0s) from
a
> file on the PC and another VHDL code to write output bits to a file on the
> PC?
> I am using both Altera and Xilinx platforms. Is it actually possible on
> these platforms ?
> Thanks in advance,
> Avinash Maddy




Tue, 10 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VHDL code to read and write bits from a file in PC

2. Read and Write files in VHDL

3. Reading & writing files with VHDL

4. Read and Write files in VHDL

5. A problem to read a SEG-file using Fortran90 code on PC

6. Clarification: read/write slow, and TCPSocket and sys{read,write}

7. read/write slow, and TCPSocket and sys{read,write}

8. Reading from input file writing to output file

9. Q: simple example of read file->convert char(s)->write file needed

10. Reading a binary file / writing binary data to a file

11. Reading and writing to PC COM ports

12. Can PC compilers read/write on mini tapes?

 

 
Powered by phpBB® Forum Software