Skip to content

Commit

Permalink
Merge pull request #3929 from chipsalliance/revert-3928-alainmarcel-p…
Browse files Browse the repository at this point in the history
…atch-1

Revert "typespec bug"
  • Loading branch information
alaindargelas authored Nov 30, 2023
2 parents 9527a0c + 55adc24 commit 6e83d46
Show file tree
Hide file tree
Showing 47 changed files with 871 additions and 1,171 deletions.
205 changes: 98 additions & 107 deletions src/DesignCompile/ElaborationStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,113 +1676,7 @@ any* ElaborationStep::makeVar_(DesignComponent* component, Signal* sig,

variables* obj = nullptr;
bool found = false;

while ((!found) && dtype) {
if (Parameter* sit =
const_cast<Parameter*>(datatype_cast<const Parameter*>(dtype))) {
if (UHDM::typespec* spec = elabTypeParameter_(component, sit, instance)) {
if (variables* var = m_helper.getSimpleVarFromTypespec(
spec, packedDimensions, m_compileDesign)) {
var->VpiConstantVariable(sig->isConst());
var->VpiSigned(sig->isSigned());
var->VpiName(signame);
if (assignExp != nullptr) {
var->Expr(assignExp);
assignExp->VpiParent(var);
}
obj = var;
found = true;
break;
}
}
}
dtype = dtype->getDefinition();
}

if ((found == false) && tps) {
UHDM::UHDM_OBJECT_TYPE tpstype = tps->UhdmType();
found = true;
if (tpstype == uhdmstruct_typespec) {
struct_var* stv = s.MakeStruct_var();
obj = stv;
} else if (tpstype == uhdmlogic_typespec) {
logic_var* stv = s.MakeLogic_var();
// Do not set packedDimensions, it is a repeat of the typespec packed
// dimension.
// stv->Ranges(packedDimensions);
obj = stv;
} else if (tpstype == uhdmenum_typespec) {
enum_var* stv = s.MakeEnum_var();
obj = stv;
} else if (tpstype == uhdmbit_typespec) {
bit_var* stv = s.MakeBit_var();
stv->Ranges(unpackedDimensions);
obj = stv;
} else if (tpstype == uhdmbyte_typespec) {
byte_var* stv = s.MakeByte_var();
obj = stv;
} else if (tpstype == uhdmreal_typespec) {
real_var* stv = s.MakeReal_var();
obj = stv;
} else if (tpstype == uhdmint_typespec) {
int_var* stv = s.MakeInt_var();
obj = stv;
} else if (tpstype == uhdminteger_typespec) {
integer_var* stv = s.MakeInteger_var();
obj = stv;
} else if (tpstype == uhdmlong_int_typespec) {
long_int_var* stv = s.MakeLong_int_var();
obj = stv;
} else if (tpstype == uhdmshort_int_typespec) {
short_int_var* stv = s.MakeShort_int_var();
obj = stv;
} else if (tpstype == uhdmstring_typespec) {
string_var* stv = s.MakeString_var();
obj = stv;
} else if (tpstype == uhdmbit_typespec) {
bit_var* stv = s.MakeBit_var();
obj = stv;
} else if (tpstype == uhdmbyte_typespec) {
byte_var* stv = s.MakeByte_var();
obj = stv;
} else if (tpstype == uhdmtime_typespec) {
time_var* stv = s.MakeTime_var();
obj = stv;
} else if (tpstype == uhdmunion_typespec) {
union_var* stv = s.MakeUnion_var();
obj = stv;
} else if (tpstype == uhdmclass_typespec) {
class_var* stv = s.MakeClass_var();
obj = stv;
} else if (tpstype == uhdmpacked_array_typespec) {
packed_array_var* stv = s.MakePacked_array_var();
obj = stv;
} else if (tpstype == uhdmarray_typespec) {
UHDM::array_var* stv = s.MakeArray_var();
obj = stv;
} else {
found = false;
}

if (obj != nullptr) {
if (assignExp != nullptr) {
assignExp->VpiParent(obj);
obj->Expr(assignExp);
}
if (tps != nullptr) {
if (obj->Typespec() == nullptr) {
ref_typespec* rt = s.MakeRef_typespec();
rt->VpiParent(obj);
obj->Typespec(rt);
}
obj->Typespec()->Actual_typespec(tps);
tps->VpiParent(obj);
}
obj->VpiName(signame);
}
}

while ((!found) && dtype) {
while (dtype) {
if (const TypeDef* tdef = datatype_cast<const TypeDef*>(dtype)) {
if (tdef->getTypespec()) {
tps = tdef->getTypespec();
Expand Down Expand Up @@ -1943,10 +1837,107 @@ any* ElaborationStep::makeVar_(DesignComponent* component, Signal* sig,
obj = stv;
found = true;
break;
} else if (Parameter* sit = const_cast<Parameter*>(
datatype_cast<const Parameter*>(dtype))) {
if (UHDM::typespec* spec = elabTypeParameter_(component, sit, instance)) {
if (variables* var = m_helper.getSimpleVarFromTypespec(
spec, packedDimensions, m_compileDesign)) {
var->VpiConstantVariable(sig->isConst());
var->VpiSigned(sig->isSigned());
var->VpiName(signame);
if (assignExp != nullptr) {
var->Expr(assignExp);
assignExp->VpiParent(var);
}
obj = var;
found = true;
break;
}
}
}
dtype = dtype->getDefinition();
}

if ((found == false) && tps) {
UHDM::UHDM_OBJECT_TYPE tpstype = tps->UhdmType();
if (tpstype == uhdmstruct_typespec) {
struct_var* stv = s.MakeStruct_var();
obj = stv;
} else if (tpstype == uhdmlogic_typespec) {
logic_var* stv = s.MakeLogic_var();
// Do not set packedDimensions, it is a repeat of the typespec packed
// dimension.
// stv->Ranges(packedDimensions);
obj = stv;
} else if (tpstype == uhdmenum_typespec) {
enum_var* stv = s.MakeEnum_var();
obj = stv;
} else if (tpstype == uhdmbit_typespec) {
bit_var* stv = s.MakeBit_var();
stv->Ranges(unpackedDimensions);
obj = stv;
} else if (tpstype == uhdmbyte_typespec) {
byte_var* stv = s.MakeByte_var();
obj = stv;
} else if (tpstype == uhdmreal_typespec) {
real_var* stv = s.MakeReal_var();
obj = stv;
} else if (tpstype == uhdmint_typespec) {
int_var* stv = s.MakeInt_var();
obj = stv;
} else if (tpstype == uhdminteger_typespec) {
integer_var* stv = s.MakeInteger_var();
obj = stv;
} else if (tpstype == uhdmlong_int_typespec) {
long_int_var* stv = s.MakeLong_int_var();
obj = stv;
} else if (tpstype == uhdmshort_int_typespec) {
short_int_var* stv = s.MakeShort_int_var();
obj = stv;
} else if (tpstype == uhdmstring_typespec) {
string_var* stv = s.MakeString_var();
obj = stv;
} else if (tpstype == uhdmbit_typespec) {
bit_var* stv = s.MakeBit_var();
obj = stv;
} else if (tpstype == uhdmbyte_typespec) {
byte_var* stv = s.MakeByte_var();
obj = stv;
} else if (tpstype == uhdmtime_typespec) {
time_var* stv = s.MakeTime_var();
obj = stv;
} else if (tpstype == uhdmunion_typespec) {
union_var* stv = s.MakeUnion_var();
obj = stv;
} else if (tpstype == uhdmclass_typespec) {
class_var* stv = s.MakeClass_var();
obj = stv;
} else if (tpstype == uhdmpacked_array_typespec) {
packed_array_var* stv = s.MakePacked_array_var();
obj = stv;
} else if (tpstype == uhdmarray_typespec) {
UHDM::array_var* stv = s.MakeArray_var();
obj = stv;
}

if (obj != nullptr) {
if (assignExp != nullptr) {
assignExp->VpiParent(obj);
obj->Expr(assignExp);
}
if (tps != nullptr) {
if (obj->Typespec() == nullptr) {
ref_typespec* rt = s.MakeRef_typespec();
rt->VpiParent(obj);
obj->Typespec(rt);
}
obj->Typespec()->Actual_typespec(tps);
tps->VpiParent(obj);
}
obj->VpiName(signame);
}
}

if (obj == nullptr) {
variables* var = nullptr;
if (subnettype == VObjectType::paIntegerAtomType_Shortint) {
Expand Down
2 changes: 0 additions & 2 deletions tests/ArrayMethodIterator/ArrayMethodIterator.log
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,6 @@ design: (work@top)
|vpiActual:
\_class_typespec: (uvm_callback), line:10:50, endln:10:62
\_class_typespec: (pkg::uvm_callbacks), line:29:1, endln:29:6
|vpiParent:
\_class_var: ([email protected]), line:29:20, endln:29:22
|vpiName:pkg::uvm_callbacks
|vpiClassDefn:
\_class_defn: (pkg::uvm_callbacks), file:${SURELOG_DIR}/tests/ArrayMethodIterator/dut.sv, line:10:1, endln:23:9
Expand Down
71 changes: 34 additions & 37 deletions tests/BitSelectExpr/BitSelectExpr.log
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ range 3
ref_obj 4
ref_typespec 8
struct_typespec 1
struct_var 1
typespec_member 1
=== UHDM Object Stats End ===
[INF:UH0707] Elaborating UHDM...
Expand All @@ -139,6 +140,7 @@ range 3
ref_obj 6
ref_typespec 9
struct_typespec 1
struct_var 1
typespec_member 1
=== UHDM Object Stats End ===
[INF:UH0708] Writing UHDM DB: ${SURELOG_DIR}/build/regression/BitSelectExpr/slpp_all/surelog.uhdm ...
Expand Down Expand Up @@ -292,16 +294,41 @@ design: (work@top)
\_packed_array_var: ([email protected]_otp_key_o), line:7:29, endln:7:43
|vpiParent:
\_module_inst: work@top (work@top), file:${SURELOG_DIR}/tests/BitSelectExpr/dut.sv, line:1:1, endln:12:10
|vpiTypespec:
\_ref_typespec: ([email protected]_otp_key_o)
|vpiParent:
\_packed_array_var: ([email protected]_otp_key_o), line:7:29, endln:7:43
|vpiFullName:[email protected]_otp_key_o
|vpiActual:
\_packed_array_typespec: , line:7:4, endln:7:28
|vpiName:sram_otp_key_o
|vpiFullName:[email protected]_otp_key_o
|vpiVisibility:1
|vpiRange:
\_range: , line:7:23, endln:7:28
|vpiParent:
\_packed_array_var: ([email protected]_otp_key_o), line:7:29, endln:7:43
|vpiLeftRange:
\_constant: , line:7:24, endln:7:25
|vpiParent:
\_range: , line:7:23, endln:7:28
|vpiDecompile:2
|vpiSize:64
|UINT:2
|vpiConstType:9
|vpiRightRange:
\_constant: , line:7:26, endln:7:27
|vpiParent:
\_range: , line:7:23, endln:7:28
|vpiDecompile:0
|vpiSize:64
|UINT:0
|vpiConstType:9
|vpiElement:
\_struct_var: ([email protected]_otp_key_o)
|vpiParent:
\_packed_array_var: ([email protected]_otp_key_o), line:7:29, endln:7:43
|vpiTypespec:
\_ref_typespec: ([email protected]_otp_key_o)
|vpiParent:
\_struct_var: ([email protected]_otp_key_o)
|vpiFullName:[email protected]_otp_key_o
|vpiActual:
\_struct_typespec: (sram_otp_key_rsp_t), line:3:12, endln:5:5
|vpiFullName:[email protected]_otp_key_o
|vpiTypedef:
\_struct_typespec: (sram_otp_key_rsp_t), line:3:12, endln:5:5
|vpiDefName:work@top
Expand Down Expand Up @@ -374,36 +401,6 @@ design: (work@top)
|vpiParent:
\_int_var: ([email protected]), line:1:23, endln:1:24
|vpiSigned:1
\_packed_array_typespec: , line:7:4, endln:7:28
|vpiParent:
\_packed_array_var: ([email protected]_otp_key_o), line:7:29, endln:7:43
|vpiRange:
\_range: , line:7:23, endln:7:28
|vpiParent:
\_packed_array_typespec: , line:7:4, endln:7:28
|vpiLeftRange:
\_constant: , line:7:24, endln:7:25
|vpiParent:
\_range: , line:7:23, endln:7:28
|vpiDecompile:2
|vpiSize:64
|UINT:2
|vpiConstType:9
|vpiRightRange:
\_constant: , line:7:26, endln:7:27
|vpiParent:
\_range: , line:7:23, endln:7:28
|vpiDecompile:0
|vpiSize:64
|UINT:0
|vpiConstType:9
|vpiElemTypespec:
\_ref_typespec: ([email protected]_otp_key_o)
|vpiParent:
\_packed_array_typespec: , line:7:4, endln:7:28
|vpiFullName:[email protected]_otp_key_o
|vpiActual:
\_struct_typespec: (sram_otp_key_rsp_t), line:3:12, endln:5:5
\_int_typespec: , line:1:19, endln:1:22
|vpiSigned:1
\_packed_array_typespec: , line:7:4, endln:7:28
Expand Down
Loading

0 comments on commit 6e83d46

Please sign in to comment.