AXI4 VIP development and integration - #688
Conversation
01fb3d1 to
3863316
Compare
rswarbrick
left a comment
There was a problem hiding this comment.
Thank you very much for doing this (and getting my completely untested code working...)
Do you think you could cherry-pick the various fixes in "axi agent compilation fixes" to the commits that made the mistakes? Since we don't use squash merge in Mocha, this is a way to avoid putting Rupert's silly mistakes into the history :-)
Hey Rupert, Sure, I can merge the patches into your commits. This would also encompass the handshaking bugfix commit, for a total of two commits :) |
This is the first step towards a simple AXI agent. It will only have to handle the subset of AXI that is in use in the blocks in question (which work by translating to TLUL, so they aren't doing anything particularly exciting). In this commit, we're just defining interfaces for the five channels (which are AW, W, B, AR and R). Co-authored-by: tchilikov-semify <christian.tchilikov@semify-eda.com>
The axi_read_request_item and axi_read_data_item classes are intended to be randomised (when a sequence wishes to send either read requests or data responses). The axi_read_item class can be used by a monitor that sees a read request and then one or more responses. Co-authored-by: tchilikov-semify <christian.tchilikov@semify-eda.com>
When the agent is representing an AXI Manager, this will be useful for the B and R channels. Co-authored-by: tchilikov-semify <christian.tchilikov@semify-eda.com>
These drive write requests (AW) and write data (W) and also drive the write response channel (B). Co-authored-by: tchilikov-semify <christian.tchilikov@semify-eda.com>
Co-authored-by: tchilikov-semify <christian.tchilikov@semify-eda.com>
Co-authored-by: tchilikov-semify <christian.tchilikov@semify-eda.com>
For an example use-case, suppose you are reading with AR / R
transfers. You send an AR transfer with some ARID that will have a
burst with k beats. Now you want consume read data with that many (k)
R transfers using the some ID.
To do so:
- Run k axi_mgr_read_data_seq sequences, calling on_response() after
each finishes.
- (In parallel) call wait_for_response() k times.
The trick is that these sequences might respond with different IDs,
but that doesn't matter: the sequences are just actings as tokens to
allow *something* to come back.
3863316 to
0d44df6
Compare
|
Hey @rswarbrick, In the meanwhile, I've folded the old compilation bugfixes commit into the respective commits that you made, so the commit history should be clear of bugs now. |
a5c0dab to
6550b3a
Compare
c90d65e to
b5b685e
Compare
rswarbrick
left a comment
There was a problem hiding this comment.
Here are some notes about the "fix axi handshaking" and "multi-beat transaction support" commits.
These both look really good: I like the code, and it's just some nitty notes about comments.
rswarbrick
left a comment
There was a problem hiding this comment.
Two more minor notes about "add multi-beat transaction support"
rswarbrick
left a comment
There was a problem hiding this comment.
A minor note about error messages in "add clk_rst_if to axi interfaces". (I really like this change though!)
rswarbrick
left a comment
There was a problem hiding this comment.
Some notes about the (excellent!) change that adds axi_widths_pkg. They're all about alignment: sorry - very boring.
rswarbrick
left a comment
There was a problem hiding this comment.
One specific question: Is there a good reason to use dv_base_agent for the IP? It's designed to a very specific OpenTitan shape, as chosen by the DV lead at the time.
It's also actively against my design for this agent. If someone more important than me mandates that we use the class, I guess we have to. If not, I'd prefer we didn't.
| parameter int UserWidth = 1, | ||
| parameter uvm_pkg::uvm_active_passive_enum IsActive = uvm_pkg::UVM_ACTIVE, | ||
| parameter string InstId = "axi_mgr", // names the published axi_agent_cfg | ||
| parameter string CfgScope = "*" // config_db publish scope glob |
There was a problem hiding this comment.
Is this design following a pattern for which you have a reference? I'm slightly surprised that you don't set things in the config db from the testbench, rather than the interface that gets instantiated.
There was a problem hiding this comment.
Yes! The intent of this file is perhaps quite unclear from the perspective of this PR... Its purpose is to take the shape of the AXI peripherals used in mocha. In our agent, the AXI bus is represented by 5 interfaces, which map to the channels. In mocha, the AXI devices have ports which are represented by 2 interfaces, basically inputs and outputs (req and resp). This interface bridges the two.
There was a problem hiding this comment.
Ah, I see. I wonder whether it would make sense to split this file out of the axi_vip directory. Although it's notionally parametised on the type of e.g. req_t, it isn't really!
Lines like this aren't really parametric in the type!
assign axi_req.aw.id = $bits(axi_req.aw.id)'(aw_if.awid);(This is an example of the standard fact from type theory that there is only one way to define a function A -> A for all types, A)
| // clear, the payload is randomised instead: still meaningless, but defined. | ||
| // | ||
| // Defaults set, so an idle channel drives X. | ||
| bit drive_x_when_idle = 1'b1; |
There was a problem hiding this comment.
I'm repeating myself here, but I think this should be set by calling a setter on the agent, which calls a setter on each of the drivers.
Note that you wrote earlier that the agent config just contained a list of virtual interfaces. I wasn't convinced. I'm still not :-)
There was a problem hiding this comment.
Yes perhaps an agent wide config permeated into the configs... You were right in this regard. 😉
For my understanding, are you proposing that the agent reads this config and then calls the setters of the drivers, rather than passing the config directly to the drivers? This value is a genuine agent-wide knob, so I think it should live in the config. Is this what you had in mind?
There was a problem hiding this comment.
I think I was rather confused when I was writing that suggestion... I think there's a nice way to structure things though! (details below). Does it sound reasonable to you?
b5b685e to
34e89c4
Compare
Honestly - its not strictly needed. This was a suggestion from an internal review that Martin did with Claude, which he told me to implement if it seems fitting. I thought it was fitting, since I saw that other mocha TBs use the dv base classes, but honestly I don't have a strong opinion on this (and honestly, I think the less dependencies an independent agent has, the better). Shall I remove it? |
34e89c4 to
70f76a5
Compare
Merge per-channel reset monitors into a unified reset monitor by introducing a shared clock and reset interface to the agent.
Add AXI transaction monitor which snoops the 5 channels and rebuilds AXI transactions, then broadcasts them. Monitor is built unconditionally.
70f76a5 to
da139c9
Compare
|
Hey @rswarbrick - thanks for the in depth review again! It seems this PR is starting to come together 😄 I think I've addressed most of your comments. There's still 1 or 2 open questions, but I've re-triggered another review. Thanks! |
|
@tchilikov-semify, thanks for the prompt! I'll go through the commits in detail again in a minute, but I've been thinking a bit about how configuration should probably work, and I think that (at last!) I've finally worked out a sensible structure. Thinking about configuration for the agent, I think there are two different sorts of configuration:
Focusing on the experience of an environment that wants to use the agent, I think the right thing is to create something like what you've currently got in the config file: essentially, it's a list of virtual interfaces, together with the behaviour configuration parameters. For the internals of the agent, I don't think that the various components (monitors and drivers) should see that config object. The danger is that everything ends up "very global" (a recurring problem in OpenTitan) and the thing that's called an "agent config" ends up being a way to store state and communicate between the different components. In the limit, you end up with "everything is a global variable". Yuck! Instead of doing that, I think the agent should responsible for copying the configuration information down to the components it creates (in the agent's build_phase). That should separate concerns nicely:
This is not how the historical |
rswarbrick
left a comment
There was a problem hiding this comment.
I've just read carefully through the read burst virtual sequence and have left lots of suggestions (sorry!)
They will apply to the write side of things as well.
| // | ||
| // To use it: | ||
| // | ||
| // - Create it, then call set_sequencers() and set_read_response_router(). |
There was a problem hiding this comment.
This might be my fault (sorry), but we've got a double "it" here. How about "To use the sequence:" on the previous line?
| // To use it: | ||
| // | ||
| // - Create it, then call set_sequencers() and set_read_response_router(). | ||
| // - Choose the request by randomising this sequence. m_ar_req is rand, so a plain randomize() |
There was a problem hiding this comment.
The indentation is a bit wonky here: I think the lines after the - line are indented by an extra space each time.
| // - Choose the request by randomising this sequence. m_ar_req is rand, so a plain randomize() | ||
| // picks a legal burst. To direct it, constrain the fields that matter in the same call: | ||
| // | ||
| // if (!vseq.randomize() with { m_ar_req.m_addr == 'h1000; |
There was a problem hiding this comment.
Nit: I'd suggest a more obviously arbitrary address here. How about 'h1234 ?
| // On completion, rsp is an axi_fixed_read_rsp_item where: | ||
| // - m_ar_status is the status of the AR transfer. Its m_sending_complete is 0 if a reset | ||
| // stopped the request being sent. | ||
| // - m_read_data holds the beats that arrived, in beat order. The same beats are also left in |
There was a problem hiding this comment.
I'd avoid "left" here: saying that something is "left in a queue" makes it sound a bit like it's there and nowhere else. Thinking about it, I don't think I'd talk about m_read_beats at all: isn't that just an implementation detail?
| // the public m_read_beats queue. | ||
| // | ||
| // If a reset happens part-way through, the sequence still completes and still populates rsp, but | ||
| // m_read_data is short: it holds only the beats that had already arrived, possibly none at all. A |
There was a problem hiding this comment.
Grammar nit: This would be more standard as "... it only holds ..."
| for (int unsigned i = 0; i < n_beats; i++) begin | ||
| automatic int unsigned beat_num = i; | ||
| fork | ||
| accept_one_beat(beat_num); | ||
| join_none | ||
| end |
There was a problem hiding this comment.
It's not a big deal, but I don't think there's any need for these accept_one_beat tasks to run in parallel with each other. Couldn't this be:
fork begin
for (int unsigned i = 0; i < n_beats; i++) accept_one_beat(i);
end join_none?
| if (!$cast(r_seq, m_r_accept.clone())) begin | ||
| `uvm_fatal(get_full_name(), "Clone of m_r_accept is not an axi_mgr_read_data_seq.") | ||
| end | ||
| // The clone carries the template's name, so rename it to say which beat it is. |
There was a problem hiding this comment.
This isn't quite correct: it might be accepting a beat that has no relation to this sequence's request! I suppose a counter might be slightly useful to someone debugging in the future, but I think the comment needs changing.
| axi_read_data_item read_data_item; | ||
|
|
||
| m_read_response_router.wait_for_response(m_ar_req.m_id, base_item); | ||
| if (base_item == null) break; // reset |
There was a problem hiding this comment.
I'd expand this to something like // We have seen a reset, to make sure it doesn't look like an instruction to reset.
| if (read_request_sequencer == null) `uvm_fatal(get_full_name(), "No read_request_sequencer.") | ||
| if (read_data_sequencer == null) `uvm_fatal(get_full_name(), "No read_data_sequencer.") | ||
|
|
||
| m_read_request_sequencer = read_request_sequencer; |
There was a problem hiding this comment.
Nit: Extra space before the "=" signs on these two lines.
| // m_use_fixed_XYZ=1 and set m_fixed_XYZ to the required value. Do this before starting the | ||
| // If non-null, this exact item is sent verbatim; no randomisation, and the | ||
| // m_use_fixed_* pins below are ignored. | ||
| axi_txn_request_item m_req; |
There was a problem hiding this comment.
Thinking about this, I think it might make more sense to define an extra sequence for the fixed example. It's extremely simple! I just did a bit of typing, and I think it ends up like this, and avoids a load of do-nothing variables.
// Copyright lowRISC contributors
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
// A fixed sequence that sends a single fixed item.
//
// This item is neither created nor randomised: a virtual sequence that wants to use this sequence
// should provide the item before starting the sequence.
//
// When the sequence completes, the rsp field will contain a status item that shows whether the
// sequence ran to completion (rather than being interrupted by a reset).
class axi_mgr_fixed_txn_request_seq extends uvm_sequence #(axi_txn_request_item, axi_status_item);
`uvm_object_utils(axi_mgr_fixed_txn_request_seq)
// This item is sent verbatim; no randomisation. Provide the item before starting the sequence.
axi_txn_request_item m_req;
extern function new(string name="");
extern task pre_start();
extern task body();
endclass
function axi_mgr_fixed_txn_request_seq::new(string name="");
super.new(name);
endfunction
task axi_mgr_fixed_txn_request_seq::pre_start();
super.pre_start();
if (m_req == null) `uvm_fatal(get_full_name(), "Cannot run fixed sequence with no item.")
endtask
task axi_mgr_fixed_txn_request_seq::body();
axi_txn_request_item item;
uvm_sequence_item base_status_item;
if (m_req != null) begin
// Send the caller-supplied item verbatim: it is already built, so no randomisation.
item = m_req;
start_item(item);
finish_item(item);
end
// Get a response, which will always be sent by the driver (and is available already: there's no
// pipelining and finish_item just completed).
get_base_response(base_status_item);
if (!$cast(rsp, base_status_item)) begin
`uvm_fatal(get_full_name(), "Status response is not an axi_status_item")
end
endtaskThere was a problem hiding this comment.
If we really don't want to repeat ourselves, we should probably define a base version of this sequence as a virtual class and give it a pure virtual "give me an item to run" function.
I'm not really convinced that's worth the hassle though: I think we repeat about 5 lines.
Yeah, if you're happy to :-) I think that Claude recommends writing code that matches other code nearby. A very good general principle! But we're trying to do better... |
This PR does a few things:
This was tested with the top level CVA6-based test cases.
Will close issue #168