aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue795/ex.vhdl
blob: 4a8654ff5a186af5bbb5d1335459ec997d780674 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
library ieee; 
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.csv_file_reader_pkg.all;
-- csv file should be in format
-- sync period,v1hexvalue,v2integervalue,v3hexvalue,comment
-- eg 123445,AD45,234,F00D,"test line, for crash example"
--
entity crashExample is
  port (
  	vctrFlNm	: in string;
  	fEnd		: out  boolean; 
  	syncCount 	: out integer;
  	syncPulse 	: out std_logic;
  	v1 			: out std_logic_vector(15 downto 0);
  	v2			: out std_logic_vector(15 downto 0);
  	v3			: out std_logic_vector(15 downto 0);
  	vctrCmt		: out string
  );
end entity crashExample;

architecture BEHAVIORAL of crashExample is
	signal commentString 		: string(1 to LINE_LENGTH_MAX);
	signal syncCntInt 			: integer;
	constant SYN_PLSE_PRD		: time := 4000 ns; 
begin
	
	-- comment map
	vctrCmt <= commentString;

	-- Vector Process
	prcs_VctrRead : process
		variable csv			: csv_file_reader_type;
		variable syncPeriod		: time;
	begin
		-- initialse end flag
		fEnd <= false;
		-- open file
		csv.initialize(vctrFlNm);
		-- read first line of file which should be a comment	
		csv.readline;
		-- initalise variables/signals
		syncCntInt <= 0;
		-- while (not end of file)
		while not csv.end_of_file loop
			-- read information until next SYN command is found
			csv.readline;
			-- read Sync period
			syncPeriod := csv.read_integer * 1 ns;
			-- read Hex integer
			v1 <= std_logic_vector(to_unsigned(csv.read_hex, v1'length));
			-- read normal integer
			v2 <= std_logic_vector(to_unsigned(csv.read_integer, v2'length));
			-- read Hex integer
			v3 <= std_logic_vector(to_unsigned(csv.read_hex, v3'length));
			-- read String comment
			commentString <= csv.read_string;
			-- Make sync pulse
			syncPulse <= '1';
			syncCount <= syncCntInt;
			wait for SYN_PLSE_PRD;
			syncPulse <= '0';
			-- wait for the sync period
			wait for (syncPeriod - SYN_PLSE_PRD);
			syncCntInt <= syncCntInt + 1;
		end loop;
		fEnd <= true;
		wait; -- end simulation
	end process prcs_VctrRead;
	
end BEHAVIORAL;