Pregunta

Tengo el siguiente código en Specman:

var x := some.very.long.path.to.a.variable.in.another.struct;

while (x == some_value) {
    //do something that uses x;
    //wait for something

    //get a new value for x
    x = some.very.long.path.to.a.variable.in.another.struct;
};

Ahora, parece un desperdicio para escribir la asignación a x dos veces; una vez durante la inicialización y una vez durante el bucle.

Lo que realmente quiero usar es una referencia al nombre de la variable tiempo, por lo que podía hacer:

var x := reference to some.very.long.path.to.a.variable.in.another.struct;

while (x == some_value) {
    //do something that uses x;
    //wait for something
    //no need to update x now since it's a reference
};

Se puede hacer esto en Specman?

¿Fue útil?

Solución

Specman / e general, utiliza referencias de estructuras y listas, así que si su tipo de variable es o bien de que su segundo ejemplo debería funcionar. Para integer o boolean no sé una manera de utilizar una referencia para una variable. De todos modos, dos ideas que te pueden ayudar:

  1. Añadir un puntero a la estructura otra y se unen en un fichero de configuración:

    struct a { other_variable : uint; };
    struct b {
        other_struct : a;
        some_func() is {
            var x : uint = other_struct.other_variable;
            while (x == some_value) {
                x = other_struct.other_variable;
            };
        };
    };
    extend cfg {
        struct_a : a;
        struct_b : b;
        keep struct_b.other_struct == struct_a;
    };
    

    ACTUALIZACIÓN: Puede encontrar más información sobre esta técnica en este equipo Specman Mensaje .

  2. Envuelva su bucle while en una función, no puede pasar parámetros por referencia (véase help pass reference):

        some_func(x : *uint) is {
            while (x == some_value) {
                // stuff ...
            };
        };
    

Espero que esto ayude!

Daniel

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top