-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ati: Add ATI timing utilities #3
Draft
colluca
wants to merge
7
commits into
master
Choose a base branch
from
ati
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1ac7896
ati: Add ATI timing utilities
colluca 03985b6
Update src/timing_pkg.sv
colluca 5ec5595
Update src/timing_pkg.sv
colluca d95efef
Update src/timing_pkg.sv
colluca 0714cd8
Update src/interfaces.sv
colluca 67963d7
Update src/timing_pkg.sv
colluca 15fb795
ati: Add ATI timing utilities
colluca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2022 ETH Zurich, University of Bologna | ||
// | ||
// Copyright and related rights are licensed under the Solderpad Hardware | ||
// License, Version 0.51 (the "License"); you may not use this file except in | ||
// compliance with the License. You may obtain a copy of the License at | ||
// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law | ||
// or agreed to in writing, software, hardware and materials distributed under | ||
// this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
interface clk_if(); | ||
logic clk; | ||
logic rst_n; | ||
endinterface |
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,93 @@ | ||
// Copyright (c) 2022 ETH Zurich, University of Bologna | ||
// | ||
// Copyright and related rights are licensed under the Solderpad Hardware | ||
// License, Version 0.51 (the "License"); you may not use this file except in | ||
// compliance with the License. You may obtain a copy of the License at | ||
// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law | ||
// or agreed to in writing, software, hardware and materials distributed under | ||
// this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
/// Package with functions and tasks commonly used in ATI timing | ||
package timing_pkg; | ||
|
||
class ati_utility; | ||
|
||
typedef virtual clk_if clk_vif_t; | ||
|
||
bit initialized; | ||
clk_vif_t clk_vif; | ||
time appl_delay, test_delay; | ||
|
||
function new(clk_vif_t clk_vif); | ||
this.clk_vif = clk_vif; | ||
this.appl_delay = 0; | ||
this.test_delay = 0; | ||
this.initialized = 0; | ||
endfunction | ||
|
||
function void uninit_warning(); | ||
if (!this.initialized) $warning("ATI delays uninitialized"); | ||
endfunction | ||
|
||
task init(time appl_delay, test_delay); | ||
// Measure clock period | ||
time st, clk_period; | ||
@(posedge clk_vif.clk); | ||
st = $time; | ||
@(posedge clk_vif.clk); | ||
clk_period = $time - st; | ||
|
||
// Consistency checks on delays | ||
assert (appl_delay < clk_period) else $error("Application delay greater than clock period"); | ||
assert (test_delay < clk_period) else $error("Test delay greater than clock period"); | ||
|
||
// Configure | ||
this.appl_delay = appl_delay; | ||
this.test_delay = test_delay; | ||
this.initialized = 1; | ||
endtask | ||
|
||
task wait_cycles(int unsigned n); | ||
repeat(n) @(posedge(clk_vif.clk)); | ||
endtask | ||
|
||
task appl_wait_cycles(int unsigned n); | ||
uninit_warning(); | ||
this.wait_cycles(n); | ||
#(appl_delay); | ||
endtask | ||
|
||
task test_wait_cycles(int unsigned n); | ||
uninit_warning(); | ||
this.wait_cycles(n); | ||
#(test_delay); | ||
endtask | ||
|
||
task test_wait_sig(ref logic sig); | ||
uninit_warning(); | ||
do begin | ||
@(posedge(clk_vif.clk)); | ||
#(test_delay); | ||
end while(sig == 1'b0); | ||
endtask | ||
|
||
task wait_test(); | ||
uninit_warning(); | ||
#(test_delay); | ||
endtask | ||
|
||
task wait_appl(); | ||
uninit_warning(); | ||
#(appl_delay); | ||
endtask | ||
|
||
task wait_appl_to_test(); | ||
uninit_warning(); | ||
#(test_delay - appl_delay); | ||
endtask | ||
|
||
endclass | ||
|
||
endpackage |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This signal is currently unused. Why is it part of
clk_if
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the purpose of this class it is not used. But since a clock is generally coupled with a reset, I thought this way one would only have to declare a single virtual interface, e.g. to pass to drivers, rather than have another interface just with the clock.
What are your opinions regarding this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep the reset outside the driver and thus also outside the virtual interface. As evident from recent group discussions, such a
rst_n
signal cannot be used as functional reset without careful consideration, so I would avoid giving that impression to users. A driver typically provides areset
method that is called by the TB-level reset controller when appropriate.The current implementation of
ati_utility
demonstrates one problem quite nicely: even though it is supposed to work withrst_n
, none of the methods are affected by it. For example, what would thewait_cycles
method do if the reset becomes active (i.e., goes low) while it is counting down? Stop counting and restart counting when the reset is deactivated? Or pause counting and continue when the reset is deactivated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are very good questions indeed, and maybe even justifies having these methods in a centralized place, so that it is taken care of for future programmers, avoiding that they incur in the same questions (or, worse, problems). How do you suggest we face these questions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see two main alternatives:
Handling reset inside
ati_utility
Define that reset asynchronously terminates any of the
wait
tasks. This could be implemented, e.g., asHandling reset outside
ati_utility
Remove
rst_n
fromclk_vif
. The user then has the responsibility (but also the flexibility) of handling reset behavior themselves.Deciding on one alternative
I think this boils down to the following question pair: Do we consider resetting a feature and design goal of
ati_utility
and then implement it as we see fit? Or do we leave resetting entirely to the user, to be implemented outsideati_utility
if necessary?I further think a good rule of thumb is: Do we see a real use case for this feature and know we want to implement it one way or the other? If not, I think we should defer this feature to when we really need it.