From ccd3f1864c4d3b93e95491dc403b52c5034e5e70 Mon Sep 17 00:00:00 2001 From: hneemann Date: Thu, 11 Jul 2019 15:03:23 +0200 Subject: [PATCH] improved the generic barrel-shifter --- src/main/dig/generic/barrelShifter/Test.dig | 30 +++++++------- .../generic/barrelShifter/barrelShifter.dig | 20 ++++++++-- .../dig/generic/barrelShifter/shift-inc.dig | 39 ++++--------------- 3 files changed, 39 insertions(+), 50 deletions(-) diff --git a/src/main/dig/generic/barrelShifter/Test.dig b/src/main/dig/generic/barrelShifter/Test.dig index eb72ae459..9a36ccc61 100644 --- a/src/main/dig/generic/barrelShifter/Test.dig +++ b/src/main/dig/generic/barrelShifter/Test.dig @@ -19,7 +19,7 @@ bin - + In @@ -41,7 +41,7 @@ - + In @@ -55,7 +55,7 @@ 5 - + barrelShifter.dig @@ -70,7 +70,7 @@ dir := "left"; - + Out @@ -162,7 +162,7 @@ end loop - + Testcase @@ -373,10 +373,6 @@ end loop - - - - @@ -385,6 +381,14 @@ end loop + + + + + + + + @@ -401,17 +405,13 @@ end loop - - - - - - + + diff --git a/src/main/dig/generic/barrelShifter/barrelShifter.dig b/src/main/dig/generic/barrelShifter/barrelShifter.dig index 5f7d26772..96dba8991 100644 --- a/src/main/dig/generic/barrelShifter/barrelShifter.dig +++ b/src/main/dig/generic/barrelShifter/barrelShifter.dig @@ -88,11 +88,23 @@ generic dataBits:=16; shiftBits:=int(4); -dir:="left"; +circuit:="shift-fixed-left-inc.dig"; if (isPresent(args)) { - dir=args.dir; - dataBits=args.dataBits; - shiftBits=bitsNeededFor(args.dataBits-1); + + if (args.dir="right") { + circuit="shift-fixed-right-inc.dig"; + } else { + if (args.dir="arith") { + circuit="shift-fixed-arith-right-inc.dig"; + } else { + if (args.dir!="left") { + panic("only \"left\", \"right\" or \"arith\" is allowed as direction, not \""+args.dir+"\"!"); + } + } + } + + dataBits=args.dataBits; + shiftBits=bitsNeededFor(args.dataBits-1); } diff --git a/src/main/dig/generic/barrelShifter/shift-inc.dig b/src/main/dig/generic/barrelShifter/shift-inc.dig index 6b5d45a4f..534259d0b 100644 --- a/src/main/dig/generic/barrelShifter/shift-inc.dig +++ b/src/main/dig/generic/barrelShifter/shift-inc.dig @@ -18,17 +18,7 @@ shift:=8; if (isPresent(args)) { dataBits = args.dataBits; shift = 1<<(args.shiftBits-1); - if (args.dir="right") { - setCircuit("shift-fixed-right-inc.dig"); - } else { - if (args.dir="arith") { - setCircuit("shift-fixed-arith-right-inc.dig"); - } else { - if (args.dir!="left") { - panic("only \"left\", \"right\" or \"arith\" is allowed as direction, not \""+args.dir+"\"!"); - } - } - } + setCircuit(args.circuit); } @@ -109,29 +99,16 @@ if (isPresent(args)) { generic dataBits:=16; shiftBits:=3; -dir:="left"; +circuit:="shift-fixed-left-inc.dig"; if (isPresent(args)) { - dataBits = args.dataBits; - shiftBits = args.shiftBits-1; - dir=args.dir; - if (args.shiftBits=2) { - - export shift := 1; - if (args.dir="right") { - setCircuit("shift-fixed-right-inc.dig"); + dataBits = args.dataBits; + if (args.shiftBits=2) { + export shift := 1; + setCircuit(args.circuit); } else { - if (args.dir="arith") { - setCircuit("shift-fixed-arith-right-inc.dig"); - } else { - if (args.dir!="left") { - panic("only \"left\", \"right\" or \"arith\" is allowed as direction, not \""+args.dir+"\"!"); - } - setCircuit("shift-fixed-left-inc.dig"); - } + shiftBits = args.shiftBits-1; + circuit=args.circuit; } - - - } }