Skip to content
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

GPIO straps verif #25868

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcelocarvalhoLowRisc
Copy link

New sequence to verify the straps feature and some additional description of the behaviour of this feature in the register document.

@marcelocarvalhoLowRisc marcelocarvalhoLowRisc requested a review from a team as a code owner January 14, 2025 15:59
@marcelocarvalhoLowRisc marcelocarvalhoLowRisc requested review from rswarbrick and martin-velay and removed request for a team January 14, 2025 15:59
@marcelocarvalhoLowRisc marcelocarvalhoLowRisc force-pushed the gpio_straps_verif branch 3 times, most recently from 74b9fcd to 7921fc9 Compare January 14, 2025 16:20
Copy link
Contributor

@martin-velay martin-velay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR still requires some changes.

hw/ip/gpio/dv/tb/tb.sv Outdated Show resolved Hide resolved
hw/ip/gpio/data/gpio_testplan.hjson Outdated Show resolved Hide resolved
hw/ip/gpio/dv/tb/tb.sv Outdated Show resolved Hide resolved
hw/ip/gpio/dv/env/gpio_env_cfg.sv Outdated Show resolved Hide resolved
hw/ip/gpio/dv/env/gpio_scoreboard.sv Outdated Show resolved Hide resolved
hw/ip/gpio/dv/env/seq_lib/gpio_rand_straps_vseq.sv Outdated Show resolved Hide resolved
hw/ip/gpio/dv/env/seq_lib/gpio_rand_straps_vseq.sv Outdated Show resolved Hide resolved
hw/ip/gpio/dv/env/seq_lib/gpio_rand_straps_vseq.sv Outdated Show resolved Hide resolved
`DV_CHECK_MEMBER_RANDOMIZE_WITH_FATAL(delay, delay >= 1;)

// Trigger the snapshot of gpio_i to be stored in the straps registers
cfg.straps_vif_inst.strap_en = 'b1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: all these 'b are useless for single bit (IMO)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for dropping that. Honestly, I think I generally use 1'b1 but I'm happy either way. But I think there's still a bare 'b1 a few lines later. Maybe switch that to 1 too?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can do that

hw/ip/gpio/doc/registers.md Outdated Show resolved Hide resolved
@marcelocarvalhoLowRisc marcelocarvalhoLowRisc force-pushed the gpio_straps_verif branch 4 times, most recently from 05e6443 to 2e49144 Compare January 15, 2025 14:21
Comment on lines 393 to 395
desc: '''GPIO Input data sampled as straps during cold boot read value
The GPIO input data is sampled after the first one pulse cycle of straps_en input after reset.
''',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise this isn't your fault but the text here is a bit dubious! How about something like this?

      desc: '''
        GPIO input data that was sampled as straps as the block came out of reset.

        This register depends on the GpioAsHwStrapsEn parameter.
        - If the parameter is false then the register reads as zero.
        - If the parameter is true then GPIO input data is sampled on the first cycle after reset
          where the strap_en_i input is high. That sampled data is stored in this register.
      ''',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better! Thanks!

Comment on lines 152 to 153
- Set the expected strap_data_in based on the condition if is the first triggered strap_en or not
- Updates the RAL model with the expected strap_data_in and strap_data_in_valid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this behaviour is in the scoreboard now, so doesn't need describing here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very true, I forgot to remove this. And I have included some new comments/steps description.

- Drives gpio_i input with random values
- Set the expected strap_data_in based on the condition if is the first triggered strap_en or not
- Updates the RAL model with the expected strap_data_in and strap_data_in_valid
- Trigger the strap_en with one clock cycle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest making this more general: we're only looking at the "posedge" anyway. Maybe something like "set strap_en_i high for at least one clock cycle".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- Updates the RAL model with the expected strap_data_in and strap_data_in_valid
- Trigger the strap_en with one clock cycle
- Read the registers hw_straps_data_in and hw_straps_data_in_valid
- Check the expected behavior in the scoreboard and also on csr checks'''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably make it more explicit that this isn't done in the sequence. Maybe "The data read will be checked by the scoreboard." ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, I will reformulate the phrase.

Comment on lines 34 to 37
// hw straps_data_in_valid register
bit straps_data_in_valid;
// hw straps_data_in register
bit [NUM_GPIOS-1:0] straps_data_in;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you're actually using either of these fields. You can probably drop them?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, I included those in the gpio_predict_and_compare() function, because was initial idea that this function it will be used in my case, but after some coding I realise that is not needed, but I forgot to remove it. I should done a proper clean up code, sorry.


// Interface definition
interface gpio_straps_if (
inout strap_en_i, // Input signal to enable straps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Stray space before "strap_en_i"

Comment on lines 12 to 13
inout strap_en_i, // Input signal to enable straps
input gpio_straps_t sampled_straps_o // Output signal of type gpio_straps_t
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something very strange is going on here. Do these need to be ports at all? I think probably not, and I definitely don't think an input port should have a name that ends in _o.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the interface is used primarily for encapsulation those signals, then you are correct, but in this case I will connect those ports signals to the GPIO module, otherwise I will have compilation issues.
You are right, besides the "input" explicitly in the sampled_straps_o feels weird/confuse, I kept the _o, just to signalise that this signal is a output from the DUT, but I can remove it, that is more reasonable, and put some comments.

Comment on lines 16 to 17
logic strap_en;
assign strap_en_i = strap_en;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'm not sure about the way this is using ports. Can't we just have an internal variable called strap_en and wire that up?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I am using the gpio_strap_en variable to initialise the strap_en_i with zero after the reset, otherwise I will have spreading X's to the input, so look at the gpio_base_test.sv

@@ -24,6 +22,8 @@ module tb;
wire [NUM_GPIOS-1:0] gpio_oe;
wire [NUM_GPIOS-1:0] gpio_intr;
wire [NUM_MAX_INTERRUPTS-1:0] interrupts;
gpio_straps_t sampled_straps;
wire strap_en_i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name doesn't quite work because the _i suffix is used for input ports in our style.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will fix this =)

// TODO: need to test snapshot functionality
.strap_en_i(1'b0),
.sampled_straps_o(),
.strap_en_i(strap_en_i),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following on from the note I left in the interface, I think this could just use straps_if_inst.strap_en.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed, I would prefer to keep the single signal name instead, makes the code more clean, and the wire makes the "connection" between the interface and the DUT. But let me know if this does not make sense to you =)

@marcelocarvalhoLowRisc marcelocarvalhoLowRisc force-pushed the gpio_straps_verif branch 7 times, most recently from 913c3a4 to b57f29c Compare January 17, 2025 18:12
Signed-off-by: Marcelo Carvalho Faleiro de Almeida <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants