Added support for "2**n" shifter encoding

This commit is contained in:
Clifford Wolf 2013-08-12 14:47:50 +02:00
parent ccf36cb7d8
commit 759852914d
2 changed files with 29 additions and 20 deletions

View 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);
}

View 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;
60: y <= 4'd2 ** u1;
61: y <= 4'd2 ** s1;
62: y <= 4'sd2 ** u1;
63: y <= 4'sd2 ** s1;
64: y <= +s1;
65: y <= -s1;
66: y <= ~s1;
67: y <= !s1;
64: y <= +u1;
65: y <= -u1;
66: y <= ~u1;
67: y <= !u1;
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] };
68: y <= +s1;
69: y <= -s1;
70: y <= ~s1;
71: y <= !s1;
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};
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[0] ? u1 : u2;
77: y <= u1[0] ? u1 : s2;
78: y <= u1[0] ? s1 : u2;
79: y <= u1[0] ? s1 : s2;
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