def GetTBProcess(DUTName):
    """
	Return VHDL code for the read of textio stimuli file.
	"""
    return (
        """
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
TEST: process
	--file TestFile : text is in "./stimValues.txt";
	file TestFile : text open read_mode is "./stimValues.txt";
	variable L           : line;
	variable TimeVector  : time;
	variable R           : integer;--real
	variable good_number : boolean := True;
	variable index       : integer;
	variable TooMuchStim : boolean := True;

begin  -- process Test

	--WRITE_STRING (OUTPUT, "*** {0} test ***");
	write(output, "*** Start {0} test ***");

	while not endfile(TestFile) loop
		readline(TestFile, L);
		--writeline(output, L);
	
		read(L, R, GOOD => good_number);-- read the time from the beginning of the line
		if not good_number then
			write(output, "Skip line:");
			writeline(output, L);
		end if;
		next when not good_number;-- skip the line if it doesn't start with a number

		TimeVector := natural(R) * 1 ns; -- convert real number to time
		if (now < TimeVector) then -- wait until vector time
			wait for TimeVector - now;
			write(output, "Time : " & integer'image(R));
		end if;
		index := NbStimuli-1;
		TooMuchStim := False;
		--write(output, "NbStimuli=" & integer'image(NbStimuli));

		--For each caracter in line:
		for i in L'range loop
			if index<0 then -- wait until vector time
				if L(i)='0' or  L(i)='1' or L(i)='H' or  L(i)='L' or L(i)='X' then
					write(output, "Error parsing line:");
					writeline(output, L);
					assert false report "Given stimuli bit number exceeds the number of stimuli signals." severity ERROR;
					exit;
				end if;
			end if;
			--write(output, "index : " & integer'image(index));
			--write(output, "Stimuli length : " & integer'image(Stimuli'length));
			case L(i) is
				when '0' => -- Drive 0
					Stimuli(index) <= '0';
				when '1' => -- Drive 1
					Stimuli(index) <= '1';
				when 'H' => -- Test for 1
					assert Stimuli(index) = '1';
				when 'L' => -- Test for 0
					assert Stimuli(index) = '0';
				when 'X' => -- Don't care
					null;
				when ' ' | HT => -- Skip white space
					next;
				when others =>
					-- Illegal character
					assert false report "Illegal char in vector file: " & L(i);
				exit;
			end case;
			index := index-1;
		end loop;  -- end of line

	end loop;  -- end of file

assert false report "*** Test complete ***";
wait;

end process TEST;"""
        .format(DUTName))
