You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Specman e中预定义sequence.item的正确使用方法咨询

Hey there, let's break down what's going on here with your Specman/e sequence code.

Why the first error happens

When you define your sequence with sequence bus_sequence using item=bus_item, created_driver=bus_sequence_driver;, that item=bus_item is a type parameter, not an actual field on the bus_sequence class. So when you try to use do item; in the extended body() method, the compiler rightfully complains that bus_sequence doesn't have a field named item—because it doesn't, you only told it what type of item the sequence should handle, not created a field for it.

Why the second error happens

When you manually add !item : bus_item; to the sequence, you're trying to create a field with the exact same name as the type parameter you already defined in the using clause. The compiler sees this as a duplicate definition, hence the error about the field being previously defined.

Fixes that work

You have a few clean options to resolve this:

Option 1: Use the type parameter to create a local item instance

Since you specified item=bus_item in the sequence definition, you can use item as a type reference in your extended code. Create a local variable of that type and execute it:

extend bus_sequence {
    body() @driver.clock is only {
        var my_item : item; // 'item' here refers to bus_item, thanks to the type parameter
        do my_item;
    };
};

Option 2: Create the implicit item field (if using item_sequence)

When you define a sequence with using item=X, it implicitly inherits from item_sequence, which already has an item field of type X. You just need to initialize it before executing:

extend bus_sequence {
    body() @driver.clock is only {
        create item; // Initialize the pre-existing item field
        do item;
    };
};

Option 3: Directly execute the item type (simplest)

If you don't need to customize the item before sending, you can skip declaring a variable entirely and just tell Specman to create and execute a bus_item directly:

extend bus_sequence {
    body() @driver.clock is only {
        do bus_item;
    };
};

All three approaches will get rid of the compilation errors and let your sequence drive the bus_item correctly.

内容的提问来源于stack exchange,提问作者Halona

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:03:07