RTLIL::SigSpec arg = children[0]->genRTLIL(width_hint);
is_signed = type == AST_NEG || (type == AST_POS && children[0]->is_signed);
int width = type == AST_NEG && arg.width < width_hint ? arg.width+1 : arg.width;
- if (width > width_hint && width_hint > 0)
+ if (width_hint > 0)
width = width_hint;
return uniop2rtlil(this, type_name, width, arg);
}
RTLIL::SigSpec left = children[0]->genRTLIL(width_hint);
RTLIL::SigSpec right = children[1]->genRTLIL(width_hint);
int width = std::max(left.width, right.width);
- if (width > width_hint && width_hint > 0)
- width = width_hint;
- if (width < width_hint)
+ if (width_hint > 0)
width = width_hint;
return binop2rtlil(this, type_name, width, left, right);
}
"===" { return OP_EQ; }
"!==" { return OP_NE; }
- /* "~&" { return OP_NAND; } */
- /* "~|" { return OP_NOR; } */
+"~&" { return OP_NAND; }
+"~|" { return OP_NOR; }
"~^" { return OP_XNOR; }
"^~" { return OP_XNOR; }
// operator precedence from low to high
%left OP_LOR
%left OP_LAND
-%left '|'
+%left '|' OP_NOR
%left '^' OP_XNOR
-%left '&'
+%left '&' OP_NAND
%left OP_EQ OP_NE
%left '<' OP_LE OP_GE '>'
%left OP_SHL OP_SHR OP_SSHL OP_SSHR
$$ = new AstNode(AST_REDUCE_AND, $3);
append_attr($$, $2);
} |
+ OP_NAND attr basic_expr %prec UNARY_OPS {
+ $$ = new AstNode(AST_REDUCE_AND, $3);
+ append_attr($$, $2);
+ $$ = new AstNode(AST_LOGIC_NOT, $$);
+ } |
'|' attr basic_expr %prec UNARY_OPS {
$$ = new AstNode(AST_REDUCE_OR, $3);
append_attr($$, $2);
} |
+ OP_NOR attr basic_expr %prec UNARY_OPS {
+ $$ = new AstNode(AST_REDUCE_OR, $3);
+ append_attr($$, $2);
+ $$ = new AstNode(AST_LOGIC_NOT, $$);
+ } |
'^' attr basic_expr %prec UNARY_OPS {
$$ = new AstNode(AST_REDUCE_XOR, $3);
append_attr($$, $2);
if (cell->type == "$_INV_" || cell->type == "$not") {
std::vector<int> a = importSigSpec(cell->connections.at("\\A"), timestep);
std::vector<int> y = importSigSpec(cell->connections.at("\\Y"), timestep);
+ extendSignalWidthUnary(a, y, cell);
ez->assume(ez->vec_eq(ez->vec_not(a), y));
return true;
}
input [A_WIDTH-1:0] A;
output [Y_WIDTH-1:0] Y;
+wire [Y_WIDTH-1:0] A_buf;
+\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
+
genvar i;
generate
for (i = 0; i < Y_WIDTH; i = i + 1) begin:V
- if (i < A_WIDTH) begin
- \$_INV_ gate (
- .A(A[i]),
- .Y(Y[i])
- );
- end else begin
- assign Y[i] = 0;
- end
+ \$_INV_ gate (
+ .A(A_buf[i]),
+ .Y(Y[i])
+ );
end
endgenerate