Skip to content

Commit

Permalink
use bus_seq_base in the sequences that uses the bus
Browse files Browse the repository at this point in the history
  • Loading branch information
M0stafaRady committed Apr 17, 2024
1 parent 701ddc8 commit 4fd0200
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
18 changes: 11 additions & 7 deletions verify/uvm-python/uart_seq_lib/uart_rx_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,32 @@
from EF_UVM.bus_env.bus_item import bus_item
from uvm.base.uvm_config_db import UVMConfigDb
import random
from EF_UVM.bus_env.bus_seq_lib.bus_seq_base import bus_seq_base


class uart_rx_read(UVMSequence):
class uart_rx_read(bus_seq_base):

def __init__(self, name="uart_rx_read"):
UVMSequence.__init__(self, name)
self.set_automatic_phase_objection(1)
self.req = bus_item()
self.rsp = bus_item()
super().__init__(name)
self.tag = name

async def body(self):
# get register names/address conversion dict
arr = []
if (not UVMConfigDb.get(self, "", "bus_regs", arr)):
if not UVMConfigDb.get(self, "", "bus_regs", arr):
uvm_fatal(self.tag, "No json file wrapper regs")
else:
adress_dict = arr[0].reg_name_to_address
# randomly config uart
# first disabled the uart
for _ in range(random.randint(1, 18)):
await uvm_do_with(self, self.req, lambda addr: addr == adress_dict["RXDATA"], lambda kind: kind == bus_item.READ, lambda data: data == 0)
await uvm_do_with(
self,
self.req,
lambda addr: addr == adress_dict["RXDATA"],
lambda kind: kind == bus_item.READ,
lambda data: data == 0,
)
# await uvm_do_with(self, self.req, lambda addr: addr == adress_dict["im"], lambda kind: kind == bus_item.WRITE, lambda data: data == 0)


Expand Down
23 changes: 14 additions & 9 deletions verify/uvm-python/uart_seq_lib/uart_tx_seq.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from uvm.seq import UVMSequence
from uvm.macros.uvm_object_defines import uvm_object_utils
from uvm.macros.uvm_message_defines import uvm_info, uvm_fatal
from uvm.macros.uvm_sequence_defines import uvm_do_with, uvm_do
Expand All @@ -9,26 +8,32 @@
import os
import random
from uart_seq_lib.uart_config import uart_config
from EF_UVM.bus_env.bus_seq_lib.bus_seq_base import bus_seq_base


class uart_tx_seq(UVMSequence):
class uart_tx_seq(bus_seq_base):

def __init__(self, name="uart_tx_seq"):
UVMSequence.__init__(self, name)
self.set_automatic_phase_objection(1)
self.req = bus_item()
self.rsp = bus_item()
super().__init__(name)
self.tag = name

async def body(self):
# configure uart
# configure uart
config_seq = uart_config("uart_config")
await uvm_do(self, config_seq) # change the presclar
for _ in range(30):
random_send = random.randint(1, 16)
for __ in range(random_send):
await uvm_do_with(self, self.req, lambda addr: addr == 0x4, lambda kind: kind == bus_item.WRITE, lambda data: data in range(0, 0x200))
for __ in range(random.randint(0, random_send-1 if random_send > 1 else 1)):
await uvm_do_with(
self,
self.req,
lambda addr: addr == 0x4,
lambda kind: kind == bus_item.WRITE,
lambda data: data in range(0, 0x200),
)
for __ in range(
random.randint(0, random_send - 1 if random_send > 1 else 1)
):
await self.monitor.tx_received.wait()
self.monitor.tx_received.clear()

Expand Down

0 comments on commit 4fd0200

Please sign in to comment.