Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Writing to an output file in VHDL

Status
Not open for further replies.

MSAKARIM

Full Member level 3
Full Member level 3
Joined
Jun 2, 2015
Messages
154
Helped
1
Reputation
2
Reaction score
4
Trophy points
1,298
Activity points
2,528
I'm trying to write some data to an output file in VHDL but i have this error during SIMULATION step :

" ** Failure: (vsim-4) ****** Memory allocation failure. *****
#
# Attempting to allocate 2147483664 bytes
#
# Please check your system for available memory and swap space.
# Time: 0 ps Iteration: 0 Process: /padtofile/line__30 "

My code is:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.All;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_TEXTIO.ALL;
USE STD.TEXTIO.ALL;
 
entity Padtofile is
generic(          block_size    :  integer      := 1024;    --bits
          length_bits   :  integer  := 128  );--bits
port(message: in std_logic_vector(63 downto 0));
end Padtofile;
 
 
architecture Behavioral of Padtofile is
signal clock,endoffile : bit := '0';
signal    linenumber : integer:=1; 
 
 
begin
clock <= not (clock) after 1 ns;   
 
 
process
variable mod_val: integer;
variable padding_length : integer;
variable padded_length : integer;
variable message_length: std_logic_vector((length_bits - 1) downto 0 ) := (others=>'0');
variable padded_message: std_logic_vector ((padded_length - 1) downto 0) := (others => '0');
Variable padding: std_logic_vector ((padding_length) downto 0) := (others => '0');
 
file      outfile  : text is out "Pad.txt";  --declare output file
variable  outline  : line;   --line number declaration  
begin
--padding message
mod_val:= (message'length) mod block_size;
padding_length := ((block_size-129)+(block_size - mod_val));
padded_length := ( message'length + (1 + padding_length) + length_bits);
message_length := std_logic_vector(to_unsigned(message'length,length_bits)); 
padding := "1" & std_logic_vector(to_unsigned(0,padding_length));  
padded_message := message & padding & message_length; 
 
 
wait until clock = '0' and clock'event;
if(endoffile='0') then  
 
write(outline, padded_message, right, block_size);
writeline(outfile, outline);
-- write line to external file.
 
linenumber <= linenumber + 1;
else
null;
end if;
 
end process;
 
end Behavioral;

 

variable padded_length : integer;
Variable padding: std_logic_vector ((padding_length) downto 0) := (others => '0');

Here is your problem
Edit----------
What probably happening is your computer is struggling to create the std_logic_vector padding, because it's such a mammoth size your local computer/software cannot create a register to capture that std_logic_vector
 
padding_length is an integer with no initial value. So will be set to -2^31+1 (same with padded_length). It means your message_length and padded_message and padding arrays have a 0 length (because they are null arrays). But this wont be the problem.
You're then trying to assign some very long stvs to these null arrays.

I also not you're using '87 style file declarations. The '93 declaration style is:

Code:
file f: text open WRITE_MODE is "some_file.txt";

Im not really sure what you're trying to do
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top