Binary operators¶
All binary RTL cells have two input ports A
and B
and one output port
Y
. They also have the following parameters:
A_SIGNED
Set to a non-zero value if the input
A
is signed and therefore should be sign-extended when needed.A_WIDTH
The width of the input port
A
.B_SIGNED
Set to a non-zero value if the input
B
is signed and therefore should be sign-extended when needed.B_WIDTH
The width of the input port
B
.Y_WIDTH
The width of the output port
Y
.
Verilog |
Cell Type |
Verilog |
Cell Type |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
The $shl
and $shr
cells implement logical shifts, whereas the $sshl
and
$sshr
cells implement arithmetic shifts. The $shl
and $sshl
cells
implement the same operation. All four of these cells interpret the second
operand as unsigned, and require B_SIGNED
to be zero.
Two additional shift operator cells are available that do not directly
correspond to any operator in Verilog, $shift
and $shiftx
. The $shift
cell
performs a right logical shift if the second operand is positive (or unsigned),
and a left logical shift if it is negative. The $shiftx
cell performs the same
operation as the $shift
cell, but the vacated bit positions are filled with
undef (x) bits, and corresponds to the Verilog indexed part-select expression.
For the binary cells that output a logical value ($logic_and
, $logic_or
,
$eqx
, $nex
, $lt
, $le
, $eq
, $ne
, $ge
, $gt
), when the Y_WIDTH
parameter is greater than 1, the output is zero-extended, and only the least
significant bit varies.
Division and modulo cells are available in two rounding modes. The original
$div
and $mod
cells are based on truncating division, and correspond to the
semantics of the verilog /
and %
operators. The $divfloor
and
$modfloor
cells represent flooring division and flooring modulo, the latter of
which corresponds to the %
operator in Python. See the following table for a
side-by-side comparison between the different semantics.
Division |
Result |
Truncating |
Flooring |
||
---|---|---|---|---|---|
$div |
$mod |
$divfloor |
$modfloor |
||
-10 / 3 |
-3.3 |
-3 |
-1 |
-4 |
2 |
10 / -3 |
-3.3 |
-3 |
1 |
-4 |
-2 |
-10 / -3 |
3.3 |
3 |
-1 |
3 |
-1 |
10 / 3 |
3.3 |
3 |
1 |
3 |
1 |
- yosys> help $add¶
Addition of inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘+’ operator.
- Properties:
- Simulation model (verilog)¶
973module \$add (A, B, Y); 974 975 parameter A_SIGNED = 0; 976 parameter B_SIGNED = 0; 977 parameter A_WIDTH = 0; 978 parameter B_WIDTH = 0; 979 parameter Y_WIDTH = 0; 980 981 input [A_WIDTH-1:0] A; 982 input [B_WIDTH-1:0] B; 983 output [Y_WIDTH-1:0] Y; 984 985 generate 986 if (A_SIGNED && B_SIGNED) begin:BLOCK1 987 assign Y = $signed(A) + $signed(B); 988 end else begin:BLOCK2 989 assign Y = A + B; 990 end 991 endgenerate 992 993endmodule
- yosys> help $and¶
A bit-wise AND. This corresponds to the Verilog ‘&’ operator.
- Properties:
- Simulation model (verilog)¶
146module \$and (A, B, Y); 147 148 parameter A_SIGNED = 0; 149 parameter B_SIGNED = 0; 150 parameter A_WIDTH = 0; 151 parameter B_WIDTH = 0; 152 parameter Y_WIDTH = 0; 153 154 input [A_WIDTH-1:0] A; 155 input [B_WIDTH-1:0] B; 156 output [Y_WIDTH-1:0] Y; 157 158 generate 159 if (A_SIGNED && B_SIGNED) begin:BLOCK1 160 assign Y = $signed(A) & $signed(B); 161 end else begin:BLOCK2 162 assign Y = A & B; 163 end 164 endgenerate 165 166endmodule
- yosys> help $bweqx¶
Bit-wise case equality
A bit-wise version of
$eqx
.- Properties:
- Simulation model (verilog)¶
2005module \$bweqx (A, B, Y); 2006 2007 parameter WIDTH = 0; 2008 2009 input [WIDTH-1:0] A, B; 2010 output [WIDTH-1:0] Y; 2011 2012 genvar i; 2013 generate 2014 for (i = 0; i < WIDTH; i = i + 1) begin:slices 2015 assign Y[i] = A[i] === B[i]; 2016 end 2017 endgenerate 2018 2019endmodule
- yosys> help $div¶
Divider
This corresponds to the Verilog ‘/’ operator, performing division and truncating the result (rounding towards 0).
- Properties:
- Simulation model (verilog)¶
1332module \$div (A, B, Y); 1333 1334 parameter A_SIGNED = 0; 1335 parameter B_SIGNED = 0; 1336 parameter A_WIDTH = 0; 1337 parameter B_WIDTH = 0; 1338 parameter Y_WIDTH = 0; 1339 1340 input [A_WIDTH-1:0] A; 1341 input [B_WIDTH-1:0] B; 1342 output [Y_WIDTH-1:0] Y; 1343 1344 generate 1345 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1346 assign Y = $signed(A) / $signed(B); 1347 end else begin:BLOCK2 1348 assign Y = A / B; 1349 end 1350 endgenerate 1351 1352endmodule
- yosys> help $divfloor¶
Division with floored result (rounded towards negative infinity).
- Properties:
- Simulation model (verilog)¶
1395module \$divfloor (A, B, Y); 1396 1397 parameter A_SIGNED = 0; 1398 parameter B_SIGNED = 0; 1399 parameter A_WIDTH = 0; 1400 parameter B_WIDTH = 0; 1401 parameter Y_WIDTH = 0; 1402 1403 input [A_WIDTH-1:0] A; 1404 input [B_WIDTH-1:0] B; 1405 output [Y_WIDTH-1:0] Y; 1406 1407 generate 1408 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1409 localparam WIDTH = 1410 A_WIDTH >= B_WIDTH && A_WIDTH >= Y_WIDTH ? A_WIDTH : 1411 B_WIDTH >= A_WIDTH && B_WIDTH >= Y_WIDTH ? B_WIDTH : Y_WIDTH; 1412 wire [WIDTH:0] A_buf, B_buf, N_buf; 1413 assign A_buf = $signed(A); 1414 assign B_buf = $signed(B); 1415 assign N_buf = (A[A_WIDTH-1] == B[B_WIDTH-1]) || A == 0 ? A_buf : $signed(A_buf - (B[B_WIDTH-1] ? B_buf+1 : B_buf-1)); 1416 assign Y = $signed(N_buf) / $signed(B_buf); 1417 end else begin:BLOCK2 1418 assign Y = A / B; 1419 end 1420 endgenerate 1421 1422endmodule
- yosys> help $eq¶
An equality comparison between inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘==’ operator.
- Properties:
- Simulation model (verilog)¶
782module \$eq (A, B, Y); 783 784 parameter A_SIGNED = 0; 785 parameter B_SIGNED = 0; 786 parameter A_WIDTH = 0; 787 parameter B_WIDTH = 0; 788 parameter Y_WIDTH = 0; 789 790 input [A_WIDTH-1:0] A; 791 input [B_WIDTH-1:0] B; 792 output [Y_WIDTH-1:0] Y; 793 794 generate 795 if (A_SIGNED && B_SIGNED) begin:BLOCK1 796 assign Y = $signed(A) == $signed(B); 797 end else begin:BLOCK2 798 assign Y = A == B; 799 end 800 endgenerate 801 802endmodule
- yosys> help $eqx¶
Case equality
An exact equality comparison between inputs ‘A’ and ‘B’. Also known as the case equality operator. This corresponds to the Verilog ‘===’ operator. Unlike equality comparison that can give ‘x’ as output, an exact equality comparison will strictly give ‘0’ or ‘1’ as output, even if input includes ‘x’ or ‘z’ values.
- Properties:
- Simulation model (verilog)¶
847module \$eqx (A, B, Y); 848 849 parameter A_SIGNED = 0; 850 parameter B_SIGNED = 0; 851 parameter A_WIDTH = 0; 852 parameter B_WIDTH = 0; 853 parameter Y_WIDTH = 0; 854 855 input [A_WIDTH-1:0] A; 856 input [B_WIDTH-1:0] B; 857 output [Y_WIDTH-1:0] Y; 858 859 generate 860 if (A_SIGNED && B_SIGNED) begin:BLOCK1 861 assign Y = $signed(A) === $signed(B); 862 end else begin:BLOCK2 863 assign Y = A === B; 864 end 865 endgenerate 866 867endmodule
- yosys> help $ge¶
A greater-than-or-equal-to comparison between inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘>=’ operator.
- Properties:
- Simulation model (verilog)¶
910module \$ge (A, B, Y); 911 912 parameter A_SIGNED = 0; 913 parameter B_SIGNED = 0; 914 parameter A_WIDTH = 0; 915 parameter B_WIDTH = 0; 916 parameter Y_WIDTH = 0; 917 918 input [A_WIDTH-1:0] A; 919 input [B_WIDTH-1:0] B; 920 output [Y_WIDTH-1:0] Y; 921 922 generate 923 if (A_SIGNED && B_SIGNED) begin:BLOCK1 924 assign Y = $signed(A) >= $signed(B); 925 end else begin:BLOCK2 926 assign Y = A >= B; 927 end 928 endgenerate 929 930endmodule
- yosys> help $gt¶
A greater-than comparison between inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘>’ operator.
- Properties:
- Simulation model (verilog)¶
942module \$gt (A, B, Y); 943 944 parameter A_SIGNED = 0; 945 parameter B_SIGNED = 0; 946 parameter A_WIDTH = 0; 947 parameter B_WIDTH = 0; 948 parameter Y_WIDTH = 0; 949 950 input [A_WIDTH-1:0] A; 951 input [B_WIDTH-1:0] B; 952 output [Y_WIDTH-1:0] Y; 953 954 generate 955 if (A_SIGNED && B_SIGNED) begin:BLOCK1 956 assign Y = $signed(A) > $signed(B); 957 end else begin:BLOCK2 958 assign Y = A > B; 959 end 960 endgenerate 961 962endmodule
- yosys> help $le¶
A less-than-or-equal-to comparison between inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘<=’ operator.
- Properties:
- Simulation model (verilog)¶
750module \$le (A, B, Y); 751 752 parameter A_SIGNED = 0; 753 parameter B_SIGNED = 0; 754 parameter A_WIDTH = 0; 755 parameter B_WIDTH = 0; 756 parameter Y_WIDTH = 0; 757 758 input [A_WIDTH-1:0] A; 759 input [B_WIDTH-1:0] B; 760 output [Y_WIDTH-1:0] Y; 761 762 generate 763 if (A_SIGNED && B_SIGNED) begin:BLOCK1 764 assign Y = $signed(A) <= $signed(B); 765 end else begin:BLOCK2 766 assign Y = A <= B; 767 end 768 endgenerate 769 770endmodule
- yosys> help $logic_and¶
A logical AND. This corresponds to the Verilog ‘&&’ operator.
- Properties:
- Simulation model (verilog)¶
1541module \$logic_and (A, B, Y); 1542 1543 parameter A_SIGNED = 0; 1544 parameter B_SIGNED = 0; 1545 parameter A_WIDTH = 0; 1546 parameter B_WIDTH = 0; 1547 parameter Y_WIDTH = 0; 1548 1549 input [A_WIDTH-1:0] A; 1550 input [B_WIDTH-1:0] B; 1551 output [Y_WIDTH-1:0] Y; 1552 1553 generate 1554 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1555 assign Y = $signed(A) && $signed(B); 1556 end else begin:BLOCK2 1557 assign Y = A && B; 1558 end 1559 endgenerate 1560 1561endmodule
- yosys> help $logic_or¶
A logical OR. This corresponds to the Verilog ‘||’ operator.
- Properties:
- Simulation model (verilog)¶
1572module \$logic_or (A, B, Y); 1573 1574 parameter A_SIGNED = 0; 1575 parameter B_SIGNED = 0; 1576 parameter A_WIDTH = 0; 1577 parameter B_WIDTH = 0; 1578 parameter Y_WIDTH = 0; 1579 1580 input [A_WIDTH-1:0] A; 1581 input [B_WIDTH-1:0] B; 1582 output [Y_WIDTH-1:0] Y; 1583 1584 generate 1585 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1586 assign Y = $signed(A) || $signed(B); 1587 end else begin:BLOCK2 1588 assign Y = A || B; 1589 end 1590 endgenerate 1591 1592endmodule
- yosys> help $lt¶
A less-than comparison between inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘<’ operator.
- Properties:
- Simulation model (verilog)¶
718module \$lt (A, B, Y); 719 720 parameter A_SIGNED = 0; 721 parameter B_SIGNED = 0; 722 parameter A_WIDTH = 0; 723 parameter B_WIDTH = 0; 724 parameter Y_WIDTH = 0; 725 726 input [A_WIDTH-1:0] A; 727 input [B_WIDTH-1:0] B; 728 output [Y_WIDTH-1:0] Y; 729 730 generate 731 if (A_SIGNED && B_SIGNED) begin:BLOCK1 732 assign Y = $signed(A) < $signed(B); 733 end else begin:BLOCK2 734 assign Y = A < B; 735 end 736 endgenerate 737 738endmodule
- yosys> help $mod¶
Modulo
This corresponds to the Verilog ‘%’ operator, giving the module (or remainder) of division and truncating the result (rounding towards 0).
Invariant: $div(A, B) * B + $mod(A, B) == A
- Properties:
- Simulation model (verilog)¶
1364module \$mod (A, B, Y); 1365 1366 parameter A_SIGNED = 0; 1367 parameter B_SIGNED = 0; 1368 parameter A_WIDTH = 0; 1369 parameter B_WIDTH = 0; 1370 parameter Y_WIDTH = 0; 1371 1372 input [A_WIDTH-1:0] A; 1373 input [B_WIDTH-1:0] B; 1374 output [Y_WIDTH-1:0] Y; 1375 1376 generate 1377 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1378 assign Y = $signed(A) % $signed(B); 1379 end else begin:BLOCK2 1380 assign Y = A % B; 1381 end 1382 endgenerate 1383 1384endmodule
- yosys> help $modfloor¶
Modulo/remainder of division with floored result (rounded towards negative infinity).
Invariant: $divfloor(A, B) * B + $modfloor(A, B) == A
- Properties:
- Simulation model (verilog)¶
1435module \$modfloor (A, B, Y); 1436 1437 parameter A_SIGNED = 0; 1438 parameter B_SIGNED = 0; 1439 parameter A_WIDTH = 0; 1440 parameter B_WIDTH = 0; 1441 parameter Y_WIDTH = 0; 1442 1443 input [A_WIDTH-1:0] A; 1444 input [B_WIDTH-1:0] B; 1445 output [Y_WIDTH-1:0] Y; 1446 1447 generate 1448 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1449 localparam WIDTH = B_WIDTH >= Y_WIDTH ? B_WIDTH : Y_WIDTH; 1450 wire [WIDTH-1:0] B_buf, Y_trunc; 1451 assign B_buf = $signed(B); 1452 assign Y_trunc = $signed(A) % $signed(B); 1453 // flooring mod is the same as truncating mod for positive division results (A and B have 1454 // the same sign), as well as when there's no remainder. 1455 // For all other cases, they behave as `floor - trunc = B` 1456 assign Y = (A[A_WIDTH-1] == B[B_WIDTH-1]) || Y_trunc == 0 ? Y_trunc : $signed(B_buf) + $signed(Y_trunc); 1457 end else begin:BLOCK2 1458 // no difference between truncating and flooring for unsigned 1459 assign Y = A % B; 1460 end 1461 endgenerate 1462 1463endmodule
- yosys> help $mul¶
Multiplication of inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘*’ operator.
- Properties:
- Simulation model (verilog)¶
1037module \$mul (A, B, Y); 1038 1039 parameter A_SIGNED = 0; 1040 parameter B_SIGNED = 0; 1041 parameter A_WIDTH = 0; 1042 parameter B_WIDTH = 0; 1043 parameter Y_WIDTH = 0; 1044 1045 input [A_WIDTH-1:0] A; 1046 input [B_WIDTH-1:0] B; 1047 output [Y_WIDTH-1:0] Y; 1048 1049 generate 1050 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1051 assign Y = $signed(A) * $signed(B); 1052 end else begin:BLOCK2 1053 assign Y = A * B; 1054 end 1055 endgenerate 1056 1057endmodule
- yosys> help $ne¶
An inequality comparison between inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘!=’ operator.
- Properties:
- Simulation model (verilog)¶
814module \$ne (A, B, Y); 815 816 parameter A_SIGNED = 0; 817 parameter B_SIGNED = 0; 818 parameter A_WIDTH = 0; 819 parameter B_WIDTH = 0; 820 parameter Y_WIDTH = 0; 821 822 input [A_WIDTH-1:0] A; 823 input [B_WIDTH-1:0] B; 824 output [Y_WIDTH-1:0] Y; 825 826 generate 827 if (A_SIGNED && B_SIGNED) begin:BLOCK1 828 assign Y = $signed(A) != $signed(B); 829 end else begin:BLOCK2 830 assign Y = A != B; 831 end 832 endgenerate 833 834endmodule
- yosys> help $nex¶
Case inequality
This corresponds to the Verilog ‘!==’ operator.
Refer to
$eqx
for more details.- Properties:
- Simulation model (verilog)¶
878module \$nex (A, B, Y); 879 880 parameter A_SIGNED = 0; 881 parameter B_SIGNED = 0; 882 parameter A_WIDTH = 0; 883 parameter B_WIDTH = 0; 884 parameter Y_WIDTH = 0; 885 886 input [A_WIDTH-1:0] A; 887 input [B_WIDTH-1:0] B; 888 output [Y_WIDTH-1:0] Y; 889 890 generate 891 if (A_SIGNED && B_SIGNED) begin:BLOCK1 892 assign Y = $signed(A) !== $signed(B); 893 end else begin:BLOCK2 894 assign Y = A !== B; 895 end 896 endgenerate 897 898endmodule
- yosys> help $or¶
A bit-wise OR. This corresponds to the Verilog ‘|’ operator.
- Properties:
- Simulation model (verilog)¶
177module \$or (A, B, Y); 178 179 parameter A_SIGNED = 0; 180 parameter B_SIGNED = 0; 181 parameter A_WIDTH = 0; 182 parameter B_WIDTH = 0; 183 parameter Y_WIDTH = 0; 184 185 input [A_WIDTH-1:0] A; 186 input [B_WIDTH-1:0] B; 187 output [Y_WIDTH-1:0] Y; 188 189 generate 190 if (A_SIGNED && B_SIGNED) begin:BLOCK1 191 assign Y = $signed(A) | $signed(B); 192 end else begin:BLOCK2 193 assign Y = A | B; 194 end 195 endgenerate 196 197endmodule
- yosys> help $pow¶
Exponentiation of an input (Y = A ** B). This corresponds to the Verilog ‘**’ operator.
- Properties:
- Simulation model (verilog)¶
1477module \$pow (A, B, Y); 1478 1479 parameter A_SIGNED = 0; 1480 parameter B_SIGNED = 0; 1481 parameter A_WIDTH = 0; 1482 parameter B_WIDTH = 0; 1483 parameter Y_WIDTH = 0; 1484 1485 input [A_WIDTH-1:0] A; 1486 input [B_WIDTH-1:0] B; 1487 output [Y_WIDTH-1:0] Y; 1488 1489 generate 1490 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1491 assign Y = $signed(A) ** $signed(B); 1492 end else if (A_SIGNED) begin:BLOCK2 1493 assign Y = $signed(A) ** B; 1494 end else if (B_SIGNED) begin:BLOCK3 1495 assign Y = A ** $signed(B); 1496 end else begin:BLOCK4 1497 assign Y = A ** B; 1498 end 1499 endgenerate 1500 1501endmodule
- yosys> help $shift¶
Variable shifter
Performs a right logical shift if the second operand is positive (or unsigned), and a left logical shift if it is negative.
- Properties:
- Simulation model (verilog)¶
535module \$shift (A, B, Y); 536 537 parameter A_SIGNED = 0; 538 parameter B_SIGNED = 0; 539 parameter A_WIDTH = 0; 540 parameter B_WIDTH = 0; 541 parameter Y_WIDTH = 0; 542 543 input [A_WIDTH-1:0] A; 544 input [B_WIDTH-1:0] B; 545 output [Y_WIDTH-1:0] Y; 546 547 generate 548 if (A_SIGNED) begin:BLOCK1 549 if (B_SIGNED) begin:BLOCK2 550 assign Y = $signed(B) < 0 ? $signed(A) << -B : $signed(A) >> B; 551 end else begin:BLOCK3 552 assign Y = $signed(A) >> B; 553 end 554 end else begin:BLOCK4 555 if (B_SIGNED) begin:BLOCK5 556 assign Y = $signed(B) < 0 ? A << -B : A >> B; 557 end else begin:BLOCK6 558 assign Y = A >> B; 559 end 560 end 561 endgenerate 562 563endmodule
- yosys> help $shiftx¶
Indexed part-select
Same as the
$shift
cell, but fills with ‘x’.- Properties:
- Simulation model (verilog)¶
572module \$shiftx (A, B, Y); 573 574 parameter A_SIGNED = 0; 575 parameter B_SIGNED = 0; 576 parameter A_WIDTH = 0; 577 parameter B_WIDTH = 0; 578 parameter Y_WIDTH = 0; 579 580 input [A_WIDTH-1:0] A; 581 input [B_WIDTH-1:0] B; 582 output [Y_WIDTH-1:0] Y; 583 584 generate 585 if (Y_WIDTH > 0) 586 if (B_SIGNED) begin:BLOCK1 587 assign Y = A[$signed(B) +: Y_WIDTH]; 588 end else begin:BLOCK2 589 assign Y = A[B +: Y_WIDTH]; 590 end 591 endgenerate 592 593endmodule
- yosys> help $shl¶
A logical shift-left operation. This corresponds to the Verilog ‘<<’ operator.
- Properties:
- Simulation model (verilog)¶
411module \$shl (A, B, Y); 412 413 parameter A_SIGNED = 0; 414 parameter B_SIGNED = 0; 415 parameter A_WIDTH = 0; 416 parameter B_WIDTH = 0; 417 parameter Y_WIDTH = 0; 418 419 input [A_WIDTH-1:0] A; 420 input [B_WIDTH-1:0] B; 421 output [Y_WIDTH-1:0] Y; 422 423 generate 424 if (A_SIGNED) begin:BLOCK1 425 assign Y = $signed(A) << B; 426 end else begin:BLOCK2 427 assign Y = A << B; 428 end 429 endgenerate 430 431endmodule
- yosys> help $shr¶
A logical shift-right operation. This corresponds to the Verilog ‘>>’ operator.
- Properties:
- Simulation model (verilog)¶
442module \$shr (A, B, Y); 443 444 parameter A_SIGNED = 0; 445 parameter B_SIGNED = 0; 446 parameter A_WIDTH = 0; 447 parameter B_WIDTH = 0; 448 parameter Y_WIDTH = 0; 449 450 input [A_WIDTH-1:0] A; 451 input [B_WIDTH-1:0] B; 452 output [Y_WIDTH-1:0] Y; 453 454 generate 455 if (A_SIGNED) begin:BLOCK1 456 assign Y = $signed(A) >> B; 457 end else begin:BLOCK2 458 assign Y = A >> B; 459 end 460 endgenerate 461 462endmodule
- yosys> help $sshl¶
An arithmatic shift-left operation. This corresponds to the Verilog ‘<<<’ operator.
- Properties:
- Simulation model (verilog)¶
474module \$sshl (A, B, Y); 475 476 parameter A_SIGNED = 0; 477 parameter B_SIGNED = 0; 478 parameter A_WIDTH = 0; 479 parameter B_WIDTH = 0; 480 parameter Y_WIDTH = 0; 481 482 input [A_WIDTH-1:0] A; 483 input [B_WIDTH-1:0] B; 484 output [Y_WIDTH-1:0] Y; 485 486 generate 487 if (A_SIGNED) begin:BLOCK1 488 assign Y = $signed(A) <<< B; 489 end else begin:BLOCK2 490 assign Y = A <<< B; 491 end 492 endgenerate 493 494endmodule
- yosys> help $sshr¶
An arithmatic shift-right operation. This corresponds to the Verilog ‘>>>’ operator.
- Properties:
- Simulation model (verilog)¶
506module \$sshr (A, B, Y); 507 508 parameter A_SIGNED = 0; 509 parameter B_SIGNED = 0; 510 parameter A_WIDTH = 0; 511 parameter B_WIDTH = 0; 512 parameter Y_WIDTH = 0; 513 514 input [A_WIDTH-1:0] A; 515 input [B_WIDTH-1:0] B; 516 output [Y_WIDTH-1:0] Y; 517 518 generate 519 if (A_SIGNED) begin:BLOCK1 520 assign Y = $signed(A) >>> B; 521 end else begin:BLOCK2 522 assign Y = A >>> B; 523 end 524 endgenerate 525 526endmodule
- yosys> help $sub¶
Subtraction between inputs ‘A’ and ‘B’. This corresponds to the Verilog ‘-’ operator.
- Properties:
- Simulation model (verilog)¶
1005module \$sub (A, B, Y); 1006 1007 parameter A_SIGNED = 0; 1008 parameter B_SIGNED = 0; 1009 parameter A_WIDTH = 0; 1010 parameter B_WIDTH = 0; 1011 parameter Y_WIDTH = 0; 1012 1013 input [A_WIDTH-1:0] A; 1014 input [B_WIDTH-1:0] B; 1015 output [Y_WIDTH-1:0] Y; 1016 1017 generate 1018 if (A_SIGNED && B_SIGNED) begin:BLOCK1 1019 assign Y = $signed(A) - $signed(B); 1020 end else begin:BLOCK2 1021 assign Y = A - B; 1022 end 1023 endgenerate 1024 1025endmodule
- yosys> help $xnor¶
A bit-wise XNOR. This corresponds to the Verilog ‘~^’ operator.
- Properties:
- Simulation model (verilog)¶
239module \$xnor (A, B, Y); 240 241 parameter A_SIGNED = 0; 242 parameter B_SIGNED = 0; 243 parameter A_WIDTH = 0; 244 parameter B_WIDTH = 0; 245 parameter Y_WIDTH = 0; 246 247 input [A_WIDTH-1:0] A; 248 input [B_WIDTH-1:0] B; 249 output [Y_WIDTH-1:0] Y; 250 251 generate 252 if (A_SIGNED && B_SIGNED) begin:BLOCK1 253 assign Y = $signed(A) ~^ $signed(B); 254 end else begin:BLOCK2 255 assign Y = A ~^ B; 256 end 257 endgenerate 258 259endmodule
- yosys> help $xor¶
A bit-wise XOR. This corresponds to the Verilog ‘^’ operator.
- Properties:
- Simulation model (verilog)¶
208module \$xor (A, B, Y); 209 210 parameter A_SIGNED = 0; 211 parameter B_SIGNED = 0; 212 parameter A_WIDTH = 0; 213 parameter B_WIDTH = 0; 214 parameter Y_WIDTH = 0; 215 216 input [A_WIDTH-1:0] A; 217 input [B_WIDTH-1:0] B; 218 output [Y_WIDTH-1:0] Y; 219 220 generate 221 if (A_SIGNED && B_SIGNED) begin:BLOCK1 222 assign Y = $signed(A) ^ $signed(B); 223 end else begin:BLOCK2 224 assign Y = A ^ B; 225 end 226 endgenerate 227 228endmodule