diff --git a/src/main/dig/generic/barrelShifter/TestBarrelShifter2.dig b/src/main/dig/generic/barrelShifter/TestBarrelShifter2.dig
new file mode 100644
index 000000000..4f7412cf6
--- /dev/null
+++ b/src/main/dig/generic/barrelShifter/TestBarrelShifter2.dig
@@ -0,0 +1,530 @@
+
+
+ 1
+
+
+
+ Out
+
+
+ Label
+ D^32
+
+
+ Bits
+ 32
+
+
+ intFormat
+ bin
+
+
+
+
+
+ In
+
+
+ Label
+ D^32_in
+
+
+ Bits
+ 32
+
+
+ intFormat
+ bin
+
+
+ InDefault
+
+
+
+
+
+
+ In
+
+
+ Label
+ sh^32
+
+
+ Bits
+ 5
+
+
+
+
+
+ barrelShifter2.dig
+
+
+ Label
+ 32 bit, left
+
+
+ generic
+ dataBits := 32;
+direction := "left";
+
+
+
+
+
+ Out
+
+
+ Label
+ D^8
+
+
+ Bits
+ 8
+
+
+ intFormat
+ bin
+
+
+
+
+
+ In
+
+
+ Label
+ D^8_in
+
+
+ Bits
+ 8
+
+
+ intFormat
+ bin
+
+
+ InDefault
+
+
+
+
+
+
+ In
+
+
+ Label
+ sh^8
+
+
+ Bits
+ 3
+
+
+
+
+
+ barrelShifter2.dig
+
+
+ Label
+ 8 bit, left
+
+
+ generic
+ dataBits := 8;
+direction := "left";
+
+
+
+
+
+ Testcase
+
+
+ Label
+ 32 bit, left
+
+
+ Testdata
+
+ D^32_in sh^32 D^32
+loop(n,32)
+ 1 (n) (1<<n)
+end loop
+
+loop(n,32)
+ 7 (n) (7<<n)
+end loop
+
+
+
+
+
+
+ Testcase
+
+
+ Label
+ 8 bit, left
+
+
+ Testdata
+
+ D^8_in sh^8 D^8
+loop(n,8)
+ 1 (n) (1<<n)
+end loop
+
+loop(n,8)
+ 7 (n) (7<<n)
+end loop
+
+
+
+
+
+
+ Out
+
+
+ Label
+ D^8_R
+
+
+ Bits
+ 8
+
+
+ intFormat
+ bin
+
+
+
+
+
+ In
+
+
+ Label
+ D^8_inR
+
+
+ Bits
+ 8
+
+
+ intFormat
+ bin
+
+
+ InDefault
+
+
+
+
+
+
+ In
+
+
+ Label
+ sh^8_R
+
+
+ Bits
+ 3
+
+
+
+
+
+ barrelShifter2.dig
+
+
+ Label
+ 8 bit, right
+
+
+ generic
+ dataBits := 8;
+direction := "right";
+
+
+
+
+
+ Testcase
+
+
+ Label
+ 8 bit, right
+
+
+ Testdata
+
+ D^8_inR sh^8_R D^8_R
+loop(n,8)
+ 128 (n) (128>>n)
+end loop
+
+loop(n,8)
+ 192 (n) (192>>n)
+end loop
+
+
+
+
+
+
+ Out
+
+
+ Label
+ D^16
+
+
+ Bits
+ 16
+
+
+ intFormat
+ bin
+
+
+
+
+
+ In
+
+
+ Label
+ D^16_in
+
+
+ Bits
+ 16
+
+
+ intFormat
+ bin
+
+
+ InDefault
+
+
+
+
+
+
+ In
+
+
+ Label
+ sh^16
+
+
+ Bits
+ 4
+
+
+
+
+
+ barrelShifter2.dig
+
+
+ Label
+ 16 bit, right, arith
+
+
+ generic
+ dataBits := 16;
+direction := "arith";
+
+
+
+
+
+ Testcase
+
+
+ Label
+ 16 bit, right arith
+
+
+ Testdata
+
+ D^16_in sh^16 D^16
+loop(n,16)
+ (1<<14) (n) ((1<<14)>>n)
+end loop
+
+loop(n,16)
+ (1<<15) (n) (-1<<(15-n))
+end loop
+
+
+
+
+
+
+ Out
+
+
+ Label
+ D^64
+
+
+ Bits
+ 64
+
+
+ intFormat
+ bin
+
+
+
+
+
+ In
+
+
+ Label
+ D^64_in
+
+
+ Bits
+ 64
+
+
+ intFormat
+ bin
+
+
+ InDefault
+
+
+
+
+
+
+ In
+
+
+ Label
+ sh^64
+
+
+ Bits
+ 6
+
+
+
+
+
+ barrelShifter2.dig
+
+
+ Label
+ 64 bit, left
+
+
+ generic
+ dataBits := 64;
+direction := "left";
+
+
+
+
+
+ Testcase
+
+
+ Label
+ 64 bit, left
+
+
+ Testdata
+
+ D^64_in sh^64 D^64
+loop(n,64)
+ 1 (n) (1<<n)
+end loop
+
+loop(n,64)
+ 7 (n) (7<<n)
+end loop
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/dig/generic/barrelShifter/barrelShifter.dig b/src/main/dig/generic/barrelShifter/barrelShifter.dig
index 3ee714b68..250127157 100644
--- a/src/main/dig/generic/barrelShifter/barrelShifter.dig
+++ b/src/main/dig/generic/barrelShifter/barrelShifter.dig
@@ -214,6 +214,17 @@ direction := "arith";
+
+ Text
+
+
+ Description
+ A BarrelShifter implemented using recursion.
+{{de Ein rekursiv implementierter BarrelShifter.}}
+
+
+
+
diff --git a/src/main/dig/generic/barrelShifter/barrelShifter2.dig b/src/main/dig/generic/barrelShifter/barrelShifter2.dig
new file mode 100644
index 000000000..56f4d3c1d
--- /dev/null
+++ b/src/main/dig/generic/barrelShifter/barrelShifter2.dig
@@ -0,0 +1,139 @@
+
+
+ 1
+
+
+ isGeneric
+ true
+
+
+
+
+ In
+
+
+ Label
+ D
+
+
+ Bits
+ 2
+
+
+ generic
+ this.Bits=args.dataBits;
+
+
+
+
+
+ GenericInitCode
+
+
+ generic
+ dataBits:=16;
+direction:="left";
+
+
+
+
+
+ GenericCode
+
+
+ generic
+ sh:=bitsNeededFor(args.dataBits)-1;
+
+circuit:="";
+if (args.direction="right") {
+ circuit="shift-fixed-right-inc.dig";
+} else {
+ if (args.direction="arith") {
+ circuit="shift-fixed-arith-right-inc.dig";
+ } else {
+ if (args.direction="left") {
+ circuit="shift-fixed-left-inc.dig";
+ } else {
+ panic("only \"left\", \"right\" or \"arith\" is allowed as direction, not \""+args.direction+"\"!");
+ }
+ }
+}
+
+
+for (i:=0;i<sh;i++) {
+ x:= i*5+2;
+ s:=addComponent(circuit,x,0);
+ s.shift:=1<<i;
+
+ addWire(x+3,1,x+5,0);
+
+ addWire(0,i+5,x-1,i+5);
+ addWire(x-1,i+5,x-1,2);
+ addWire(x-1,2,x,2);
+}
+
+o:=addComponent("Out",sh*5+2,0);
+o.Bits=args.dataBits;
+o.Label="Out";
+
+
+
+
+
+ In
+
+
+ Label
+ sh
+
+
+ generic
+ this.Bits=bitsNeededFor(args.dataBits)-1;
+
+
+
+
+
+ Splitter
+
+
+ Input Splitting
+ 2
+
+
+ generic
+ sh:=bitsNeededFor(args.dataBits)-1;
+this.'Input Splitting'=""+sh;
+this.'Output Splitting'="1*"+sh;
+
+
+ Output Splitting
+ 1,1
+
+
+
+
+
+ Text
+
+
+ Description
+ A BarrelShifter implemented using component creation.
+{{de Ein BarrelShifter implementiert durch Bauteilerzeugung.}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/java/de/neemann/digital/integration/TestExamples.java b/src/test/java/de/neemann/digital/integration/TestExamples.java
index ae7879cef..1d844da01 100644
--- a/src/test/java/de/neemann/digital/integration/TestExamples.java
+++ b/src/test/java/de/neemann/digital/integration/TestExamples.java
@@ -40,8 +40,8 @@ public class TestExamples extends TestCase {
*/
public void testDistExamples() throws Exception {
File examples = new File(Resources.getRoot().getParentFile().getParentFile(), "/main/dig");
- assertEquals(309, new FileScanner(this::check).scan(examples));
- assertEquals(495, testCasesInFiles);
+ assertEquals(311, new FileScanner(this::check).scan(examples));
+ assertEquals(500, testCasesInFiles);
}
/**