diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-12-24 07:23:08 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-12-26 06:59:48 +0100 |
commit | c31485ff2c32f2aaf6e00e3447be2783a49bd71e (patch) | |
tree | ea0a437888bef401606716593339c158fb60a488 /testsuite/gna/issue718 | |
parent | b75f074b9f5c9a5930dd36d37a2e6836c5251265 (diff) | |
download | ghdl-c31485ff2c32f2aaf6e00e3447be2783a49bd71e.tar.gz ghdl-c31485ff2c32f2aaf6e00e3447be2783a49bd71e.tar.bz2 ghdl-c31485ff2c32f2aaf6e00e3447be2783a49bd71e.zip |
Add testcase for #718
Diffstat (limited to 'testsuite/gna/issue718')
-rw-r--r-- | testsuite/gna/issue718/bug_repro.vhdl | 67 | ||||
-rw-r--r-- | testsuite/gna/issue718/rom.txt | 4 | ||||
-rwxr-xr-x | testsuite/gna/issue718/testsuite.sh | 11 |
3 files changed, 82 insertions, 0 deletions
diff --git a/testsuite/gna/issue718/bug_repro.vhdl b/testsuite/gna/issue718/bug_repro.vhdl new file mode 100644 index 000000000..30fcc4a58 --- /dev/null +++ b/testsuite/gna/issue718/bug_repro.vhdl @@ -0,0 +1,67 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use ieee.numeric_std_unsigned.all; +use std.textio.all; + +package rom is + generic ( + word_bits: positive; + address_bits: positive; + rom_filename: string + ); + + subtype word_type is std_logic_vector(word_bits-1 downto 0); + + impure function read_at(address: in integer range 0 to 2**address_bits-1) return word_type; +end package rom; + +package body rom is + + impure function read_at( + address: in integer range 0 to 2**address_bits-1 + ) return word_type is + type rom_type is array(0 to 2**address_bits-1) of word_type; + + impure function init_rom_from_file (filename: in string) return rom_type is + file rom_file: text; + variable file_line : line; + variable rom_array: rom_type; + begin + file_open(rom_file, filename, read_mode); + for i in rom_type'range loop + readline(rom_file, file_line); + read(file_line, rom_array(i)); + end loop; + file_close(rom_file); + return rom_array; + end function; + constant rom_array: rom_type := init_rom_from_file(rom_filename); + begin + return rom_array(address); + end function read_at; +end package body rom; + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use ieee.numeric_std_unsigned.all; +use std.textio.all; + +entity test is +end test; + +architecture dataflow of test is + package p is new work.rom generic map( + word_bits => 2, + address_bits => 2, + rom_filename => "rom.txt" + ); + + signal word: std_logic_vector(1 downto 0); +begin + process (all) + begin + word <= p.read_at(0); + end process; +end dataflow; diff --git a/testsuite/gna/issue718/rom.txt b/testsuite/gna/issue718/rom.txt new file mode 100644 index 000000000..22c8c838b --- /dev/null +++ b/testsuite/gna/issue718/rom.txt @@ -0,0 +1,4 @@ +01 +00 +10 +11 diff --git a/testsuite/gna/issue718/testsuite.sh b/testsuite/gna/issue718/testsuite.sh new file mode 100755 index 000000000..608340a12 --- /dev/null +++ b/testsuite/gna/issue718/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze bug_repro.vhdl +elab_simulate test + +clean + +echo "Test successful" |