Skip to content

Commit

Permalink
Merge pull request #1071 from alainmarcel/alainmarcel-patch-1
Browse files Browse the repository at this point in the history
Ram inference transform
  • Loading branch information
alaindargelas authored Jan 8, 2024
2 parents 1e28f73 + e095c6b commit 90a55f7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
31 changes: 31 additions & 0 deletions templates/SynthSubset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,4 +728,35 @@ void SynthSubset::leaveAlways(const always* object, vpiHandle handle) {
}
}

void SynthSubset::leaveArray_var(const array_var* object, vpiHandle handle) {
VectorOfvariables* vars = object->Variables();
if (!vars) return;
if (vars->empty()) return;
variables* var = vars->at(0);
const ref_typespec* ref_tps = var->Typespec();
const typespec* tps = ref_tps->Actual_typespec();
if (tps->UhdmType() == uhdmlogic_typespec) {
logic_typespec* ltps = (logic_typespec*)tps;
if ((tps->VpiName().empty())) {
if (ltps->Ranges() && ltps->Ranges()->size() == 1) {
((array_var*)object)->Typespec((ref_typespec*)ref_tps);
}
} else {
if (ltps->Ranges() && ltps->Ranges()->size() == 1) {
ElaboratorContext elaboratorContext(serializer_);
logic_typespec* clone =
(logic_typespec*)clone_tree(ltps, &elaboratorContext);
clone->VpiName("");
((ref_typespec*)ref_tps)->Actual_typespec(clone);
((array_var*)object)->Typespec((ref_typespec*)ref_tps);
}
}
}
}

void SynthSubset::leaveLogic_net(const logic_net* object, vpiHandle handle) {
if (!isInUhdmAllIterator()) return;
((logic_net*) object)->Typespec(nullptr);
}

} // namespace UHDM
6 changes: 6 additions & 0 deletions templates/SynthSubset.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class SynthSubset final : public VpiListener {
// Signed/Unsigned port transform to allow Yosys to Synthesize
void leavePort(const port* object, vpiHandle handle) override;

// Typespec substitution to allow Yosys to perform RAM Inference
void leaveArray_var(const array_var* object, vpiHandle handle) override;

// Remove Typespec information on allModules to allow Yosys to perform RAM Inference
void leaveLogic_net(const logic_net* object, vpiHandle handle) override;

void reportError(const any* object);
void mark(const any* object);
bool reportedParent(const any* object);
Expand Down

0 comments on commit 90a55f7

Please sign in to comment.