{"id":928,"date":"2015-11-12T15:01:43","date_gmt":"2015-11-12T15:01:43","guid":{"rendered":"http:\/\/coolt.ch\/notizen\/?p=928"},"modified":"2015-11-12T15:01:55","modified_gmt":"2015-11-12T15:01:55","slug":"std_logic_textio-vhd","status":"publish","type":"post","link":"https:\/\/coolt.ch\/notizen\/std_logic_textio-vhd\/","title":{"rendered":"std_logic_textio.vhd"},"content":{"rendered":"<p>Die Vollversion:<\/p>\n<pre class=\"lang:sh decode:true  \">use STD.textio.all;\r\nlibrary IEEE;\r\nuse IEEE.std_logic_1164.all;\r\n\r\npackage STD_LOGIC_TEXTIO is\r\n--synopsys synthesis_off\r\n\t-- Read and Write procedures for STD_ULOGIC and STD_ULOGIC_VECTOR\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_ULOGIC);\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_ULOGIC; GOOD: out BOOLEAN);\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR);\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD: out BOOLEAN);\r\n\tprocedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);\r\n\tprocedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);\r\n\r\n\t-- Read and Write procedures for STD_LOGIC_VECTOR\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR);\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN);\r\n\tprocedure WRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);\r\n\r\n\t--\r\n\t-- Read and Write procedures for Hex and Octal values.\r\n\t-- The values appear in the file as a series of characters\r\n\t-- between 0-F (Hex), or 0-7 (Octal) respectively.\r\n\t--\r\n\r\n\t-- Hex\r\n\tprocedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR);\r\n\tprocedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD: out BOOLEAN);\r\n\tprocedure HWRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);\r\n\tprocedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR);\r\n\tprocedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN);\r\n\tprocedure HWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);\r\n\r\n\t-- Octal\r\n\tprocedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR);\r\n\tprocedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD: out BOOLEAN);\r\n\tprocedure OWRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);\r\n\tprocedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR);\r\n\tprocedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN);\r\n\tprocedure OWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);\r\n\r\n\t\r\n--synopsys synthesis_on\r\nend STD_LOGIC_TEXTIO;\r\n\r\npackage body STD_LOGIC_TEXTIO is\r\n--synopsys synthesis_off\r\n\r\n\t-- Type and constant definitions used to map STD_ULOGIC values \r\n\t-- into\/from character values.\r\n\r\n\ttype MVL9plus is ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-', ERROR);\r\n\ttype char_indexed_by_MVL9 is array (STD_ULOGIC) of character;\r\n\ttype MVL9_indexed_by_char is array (character) of STD_ULOGIC;\r\n\ttype MVL9plus_indexed_by_char is array (character) of MVL9plus;\r\n\r\n\tconstant MVL9_to_char: char_indexed_by_MVL9 := \"UX01ZWLH-\";\r\n\tconstant char_to_MVL9: MVL9_indexed_by_char := \r\n\t\t('U' =&gt; 'U', 'X' =&gt; 'X', '0' =&gt; '0', '1' =&gt; '1', 'Z' =&gt; 'Z',\r\n\t\t 'W' =&gt; 'W', 'L' =&gt; 'L', 'H' =&gt; 'H', '-' =&gt; '-', others =&gt; 'U');\r\n\tconstant char_to_MVL9plus: MVL9plus_indexed_by_char := \r\n\t\t('U' =&gt; 'U', 'X' =&gt; 'X', '0' =&gt; '0', '1' =&gt; '1', 'Z' =&gt; 'Z',\r\n\t\t 'W' =&gt; 'W', 'L' =&gt; 'L', 'H' =&gt; 'H', '-' =&gt; '-', others =&gt; ERROR);\r\n\r\n\r\n\t-- Overloaded procedures.\r\n\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_ULOGIC; GOOD:out BOOLEAN) is\r\n\t\tvariable c: character;\r\n\t\tvariable readOk: BOOLEAN;\r\n\tbegin\r\n\t\tloop\t\t\t\t\t-- skip white space\r\n\t\t\tread(l,c,readOk);\t\t-- but also exit on a bad read\r\n\t\t\texit when ((readOk = FALSE) or ((c \/= ' ') and (c \/= CR) and (c \/= HT)));\r\n\t\tend loop;\r\n\r\n\t\tif (readOk = FALSE) then\r\n\t\t\tgood := FALSE;\r\n\t\telse\r\n\t\t    if (char_to_MVL9plus(c) = ERROR) then\r\n\t\t\tvalue := 'U';\r\n\t\t\tgood := FALSE;\r\n\t\t     else\r\n\t\t\tvalue := char_to_MVL9(c);\r\n\t\t\tgood := TRUE;\r\n\t\t    end if;\r\n\t\tend if;\r\n\tend READ;\r\n\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD:out BOOLEAN) is\r\n\t\tvariable m:  STD_ULOGIC;\r\n\t\tvariable c:  character;\r\n\t\tvariable s:  string(1 to value'length-1);\r\n\t\tvariable mv: STD_ULOGIC_VECTOR(0 to value'length-1);\r\n\t\tconstant allU: STD_ULOGIC_VECTOR(0 to value'length-1)\r\n\t\t \t\t\t\t:= (others =&gt; 'U');\r\n                variable readOk: BOOLEAN;\r\n\r\n\tbegin\r\n\t\tloop\t\t\t\t\t-- skip white space\r\n\t\t\tread(l,c,readOk);\r\n\t\t\texit when ((readOk = FALSE) or ((c \/= ' ') and (c \/= CR) and (c \/= HT)));\r\n\t\tend loop;\r\n \r\n-- Bail out if there was a bad read\r\n                if (readOk = FALSE) then\r\n                        good := FALSE;\r\n\t\t\treturn;\r\n                end if;\r\n\r\n\t\tif (char_to_MVL9plus(c) = ERROR) then\r\n\t\t\tvalue := allU;\r\n\t\t\tgood := FALSE;\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tread(l, s, readOk);\r\n-- Bail out if there was a bad read\r\n                if (readOk = FALSE) then\r\n                        good := FALSE;\r\n                        return;\r\n                end if;\r\n\r\n\t    \tfor i in 1 to value'length-1 loop\r\n\t\t\tif (char_to_MVL9plus(s(i)) = ERROR) then\r\n\t\t\t\tvalue := allU;\r\n\t\t\t\tgood := FALSE;\r\n\t\t\t    \treturn;\r\n\t\t\tend if;\r\n\t\tend loop;\r\n\r\n\t\tmv(0) := char_to_MVL9(c);\r\n\t    \tfor i in 1 to value'length-1 loop\r\n\t\t\tmv(i) := char_to_MVL9(s(i));\r\n\t    \tend loop;\r\n\t\tvalue := mv;\r\n\t\tgood := TRUE;\r\n\tend READ;\r\n\t\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_ULOGIC) is\r\n\t\tvariable c: character;\r\n\tbegin\r\n\t\tloop\t\t\t\t\t-- skip white space\r\n\t\t\tread(l,c);\r\n\t\t\texit when ((c \/= ' ') and (c \/= CR) and (c \/= HT));\r\n\t\tend loop;\r\n\r\n\t\tif (char_to_MVL9plus(c) = ERROR) then\r\n\t\t\tvalue := 'U';\r\n\t\t\tassert FALSE report \"READ(STD_ULOGIC) Error: Character '\" &amp;\r\n\t\t\t\t\tc &amp; \"' read, expected STD_ULOGIC literal.\";\r\n\t\telse\r\n\t\t\tvalue := char_to_MVL9(c);\r\n\t\tend if;\r\n\tend READ;\r\n\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR) is\r\n\t\tvariable m: STD_ULOGIC;\r\n\t\tvariable c: character;\r\n\t\tvariable s: string(1 to value'length-1);\r\n\t\tvariable mv: STD_ULOGIC_VECTOR(0 to value'length-1);\r\n\t\tconstant allU: STD_ULOGIC_VECTOR(0 to value'length-1)\r\n\t\t\t\t := (others =&gt; 'U');\r\n\tbegin\r\n\t\tloop\t\t\t\t\t -- skip white space\r\n\t\t\tread(l,c);\r\n\t\t\texit when ((c \/= ' ') and (c \/= CR) and (c \/= HT));\r\n\t\tend loop;\r\n\r\n\t\tif (char_to_MVL9plus(c) = ERROR) then\r\n\t\t\tvalue := allU;\r\n\t\t\tassert FALSE report\r\n\t\t\t\t\"READ(STD_ULOGIC_VECTOR) Error: Character '\" &amp; \r\n\t\t\t\t\tc &amp; \"' read, expected STD_ULOGIC literal.\";\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tread(l, s);\r\n\t    \tfor i in 1 to value'length-1 loop\r\n\t\t\tif (char_to_MVL9plus(s(i)) = ERROR) then\r\n\t\t\t    value := allU;\r\n\t\t\t    assert FALSE report \r\n\t\t\t\t\"READ(STD_ULOGIC_VECTOR) Error: Character '\" &amp;\r\n\t\t\t\t\ts(i) &amp; \"' read, expected STD_ULOGIC literal.\";\r\n\t\t\t    return;\r\n\t\t\tend if;\r\n\t\tend loop;\r\n\r\n\t\tmv(0) := char_to_MVL9(c);\r\n\t    \tfor i in 1 to value'length-1 loop\r\n\t\t\tmv(i) := char_to_MVL9(s(i));\r\n\t    \tend loop;\r\n\t\tvalue := mv;\r\n\tend READ;\r\n\r\n\tprocedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is\r\n\tbegin\r\n\t\twrite(l, MVL9_to_char(value), justified, field);\r\n\tend WRITE;\r\n\t\r\n\r\n\tprocedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is\r\n\t\tvariable s: string(1 to value'length);\r\n\t\tvariable m: STD_ULOGIC_VECTOR(1 to value'length) := value;\r\n\tbegin\r\n\t    \tfor i in 1 to value'length loop\r\n\t\t\ts(i) := MVL9_to_char(m(i));\r\n\t\tend loop;\r\n\t\twrite(l, s, justified, field);\r\n\tend WRITE;\r\n\r\n\t-- Read and Write procedures for STD_LOGIC_VECTOR\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is\r\n\t\tvariable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tREAD(L, tmp);\r\n\t\tVALUE := STD_LOGIC_VECTOR(tmp);\r\n\tend READ;\r\n\r\n\tprocedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN) is\r\n\t\tvariable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tREAD(L, tmp, GOOD);\r\n\t\tVALUE := STD_LOGIC_VECTOR(tmp);\r\n\tend READ;\r\n\r\n\tprocedure WRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is\r\n\tbegin\r\n\t\tWRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD);\r\n\tend WRITE;\r\n\r\n\r\n\t--\r\n\t-- Hex Read and Write procedures.\r\n\t--\r\n\r\n\t--\r\n\t-- Hex, and Octal Read and Write procedures for BIT_VECTOR\r\n\t--  (these procedures are not exported, they are only used\r\n\t--   by the STD_ULOGIC hex\/octal reads and writes below.\r\n\t--\r\n\t--\r\n\r\n\tprocedure Char2QuadBits(C: Character; \r\n\t\t\t\tRESULT: out std_ulogic_vector(3 downto 0);\r\n\t\t\t\tGOOD: out Boolean;\r\n\t\t\t\tISSUE_ERROR: in Boolean) is\r\n\tbegin\r\n\t\tcase c is\r\n\t\t\twhen '0' =&gt; result :=  x\"0\"; good := TRUE;\r\n\t\t\twhen '1' =&gt; result :=  x\"1\"; good := TRUE;\r\n\t\t\twhen '2' =&gt; result :=  x\"2\"; good := TRUE;\r\n\t\t\twhen '3' =&gt; result :=  x\"3\"; good := TRUE;\r\n\t\t\twhen '4' =&gt; result :=  x\"4\"; good := TRUE;\r\n\t\t\twhen '5' =&gt; result :=  x\"5\"; good := TRUE;\r\n\t\t\twhen '6' =&gt; result :=  x\"6\"; good := TRUE;\r\n\t\t\twhen '7' =&gt; result :=  x\"7\"; good := TRUE;\r\n\t\t\twhen '8' =&gt; result :=  x\"8\"; good := TRUE;\r\n\t\t\twhen '9' =&gt; result :=  x\"9\"; good := TRUE;\r\n\t\t\twhen 'A' =&gt; result :=  x\"A\"; good := TRUE;\r\n\t\t\twhen 'B' =&gt; result :=  x\"B\"; good := TRUE;\r\n\t\t\twhen 'C' =&gt; result :=  x\"C\"; good := TRUE;\r\n\t\t\twhen 'D' =&gt; result :=  x\"D\"; good := TRUE;\r\n\t\t\twhen 'E' =&gt; result :=  x\"E\"; good := TRUE;\r\n\t\t\twhen 'F' =&gt; result :=  x\"F\"; good := TRUE;\r\n\t\t\twhen 'Z' =&gt; result(0) :=  'Z'; result(1) :=  'Z'; result(2) :=  'Z'; result(3) :=  'Z'; good := TRUE;\r\n\t\t\twhen 'X' =&gt; result(0) :=  'X'; result(1) :=  'X'; result(2) :=  'X'; result(3) :=  'X'; good := TRUE;\r\n \r\n\t\t\twhen 'a' =&gt; result :=  x\"A\"; good := TRUE;\r\n\t\t\twhen 'b' =&gt; result :=  x\"B\"; good := TRUE;\r\n\t\t\twhen 'c' =&gt; result :=  x\"C\"; good := TRUE;\r\n\t\t\twhen 'd' =&gt; result :=  x\"D\"; good := TRUE;\r\n\t\t\twhen 'e' =&gt; result :=  x\"E\"; good := TRUE;\r\n\t\t\twhen 'f' =&gt; result :=  x\"F\"; good := TRUE;\r\n\t\t\twhen others =&gt;\r\n\t\t\t   if ISSUE_ERROR then \r\n\t\t\t\t   assert FALSE report\r\n\t\t\t\t\t\"HREAD Error: Read a '\" &amp; c &amp;\r\n\t\t\t\t\t   \"', expected a Hex character (0-F).\";\r\n\t\t\t   end if;\r\n\t\t\t   good := FALSE;\r\n\t\tend case;\r\n\tend;\r\n\r\n\tprocedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR)  is\r\n\t\tvariable ok: boolean;\r\n\t\tvariable c:  character;\r\n\t\tconstant ne: integer := value'length\/4;\r\n\t\tvariable bv: std_ulogic_vector(0 to value'length-1);\r\n\t\tvariable s:  string(1 to ne-1);\r\n\tbegin\r\n\t\tif value'length mod 4 \/= 0 then\r\n\t\t\tassert FALSE report \r\n\t\t\t\t\"HREAD Error: Trying to read vector \" &amp;\r\n\t\t\t\t   \"with an odd (non multiple of 4) length\";\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tloop\t\t\t\t\t-- skip white space\r\n\t\t\tread(l,c);\r\n\t\t\texit when ((c \/= ' ') and (c \/= CR) and (c \/= HT));\r\n\t\tend loop;\r\n\r\n\t\tChar2QuadBits(c, bv(0 to 3), ok, TRUE);\r\n\t\tif not ok then \r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tread(L, s, ok);\r\n\t\tif not ok then\r\n\t\t\tassert FALSE \r\n\t\t\t\treport \"HREAD Error: Failed to read the STRING\";\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tfor i in 1 to ne-1 loop\r\n\t\t\tChar2QuadBits(s(i), bv(4*i to 4*i+3), ok, TRUE);\r\n\t\t\tif not ok then\r\n\t\t\t\treturn;\r\n\t\t\tend if;\r\n\t\tend loop;\r\n\t\tvalue := bv;\r\n\tend HREAD; \r\n\r\n\tprocedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR;GOOD: out BOOLEAN) is\r\n\t\tvariable ok: boolean;\r\n\t\tvariable c:  character;\r\n\t\tconstant ne: integer := value'length\/4;\r\n\t\tvariable bv: std_ulogic_vector(0 to value'length-1);\r\n\t\tvariable s:  string(1 to ne-1);\r\n\tbegin\r\n\t\tif value'length mod 4 \/= 0 then\r\n\t\t\tgood := FALSE;\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tloop\t\t\t\t\t-- skip white space\r\n\t\t\tread(l,c);\r\n\t\t\texit when ((c \/= ' ') and (c \/= CR) and (c \/= HT));\r\n\t\tend loop;\r\n\r\n\t\tChar2QuadBits(c, bv(0 to 3), ok, FALSE);\r\n\t\tif not ok then \r\n\t\t\tgood := FALSE;\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tread(L, s, ok);\r\n\t\tif not ok then\r\n\t\t\tgood := FALSE;\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tfor i in 1 to ne-1 loop\r\n\t\t\tChar2QuadBits(s(i), bv(4*i to 4*i+3), ok, FALSE);\r\n\t\t\tif not ok then\r\n\t\t\t\tgood := FALSE;\r\n\t\t\t\treturn;\r\n\t\t\tend if;\r\n\t\tend loop;\r\n\t\tgood := TRUE;\r\n\t\tvalue := bv;\r\n\tend HREAD; \r\n\r\n\tprocedure HWRITE(L:inout LINE; VALUE:in std_ulogic_vector;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is\r\n\t\tvariable quad: std_ulogic_vector(0 to 3);\r\n\t\tconstant ne:   integer := value'length\/4;\r\n\t\tvariable bv:   std_ulogic_vector(0 to value'length-1) := value;\r\n\t\tvariable s:    string(1 to ne);\r\n\tbegin\r\n\t\tif value'length mod 4 \/= 0 then\r\n\t\t\tassert FALSE report \r\n\t\t\t\t\"HWRITE Error: Trying to read vector \" &amp;\r\n\t\t\t\t   \"with an odd (non multiple of 4) length\";\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tfor i in 0 to ne-1 loop\r\n\t\t\tquad := To_X01Z(bv(4*i to 4*i+3));\r\n\t\t\tcase quad is\r\n\t\t\t\twhen x\"0\" =&gt; s(i+1) := '0';\r\n\t\t\t\twhen x\"1\" =&gt; s(i+1) := '1';\r\n\t\t\t\twhen x\"2\" =&gt; s(i+1) := '2';\r\n\t\t\t\twhen x\"3\" =&gt; s(i+1) := '3';\r\n\t\t\t\twhen x\"4\" =&gt; s(i+1) := '4';\r\n\t\t\t\twhen x\"5\" =&gt; s(i+1) := '5';\r\n\t\t\t\twhen x\"6\" =&gt; s(i+1) := '6';\r\n\t\t\t\twhen x\"7\" =&gt; s(i+1) := '7';\r\n\t\t\t\twhen x\"8\" =&gt; s(i+1) := '8';\r\n\t\t\t\twhen x\"9\" =&gt; s(i+1) := '9';\r\n\t\t\t\twhen x\"A\" =&gt; s(i+1) := 'A';\r\n\t\t\t\twhen x\"B\" =&gt; s(i+1) := 'B';\r\n\t\t\t\twhen x\"C\" =&gt; s(i+1) := 'C';\r\n\t\t\t\twhen x\"D\" =&gt; s(i+1) := 'D';\r\n\t\t\t\twhen x\"E\" =&gt; s(i+1) := 'E';\r\n\t\t\t\twhen x\"F\" =&gt; s(i+1) := 'F';\r\n\t\t\t\twhen others =&gt;  \r\n\t\t\t\t\tif (quad = \"ZZZZ\") then\r\n\t\t\t\t\t   s(i+1) := 'Z';\r\n\t\t\t\t\telse\r\n\t\t\t\t\t   s(i+1) := 'X';\r\n\t\t\t\t\tend if;\r\n\t\t\tend case;\r\n\t\tend loop;\r\n\t\twrite(L, s, JUSTIFIED, FIELD);\r\n\tend HWRITE; \r\n\r\n\tprocedure Char2TriBits(C: Character; \r\n\t\t\t\tRESULT: out bit_vector(2 downto 0);\r\n\t\t\t\tGOOD: out Boolean;\r\n\t\t\t\tISSUE_ERROR: in Boolean) is\r\n\tbegin\r\n\t\tcase c is\r\n\t\t\twhen '0' =&gt; result :=  o\"0\"; good := TRUE;\r\n\t\t\twhen '1' =&gt; result :=  o\"1\"; good := TRUE;\r\n\t\t\twhen '2' =&gt; result :=  o\"2\"; good := TRUE;\r\n\t\t\twhen '3' =&gt; result :=  o\"3\"; good := TRUE;\r\n\t\t\twhen '4' =&gt; result :=  o\"4\"; good := TRUE;\r\n\t\t\twhen '5' =&gt; result :=  o\"5\"; good := TRUE;\r\n\t\t\twhen '6' =&gt; result :=  o\"6\"; good := TRUE;\r\n\t\t\twhen '7' =&gt; result :=  o\"7\"; good := TRUE;\r\n\t\t\twhen others =&gt;\r\n\t\t\t   if ISSUE_ERROR then \r\n\t\t\t\t   assert FALSE report\r\n\t\t\t\t\t\"OREAD Error: Read a '\" &amp; c &amp;\r\n\t\t\t\t\t\"', expected an Octal character (0-7).\";\r\n\t\t\t   end if;\r\n\t\t\t   good := FALSE;\r\n\t\tend case;\r\n\tend;\r\n\r\n\tprocedure OREAD(L:inout LINE; VALUE:out BIT_VECTOR)  is\r\n\t\tvariable c: character;\r\n\t\tvariable ok: boolean;\r\n\t\tconstant ne: integer := value'length\/3;\r\n\t\tvariable bv: bit_vector(0 to value'length-1);\r\n\t\tvariable s: string(1 to ne-1);\r\n\tbegin\r\n\t\tif value'length mod 3 \/= 0 then\r\n\t\t\tassert FALSE report \r\n\t\t\t\t\"OREAD Error: Trying to read vector \" &amp;\r\n\t\t\t\t   \"with an odd (non multiple of 3) length\";\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tloop\t\t\t\t\t-- skip white space\r\n\t\t\tread(l,c);\r\n\t\t\texit when ((c \/= ' ') and (c \/= CR) and (c \/= HT));\r\n\t\tend loop;\r\n\r\n\t\tChar2TriBits(c, bv(0 to 2), ok, TRUE);\r\n\t\tif not ok then \r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tread(L, s, ok);\r\n\t\tif not ok then\r\n\t\t\tassert FALSE \r\n\t\t\t\treport \"OREAD Error: Failed to read the STRING\";\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tfor i in 1 to ne-1 loop\r\n\t\t\tChar2TriBits(s(i), bv(3*i to 3*i+2), ok, TRUE);\r\n\t\t\tif not ok then\r\n\t\t\t\treturn;\r\n\t\t\tend if;\r\n\t\tend loop;\r\n\t\tvalue := bv;\r\n\tend OREAD; \r\n\r\n\tprocedure OREAD(L:inout LINE; VALUE:out BIT_VECTOR;GOOD: out BOOLEAN) is\r\n\t\tvariable ok: boolean;\r\n\t\tvariable c:  character;\r\n\t\tconstant ne: integer := value'length\/3;\r\n\t\tvariable bv: bit_vector(0 to value'length-1);\r\n\t\tvariable s:  string(1 to ne-1);\r\n\tbegin\r\n\t\tif value'length mod 3 \/= 0 then\r\n\t\t\tgood := FALSE;\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tloop\t\t\t\t\t-- skip white space\r\n\t\t\tread(l,c);\r\n\t\t\texit when ((c \/= ' ') and (c \/= CR) and (c \/= HT));\r\n\t\tend loop;\r\n\r\n\t\tChar2TriBits(c, bv(0 to 2), ok, FALSE);\r\n\t\tif not ok then \r\n\t\t\tgood := FALSE;\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tread(L, s, ok);\r\n\t\tif not ok then\r\n\t\t\tgood := FALSE;\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tfor i in 1 to ne-1 loop\r\n\t\t\tChar2TriBits(s(i), bv(3*i to 3*i+2), ok, FALSE);\r\n\t\t\tif not ok then\r\n\t\t\t\tgood := FALSE;\r\n\t\t\t\treturn;\r\n\t\t\tend if;\r\n\t\tend loop;\r\n\t\tgood := TRUE;\r\n\t\tvalue := bv;\r\n\tend OREAD; \r\n\r\n\r\n\tprocedure OWRITE(L:inout LINE; VALUE:in std_ulogic_vector;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is\r\n\t\tvariable tri: std_ulogic_vector(0 to 2);\r\n\t\tconstant ne:  integer := value'length\/3;\r\n\t\tvariable bv:  std_ulogic_vector(0 to value'length-1) := value;\r\n\t\tvariable s:   string(1 to ne);\r\n\tbegin\r\n\t\tif value'length mod 3 \/= 0 then\r\n\t\t\tassert FALSE report \r\n\t\t\t\t\"OWRITE Error: Trying to read vector \" &amp;\r\n\t\t\t\t   \"with an odd (non multiple of 3) length\";\r\n\t\t\treturn;\r\n\t\tend if;\r\n\r\n\t\tfor i in 0 to ne-1 loop\r\n\t\t\ttri := To_X01Z(bv(3*i to 3*i+2));\r\n\t\t\tcase tri is\r\n\t\t\t\twhen o\"0\" =&gt; s(i+1) := '0';\r\n\t\t\t\twhen o\"1\" =&gt; s(i+1) := '1';\r\n\t\t\t\twhen o\"2\" =&gt; s(i+1) := '2';\r\n\t\t\t\twhen o\"3\" =&gt; s(i+1) := '3';\r\n\t\t\t\twhen o\"4\" =&gt; s(i+1) := '4';\r\n\t\t\t\twhen o\"5\" =&gt; s(i+1) := '5';\r\n\t\t\t\twhen o\"6\" =&gt; s(i+1) := '6';\r\n\t\t\t\twhen o\"7\" =&gt; s(i+1) := '7';\r\n\t\t\t\twhen others =&gt;  \r\n\t\t\t\t\tif (tri = \"ZZZ\") then\r\n\t\t\t\t\t   s(i+1) := 'Z';\r\n\t\t\t\t\telse\r\n\t\t\t\t\t   s(i+1) := 'X';\r\n\t\t\t\t\tend if;\r\n\t\t\tend case;\r\n\t\tend loop;\r\n\t\twrite(L, s, JUSTIFIED, FIELD);\r\n\tend OWRITE; \r\n\r\n\t-- Hex Read and Write procedures for STD_LOGIC_VECTOR\r\n\tprocedure HREAD(L:inout LINE; VALUE:out BIT_VECTOR;GOOD:out BOOLEAN) is\r\n\t\tvariable tmp: std_ulogic_vector(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tHREAD(L, tmp, GOOD);\r\n\t\tVALUE := To_BitVector(tmp);\r\n\tend HREAD;\r\n\t\r\n\tprocedure HREAD(L:inout LINE; VALUE:out BIT_VECTOR) is\r\n\t\tvariable tmp: std_ulogic_vector(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tHREAD(L, tmp);\r\n\t\tVALUE := To_BitVector(tmp);\r\n\tend HREAD;\r\n\r\n\t-- Hex Read and Write procedures for STD_LOGIC_VECTOR\r\n\r\n\tprocedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is\r\n\t\tvariable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tHREAD(L, tmp);\r\n\t\tVALUE := STD_LOGIC_VECTOR(tmp);\r\n\tend HREAD;\r\n\r\n\tprocedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN) is\r\n\t\tvariable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tHREAD(L, tmp, GOOD);\r\n\t\tVALUE := STD_LOGIC_VECTOR(tmp);\r\n\tend HREAD;\r\n\r\n\tprocedure HWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is\r\n\tbegin\r\n\t\tHWRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD);\r\n\tend HWRITE;\r\n\r\n\r\n\t-- Octal Read and Write procedures for STD_ULOGIC_VECTOR\r\n\tprocedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR;GOOD:out BOOLEAN) is\r\n\t\tvariable tmp: bit_vector(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tOREAD(L, tmp, GOOD);\r\n\t\tVALUE := To_X01(tmp);\r\n\tend OREAD;\r\n\t\r\n\tprocedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR) is\r\n\t\tvariable tmp: bit_vector(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tOREAD(L, tmp);\r\n\t\tVALUE := To_X01(tmp);\r\n\tend OREAD;\r\n\r\n\t-- Octal Read and Write procedures for STD_LOGIC_VECTOR\r\n\r\n\tprocedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is\r\n\t\tvariable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tOREAD(L, tmp);\r\n\t\tVALUE := STD_LOGIC_VECTOR(tmp);\r\n\tend OREAD;\r\n\r\n\tprocedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN) is\r\n\t\tvariable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);\r\n\tbegin\r\n\t\tOREAD(L, tmp, GOOD);\r\n\t\tVALUE := STD_LOGIC_VECTOR(tmp);\r\n\tend OREAD;\r\n\r\n\tprocedure OWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;\r\n\t\t\tJUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is\r\n\tbegin\r\n\t\tOWRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD);\r\n\tend OWRITE;\r\n\r\n\r\n--synopsys synthesis_on\r\nend STD_LOGIC_TEXTIO;<\/pre>\n<p>Sie muss mit vcim 2002 kompiliert werden.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Die Vollversion: use STD.textio.all; library IEEE; use IEEE.std_logic_1164.all; package STD_LOGIC_TEXTIO is &#8211;synopsys synthesis_off &#8212; Read and Write procedures for STD_ULOGIC and STD_ULOGIC_VECTOR procedure READ(L:inout LINE; VALUE:out STD_ULOGIC); procedure READ(L:inout LINE; VALUE:out STD_ULOGIC; GOOD: out BOOLEAN); procedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR); procedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD: out BOOLEAN); procedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC; JUSTIFIED:in SIDE &hellip; <a href=\"https:\/\/coolt.ch\/notizen\/std_logic_textio-vhd\/\" class=\"more-link\"><span class=\"screen-reader-text\">std_logic_textio.vhd<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[60,59],"tags":[],"_links":{"self":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/928"}],"collection":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/comments?post=928"}],"version-history":[{"count":2,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/928\/revisions"}],"predecessor-version":[{"id":930,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/posts\/928\/revisions\/930"}],"wp:attachment":[{"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/media?parent=928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/categories?post=928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coolt.ch\/notizen\/wp-json\/wp\/v2\/tags?post=928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}