Added support for "2**n" shifter encoding
authorClifford Wolf <clifford@clifford.at>
Mon, 12 Aug 2013 12:47:50 +0000 (14:47 +0200)
committerClifford Wolf <clifford@clifford.at>
Mon, 12 Aug 2013 12:47:50 +0000 (14:47 +0200)
frontends/ast/genrtlil.cc
tests/simple/operators.v

index 9c027878aa379a8ddf5d1f25895b19a3afcec3ff..50e9597548390f137f62eee0597203e8a180f00b 100644 (file)
@@ -974,8 +974,12 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
                                        width = width_hint;
                                if (type == AST_MUL)
                                        width = std::min(left.width + right.width, width_hint);
+                               if (type == AST_POW)
+                                       width = width_hint;
                        }
                        is_signed = children[0]->is_signed && children[1]->is_signed;
+                       if (!flag_noopt && type == AST_POW && left.is_fully_const() && left.as_int() == 2)
+                               return binop2rtlil(this, "$shl", width, RTLIL::SigSpec(1, left.width), right);
                        return binop2rtlil(this, type_name, width, left, right);
                }
 
index 6ca6ca7a8ee5539c1f1ec725d39986136e4e445b..7439101c8c28e8ecae9e7959338339eb33606a57 100644 (file)
@@ -86,30 +86,35 @@ always @(posedge clk) begin
                58: y <= s1 % u2;
                59: y <= s1 % s2;
 
-               60: y <= +u1;
-               61: y <= -u1;
-               62: y <= ~u1;
-               63: y <= !u1;
-
-               64: y <= +s1;
-               65: y <= -s1;
-               66: y <= ~s1;
-               67: y <= !s1;
-
-               68: y <= { &u1, ~&u1, |u1, ~|u1, ^u1, ~^u1, ^~u1 };
-               69: y <= { &s1, ~&s1, |s1, ~|s1, ^s1, ~^s1, ^~s1 };
-               70: y <= { &u1[1:0], ~&u1[1:0], |u1[1:0], ~|u1[1:0], ^u1[1:0], ~^u1[1:0], ^~u1[1:0] };
-               71: y <= { &s1[1:0], ~&s1[1:0], |s1[1:0], ~|s1[1:0], ^s1[1:0], ~^s1[1:0], ^~s1[1:0] };
-
-               72: y <= { u1[1:0] && u2[1:0], u1[1:0] && u2[1:0], !u1[1:0] };
-               73: y <= {4{u1[1:0]}};
-               74: y <= {u1, u2} ^ {s1, s2};
-               75: y <= {u1, u2} & {s1, s2};
-
-               76: y <= u1[0] ? u1 : u2;
-               77: y <= u1[0] ? u1 : s2;
-               78: y <= u1[0] ? s1 : u2;
-               79: y <= u1[0] ? s1 : s2;
+               60: y <= 4'd2 ** u1;
+               61: y <= 4'd2 ** s1;
+               62: y <= 4'sd2 ** u1;
+               63: y <= 4'sd2 ** s1;
+
+               64: y <= +u1;
+               65: y <= -u1;
+               66: y <= ~u1;
+               67: y <= !u1;
+
+               68: y <= +s1;
+               69: y <= -s1;
+               70: y <= ~s1;
+               71: y <= !s1;
+
+               72: y <= { &u1, ~&u1, |u1, ~|u1, ^u1, ~^u1, ^~u1 };
+               73: y <= { &s1, ~&s1, |s1, ~|s1, ^s1, ~^s1, ^~s1 };
+               74: y <= { &u1[1:0], ~&u1[1:0], |u1[1:0], ~|u1[1:0], ^u1[1:0], ~^u1[1:0], ^~u1[1:0] };
+               75: y <= { &s1[1:0], ~&s1[1:0], |s1[1:0], ~|s1[1:0], ^s1[1:0], ~^s1[1:0], ^~s1[1:0] };
+
+               76: y <= { u1[1:0] && u2[1:0], u1[1:0] && u2[1:0], !u1[1:0] };
+               77: y <= {4{u1[1:0]}};
+               78: y <= {u1, u2} ^ {s1, s2};
+               79: y <= {u1, u2} & {s1, s2};
+
+               80: y <= u1[0] ? u1 : u2;
+               81: y <= u1[0] ? u1 : s2;
+               82: y <= u1[0] ? s1 : u2;
+               83: y <= u1[0] ? s1 : s2;
        endcase
 end