Skip to content

Commit

Permalink
Correct generateZeroPad.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Mar 6, 2025
1 parent bc9c332 commit 057107c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compiler/generator/compile_scal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,7 @@ string ScalarCompiler::generatePermVar(Tree sig, Tree x)
string ScalarCompiler::generateZeroPad(Tree sig, Tree x, Tree y)
{
return generateCacheCode(
sig, subst("(($0 % ($1 - 1) == 0) ? $2 : 0)", getCurrentLoopIndex(), CS(y), CS(x)));
sig, subst("(($0 == ($1 - 1)) ? $2 : 0)", getCurrentLoopIndex(), CS(y), CS(x)));
}

// Ondemand: generate the code of the ondemand circuit
Expand Down
5 changes: 2 additions & 3 deletions compiler/generator/instructions_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3549,9 +3549,8 @@ ValueInst* InstructionsCompiler::generatePermVar(Tree sig, Tree x)
ValueInst* InstructionsCompiler::generateZeroPad(Tree sig, Tree x, Tree y)
{
return generateCacheCode(
sig, IB::genSelect2Inst(IB::genEqual(IB::genRem(getCurrentLoopIndex(), FIRIndex(CS(y)) - 1),
IB::genInt32NumInst(0)),
CS(x), IB::genTypedZero(genBasicFIRTyped(sig))));
sig, IB::genSelect2Inst(IB::genEqual(getCurrentLoopIndex(), FIRIndex(CS(y)) - 1), CS(x),
IB::genTypedZero(genBasicFIRTyped(sig))));
}

// Ondemand: generate the code of the ondemand circuit
Expand Down
6 changes: 3 additions & 3 deletions compiler/parallelize/code_loop.hh
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ struct FIRCodeUSblock : public FIRCodeblock {
Code block for downsampling blocks
*/
struct FIRCodeDSblock : public FIRCodeblock {
ValueInst* fDSfactor; ///< downsampling factor
std::string fDSCounter;
ValueInst* fDSfactor; ///< downsampling factor
std::string fDSCounter; ///< downsampling counter

FIRCodeDSblock(ValueInst* ds_factor, const std::string& ds_counter)
: FIRCodeblock(), fDSfactor(ds_factor), fDSCounter(ds_counter)
Expand Down Expand Up @@ -296,7 +296,7 @@ class CodeLoop : public virtual Garbageable {
}

/**
* Close the current/top US block.
* Close the current/top DS block.
*/
void closeDSblock();

Expand Down
6 changes: 3 additions & 3 deletions compiler/parallelize/loop.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct CodeODblock : public Codeblock {
};

struct CodeUSblock : public Codeblock {
std::string fUSfactor; ///< ondemand factor
std::string fUSfactor; ///< upsampling factor
std::string fLoopIndex;

CodeUSblock(const std::string& us_factor) : Codeblock(), fUSfactor(us_factor)
Expand All @@ -74,8 +74,8 @@ struct CodeUSblock : public Codeblock {
};

struct CodeDSblock : public Codeblock {
std::string fDSfactor; ///< ondemand factor
std::string fDSCounter;
std::string fDSfactor; ///< downsampling factor
std::string fDSCounter; ///< downsampling counter

CodeDSblock(const std::string& ds_factor, const std::string& ds_counter)
: Codeblock(), fDSfactor(ds_factor), fDSCounter(ds_counter)
Expand Down

0 comments on commit 057107c

Please sign in to comment.