Skip to content

Commit 877ed5b

Browse files
author
Lars Asplund
committed
Updated to OSVVM 2015_01.
1 parent 2cfb732 commit 877ed5b

21 files changed

Lines changed: 9667 additions & 7031 deletions

vhdl/osvvm/AlertLogPkg.vhd

Lines changed: 1495 additions & 0 deletions
Large diffs are not rendered by default.

vhdl/osvvm/CoveragePkg.vhd

Lines changed: 4790 additions & 4694 deletions
Large diffs are not rendered by default.
-152 KB
Binary file not shown.

vhdl/osvvm/MessagePkg.vhd

Lines changed: 164 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,164 @@
1-
--
2-
-- File Name: MessagePkg.vhd
3-
-- Design Unit Name: MessagePkg
4-
-- Revision: STANDARD VERSION, revision 2014.01
5-
--
6-
-- Maintainer: Jim Lewis email: jim@synthworks.com
7-
-- Contributor(s):
8-
-- Jim Lewis SynthWorks
9-
--
10-
--
11-
-- Package Defines
12-
-- Data structure for multi-line name/message to be associated with a data structure.
13-
--
14-
-- Developed for:
15-
-- SynthWorks Design Inc.
16-
-- VHDL Training Classes
17-
-- 11898 SW 128th Ave. Tigard, Or 97223
18-
-- http://www.SynthWorks.com
19-
--
20-
-- Latest standard version available at:
21-
-- http://www.SynthWorks.com/downloads
22-
--
23-
-- Revision History:
24-
-- Date Version Description
25-
-- 06/2010: 0.1 Initial revision
26-
-- 07/2014: 2014.07 Moved specialization required by CoveragePkg to CoveragePkg
27-
-- 07/2014: 2014.07a Removed initialized pointers which can lead to memory leaks.
28-
--
29-
--
30-
-- Copyright (c) 2010 - 2014 by SynthWorks Design Inc. All rights reserved.
31-
--
32-
-- Verbatim copies of this source file may be used and
33-
-- distributed without restriction.
34-
--
35-
-- This source file is free software; you can redistribute it
36-
-- and/or modify it under the terms of the ARTISTIC License
37-
-- as published by The Perl Foundation; either version 2.0 of
38-
-- the License, or (at your option) any later version.
39-
--
40-
-- This source is distributed in the hope that it will be
41-
-- useful, but WITHOUT ANY WARRANTY; without even the implied
42-
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
43-
-- PURPOSE. See the Artistic License for details.
44-
--
45-
-- You should have received a copy of the license with this source.
46-
-- If not download it from,
47-
-- http://www.perlfoundation.org/artistic_license_2_0
48-
--
49-
50-
library ieee ;
51-
use ieee.std_logic_1164.all ;
52-
use ieee.numeric_std.all ;
53-
use ieee.math_real.all ;
54-
use std.textio.all ;
55-
56-
package MessagePkg is
57-
58-
type MessagePType is protected
59-
60-
procedure Set (MessageIn : String) ;
61-
impure function Get (ItemNumber : integer := 1) return string ;
62-
impure function GetCount return integer ;
63-
impure function IsSet return boolean ;
64-
procedure Clear ; -- clear message
65-
procedure Deallocate ; -- clear message
66-
67-
end protected MessagePType ;
68-
69-
end package MessagePkg ;
70-
package body MessagePkg is
71-
72-
-- Local Data Structure Types
73-
type LineArrayType is array (natural range <>) of line ;
74-
type LineArrayPtrType is access LineArrayType ;
75-
76-
type MessagePType is protected body
77-
78-
variable MessageCount : integer := 0 ;
79-
constant INITIAL_ITEM_COUNT : integer := 16 ;
80-
variable MaxMessageCount : integer := 0 ;
81-
variable MessagePtr : LineArrayPtrType ;
82-
83-
------------------------------------------------------------
84-
procedure Set (MessageIn : String) is
85-
------------------------------------------------------------
86-
variable NamePtr : line ;
87-
variable OldMaxMessageCount : integer ;
88-
variable OldMessagePtr : LineArrayPtrType ;
89-
begin
90-
MessageCount := MessageCount + 1 ;
91-
if MessageCount > MaxMessageCount then
92-
OldMaxMessageCount := MaxMessageCount ;
93-
MaxMessageCount := MaxMessageCount + INITIAL_ITEM_COUNT ;
94-
OldMessagePtr := MessagePtr ;
95-
MessagePtr := new LineArrayType(1 to MaxMessageCount) ;
96-
for i in 1 to OldMaxMessageCount loop
97-
MessagePtr(i) := OldMessagePtr(i) ;
98-
end loop ;
99-
Deallocate( OldMessagePtr ) ;
100-
end if ;
101-
MessagePtr(MessageCount) := new string'(MessageIn) ;
102-
end procedure Set ;
103-
104-
------------------------------------------------------------
105-
impure function Get (ItemNumber : integer := 1) return string is
106-
------------------------------------------------------------
107-
begin
108-
if MessageCount > 0 then
109-
if ItemNumber >= 1 and ItemNumber <= MessageCount then
110-
return MessagePtr(ItemNumber).all ;
111-
else
112-
report LF & "%% MessagePkg:MessagePType.GetMessage input value out of range" severity failure ;
113-
return "" ; -- error if this happens
114-
end if ;
115-
else
116-
report LF & "%% MessagePkg:MessagePType.GetMessage message is not set" severity failure ;
117-
return "" ; -- error if this happens
118-
end if ;
119-
end function Get ;
120-
121-
------------------------------------------------------------
122-
impure function GetCount return integer is
123-
------------------------------------------------------------
124-
begin
125-
return MessageCount ;
126-
end function GetCount ;
127-
128-
------------------------------------------------------------
129-
impure function IsSet return boolean is
130-
------------------------------------------------------------
131-
begin
132-
return MessageCount > 0 ;
133-
end function IsSet ;
134-
135-
------------------------------------------------------------
136-
procedure Deallocate is -- clear message
137-
------------------------------------------------------------
138-
variable CurPtr : LineArrayPtrType ;
139-
begin
140-
for i in 1 to MessageCount loop
141-
deallocate( MessagePtr(i) ) ;
142-
end loop ;
143-
MessageCount := 0 ;
144-
MaxMessageCount := 0 ;
145-
deallocate( MessagePtr ) ;
146-
end procedure Deallocate ;
147-
148-
------------------------------------------------------------
149-
procedure Clear is -- clear
150-
------------------------------------------------------------
151-
begin
152-
Deallocate ;
153-
end procedure Clear ;
154-
155-
end protected body MessagePType ;
156-
157-
end package body MessagePkg ;
158-
159-
1+
--
2+
-- File Name: MessagePkg.vhd
3+
-- Design Unit Name: MessagePkg
4+
-- Revision: STANDARD VERSION, revision 2015.01
5+
--
6+
-- Maintainer: Jim Lewis email: jim@synthworks.com
7+
-- Contributor(s):
8+
-- Jim Lewis SynthWorks
9+
--
10+
--
11+
-- Package Defines
12+
-- Data structure for multi-line name/message to be associated with a data structure.
13+
--
14+
-- Developed for:
15+
-- SynthWorks Design Inc.
16+
-- VHDL Training Classes
17+
-- 11898 SW 128th Ave. Tigard, Or 97223
18+
-- http://www.SynthWorks.com
19+
--
20+
-- Latest standard version available at:
21+
-- http://www.SynthWorks.com/downloads
22+
--
23+
-- Revision History:
24+
-- Date Version Description
25+
-- 06/2010: 0.1 Initial revision
26+
-- 07/2014: 2014.07 Moved specialization required by CoveragePkg to CoveragePkg
27+
-- 07/2014: 2014.07a Removed initialized pointers which can lead to memory leaks.
28+
-- 01/2015: 2015.01 Removed initialized parameter from Get
29+
--
30+
--
31+
-- Copyright (c) 2010 - 2015 by SynthWorks Design Inc. All rights reserved.
32+
--
33+
-- Verbatim copies of this source file may be used and
34+
-- distributed without restriction.
35+
--
36+
-- This source file is free software; you can redistribute it
37+
-- and/or modify it under the terms of the ARTISTIC License
38+
-- as published by The Perl Foundation; either version 2.0 of
39+
-- the License, or (at your option) any later version.
40+
--
41+
-- This source is distributed in the hope that it will be
42+
-- useful, but WITHOUT ANY WARRANTY; without even the implied
43+
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
44+
-- PURPOSE. See the Artistic License for details.
45+
--
46+
-- You should have received a copy of the license with this source.
47+
-- If not download it from,
48+
-- http://www.perlfoundation.org/artistic_license_2_0
49+
--
50+
use work.OsvvmGlobalPkg.all ;
51+
use work.AlertLogPkg.all ;
52+
53+
library ieee ;
54+
use ieee.std_logic_1164.all ;
55+
use ieee.numeric_std.all ;
56+
use ieee.math_real.all ;
57+
use std.textio.all ;
58+
59+
package MessagePkg is
60+
61+
type MessagePType is protected
62+
63+
procedure Set (MessageIn : String) ;
64+
impure function Get (ItemNumber : integer) return string ;
65+
impure function GetCount return integer ;
66+
impure function IsSet return boolean ;
67+
procedure Clear ; -- clear message
68+
procedure Deallocate ; -- clear message
69+
70+
end protected MessagePType ;
71+
72+
end package MessagePkg ;
73+
74+
--- ///////////////////////////////////////////////////////////////////////////
75+
--- ///////////////////////////////////////////////////////////////////////////
76+
--- ///////////////////////////////////////////////////////////////////////////
77+
78+
package body MessagePkg is
79+
80+
-- Local Data Structure Types
81+
type LineArrayType is array (natural range <>) of line ;
82+
type LineArrayPtrType is access LineArrayType ;
83+
84+
type MessagePType is protected body
85+
86+
variable MessageCount : integer := 0 ;
87+
constant INITIAL_ITEM_COUNT : integer := 16 ;
88+
variable MaxMessageCount : integer := 0 ;
89+
variable MessagePtr : LineArrayPtrType ;
90+
91+
------------------------------------------------------------
92+
procedure Set (MessageIn : String) is
93+
------------------------------------------------------------
94+
variable NamePtr : line ;
95+
variable OldMaxMessageCount : integer ;
96+
variable OldMessagePtr : LineArrayPtrType ;
97+
begin
98+
MessageCount := MessageCount + 1 ;
99+
if MessageCount > MaxMessageCount then
100+
OldMaxMessageCount := MaxMessageCount ;
101+
MaxMessageCount := MaxMessageCount + INITIAL_ITEM_COUNT ;
102+
OldMessagePtr := MessagePtr ;
103+
MessagePtr := new LineArrayType(1 to MaxMessageCount) ;
104+
for i in 1 to OldMaxMessageCount loop
105+
MessagePtr(i) := OldMessagePtr(i) ;
106+
end loop ;
107+
Deallocate( OldMessagePtr ) ;
108+
end if ;
109+
MessagePtr(MessageCount) := new string'(MessageIn) ;
110+
end procedure Set ;
111+
112+
------------------------------------------------------------
113+
impure function Get (ItemNumber : integer) return string is
114+
------------------------------------------------------------
115+
begin
116+
if MessageCount > 0 then
117+
if ItemNumber >= 1 and ItemNumber <= MessageCount then
118+
return MessagePtr(ItemNumber).all ;
119+
else
120+
Alert(OSVVM_ALERTLOG_ID, "%% MessagePkg.Get input value out of range", FAILURE) ;
121+
return "" ; -- error if this happens
122+
end if ;
123+
else
124+
Alert(OSVVM_ALERTLOG_ID, "%% MessagePkg.Get message is not set", FAILURE) ;
125+
return "" ; -- error if this happens
126+
end if ;
127+
end function Get ;
128+
129+
------------------------------------------------------------
130+
impure function GetCount return integer is
131+
------------------------------------------------------------
132+
begin
133+
return MessageCount ;
134+
end function GetCount ;
135+
136+
------------------------------------------------------------
137+
impure function IsSet return boolean is
138+
------------------------------------------------------------
139+
begin
140+
return MessageCount > 0 ;
141+
end function IsSet ;
142+
143+
------------------------------------------------------------
144+
procedure Deallocate is -- clear message
145+
------------------------------------------------------------
146+
variable CurPtr : LineArrayPtrType ;
147+
begin
148+
for i in 1 to MessageCount loop
149+
deallocate( MessagePtr(i) ) ;
150+
end loop ;
151+
MessageCount := 0 ;
152+
MaxMessageCount := 0 ;
153+
deallocate( MessagePtr ) ;
154+
end procedure Deallocate ;
155+
156+
------------------------------------------------------------
157+
procedure Clear is -- clear
158+
------------------------------------------------------------
159+
begin
160+
Deallocate ;
161+
end procedure Clear ;
162+
163+
end protected body MessagePType ;
164+
end package body MessagePkg ;

0 commit comments

Comments
 (0)