bitworks/hwo.bitworks/RotateRight.cs

33 lines
519 B
C#

using System;
namespace hwo.bitworks
{
public class RotateRight : MultipleBitsSource
{
int n;
public RotateRight(LogicBase[] sources,int n)
:base(sources)
{
this.n = n;
}
public override bool bitValue(int bit)
{
int m = (bit + n) % getBits();
if (m < 0)
m += getBits();
return sources[m].value();
}
public override identity.BitIdentity getBitIdentity(int bit)
{
int m = (bit + n) % getBits();
if (m < 0)
m += getBits();
return sources[m].identity();
}
}
}