123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- /*
- * prims.v
- *
- * vim: ts=4 sw=4
- *
- * Copyright (C) 2019 Sylvain Munaut <tnt@246tNt.com>
- * All rights reserved.
- *
- * BSD 3-clause, see LICENSE.bsd
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the <organization> nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- `default_nettype none
- module lut4_n #(
- parameter [15:0] LUT_INIT = 0,
- parameter integer WIDTH = 16,
- parameter integer RBEL_X = 0,
- parameter integer RBEL_Y = 0,
- parameter integer RBEL_Z = 0,
- parameter RBEL_GROUP = ""
- )(
- input wire [WIDTH-1:0] i0,
- input wire [WIDTH-1:0] i1,
- input wire [WIDTH-1:0] i2,
- input wire [WIDTH-1:0] i3,
- output wire [WIDTH-1:0] o
- );
- genvar i;
- generate
- for (i=0; i<WIDTH; i=i+1)
- begin : bit
- (* RBEL_X=RBEL_X *)
- (* RBEL_Y=RBEL_Y+(RBEL_Z+i)>>3 *)
- (* RBEL_Z=(RBEL_Z+i)&7 *)
- (* RBEL_GROUP=RBEL_GROUP *)
- SB_LUT4 #(
- .LUT_INIT(LUT_INIT)
- ) lut_I (
- .I0(i0[i]),
- .I1(i1[i]),
- .I2(i2[i]),
- .I3(i3[i]),
- .O(o[i])
- );
- end
- endgenerate
- endmodule // lut4_n
- module lut4_carry_n #(
- parameter [15:0] LUT_INIT = 0,
- parameter integer WIDTH = 16,
- parameter integer RBEL_X = 0,
- parameter integer RBEL_Y = 0,
- parameter integer RBEL_Z = 0,
- parameter RBEL_GROUP = ""
- )(
- input wire [WIDTH-1:0] i0,
- input wire [WIDTH-1:0] i1,
- input wire [WIDTH-1:0] i2,
- input wire cin,
- output wire [WIDTH-1:0] o,
- output wire cout
- );
- wire [WIDTH:0] carry;
- assign cout = carry[WIDTH];
- assign carry[0] = cin;
- genvar i;
- generate
- for (i=0; i<WIDTH; i=i+1)
- begin : bit
- (* RBEL_X=RBEL_X *)
- (* RBEL_Y=RBEL_Y+(RBEL_Z+i)>>3 *)
- (* RBEL_Z=(RBEL_Z+i)&7 *)
- (* RBEL_GROUP=RBEL_GROUP *)
- SB_LUT4 #(
- .LUT_INIT(LUT_INIT)
- ) lut_I (
- .I0(i0[i]),
- .I1(i1[i]),
- .I2(i2[i]),
- .I3(carry[i]),
- .O(o[i])
- );
- SB_CARRY carry_I (
- .CO(carry[i+1]),
- .I0(i0[i]),
- .I1(i1[i]),
- .CI(carry[i])
- );
- end
- endgenerate
- endmodule // lut4_carry_n
- module dff_n #(
- parameter integer WIDTH = 16,
- parameter integer RBEL_X = 0,
- parameter integer RBEL_Y = 0,
- parameter integer RBEL_Z = 0,
- parameter RBEL_GROUP = ""
- )(
- input wire [WIDTH-1:0] d,
- output wire [WIDTH-1:0] q,
- input wire clk
- );
- genvar i;
- generate
- for (i=0; i<WIDTH; i=i+1)
- begin : bit
- (* RBEL_X=RBEL_X *)
- (* RBEL_Y=RBEL_Y+(RBEL_Z+i)>>3 *)
- (* RBEL_Z=(RBEL_Z+i)&7 *)
- (* RBEL_GROUP=RBEL_GROUP *)
- (* dont_touch="true" *)
- SB_DFF dff_I (
- .D(d[i]),
- .Q(q[i]),
- .C(clk)
- );
- end
- endgenerate
- endmodule // dff_n
- module dffe_n #(
- parameter integer WIDTH = 16,
- parameter integer RBEL_X = 0,
- parameter integer RBEL_Y = 0,
- parameter integer RBEL_Z = 0,
- parameter RBEL_GROUP = ""
- )(
- input wire [WIDTH-1:0] d,
- output wire [WIDTH-1:0] q,
- input wire ce,
- input wire clk
- );
- genvar i;
- generate
- for (i=0; i<WIDTH; i=i+1)
- begin : bit
- (* RBEL_X=RBEL_X *)
- (* RBEL_Y=RBEL_Y+((RBEL_Z+i)>>3) *)
- (* RBEL_Z=(RBEL_Z+i)&7 *)
- (* RBEL_GROUP=RBEL_GROUP *)
- (* dont_touch="true" *)
- SB_DFFE dff_I (
- .D(d[i]),
- .Q(q[i]),
- .E(ce),
- .C(clk)
- );
- end
- endgenerate
- endmodule // dffe_n
- module dffer_n #(
- parameter RSTVAL = 16'h0000,
- parameter integer WIDTH = 16,
- parameter integer RBEL_X = 0,
- parameter integer RBEL_Y = 0,
- parameter integer RBEL_Z = 0,
- parameter RBEL_GROUP = ""
- )(
- input wire [WIDTH-1:0] d,
- output wire [WIDTH-1:0] q,
- input wire ce,
- input wire clk,
- input wire rst
- );
- genvar i;
- generate
- for (i=0; i<WIDTH; i=i+1)
- begin : bit
- if (RSTVAL[i] == 1'b1)
- (* RBEL_X=RBEL_X *)
- (* RBEL_Y=RBEL_Y+((RBEL_Z+i)>>3) *)
- (* RBEL_Z=(RBEL_Z+i)&7 *)
- (* RBEL_GROUP=RBEL_GROUP *)
- (* dont_touch="true" *)
- SB_DFFES dff_I (
- .D(d[i]),
- .Q(q[i]),
- .E(ce),
- .S(rst),
- .C(clk)
- );
- else
- (* RBEL_X=RBEL_X *)
- (* RBEL_Y=RBEL_Y+((RBEL_Z+i)>>3) *)
- (* RBEL_Z=(RBEL_Z+i)&7 *)
- (* RBEL_GROUP=RBEL_GROUP *)
- (* dont_touch="true" *)
- SB_DFFER dff_I (
- .D(d[i]),
- .Q(q[i]),
- .E(ce),
- .R(rst),
- .C(clk)
- );
- end
- endgenerate
- endmodule // dffer_n
- module dffesr_n #(
- parameter RSTVAL = 16'h0000,
- parameter integer WIDTH = 16,
- parameter integer RBEL_X = 0,
- parameter integer RBEL_Y = 0,
- parameter integer RBEL_Z = 0,
- parameter RBEL_GROUP = ""
- )(
- input wire [WIDTH-1:0] d,
- output wire [WIDTH-1:0] q,
- input wire ce,
- input wire clk,
- input wire rst
- );
- genvar i;
- generate
- for (i=0; i<WIDTH; i=i+1)
- begin : bit
- if (RSTVAL[i] == 1'b1)
- (* RBEL_X=RBEL_X *)
- (* RBEL_Y=RBEL_Y+((RBEL_Z+i)>>3) *)
- (* RBEL_Z=(RBEL_Z+i)&7 *)
- (* RBEL_GROUP=RBEL_GROUP *)
- (* dont_touch="true" *)
- SB_DFFESS dff_I (
- .D(d[i]),
- .Q(q[i]),
- .E(ce),
- .S(rst),
- .C(clk)
- );
- else
- (* RBEL_X=RBEL_X *)
- (* RBEL_Y=RBEL_Y+((RBEL_Z+i)>>3) *)
- (* RBEL_Z=(RBEL_Z+i)&7 *)
- (* RBEL_GROUP=RBEL_GROUP *)
- (* dont_touch="true" *)
- SB_DFFESR dff_I (
- .D(d[i]),
- .Q(q[i]),
- .E(ce),
- .R(rst),
- .C(clk)
- );
- end
- endgenerate
- endmodule // dffesr_n
|