fpga: aps6404l device model: Allow preloading memory from file
This commit is contained in:
parent
8cf103a18d
commit
539d2e0908
@ -16,7 +16,9 @@ use std.textio.all;
|
|||||||
|
|
||||||
entity aps6404l is
|
entity aps6404l is
|
||||||
generic(
|
generic(
|
||||||
LOG_EN : boolean := true
|
SIZE : natural := 1024;
|
||||||
|
LOG_EN : boolean := true;
|
||||||
|
MEMFILE : string := ""
|
||||||
);
|
);
|
||||||
port(
|
port(
|
||||||
ce_n : in std_logic;
|
ce_n : in std_logic;
|
||||||
@ -41,7 +43,24 @@ begin
|
|||||||
test : process is
|
test : process is
|
||||||
type rx_state_t is (COMMAND, READ, WRITE, COMPLETE);
|
type rx_state_t is (COMMAND, READ, WRITE, COMPLETE);
|
||||||
type byte_vector is array (natural range <>) of std_logic_vector(7 downto 0);
|
type byte_vector is array (natural range <>) of std_logic_vector(7 downto 0);
|
||||||
variable mem : byte_vector(0 to 1023);
|
subtype mem_t is byte_vector(0 to SIZE - 1);
|
||||||
|
impure function init_ram_hex return mem_t is
|
||||||
|
file text_file : text;
|
||||||
|
variable text_line : line;
|
||||||
|
variable ram_content : mem_t := (others => x"5A");
|
||||||
|
begin
|
||||||
|
if MEMFILE /= "" then
|
||||||
|
file_open(text_file, MEMFILE, read_mode);
|
||||||
|
for i in 0 to SIZE - 1 loop
|
||||||
|
exit when endfile(text_file);
|
||||||
|
readline(text_file, text_line);
|
||||||
|
hread(text_line, ram_content(i));
|
||||||
|
end loop;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
return ram_content;
|
||||||
|
end function;
|
||||||
|
variable mem : mem_t := init_ram_hex;
|
||||||
variable bytes : byte_vector(0 to 32);
|
variable bytes : byte_vector(0 to 32);
|
||||||
variable cnt, bytecnt : integer;
|
variable cnt, bytecnt : integer;
|
||||||
variable state : rx_state_t;
|
variable state : rx_state_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user