summaryrefslogtreecommitdiff
path: root/library/tlv
diff options
context:
space:
mode:
authorrahulp132022-02-22 00:15:25 +0530
committerrahulp132022-02-22 00:15:25 +0530
commit5000da993e5d83bc4306a556da4ccc254145bd31 (patch)
tree3fe537086f794935efd9f2db89d8a09b9512c0cf /library/tlv
parentfd196488664dc381f6152d18af6e1afbe906d5f0 (diff)
downloadeSim-5000da993e5d83bc4306a556da4ccc254145bd31.tar.gz
eSim-5000da993e5d83bc4306a556da4ccc254145bd31.tar.bz2
eSim-5000da993e5d83bc4306a556da4ccc254145bd31.zip
Restructured Verilator libraries
Diffstat (limited to 'library/tlv')
-rwxr-xr-xlibrary/tlv/clk_gate.v40
-rwxr-xr-xlibrary/tlv/lint_off.txt29
-rwxr-xr-xlibrary/tlv/pseudo_rand.m4out.tlv69
-rwxr-xr-xlibrary/tlv/pseudo_rand.sv70
-rwxr-xr-xlibrary/tlv/pseudo_rand_gen.sv46
-rwxr-xr-xlibrary/tlv/sandpiper.vh72
-rwxr-xr-xlibrary/tlv/sandpiper_gen.vh4
-rwxr-xr-xlibrary/tlv/sp_default.vh66
8 files changed, 396 insertions, 0 deletions
diff --git a/library/tlv/clk_gate.v b/library/tlv/clk_gate.v
new file mode 100755
index 00000000..77e9186d
--- /dev/null
+++ b/library/tlv/clk_gate.v
@@ -0,0 +1,40 @@
+/*
+Copyright (c) 2015, Steven F. Hoover
+
+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.
+ * The name of Steven F. Hoover
+ may not 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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
+*/
+
+`include "sp_default.vh"
+/* verilator lint_off LATCH */
+
+// Clock gate module used by SandPiper default project.
+
+module clk_gate (output gated_clk, input free_clk, func_en, pwr_en, gating_override);
+ wire clk_en;
+ reg latched_clk_en /*verilator clock_enable*/;
+ assign clk_en = func_en & (pwr_en | gating_override);
+ `TLV_BLATCH(latched_clk_en, clk_en, free_clk)
+ assign gated_clk = latched_clk_en & free_clk;
+endmodule
+
diff --git a/library/tlv/lint_off.txt b/library/tlv/lint_off.txt
new file mode 100755
index 00000000..5d4b7f0a
--- /dev/null
+++ b/library/tlv/lint_off.txt
@@ -0,0 +1,29 @@
+UNUSED
+DECLFILENAME
+BLKSEQ
+WIDTH
+SELRANGE
+PINCONNECTEMPTY
+DEFPARAM
+IMPLICIT
+COMBDLY
+SYNCASYNCNET
+UNOPTFLAT
+UNSIGNED
+CASEINCOMPLETE
+UNDRIVEN
+VARHIDDEN
+CASEX
+CASEOVERLAP
+PINMISSING
+LATCH
+BLKANDNBLK
+MULTIDRIVEN
+NULLPORT
+EOFNEWLINE
+WIDTHCONCAT
+ASSIGNDLY
+MODDUP
+STMTDLY
+LITENDIAN
+INITIALDLY
diff --git a/library/tlv/pseudo_rand.m4out.tlv b/library/tlv/pseudo_rand.m4out.tlv
new file mode 100755
index 00000000..cb0d6149
--- /dev/null
+++ b/library/tlv/pseudo_rand.m4out.tlv
@@ -0,0 +1,69 @@
+\m4_TLV_version 1b: tl-x.org
+\SV
+/*
+Copyright (c) 2014, Steven F. Hoover
+
+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.
+ * The name of Steven F. Hoover
+ may not 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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
+*/
+
+module pseudo_rand
+ #(parameter WIDTH=257) // Random vector width, to a max of 257.
+ (input logic clk,
+ input logic reset,
+ output logic [WIDTH-1:0] rand_vect
+ );
+
+// Currently, this implements a Galois LFSR.
+// TODO: It should be XORed with something else so it doesn't just shift.
+// Using polynomials with maximal number of taps would have less regular shifting behavior.
+
+// Bits are numbered in the reverse of the traditional order. This puts the taps in the lower bit positions.
+
+// Choose optimal parameters for given WIDTH.
+localparam LFSR_WIDTH =
+ (WIDTH <= 64) ? 64 :
+ (WIDTH <= 128) ? 128 :
+ (WIDTH <= 257) ? 257 : 0; // 257 enables a large non-power of two for replication on an irregular boundary.
+// Polynomial source: http://www.eej.ulst.ac.uk/~ian/modules/EEE515/files/old_files/lfsr/lfsr_table.pdf
+localparam [LFSR_WIDTH-1:0] LFSR_POLY = {{(LFSR_WIDTH-8){1'b0}},
+ (LFSR_WIDTH == 64) ? 8'b00011011 :
+ (LFSR_WIDTH == 128) ? 8'b10000111 :
+ (LFSR_WIDTH == 257) ? 8'b11000101 : 8'b0};
+
+bit [256:0] SEED = 257'h0_7163e168_713d5431_6684e132_5cd84848_f3048b46_76874654_0c45f864_04e4684a;
+
+
+
+\TLV
+ |default
+ @0
+ $reset = reset;
+ @1
+ $lfsr[LFSR_WIDTH-1:0] = $reset ? *SEED : {$lfsr#+1[LFSR_WIDTH-2:0], 1'b0} ^ ({LFSR_WIDTH{$lfsr#+1[LFSR_WIDTH-1]}} & *LFSR_POLY);
+ @2
+ *rand_vect = $lfsr[WIDTH-1:0];
+
+\SV
+
+endmodule
diff --git a/library/tlv/pseudo_rand.sv b/library/tlv/pseudo_rand.sv
new file mode 100755
index 00000000..a9988b58
--- /dev/null
+++ b/library/tlv/pseudo_rand.sv
@@ -0,0 +1,70 @@
+`line 2 "pseudo_rand.m4out.tlv" 0 //_\TLV_version 1b: tl-x.org, generated by SandPiper(TM) 1.11-2021/01/28-beta
+`include "sp_default.vh" //_\SV
+/*
+Copyright (c) 2014, Steven F. Hoover
+
+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.
+ * The name of Steven F. Hoover
+ may not 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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
+*/
+
+module pseudo_rand
+ #(parameter WIDTH=257) // Random vector width, to a max of 257.
+ (input logic clk,
+ input logic reset,
+ output logic [WIDTH-1:0] rand_vect
+ );
+
+// Currently, this implements a Galois LFSR.
+// TODO: It should be XORed with something else so it doesn't just shift.
+// Using polynomials with maximal number of taps would have less regular shifting behavior.
+
+// Bits are numbered in the reverse of the traditional order. This puts the taps in the lower bit positions.
+
+// Choose optimal parameters for given WIDTH.
+localparam LFSR_WIDTH =
+ (WIDTH <= 64) ? 64 :
+ (WIDTH <= 128) ? 128 :
+ (WIDTH <= 257) ? 257 : 0; // 257 enables a large non-power of two for replication on an irregular boundary.
+// Polynomial source: http://www.eej.ulst.ac.uk/~ian/modules/EEE515/files/old_files/lfsr/lfsr_table.pdf
+localparam [LFSR_WIDTH-1:0] LFSR_POLY = {{(LFSR_WIDTH-8){1'b0}},
+ (LFSR_WIDTH == 64) ? 8'b00011011 :
+ (LFSR_WIDTH == 128) ? 8'b10000111 :
+ (LFSR_WIDTH == 257) ? 8'b11000101 : 8'b0};
+
+bit [256:0] SEED = 257'h0_7163e168_713d5431_6684e132_5cd84848_f3048b46_76874654_0c45f864_04e4684a;
+
+
+
+`include "pseudo_rand_gen.sv" //_\TLV
+ //_|default
+ //_@0
+ assign DEFAULT_reset_a0 = reset;
+ //_@1
+ assign DEFAULT_lfsr_a1[LFSR_WIDTH-1:0] = DEFAULT_reset_a1 ? SEED : {DEFAULT_lfsr_a2[LFSR_WIDTH-2:0], 1'b0} ^ ({LFSR_WIDTH{DEFAULT_lfsr_a2[LFSR_WIDTH-1]}} & LFSR_POLY);
+ //_@2
+ assign rand_vect = DEFAULT_lfsr_a2[WIDTH-1:0]; endgenerate
+
+//_\SV
+
+endmodule
+
diff --git a/library/tlv/pseudo_rand_gen.sv b/library/tlv/pseudo_rand_gen.sv
new file mode 100755
index 00000000..ec008179
--- /dev/null
+++ b/library/tlv/pseudo_rand_gen.sv
@@ -0,0 +1,46 @@
+// Generated by SandPiper(TM) 1.11-2021/01/28-beta from Redwood EDA.
+// Redwood EDA does not claim intellectual property rights to this file and provides no warranty regarding its correctness or quality.
+
+
+`include "sandpiper_gen.vh"
+
+
+
+
+
+//
+// Signals declared top-level.
+//
+
+// For |default$lfsr.
+logic [LFSR_WIDTH-1:0] DEFAULT_lfsr_a1,
+ DEFAULT_lfsr_a2;
+
+// For |default$reset.
+logic DEFAULT_reset_a0,
+ DEFAULT_reset_a1;
+
+
+
+generate
+
+
+ //
+ // Scope: |default
+ //
+
+ // For $lfsr.
+ always_ff @(posedge clk) DEFAULT_lfsr_a2[LFSR_WIDTH-1:0] <= DEFAULT_lfsr_a1[LFSR_WIDTH-1:0];
+
+ // For $reset.
+ always_ff @(posedge clk) DEFAULT_reset_a1 <= DEFAULT_reset_a0;
+
+
+
+
+endgenerate
+
+
+
+
+generate // This is awkward, but we need to go into 'generate' context in the line that `includes the declarations file.
diff --git a/library/tlv/sandpiper.vh b/library/tlv/sandpiper.vh
new file mode 100755
index 00000000..ccba8b0e
--- /dev/null
+++ b/library/tlv/sandpiper.vh
@@ -0,0 +1,72 @@
+/*
+Copyright (c) 2015, Steven F. Hoover
+
+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.
+ * The name of Steven F. Hoover
+ may not 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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
+*/
+
+// Project-independent SandPiper header file.
+
+`ifndef SANDPIPER_VH
+`define SANDPIPER_VH
+
+
+// Note, these have no SP prefix, so collisions are possible.
+
+
+`ifdef WHEN
+ // Make sure user definition does not collide.
+ !!!ERROR: WHEN macro already defined
+`else
+ `ifdef SP_PHYS
+ // Phys compilation disabled X-injection.
+ `define WHEN(valid_sig)
+ `else
+ // Inject X.
+ `define WHEN(valid_sig) !valid_sig ? 'x :
+ `endif
+`endif
+
+
+// SandPiper does not generate set/reset flops. Reset is implemented as combinational
+// logic, and it is up to synthesis to infer set/reset flops when possible.
+//`ifdef RESET
+// // Make sure user definition does not collide.
+// !!!ERROR: RESET macro already defined
+//`else
+// `define RESET(i, reset) ((reset) ? '0 : i)
+//`endif
+//
+//`ifdef SET
+// // Make sure user definition does not collide.
+// !!!ERROR: SET macro already defined
+//`else
+// `define SET(i, set) ((set) ? '1 : i)
+//`endif
+
+// Since SandPiper required use of all signals, this is useful to create a
+// bogus use and keep SandPiper happy when a signal, by intent, has no uses.
+`define BOGUS_USE(ignore)
+
+`endif // SANDPIPER_VH
+
diff --git a/library/tlv/sandpiper_gen.vh b/library/tlv/sandpiper_gen.vh
new file mode 100755
index 00000000..d063661a
--- /dev/null
+++ b/library/tlv/sandpiper_gen.vh
@@ -0,0 +1,4 @@
+// This just verifies that sandpiper.vh has been included.
+`ifndef SANDPIPER_VH
+ !!!ERROR: SandPiper project's sp_<proj>.vh file must include sandpiper.vh.
+`endif
diff --git a/library/tlv/sp_default.vh b/library/tlv/sp_default.vh
new file mode 100755
index 00000000..5e74259a
--- /dev/null
+++ b/library/tlv/sp_default.vh
@@ -0,0 +1,66 @@
+`ifndef SP_DEFAULT
+`define SP_DEFAULT
+/*
+Copyright (c) 2015, Steven F. Hoover
+
+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.
+ * The name of Steven F. Hoover
+ may not 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 THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
+*/
+
+
+// File included by SandPiper-generated code for the default project configuration.
+`include "sandpiper.vh"
+
+
+// Latch macros. Inject 'x in simulation for clk === 'x.
+
+// A-phase latch.
+`ifdef SP_PHYS
+`define TLV_LATCH(in, out, clk) \
+always @ (in, clk) begin \
+ if (clk === 1'b1) \
+ out <= in; \
+ else if (clk === 1'bx) \
+ out <= 'x; \
+end
+`else
+`define TLV_LATCH(in, out, clk) always @ (in, clk) if (clk == 1'b1) out <= in;
+`endif // SP_PHYS
+
+// B-phase latch.
+`ifdef SP_PHYS
+`define TLV_BLATCH(out, in, clk) \
+always @ (in, clk) begin \
+ if (!clk === 1'b1) \
+ out <= in; \
+ else if (!clk === 1'bx) \
+ out <= 'x; \
+end
+`else
+`define TLV_BLATCH(out, in, clk) always @ (in, clk) if (!clk == 1'b1) out <= in;
+`endif // SP_PHYS
+
+
+
+`endif // SP_DEFAULT
+