-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add coverage and update the ref model
- Loading branch information
1 parent
77bbd92
commit f779587
Showing
8 changed files
with
154 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from uvm.macros.uvm_message_defines import uvm_info | ||
from uvm.base.uvm_object_globals import UVM_HIGH, UVM_LOW | ||
from cocotb_coverage.coverage import CoverPoint, CoverCross | ||
from uvm.macros import uvm_component_utils | ||
|
||
|
||
class ip_cov_groups: | ||
def __init__(self, hierarchy, regs) -> None: | ||
self.hierarchy = hierarchy | ||
self.regs = regs | ||
self.ip_cov(None, do_sampling=False) | ||
self.item_width = 8 | ||
|
||
def ip_cov(self, tr, do_sampling=True): | ||
@CoverPoint( | ||
f"{self.hierarchy}.MISO", | ||
xf=lambda tr: tr.MISO, | ||
bins=[(0, 0xF), (0x10, 0xF0), (0xF1, 0xFF)], | ||
at_least=3, | ||
rel=lambda val, b: b[0] <= val <= b[1], | ||
) | ||
@CoverPoint( | ||
f"{self.hierarchy}.MOSI", | ||
xf=lambda tr: tr.MOSI, | ||
bins=[(0, 0xF), (0x10, 0xF0), (0xF1, 0xFF)], | ||
at_least=3, | ||
rel=lambda val, b: b[0] <= val <= b[1], | ||
) | ||
@CoverPoint( | ||
f"{self.hierarchy}.clock_polarity", | ||
xf=lambda tr: self.regs.read_reg_value("CFG") & 0b1, | ||
bins=[False, True], | ||
bins_labels=["normal", "inverted"], | ||
at_least=3, | ||
) | ||
@CoverPoint( | ||
f"{self.hierarchy}.clock_phase", | ||
xf=lambda tr: (self.regs.read_reg_value("CFG") & 0b10) >> 1, | ||
bins=[False, True], | ||
bins_labels=["normal", "shifted90"], | ||
at_least=3, | ||
) | ||
@CoverPoint( | ||
f"{self.hierarchy}.PRESCALER", | ||
xf=lambda tr: self.regs.read_reg_value("PR"), | ||
bins=[(0, 0x5), (0x5, 0xFFFF)], | ||
at_least=3, | ||
rel=lambda val, b: b[0] <= val <= b[1], | ||
) | ||
@CoverCross( | ||
f"{self.hierarchy}.clock_polarity_phase", | ||
items=[f"{self.hierarchy}.clock_polarity", f"{self.hierarchy}.clock_phase"], | ||
) | ||
def sample(tr): | ||
uvm_info("coverage_ip", f"tr = {tr}", UVM_LOW) | ||
|
||
if do_sampling: | ||
sample(tr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from uvm.seq import UVMSequence | ||
from uvm.macros.uvm_object_defines import uvm_object_utils | ||
from uvm.macros.uvm_message_defines import uvm_fatal | ||
from uvm.base.uvm_config_db import UVMConfigDb | ||
from EF_UVM.bus_env.bus_seq_lib.bus_seq_base import bus_seq_base | ||
from cocotb.triggers import Timer | ||
from uvm.macros.uvm_sequence_defines import uvm_do_with, uvm_do | ||
from uvm.base.uvm_object_globals import UVM_ALL_ON, UVM_NOPACK, UVM_HIGH, UVM_MEDIUM | ||
from uvm.macros import uvm_component_utils, uvm_fatal, uvm_info | ||
|
||
|
||
class spi_send_MOSI_seq(bus_seq_base): | ||
# use this sequence write or read from register by the bus interface | ||
# this sequence should be connected to the bus sequencer in the testbench | ||
# you should create as many sequences as you need not only this one | ||
def __init__(self, name="spi_send_MOSI_seq", num_data=10, data_width=8): | ||
super().__init__(name) | ||
self.num_data = num_data | ||
self.data_width = data_width | ||
regs_arr = [] | ||
if not UVMConfigDb.get(self, "", "bus_regs", regs_arr): | ||
uvm_fatal(self.tag, "No json file wrapper regs") | ||
else: | ||
self.regs = regs_arr[0] | ||
|
||
async def body(self): | ||
await super().body() | ||
# Add the sequqnce here | ||
# you could use method send_req to send a write or read using the register name | ||
# example for writing register by value > 5 | ||
await self.send_req( | ||
is_write=True, reg="CTRL", data_condition=lambda data: data == 0b10 | ||
) | ||
for _ in range(self.num_data): | ||
await self.send_req( | ||
is_write=True, | ||
reg="DATA", | ||
data_condition=lambda data: data < (1 << self.data_width) - 1, | ||
) | ||
await self.send_req( | ||
is_write=True, reg="CTRL", data_condition=lambda data: data == 0b11 | ||
) # go | ||
while True: | ||
await self.send_req(is_write=False, reg="STATUS") | ||
# pop non needed response in the fifo | ||
while True: | ||
rsp = [] | ||
await self.get_response(rsp) | ||
rsp = rsp[0] | ||
uvm_info(self.get_full_name(), f"RSP: {rsp}", UVM_MEDIUM) | ||
if rsp.addr == self.regs.reg_name_to_address["STATUS"]: | ||
break | ||
if rsp.data & 0b10 == 0b0: # not busy | ||
break | ||
|
||
await self.send_req( | ||
is_write=True, reg="CTRL", data_condition=lambda data: data == 0b00 | ||
) # csb disable | ||
|
||
|
||
uvm_object_utils(spi_send_MOSI_seq) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters