-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'rd_swacc' and 'wr_swacc' UDPs. #21
- Loading branch information
Showing
17 changed files
with
243 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,4 @@ Links | |
udps/intro | ||
udps/read_buffering | ||
udps/write_buffering | ||
udps/extended_swacc |
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,47 @@ | ||
.. _extended_swacc: | ||
|
||
Read/Write-specific swacc | ||
========================= | ||
|
||
SystemRDL defines the ``swacc`` property, but it does not distinguish between | ||
read and write operations - it is asserted on *all* software accesses. | ||
Similarly, the spec defines ``swmod`` which gets asserted on software writes, | ||
but can also get asserted if the field has on-read side-effects. | ||
|
||
What if you just wanted a plan and simple strobe that is asserted when software | ||
reads or writes a field? The ``rd_swacc`` and ``wr_swacc`` UDPs provide this | ||
functionality. | ||
|
||
|
||
Properties | ||
---------- | ||
These UDP definitions, along with others supported by PeakRDL-regblock can be | ||
enabled by compiling the following file along with your design: | ||
:download:`regblock_udps.rdl <../../hdl-src/regblock_udps.rdl>`. | ||
|
||
``rd_swacc`` | ||
If true, infers an output signal ``hwif_out..rd_swacc`` that is asserted | ||
when accessed by a software read operation. The output signal is asserted | ||
on the same clock cycle that the field is being sampled during the software | ||
read operation. | ||
|
||
.. wavedrom:: | ||
|
||
{"signal": [ | ||
{"name": "clk", "wave": "p...."}, | ||
{"name": "hwif_in..next", "wave": "x.=x.", "data": ["D"]}, | ||
{"name": "hwif_out..rd_swacc", "wave": "0.10."} | ||
]} | ||
|
||
|
||
``wr_swacc`` | ||
If true, infers an output signal ``hwif_out..wr_swacc`` that is asserted | ||
as the field is being modified by a software write operation. | ||
|
||
.. wavedrom:: | ||
|
||
{"signal": [ | ||
{"name": "clk", "wave": "p....."}, | ||
{"name": "hwif_out..value", "wave": "=..=..", "data": ["old", "new"]}, | ||
{"name": "hwif_out..wr_swacc", "wave": "0.10.."} | ||
]} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.8.0" | ||
__version__ = "0.9.0" |
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
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,12 @@ | ||
from .rw_buffering import BufferWrites, WBufferTrigger | ||
from .rw_buffering import BufferReads, RBufferTrigger | ||
from .extended_swacc import ReadSwacc, WriteSwacc | ||
|
||
ALL_UDPS = [ | ||
BufferWrites, | ||
WBufferTrigger, | ||
BufferReads, | ||
RBufferTrigger, | ||
ReadSwacc, | ||
WriteSwacc, | ||
] |
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,23 @@ | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from systemrdl.udp import UDPDefinition | ||
from systemrdl.component import Field | ||
|
||
if TYPE_CHECKING: | ||
from systemrdl.node import Node | ||
|
||
class ReadSwacc(UDPDefinition): | ||
name = "rd_swacc" | ||
valid_components = {Field} | ||
valid_type = bool | ||
|
||
def get_unassigned_default(self, node: 'Node') -> Any: | ||
return False | ||
|
||
class WriteSwacc(UDPDefinition): | ||
name = "wr_swacc" | ||
valid_components = {Field} | ||
valid_type = bool | ||
|
||
def get_unassigned_default(self, node: 'Node') -> Any: | ||
return False |
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
Empty file.
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,17 @@ | ||
addrmap top { | ||
default regwidth = 8; | ||
|
||
reg { | ||
field { | ||
sw=r; hw=w; | ||
rd_swacc; | ||
} f[8]; | ||
} r1; | ||
|
||
reg { | ||
field { | ||
sw=rw; hw=r; | ||
wr_swacc; | ||
} f[8] = 20; | ||
} r2; | ||
}; |
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,68 @@ | ||
{% extends "lib/tb_base.sv" %} | ||
|
||
{% block seq %} | ||
{% sv_line_anchor %} | ||
logic [7:0] counter; | ||
logic [7:0] rd_data; | ||
logic [7:0] latched_data; | ||
int event_count; | ||
latched_data = 'x; | ||
|
||
##1; | ||
cb.rst <= '0; | ||
##1; | ||
|
||
// Verify that hwif gets sampled at the same cycle as rd_swacc strobe | ||
counter = 'h10; | ||
cb.hwif_in.r1.f.next <= counter; | ||
@cb; | ||
event_count = 0; | ||
fork | ||
begin | ||
##0; | ||
forever begin | ||
counter++; | ||
cb.hwif_in.r1.f.next <= counter; | ||
@cb; | ||
if(cb.hwif_out.r1.f.rd_swacc) begin | ||
latched_data = counter; | ||
event_count++; | ||
end | ||
end | ||
end | ||
|
||
begin | ||
cpuif.read('h0, rd_data); | ||
@cb; | ||
end | ||
join_any | ||
disable fork; | ||
assert(rd_data == latched_data) else $error("Read returned 0x%0x but rd_swacc strobed during 0x%0x", rd_data, latched_data); | ||
assert(event_count == 1) else $error("Observed excess rd_swacc events: %0d", event_count); | ||
|
||
|
||
// Verify that hwif changes 1 cycle after wr_swacc | ||
fork | ||
begin | ||
##0; | ||
forever begin | ||
assert(cb.hwif_out.r2.f.value == 20); | ||
if(cb.hwif_out.r2.f.wr_swacc) break; | ||
@cb; | ||
end | ||
@cb; | ||
forever begin | ||
assert(cb.hwif_out.r2.f.value == 21); | ||
assert(cb.hwif_out.r2.f.wr_swacc == 0); | ||
@cb; | ||
end | ||
end | ||
|
||
begin | ||
cpuif.write('h1, 21); | ||
@cb; | ||
end | ||
join_any | ||
disable fork; | ||
|
||
{% endblock %} |
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,5 @@ | ||
from ..lib.sim_testcase import SimTestCase | ||
|
||
class Test(SimTestCase): | ||
def test_dut(self): | ||
self.run_test() |