6
6
7
7
library ieee;
8
8
use ieee.std_logic_1164.all ;
9
- use ieee.numeric_std .all ;
9
+ use ieee.numeric_std_unsigned .all ;
10
10
11
11
library vunit_lib;
12
12
context vunit_lib.vunit_context;
13
13
context vunit_lib.com_context;
14
14
context vunit_lib.vc_context;
15
15
16
- package i2c_peripheral_pkg is
16
+ package i2c_target_vc_pkg is
17
17
18
18
-- Message definitions
19
19
constant got_start : msg_type_t := new_msg_type(" got_start" );
@@ -24,7 +24,7 @@ package i2c_peripheral_pkg is
24
24
constant got_byte : msg_type_t := new_msg_type(" got_byte" );
25
25
constant got_stop : msg_type_t := new_msg_type(" got_stop" );
26
26
27
- type i2c_peripheral_t is record
27
+ type i2c_target_vc_t is record
28
28
-- private
29
29
p_actor : actor_t;
30
30
p_buffer : buffer_t;
@@ -33,51 +33,51 @@ package i2c_peripheral_pkg is
33
33
P_address : std_logic_vector (6 downto 0 );
34
34
end record ;
35
35
36
- constant i2c_peripheral_vc_logger : logger_t := get_logger(" work:i2c_peripheral_vc" );
36
+ constant i2c_target_vc_logger : logger_t := get_logger(" work:i2c_peripheral_vc" );
37
37
38
- impure function new_i2c_peripheral_vc (
39
- name : string ;
38
+ impure function new_i2c_target_vc (
39
+ name : string := " I2C_TARGET_VC " ;
40
40
address : std_logic_vector (6 downto 0 ) := b"1010101" ;
41
- logger : logger_t := i2c_peripheral_vc_logger
42
- ) return i2c_peripheral_t ;
41
+ logger : logger_t := i2c_target_vc_logger
42
+ ) return i2c_target_vc_t ;
43
43
44
- impure function address (i2c_periph: i2c_peripheral_t ) return std_logic_vector ;
45
- impure function buf (i2c_periph: i2c_peripheral_t ) return buffer_t;
46
- impure function memory (i2c_periph: i2c_peripheral_t ) return memory_t;
44
+ impure function address (i2c_periph: i2c_target_vc_t ) return std_logic_vector ;
45
+ impure function buf (i2c_periph: i2c_target_vc_t ) return buffer_t;
46
+ impure function memory (i2c_periph: i2c_target_vc_t ) return memory_t;
47
47
48
48
procedure expect_message (
49
49
signal net : inout network_t;
50
- constant vc : i2c_peripheral_t ;
50
+ constant vc : i2c_target_vc_t ;
51
51
constant expected_msg : msg_type_t;
52
52
) ;
53
53
54
54
procedure expect_stop (
55
55
signal net : inout network_t;
56
- constant vc : i2c_peripheral_t ;
56
+ constant vc : i2c_target_vc_t ;
57
57
) ;
58
58
59
59
procedure start_byte_ack (
60
60
signal net : inout network_t;
61
- constant vc : i2c_peripheral_t ;
61
+ constant vc : i2c_target_vc_t ;
62
62
variable ack : out boolean ;
63
63
) ;
64
64
65
65
procedure check_written_byte (
66
66
signal net : inout network_t;
67
- constant vc : i2c_peripheral_t ;
67
+ constant vc : i2c_target_vc_t ;
68
68
variable data : std_logic_vector ;
69
- variable addr : unsigned ;
69
+ variable addr : std_logic_vector ;
70
70
) ;
71
71
72
72
end package ;
73
73
74
- package body i2c_peripheral_pkg is
74
+ package body i2c_target_vc_pkg is
75
75
76
- impure function new_i2c_peripheral_vc (
77
- name : string ;
76
+ impure function new_i2c_target_vc (
77
+ name : string := " I2C_TARGET_VC " ;
78
78
address : std_logic_vector (6 downto 0 ) := b"1010101" ;
79
- logger : logger_t := i2c_peripheral_vc_logger
80
- ) return i2c_peripheral_t is
79
+ logger : logger_t := i2c_target_vc_logger
80
+ ) return i2c_target_vc_t is
81
81
variable buf : buffer_t;
82
82
begin
83
83
-- I2C can address 256 bytes, so construct an internal buffer to reflect that
@@ -91,24 +91,24 @@ package body i2c_peripheral_pkg is
91
91
);
92
92
end ;
93
93
94
- impure function address (i2c_periph: i2c_peripheral_t ) return std_logic_vector is
94
+ impure function address (i2c_periph: i2c_target_vc_t ) return std_logic_vector is
95
95
begin
96
96
return i2c_periph.p_address;
97
97
end function ;
98
98
99
- impure function buf (i2c_periph: i2c_peripheral_t ) return buffer_t is
99
+ impure function buf (i2c_periph: i2c_target_vc_t ) return buffer_t is
100
100
begin
101
101
return i2c_periph.p_buffer;
102
102
end function ;
103
103
104
- impure function memory (i2c_periph: i2c_peripheral_t ) return memory_t is
104
+ impure function memory (i2c_periph: i2c_target_vc_t ) return memory_t is
105
105
begin
106
106
return i2c_periph.p_buffer.p_memory_ref;
107
107
end function ;
108
108
109
109
procedure expect_message (
110
110
signal net : inout network_t;
111
- constant vc : i2c_peripheral_t ;
111
+ constant vc : i2c_target_vc_t ;
112
112
constant expected_msg : msg_type_t;
113
113
) is
114
114
variable msg : msg_t;
@@ -121,15 +121,15 @@ package body i2c_peripheral_pkg is
121
121
122
122
procedure expect_stop (
123
123
signal net : inout network_t;
124
- constant vc : i2c_peripheral_t ;
124
+ constant vc : i2c_target_vc_t ;
125
125
) is
126
126
begin
127
127
expect_message(net, vc, got_stop);
128
128
end procedure ;
129
129
130
130
procedure start_byte_ack (
131
131
signal net : inout network_t;
132
- constant vc : i2c_peripheral_t ;
132
+ constant vc : i2c_target_vc_t ;
133
133
variable ack : out boolean ;
134
134
) is
135
135
variable msg : msg_t;
@@ -149,9 +149,9 @@ package body i2c_peripheral_pkg is
149
149
150
150
procedure check_written_byte (
151
151
signal net : inout network_t;
152
- constant vc : i2c_peripheral_t ;
152
+ constant vc : i2c_target_vc_t ;
153
153
variable data : std_logic_vector ;
154
- variable addr : unsigned ;
154
+ variable addr : std_logic_vector ;
155
155
) is
156
156
variable msg : msg_t;
157
157
begin
0 commit comments