diff options
| author | Eddie Hung <eddie@fpgeh.com> | 2019-08-16 16:51:22 -0700 | 
|---|---|---|
| committer | Eddie Hung <eddie@fpgeh.com> | 2019-08-16 16:51:22 -0700 | 
| commit | 24c934f1af3859fe64ff4fb87a2a3de97695cde4 (patch) | |
| tree | 131c64cee5a0cf09adc68b32f25e06a9da668ad0 /techlibs/common | |
| parent | 1c9f3fadb9f60653fc9d1d7d72ba22033e077468 (diff) | |
| parent | 5abe133323b2a6a46959f796c4730b2d70cdea26 (diff) | |
| download | yosys-24c934f1af3859fe64ff4fb87a2a3de97695cde4.tar.gz yosys-24c934f1af3859fe64ff4fb87a2a3de97695cde4.tar.bz2 yosys-24c934f1af3859fe64ff4fb87a2a3de97695cde4.zip | |
Merge branch 'eddie/abc9_refactor' into xaig_dff
Diffstat (limited to 'techlibs/common')
| -rw-r--r-- | techlibs/common/cmp2lut.v | 2 | ||||
| -rw-r--r-- | techlibs/common/simcells.v | 19 | ||||
| -rw-r--r-- | techlibs/common/simlib.v | 44 | 
3 files changed, 56 insertions, 9 deletions
| diff --git a/techlibs/common/cmp2lut.v b/techlibs/common/cmp2lut.v index 8aa1eb957..0d0757767 100644 --- a/techlibs/common/cmp2lut.v +++ b/techlibs/common/cmp2lut.v @@ -27,7 +27,7 @@ parameter _TECHMAP_CONSTVAL_A_ = 0;  parameter _TECHMAP_CONSTMSK_B_ = 0;  parameter _TECHMAP_CONSTVAL_B_ = 0; -function automatic integer gen_lut; +function automatic [(1 << `LUT_WIDTH)-1:0] gen_lut;  	input integer width;  	input integer operation;  	input integer swap; diff --git a/techlibs/common/simcells.v b/techlibs/common/simcells.v index 289673e82..64720e598 100644 --- a/techlibs/common/simcells.v +++ b/techlibs/common/simcells.v @@ -230,6 +230,25 @@ endmodule  //  |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|  //- +//-     $_NMUX_ (A, B, S, Y) +//- +//- A 2-input inverting MUX gate. +//- +//- Truth table:    A B S | Y +//-                -------+--- +//-                 0 - 0 | 1 +//-                 1 - 0 | 0 +//-                 - 0 1 | 1 +//-                 - 1 1 | 0 +//- +module \$_NMUX_ (A, B, S, Y); +input A, B, S; +output Y; +assign Y = S ? !B : !A; +endmodule + +//  |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| +//-  //-     $_MUX4_ (A, B, C, D, S, T, Y)  //-  //- A 4-input MUX gate. diff --git a/techlibs/common/simlib.v b/techlibs/common/simlib.v index a424d3089..7845a3fed 100644 --- a/techlibs/common/simlib.v +++ b/techlibs/common/simlib.v @@ -532,14 +532,26 @@ endmodule  // -------------------------------------------------------- +//  |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| +//- +//-     $lcu (P, G, CI, CO) +//- +//- Lookahead carry unit +//- A building block dedicated to fast computation of carry-bits used in binary +//- arithmetic operations. By replacing the ripple carry structure used in full-adder +//- blocks, the more significant  bits of the sum can be expected to be computed more +//- quickly. +//- Typically created during `techmap` of $alu cells (see the "_90_alu" rule in +//- +/techmap.v).  module \$lcu (P, G, CI, CO);  parameter WIDTH = 1; -input [WIDTH-1:0] P, G; -input CI; +input [WIDTH-1:0] P;    // Propagate +input [WIDTH-1:0] G;    // Generate +input CI;               // Carry-in -output reg [WIDTH-1:0] CO; +output reg [WIDTH-1:0] CO; // Carry-out  integer i;  always @* begin @@ -555,6 +567,17 @@ endmodule  // -------------------------------------------------------- +//  |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| +//- +//-     $alu (A, B, CI, BI, X, Y, CO) +//- +//- Arithmetic logic unit. +//- A building block supporting both binary addition/subtraction operations, and +//- indirectly, comparison operations. +//- Typically created by the `alumacc` pass, which transforms: +//-   $add, $sub, $lt, $le, $ge, $gt, $eq, $eqx, $ne, $nex +//- cells into this $alu cell. +//-  module \$alu (A, B, CI, BI, X, Y, CO);  parameter A_SIGNED = 0; @@ -563,12 +586,16 @@ parameter A_WIDTH = 1;  parameter B_WIDTH = 1;  parameter Y_WIDTH = 1; -input [A_WIDTH-1:0] A; -input [B_WIDTH-1:0] B; -output [Y_WIDTH-1:0] X, Y; +input [A_WIDTH-1:0] A;      // Input operand +input [B_WIDTH-1:0] B;      // Input operand +output [Y_WIDTH-1:0] X;     // A xor B (sign-extended, optional B inversion, +                            //          used in combination with +                            //          reduction-AND for $eq/$ne ops) +output [Y_WIDTH-1:0] Y;     // Sum -input CI, BI; -output [Y_WIDTH-1:0] CO; +input CI;                   // Carry-in (set for $sub) +input BI;                   // Invert-B (set for $sub) +output [Y_WIDTH-1:0] CO;    // Carry-out  wire [Y_WIDTH-1:0] AA, BB; @@ -584,6 +611,7 @@ endgenerate  wire y_co_undef = ^{A, A, B, B, CI, CI, BI, BI};  assign X = AA ^ BB; +// Full adder  assign Y = (AA + BB + CI) ^ {Y_WIDTH{y_co_undef}};  function get_carry; | 
