@@ -80,27 +80,33 @@ async def register_test_interfaces(self, fclk=500.0):
80
80
await cocotb .start (setup_dut (self .clk , self .rst_n , (tclk , "ps" )))
81
81
82
82
async def read_csr (
83
- self , addr : int , size : int = 4 , timeout : int = 1 , units : str = "us"
83
+ self , addr : int , size : int = 4 , arid = None , timeout : int = 1 , units : str = "us"
84
84
) -> List [int ]:
85
85
"""Send a read request & await the response."""
86
86
raise NotImplementedError
87
87
88
88
async def write_csr (
89
- self , addr : int , data : List [int ], size : int = 4 , timeout : int = 1 , units : str = "us"
89
+ self ,
90
+ addr : int ,
91
+ data : List [int ],
92
+ size : int = 4 ,
93
+ awid = None ,
94
+ timeout : int = 1 ,
95
+ units : str = "us" ,
90
96
) -> None :
91
97
"""Send a write request & await transfer to finish."""
92
98
raise NotImplementedError
93
99
94
- async def write_csr_field (self , reg_addr , field , data ) -> None :
100
+ async def write_csr_field (self , reg_addr , field , data , awid = None ) -> None :
95
101
"""Read -> modify -> write CSR"""
96
- value = bytes2int (await self .read_csr (reg_addr ))
102
+ value = bytes2int (await self .read_csr (reg_addr , arid = awid ))
97
103
value = value & ~ field .mask
98
104
value = value | (data << field .low )
99
- await self .write_csr (reg_addr , int2bytes (value ))
105
+ await self .write_csr (reg_addr , int2bytes (value ), awid = awid )
100
106
101
- async def read_csr_field (self , reg_addr , field ) -> int :
107
+ async def read_csr_field (self , reg_addr , field , arid = None ) -> int :
102
108
"""Read -> modify -> write CSR"""
103
- value = bytes2int (await self .read_csr (reg_addr ))
109
+ value = bytes2int (await self .read_csr (reg_addr , arid = arid ))
104
110
value = value & field .mask
105
111
value = value >> field .low
106
112
return value
@@ -149,18 +155,28 @@ async def register_test_interfaces(self, *args, **kw):
149
155
await super ().register_test_interfaces (* args , ** kw )
150
156
151
157
async def read_csr (
152
- self , addr : int , size : int = 4 , timeout : int = 1 , units : str = "us"
158
+ self , addr : int , size : int = 4 , arid = None , timeout : int = 1 , units : str = "us"
153
159
) -> List [int ]:
154
160
"""Send a read request & await the response for 'timeout' in 'units'."""
161
+ if arid :
162
+ self .dut ._log .debug (f"AHB doesn't support transaction IDs, ignoring arid={ arid } " )
155
163
self .AHBManager .read (addr , size )
156
164
await with_timeout (self .AHBManager .transfer_done (), timeout , units )
157
165
read = self .AHBManager .get_rsp (addr , self .data_byte_width )
158
166
return read
159
167
160
168
async def write_csr (
161
- self , addr : int , data : List [int ], size : int = 4 , timeout : int = 1 , units : str = "us"
169
+ self ,
170
+ addr : int ,
171
+ data : List [int ],
172
+ size : int = 4 ,
173
+ awid = None ,
174
+ timeout : int = 1 ,
175
+ units : str = "us" ,
162
176
) -> None :
163
177
"""Send a write request & await transfer to finish for 'timeout' in 'units'."""
178
+ if awid :
179
+ self .dut ._log .debug (f"AHB doesn't support transaction IDs, ignoring awid={ awid } " )
164
180
data_len = len (data )
165
181
# Extend bytes to size if there's less than that
166
182
if data_len <= size :
0 commit comments