bitworks/hwo.bitworks/RotateLeft.cs

33 lines
520 B
C#
Raw Permalink Normal View History

2017-06-14 15:06:37 +02:00
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();
}
}
}