📄 std_logic_textio.vhdl
字号:
return; end if; for i in 1 to ne-1 loop Char2QuadBits(s(i), bv(4*i to 4*i+3), ok, TRUE); if not ok then return; end if; end loop; value := bv; end HREAD; procedure HREAD(L:inout LINE; VALUE:out BIT_VECTOR;GOOD: out BOOLEAN) is variable ok: boolean; variable c: character; constant ne: integer := value'length/4; variable bv: bit_vector(0 to value'length-1); variable s: string(1 to ne-1); begin if value'length mod 4 /= 0 then good := FALSE; return; end if; loop -- skip white space read(l,c); exit when ((c /= ' ') and (c /= CR) and (c /= HT)); end loop; Char2QuadBits(c, bv(0 to 3), ok, FALSE); if not ok then good := FALSE; return; end if; read(L, s, ok); if not ok then good := FALSE; return; end if; for i in 1 to ne-1 loop Char2QuadBits(s(i), bv(4*i to 4*i+3), ok, FALSE); if not ok then good := FALSE; return; end if; end loop; good := TRUE; value := bv; end HREAD; procedure HWRITE(L:inout LINE; VALUE:in BIT_VECTOR; JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is variable quad: bit_vector(0 to 3); constant ne: integer := value'length/4; variable bv: bit_vector(0 to value'length-1) := value; variable s: string(1 to ne); begin if value'length mod 4 /= 0 then assert FALSE report "HWRITE Error: Trying to read vector " & "with an odd (non multiple of 4) length"; return; end if; for i in 0 to ne-1 loop quad := bv(4*i to 4*i+3); case quad is when x"0" => s(i+1) := '0'; when x"1" => s(i+1) := '1'; when x"2" => s(i+1) := '2'; when x"3" => s(i+1) := '3'; when x"4" => s(i+1) := '4'; when x"5" => s(i+1) := '5'; when x"6" => s(i+1) := '6'; when x"7" => s(i+1) := '7'; when x"8" => s(i+1) := '8'; when x"9" => s(i+1) := '9'; when x"A" => s(i+1) := 'A'; when x"B" => s(i+1) := 'B'; when x"C" => s(i+1) := 'C'; when x"D" => s(i+1) := 'D'; when x"E" => s(i+1) := 'E'; when x"F" => s(i+1) := 'F'; end case; end loop; write(L, s, JUSTIFIED, FIELD); end HWRITE; procedure Char2TriBits(C: Character; RESULT: out bit_vector(2 downto 0); GOOD: out Boolean; ISSUE_ERROR: in Boolean) is begin case c is when '0' => result := o"0"; good := TRUE; when '1' => result := o"1"; good := TRUE; when '2' => result := o"2"; good := TRUE; when '3' => result := o"3"; good := TRUE; when '4' => result := o"4"; good := TRUE; when '5' => result := o"5"; good := TRUE; when '6' => result := o"6"; good := TRUE; when '7' => result := o"7"; good := TRUE; when others => if ISSUE_ERROR then assert FALSE report "OREAD Error: Read a '" & c & "', expected an Octal character (0-7)."; end if; good := FALSE; end case; end; procedure OREAD(L:inout LINE; VALUE:out BIT_VECTOR) is variable c: character; variable ok: boolean; constant ne: integer := value'length/3; variable bv: bit_vector(0 to value'length-1); variable s: string(1 to ne-1); begin if value'length mod 3 /= 0 then assert FALSE report "OREAD Error: Trying to read vector " & "with an odd (non multiple of 3) length"; return; end if; loop -- skip white space read(l,c); exit when ((c /= ' ') and (c /= CR) and (c /= HT)); end loop; Char2TriBits(c, bv(0 to 2), ok, TRUE); if not ok then return; end if; read(L, s, ok); if not ok then assert FALSE report "OREAD Error: Failed to read the STRING"; return; end if; for i in 1 to ne-1 loop Char2TriBits(s(i), bv(3*i to 3*i+2), ok, TRUE); if not ok then return; end if; end loop; value := bv; end OREAD; procedure OREAD(L:inout LINE; VALUE:out BIT_VECTOR;GOOD: out BOOLEAN) is variable ok: boolean; variable c: character; constant ne: integer := value'length/3; variable bv: bit_vector(0 to value'length-1); variable s: string(1 to ne-1); begin if value'length mod 3 /= 0 then good := FALSE; return; end if; loop -- skip white space read(l,c); exit when ((c /= ' ') and (c /= CR) and (c /= HT)); end loop; Char2TriBits(c, bv(0 to 2), ok, FALSE); if not ok then good := FALSE; return; end if; read(L, s, ok); if not ok then good := FALSE; return; end if; for i in 1 to ne-1 loop Char2TriBits(s(i), bv(3*i to 3*i+2), ok, FALSE); if not ok then good := FALSE; return; end if; end loop; good := TRUE; value := bv; end OREAD; procedure OWRITE(L:inout LINE; VALUE:in BIT_VECTOR; JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is variable tri: bit_vector(0 to 2); constant ne: integer := value'length/3; variable bv: bit_vector(0 to value'length-1) := value; variable s: string(1 to ne); begin if value'length mod 3 /= 0 then assert FALSE report "OWRITE Error: Trying to read vector " & "with an odd (non multiple of 3) length"; return; end if; for i in 0 to ne-1 loop tri := bv(3*i to 3*i+2); case tri is when o"0" => s(i+1) := '0'; when o"1" => s(i+1) := '1'; when o"2" => s(i+1) := '2'; when o"3" => s(i+1) := '3'; when o"4" => s(i+1) := '4'; when o"5" => s(i+1) := '5'; when o"6" => s(i+1) := '6'; when o"7" => s(i+1) := '7'; end case; end loop; write(L, s, JUSTIFIED, FIELD); end OWRITE; -- Hex Read and Write procedures for STD_LOGIC_VECTOR procedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR;GOOD:out BOOLEAN) is variable tmp: bit_vector(VALUE'length-1 downto 0); begin HREAD(L, tmp, GOOD); VALUE := To_X01(tmp); end HREAD; procedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR) is variable tmp: bit_vector(VALUE'length-1 downto 0); begin HREAD(L, tmp); VALUE := To_X01(tmp); end HREAD; procedure HWRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR; JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is begin HWRITE(L, To_bitvector(VALUE),JUSTIFIED, FIELD); end HWRITE; -- Hex Read and Write procedures for STD_LOGIC_VECTOR procedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0); begin HREAD(L, tmp); VALUE := STD_LOGIC_VECTOR(tmp); end HREAD; procedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN) is variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0); begin HREAD(L, tmp, GOOD); VALUE := STD_LOGIC_VECTOR(tmp); end HREAD; procedure HWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR; JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is begin HWRITE(L, To_bitvector(VALUE), JUSTIFIED, FIELD); end HWRITE; -- Octal Read and Write procedures for STD_ULOGIC_VECTOR procedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR;GOOD:out BOOLEAN) is variable tmp: bit_vector(VALUE'length-1 downto 0); begin OREAD(L, tmp, GOOD); VALUE := To_X01(tmp); end OREAD; procedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR) is variable tmp: bit_vector(VALUE'length-1 downto 0); begin OREAD(L, tmp); VALUE := To_X01(tmp); end OREAD; procedure OWRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR; JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is begin OWRITE(L, To_bitvector(VALUE),JUSTIFIED, FIELD); end OWRITE; -- Octal Read and Write procedures for STD_LOGIC_VECTOR procedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0); begin OREAD(L, tmp); VALUE := STD_LOGIC_VECTOR(tmp); end OREAD; procedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN) is variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0); begin OREAD(L, tmp, GOOD); VALUE := STD_LOGIC_VECTOR(tmp); end OREAD; procedure OWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR; JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is begin OWRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD); end OWRITE;--synopsys synthesis_onend STD_LOGIC_TEXTIO;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -