⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mms.vhd

📁 ERC32 经典的sparc v7 cpu
💻 VHD
📖 第 1 页 / 共 5 页
字号:
		end if;		assert StrLen(Si) = 0 or Si(1) = ' ' or Si(1) = HT			report "Not an boolean string !" severity error;		return Res;	end FromString;	-- function	----------------------------	function ToBit(VALUE : character) return bit is		variable Res : bit := '0';	begin		case VALUE is			when '0' => Res := '0';			when '1' => Res := '1';			when others => assert FALSE					report "character is not a bit value !" severity error;		end case;	return Res;	end ToBit;	-- local function	----------------------------	function ToStdUlogic(VALUE : character) return std_ulogic is		variable Res : std_ulogic := 'U';	begin		case VALUE is			when 'U' => Res := 'U';			when 'X' => Res := 'X';			when '0' => Res := '0';			when '1' => Res := '1';			when 'Z' => Res := 'Z';			when 'L' => Res := 'L';			when 'H' => Res := 'H';			when 'W' => Res := 'W';			when '-' => Res := '-';			when others => assert FALSE					report "character is not a std_ulogic value !" severity error;		end case;	return Res;	end ToStdUlogic;	-- local function	----------------------------	function FromString (S : string) return bit is		alias Si : string (1 to S'length) is S;	begin		assert not IsBlank(Si) report "Empty or blank string !" severity error;		return ToBit(Si(LeadBlank(Si) + 1));	end FromString;	-- function	----------------------------		function FromString (S : string) return std_ulogic is		alias Si : string (1 to S'length) is S;	begin		assert not IsBlank(Si) report "Empty or blank string !" severity error;		return ToStdUlogic(Si(LeadBlank(Si) + 1));	end FromString;	-- function	----------------------------	function FromString (S : string; N : natural) return bit_vector is		alias Si : string (1 to S'length) is S;		variable Res : bit_vector (0 to N - 1) := (others => '0');		variable Index : integer := LeadBlank(Si) + 1;	begin		if N > StrLen(Si) - Index + 1 then			assert FALSE report "String too small !" severity error;		else			for i in 0 to N - 1 loop				Res(i) := ToBit(Si(Index));				Index := Index + 1;			end loop;		end if;		return Res;	end FromString;	-- function	----------------------------	function FromString (S : string; N : natural) return std_ulogic_vector is		alias Si : string (1 to S'length) is S;		variable Res : std_ulogic_vector (0 to N - 1) := (others => 'U');		variable Index : integer := LeadBlank(Si) + 1;	begin		if N > StrLen(Si) - Index + 1 then			assert FALSE report "String too small !" severity error;		else			for i in 0 to N - 1 loop				Res(i) := ToStdUlogic(Si(Index));				Index := Index + 1;			end loop;		end if;		return Res;	end FromString;	-- function	----------------------------	function FromString (S : string; N : natural) return std_logic_vector is		alias Si : string (1 to S'length) is S;		variable Res : std_logic_vector (0 to N - 1) := (others => 'U');		variable Index : integer := LeadBlank(Si) + 1;	begin		if N > StrLen(Si) - Index + 1 then			assert FALSE report "String too small !" severity error;		else			for i in 0 to N - 1 loop				Res(i) := ToStdUlogic(Si(Index));				Index := Index + 1;			end loop;		end if;		return Res;	end FromString;	-- function	----------------------------	procedure Print (S : string) is	begin		Print(OUTPUT, S);	end Print;	-- procedure	----------------------------	procedure Print (F : out text; S : string) is		alias Si : string (1 to S'length) is S;		variable L : line := new string'(Si(1 to Strlen(Si)));	begin		writeline(F, L);	end Print;	-- procedure	----------------------------	procedure Scan (S : out string) is	begin		Scan(INPUT, S);	end Scan;	-- procedure	----------------------------	procedure Scan (variable F : in text; S : out string) is 		alias Si : string (1 to S'length) is S;		variable L : line;		constant S_LENGTH : natural := S'length;		variable LLength : natural;	begin	 	readline(F, L);	 	if L = NULL then	 		assert FALSE report "Read error !" severity error;	 		return;	 	end if;	 	LLength := L'length;		if LLength < S_LENGTH then Si(1 to LLength + 1) := L.all & NUL;		elsif LLength = S_LENGTH then Si(1 to LLength) := L.all;		else			Si := L(1 to S_LENGTH);	 		assert FALSE report "String too short to contain input line !" 	 			severity error;	 	end if;	end Scan;	-- procedure	----------------------------	---------------	-- NbWord returns the number of words in a string (separator : blank)	---------------	function NbWord(S : string) return integer is		variable InBlank : boolean := TRUE;		variable Res : integer := 0;	begin		for i in S'range loop			case S(i) is				when NUL 			=> exit;	-- respect string convention				when ' ' | HT => InBlank := TRUE;				when others 	=> 					if InBlank then Res := Res + 1; end if;					InBlank := FALSE;			end case;		end loop;		return Res;	end NbWord;	-- local function	---------------	function GetTiming (	TP_NAME : string;												N : natural;												FILE_NAME : string) return tp_array is		file F : text is in FILE_NAME;		constant TP_NAME_L : natural := TP_NAME'length;		alias TpName : string (1 to TP_NAME_L) is TP_NAME;		variable MyLine : string(1 to BUF_SIZE);		variable IndexS : natural := LeadBlank(TpName) + 1;		variable IndexTp, OldIndexTp : natural := 1;		variable NextTpLength : integer;		variable Res : tp_array (1 to N) := (others => 0 ns);		variable WriteCount : bit_vector(1 to N) := (others => '0');		constant ALL_WRITTEN : bit_vector(1 to N) := (others => '1');		variable Found : boolean;	begin		if N /= NbWord(TpName) then			assert FALSE report "TP_NAME string incorrect !" severity error;			return Res;		end if;		ForeachLineInFile : while not endfile(F) loop			Scan(F, MyLine);			Shift(MyLine, LeadBlank(MyLine));			next when MyLine(1) = NUL or MyLine(1 to 2) = "--";			OldIndexTp := IndexTp;			ForeachTpInTpName : loop				NextTpLength := WordLen(MyLine);				Found := StrNcEqu(MyLine, TpName(IndexS to TP_NAME_L), NextTpLength);				if Found then					if WriteCount(IndexTp) > '0' then						assert FALSE report "Field " & MyLine(1 to NextTpLength) & 							" already loaded !" severity error;						exit;					end if;					Shift(MyLine, NextTpLength);					Res(IndexTp) := FromString(MyLine);					WriteCount(IndexTp) := '1';				end if;				IndexTp := IndexTp mod N + 1;				IndexS := NextWord(TpName, IndexS);				exit when Found or IndexTp = OldIndexTp;				-- if the line not relevant, it is skipped			end loop ForeachTpInTpName;		end loop ForeachLineInFile;		if WriteCount /= ALL_WRITTEN then			Diagnosis : for i in 1 to N loop				assert WriteCount(i) /= '0' report "TP number " & ToString(i) & 					" not found !" severity error;			end loop Diagnosis;		end if;		return Res;	end GetTiming;	-- function	----------------------------	function GetVal (FILE_NAME, FIELD : string) return integer is		file F : text is in FILE_NAME;		variable S : string(1 to BUF_SIZE);		variable MyVal : integer := 0;		constant L : integer := StrLen(FIELD);	begin		loop			if endfile(F) then				assert FALSE report FIELD & " not found in file " & FILE_NAME					severity error;				exit;			end if;			Scan(F, S);			Shift(S, LeadBlank(S));			if StrNcEqu(S, FIELD, L) then				Shift(S, L);				MyVal := FromString(S);				exit;			end if;		end loop;		return MyVal;	end GetVal;	-- function	----------------------------	function GetVal (	FILE_NAME, FIELD : string; 										INF, SUP : integer) return integer is		file F : text is in FILE_NAME;		variable S : string(1 to BUF_SIZE);		variable MyVal : integer := INF;		constant L : integer := StrLen(FIELD);	begin		loop			if endfile(F) then				assert FALSE report FIELD & " not found in file " & FILE_NAME					severity error;				exit;			end if;			Scan(F, S);			Shift(S, LeadBlank(S));			if StrNcEqu(S, FIELD, L) then				Shift(S, L);				MyVal := FromString(S);				if MyVal < INF or MyVal > SUP then					assert FALSE report "Value " & ToString(MyVal) & " out of range [" & 						ToString(INF) & ", " & ToString(SUP) & "] in file " & FILE_NAME						severity error;					MyVal := INF;				end if;				exit;			end if;		end loop;		return MyVal;	end GetVal;	-- function	----------------------------end StdIoImp;	-- package body-------------------------------------------------------------- File name : stdsim.vhd-- Title : StdSim-- project : SPARC-- Library : MMS-- Author(s) : E. Laubacher-- Purpose : package for standard simulations declarations-- notes :  to change the simulation conditions, alter -- 	the stdsim.dft file in your working directory-------------------------------------------------------------- Modification history :-------------------------------------------------------------- Version No : | Author | Mod. Date : | Changes made :-------------------------------------------------------------- v 1.0        | EL     | 92/08/11    | first version-------------------------------------------------------------- Copyright MATRA MARCONI SPACE FRANCE------------------------------------------------------------package StdSim is	----------------------------------	-- definition of types necessary for simulation control	----------------------------------	type environment is (COMMERCIAL, INDUSTRIAL, MILITARY);	type sim_type is (SPECIFIC, MINIMUM, TYPICAL, MAXIMUM);	type proces_type is (TYPICAL, BEST, WORST);	type temperature is range -55 to +125		units			Celsius;		end units;	type voltage is range 4500 to 5500		units			mV;			V = 1000 mV;		end units;	type capacitance is range integer'low to integer'high		units			fF;			pF = 1000 fF;			nF = 1000 pF;			uF = 1000 nF;		end units;	----------------------------------	-- Deferred constants	-- CHECK_ON to turn on or off the timing checkers (SetupHoldCheck, 	--   PulseWidthCheck)	-- ENVIRONMENT_BOARD and SIM_BOARD are visible for information purpose only 	-- BOARD conditions for temperature, voltage, process, capacitance	--  Capacitance is generally set globally, and not pin-by-pin	--   to avoid numerous unuseful parameters	----------------------------------	constant CHECK_ON : boolean;	constant ENVIRONMENT_BOARD : environment;	constant SIM_BOARD : sim_type;	constant T_BOARD : temperature;	constant V_BOARD : voltage;	constant PROCES_BOARD : proces_type;	constant LOAD_BOARD : capacitance;end StdSim;	-- package------------------------------------------------------------library MMS;use MMS.StdIoImp.GetVal;package body StdSim is	------------------------------------	-- values loaded from file "stdsim.dft"	------------------------------------	constant CHECK_ON : boolean := boolean'val(GetVal("stdsim.dft", "CHECK_ON", 		boolean'pos(boolean'low), boolean'pos(boolean'high)));	constant ENVIRONMENT_BOARD : environment := 		environment'val(GetVal("stdsim.dft", "ENVIRONMENT_BOARD",			environment'pos(environment'low), environment'pos(environment'high)));	constant SIM_BOARD : sim_type := 		sim_type'val(GetVal("stdsim.dft", "SIM_BOARD",			sim_type'pos(sim_type'low), sim_type'pos(sim_type'high)));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -