Skip to content

Commit

Permalink
fixed an issue where sameas could not be used together with auto when…
Browse files Browse the repository at this point in the history
… output was bound to a module (test: auto1.si)
  • Loading branch information
sylefeb committed Jun 30, 2022
1 parent 094d2b3 commit 17b581a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/Algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5008,7 +5008,7 @@ void Algorithm::determineUsage()

// -------------------------------------------------

void Algorithm::determineBlueprintBoundVIO()
void Algorithm::determineBlueprintBoundVIO(const t_instantiation_context& ictx)
{
// find out vio bound to a blueprint output
for (const auto& ib : m_InstancedBlueprints) {
Expand All @@ -5027,7 +5027,7 @@ void Algorithm::determineBlueprintBoundVIO()
part_access = true;
// check width of output vs range width
// -> get output width
string obw = ib.second.blueprint->resolveWidthOf(b.left, t_instantiation_context(), sourceloc(access));
string obw = ib.second.blueprint->resolveWidthOf(b.left, ictx, sourceloc(access));
int iobw;
try {
iobw = stoi(obw);
Expand All @@ -5041,7 +5041,7 @@ void Algorithm::determineBlueprintBoundVIO()
reportError(sourceloc(access), "bound vio '%s' selected width is smaller than output '%s' width", bindingRightIdentifier(b).c_str(), b.left.c_str());
}
// -> get bound var width
string bbw = resolveWidthOf(bindingRightIdentifier(b), t_instantiation_context(), sourceloc(access));
string bbw = resolveWidthOf(bindingRightIdentifier(b), ictx, sourceloc(access));
int ibbw;
try {
ibbw = stoi(bbw);
Expand Down Expand Up @@ -5512,7 +5512,7 @@ void Algorithm::resolveInOuts()

// -------------------------------------------------

void Algorithm::optimize()
void Algorithm::optimize(const t_instantiation_context& ictx)
{
if (!m_Optimized) {
// NOTE: recalls the algorithm is optimized, as it can be used by multiple instances
Expand All @@ -5523,7 +5523,7 @@ void Algorithm::optimize()
// resolve inouts
resolveInOuts();
// determine which VIO are bound
determineBlueprintBoundVIO();
determineBlueprintBoundVIO(ictx);
// analyze instances inputs
analyzeInstancedBlueprintInputs();
// check var access permissions
Expand Down Expand Up @@ -7670,7 +7670,7 @@ void Algorithm::writeAsModule(SiliceCompiler *compiler, std::ostream &out, const
/// first pass

// optimize
optimize();
optimize(ictx);
// lint upon instantiation
lint(ictx);

Expand Down
4 changes: 2 additions & 2 deletions src/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ namespace Silice
/// \brief verify member in bitfield
void verifyMemberBitfield(std::string member, siliceParser::BitfieldContext* group) const;
/// \brief run optimizations
void optimize();
void optimize(const t_instantiation_context& ictx);
///\brief Runs the linter on the algorithm, at instantiation time
void lint(const t_instantiation_context &ictx);

Expand Down Expand Up @@ -885,7 +885,7 @@ namespace Silice
/// \brief analyze variables access and classifies variables
void determineUsage();
/// \brief determines the list of bound VIO
void determineBlueprintBoundVIO();
void determineBlueprintBoundVIO(const t_instantiation_context& ictx);
/// \brief analyze the subroutine calls
void analyzeSubroutineCalls();
/// \brief analyze usage of inputs of instanced blueprints
Expand Down
24 changes: 24 additions & 0 deletions tests/auto1.si
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
unit foo(input uint1 p,output uint1 q)
{
always {
q = p;
}
}

unit test(input auto a,output sameas(a) b)
{
foo _(p <: a[0,1], q :> b[0,1]);
// ^^^^^^ error due to sameas
}

unit main(output uint8 leds)
{
uint8 v(15);
uint8 w(15);
test bla(a <: v, b :> w);

always {
//__display("b : %d");
__finish();
}
}

0 comments on commit 17b581a

Please sign in to comment.