bitworks/hwo.bitworks/RotateLeft.cs

33 lines
520 B
C#

using System;
namespace hwo.bitworks
{
public class RotateLeft : MultipleBitsSource
{
int n;
public RotateLeft(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();
}
}
}