| Line 22... |
Line 22... |
|
|
PACKAGE hexio IS
|
PACKAGE hexio IS
|
|
|
-- This type must be used for base memory arrays
|
-- This type must be used for base memory arrays
|
TYPE cstr_array_type IS ARRAY(INTEGER RANGE <>) OF INTEGER RANGE 0 TO 65535;
|
TYPE cstr_array_type IS ARRAY(INTEGER RANGE <>) OF INTEGER RANGE 0 TO 65535;
|
TYPE B32K_array_type IS ARRAY(0 TO 3) OF cstr_array_type(0 TO 8192);
|
TYPE B32K_array_type IS ARRAY(0 TO 3) OF cstr_array_type(0 TO 8191);
|
|
|
FUNCTION init_cstr (
|
FUNCTION init_cstr (
|
CONSTANT array_size : IN INTEGER;
|
CONSTANT array_size : IN INTEGER;
|
CONSTANT input_file : IN STRING)
|
CONSTANT input_file : IN STRING)
|
RETURN cstr_array_type;
|
RETURN cstr_array_type;
|
|
|
|
FUNCTION init_b32k (
|
|
CONSTANT input_file : IN STRING)
|
|
RETURN B32K_array_type;
|
|
|
PROCEDURE init_b32k_array (
|
PROCEDURE init_b32k_array (
|
SIGNAL array_io : INOUT B32K_array_type;
|
VARIABLE array_io : INOUT B32K_array_type;
|
CONSTANT filename : IN STRING);
|
CONSTANT filename : IN STRING);
|
|
|
PROCEDURE init_var_array (
|
PROCEDURE init_var_array (
|
VARIABLE array_in : INOUT cstr_array_type;
|
VARIABLE array_in : INOUT cstr_array_type;
|
CONSTANT filename : IN STRING);
|
CONSTANT filename : IN STRING);
|
| Line 44... |
Line 48... |
CONSTANT filename : IN STRING);
|
CONSTANT filename : IN STRING);
|
|
|
PROCEDURE dump_array (
|
PROCEDURE dump_array (
|
CONSTANT array_in : IN cstr_array_type);
|
CONSTANT array_in : IN cstr_array_type);
|
|
|
|
PROCEDURE notify (
|
|
CONSTANT message : IN STRING);
|
|
|
|
FUNCTION notify_f (
|
|
CONSTANT message : IN STRING)
|
|
RETURN INTEGER;
|
|
|
END PACKAGE hexio;
|
END PACKAGE hexio;
|
|
|
PACKAGE BODY hexio IS
|
PACKAGE BODY hexio IS
|
|
|
-- Private declarations
|
-- Private declarations
|
| Line 74... |
Line 85... |
PROCEDURE read_file_into_sig_array (
|
PROCEDURE read_file_into_sig_array (
|
SIGNAL array_in : INOUT cstr_array_type;
|
SIGNAL array_in : INOUT cstr_array_type;
|
CONSTANT filename : IN STRING);
|
CONSTANT filename : IN STRING);
|
|
|
-- Procedure and function body definitions
|
-- Procedure and function body definitions
|
|
PROCEDURE notify (
|
|
CONSTANT message : IN STRING) IS
|
|
|
|
VARIABLE output_line : LINE;
|
|
BEGIN
|
|
write(output_line, message);
|
|
writeline(OUTPUT, output_line);
|
|
END;
|
|
|
|
FUNCTION notify_f (
|
|
CONSTANT message : IN STRING)
|
|
RETURN INTEGER IS
|
|
BEGIN
|
|
notify(message);
|
|
|
|
RETURN 0;
|
|
END;
|
|
|
FUNCTION init_cstr (
|
FUNCTION init_cstr (
|
CONSTANT array_size : IN INTEGER;
|
CONSTANT array_size : IN INTEGER;
|
CONSTANT input_file : IN STRING)
|
CONSTANT input_file : IN STRING)
|
RETURN cstr_array_type IS
|
RETURN cstr_array_type IS
|
|
|
VARIABLE rv : cstr_array_type(0 TO array_size - 1) := (OTHERS => 0);
|
VARIABLE rv : cstr_array_type(0 TO array_size - 1) := (OTHERS => 0);
|
|
|
VARIABLE output_line : LINE;
|
|
|
|
BEGIN -- FUNCTION init_cstr
|
BEGIN -- FUNCTION init_cstr
|
|
|
write(output_line, STRING'("Initialising memory"));
|
notify("Initialising memory");
|
writeline(OUTPUT, output_line);
|
|
|
|
init_var_array(rv, input_file);
|
init_var_array(rv, input_file);
|
|
|
RETURN rv;
|
RETURN rv;
|
END FUNCTION init_cstr;
|
END FUNCTION init_cstr;
|
|
|
|
FUNCTION init_b32k (
|
|
CONSTANT input_file : IN STRING)
|
|
RETURN B32K_array_type IS
|
|
|
|
VARIABLE rv : B32K_array_type;
|
|
|
|
BEGIN -- FUNCTION init_b32K
|
|
|
|
init_b32k_array(rv, input_file);
|
|
|
|
RETURN rv;
|
|
END FUNCTION init_b32K;
|
|
|
PROCEDURE init_b32k_array (
|
PROCEDURE init_b32k_array (
|
SIGNAL array_io : INOUT B32K_array_type;
|
VARIABLE array_io : INOUT B32K_array_type;
|
CONSTANT filename : IN STRING) IS
|
CONSTANT filename : IN STRING) IS
|
|
|
FILE input_file : TEXT;
|
FILE input_file : TEXT;
|
|
|
VARIABLE input_line : LINE;
|
VARIABLE input_line : LINE;
|
| Line 111... |
Line 149... |
VARIABLE line_value : STRING(1 TO 4);
|
VARIABLE line_value : STRING(1 TO 4);
|
|
|
BEGIN
|
BEGIN
|
|
|
FOR i IN 0 TO 3 LOOP
|
FOR i IN 0 TO 3 LOOP
|
array_io(i) <= (OTHERS => 0);
|
array_io(i) := (OTHERS => 0);
|
END LOOP;
|
END LOOP;
|
|
|
file_open(fstatus, input_file, filename, READ_MODE);
|
file_open(fstatus, input_file, filename, READ_MODE);
|
|
|
IF fstatus = OPEN_OK THEN
|
IF fstatus = OPEN_OK THEN
|
| Line 131... |
Line 169... |
writeline(OUTPUT, output_line);
|
writeline(OUTPUT, output_line);
|
|
|
-- Turn a hex value into an integer value
|
-- Turn a hex value into an integer value
|
read_hex(line_value, i_value);
|
read_hex(line_value, i_value);
|
|
|
array_io(i)(j) <= i_value;
|
array_io(i)(j) := i_value;
|
|
|
write(output_line, STRING'("Index :"));
|
write(output_line, STRING'("Index :"));
|
write(output_line, i*8192+j);
|
write(output_line, i*8192+j);
|
write(output_line, STRING'(" Value: "));
|
write(output_line, STRING'(" Value: "));
|
write(output_line, i_value);
|
write(output_line, i_value);
|