mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-10 13:10:51 +00:00
Merge remote-tracking branch 'origin/master' into xaig
This commit is contained in:
commit
f7a9769c14
140 changed files with 4698 additions and 1852 deletions
|
@ -1,3 +0,0 @@
|
|||
aig 3 2 0 1 1
|
||||
6
|
||||
|
|
@ -3,3 +3,6 @@ aag 3 2 0 1 1
|
|||
4
|
||||
6
|
||||
6 2 4
|
||||
i0 pi0
|
||||
i1 pi1
|
||||
o0 po0
|
5
tests/aiger/and_.aig
Normal file
5
tests/aiger/and_.aig
Normal file
|
@ -0,0 +1,5 @@
|
|||
aig 3 2 0 1 1
|
||||
6
|
||||
i0 pi0
|
||||
i1 pi1
|
||||
o0 po0
|
|
@ -1,3 +1,5 @@
|
|||
aag 1 1 0 1 0
|
||||
2
|
||||
2
|
||||
i0 pi0
|
||||
o0 po0
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
aig 1 1 0 1 0
|
||||
2
|
||||
i0 pi0
|
||||
o0 po0
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
aag 1 0 1 0 0 1
|
||||
2 3
|
||||
2
|
||||
b0 po0
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
aig 1 0 1 0 0 1
|
||||
3
|
||||
2
|
||||
b0 po0
|
||||
|
|
|
@ -6,3 +6,4 @@ aag 5 1 1 0 3 1
|
|||
8 4 2
|
||||
10 9 7
|
||||
b0 AIGER_NEVER
|
||||
i0 po0
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
aig 5 1 1 0 3 1
|
||||
10
|
||||
4
|
||||
b0 AIGER_NEVER
|
||||
i0 po0
|
||||
b0 AIGER_NEVER
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
aag 0 0 0 1 0
|
||||
0
|
||||
o0 po0
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
aig 0 0 0 1 0
|
||||
0
|
||||
o0 po0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
aag 1 1 0 1 0
|
||||
2
|
||||
3
|
||||
i0 pi0
|
||||
o0 po0
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
aig 1 1 0 1 0
|
||||
3
|
||||
i0 pi0
|
||||
o0 po0
|
||||
|
|
|
@ -6,3 +6,4 @@ aag 5 1 1 0 3 1
|
|||
8 4 2
|
||||
10 9 7
|
||||
b0 AIGER_NEVER
|
||||
i0 pi0
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
aig 5 1 1 0 3 1
|
||||
10
|
||||
5
|
||||
b0 AIGER_NEVER
|
||||
i0 pi0
|
||||
b0 AIGER_NEVER
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
aig 3 2 0 1 1
|
||||
7
|
||||
|
|
@ -3,3 +3,6 @@ aag 3 2 0 1 1
|
|||
4
|
||||
7
|
||||
6 3 5
|
||||
i0 pi0
|
||||
i1 pi1
|
||||
o0 po0
|
5
tests/aiger/or_.aig
Normal file
5
tests/aiger/or_.aig
Normal file
|
@ -0,0 +1,5 @@
|
|||
aig 3 2 0 1 1
|
||||
7
|
||||
i0 pi0
|
||||
i1 pi1
|
||||
o0 po0
|
|
@ -1,24 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
OPTIND=1
|
||||
seed="" # default to no seed specified
|
||||
while getopts "S:" opt
|
||||
do
|
||||
case "$opt" in
|
||||
S) arg="${OPTARG#"${OPTARG%%[![:space:]]*}"}" # remove leading space
|
||||
seed="SEED=$arg" ;;
|
||||
esac
|
||||
set -e
|
||||
|
||||
# NB: *.aag and *.aig must contain a symbol table naming the primary
|
||||
# inputs and outputs, otherwise ABC and Yosys will name them
|
||||
# arbitrarily (and inconsistently with each other).
|
||||
|
||||
for aag in *.aag; do
|
||||
# Since ABC cannot read *.aag, read the *.aig instead
|
||||
# (which would have been created by the reference aig2aig utility,
|
||||
# available from http://fmv.jku.at/aiger/)
|
||||
../../yosys-abc -c "read -c ${aag%.*}.aig; write ${aag%.*}_ref.v"
|
||||
../../yosys -p "
|
||||
read_verilog ${aag%.*}_ref.v
|
||||
prep
|
||||
design -stash gold
|
||||
read_aiger -clk_name clock $aag
|
||||
prep
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports -seq 16 miter
|
||||
"
|
||||
done
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
# check for Icarus Verilog
|
||||
if ! which iverilog > /dev/null ; then
|
||||
echo "$0: Error: Icarus Verilog 'iverilog' not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "===== AAG ======"
|
||||
${MAKE:-make} -f ../tools/autotest.mk $seed *.aag EXTRA_FLAGS="-f aiger"
|
||||
|
||||
echo "===== AIG ======"
|
||||
exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.aig EXTRA_FLAGS="-f aiger"
|
||||
for aig in *.aig; do
|
||||
../../yosys-abc -c "read -c $aig; write ${aig%.*}_ref.v"
|
||||
../../yosys -p "
|
||||
read_verilog ${aig%.*}_ref.v
|
||||
prep
|
||||
design -stash gold
|
||||
read_aiger -clk_name clock $aig
|
||||
prep
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports -seq 16 miter
|
||||
"
|
||||
done
|
||||
|
|
|
@ -2,3 +2,5 @@ aag 1 0 1 2 0
|
|||
2 3
|
||||
2
|
||||
3
|
||||
o0 po0
|
||||
o1 po1
|
||||
|
|
|
@ -2,3 +2,5 @@ aig 1 0 1 2 0
|
|||
3
|
||||
2
|
||||
3
|
||||
o0 po0
|
||||
o1 po1
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
aag 0 0 0 1 0
|
||||
1
|
||||
o0 po0
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
aig 0 0 0 1 0
|
||||
1
|
||||
o0 po0
|
||||
|
|
22
tests/memories/firrtl_938.v
Normal file
22
tests/memories/firrtl_938.v
Normal file
|
@ -0,0 +1,22 @@
|
|||
module top
|
||||
(
|
||||
input [7:0] data_a,
|
||||
input [6:1] addr_a,
|
||||
input we_a, clk,
|
||||
output reg [7:0] q_a
|
||||
);
|
||||
// Declare the RAM variable
|
||||
reg [7:0] ram[63:0];
|
||||
|
||||
// Port A
|
||||
always @ (posedge clk)
|
||||
begin
|
||||
if (we_a)
|
||||
begin
|
||||
ram[addr_a] <= data_a;
|
||||
q_a <= data_a;
|
||||
end
|
||||
q_a <= ram[addr_a];
|
||||
end
|
||||
|
||||
endmodule
|
21
tests/simple/attrib01_module.v
Normal file
21
tests/simple/attrib01_module.v
Normal file
|
@ -0,0 +1,21 @@
|
|||
module bar(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output reg out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 1'd0;
|
||||
else out <= ~inp;
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output wire out;
|
||||
|
||||
bar bar_instance (clk, rst, inp, out);
|
||||
endmodule
|
||||
|
25
tests/simple/attrib02_port_decl.v
Normal file
25
tests/simple/attrib02_port_decl.v
Normal file
|
@ -0,0 +1,25 @@
|
|||
module bar(clk, rst, inp, out);
|
||||
(* this_is_clock = 1 *)
|
||||
input wire clk;
|
||||
(* this_is_reset = 1 *)
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
(* an_output_register = 1*)
|
||||
output reg out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 1'd0;
|
||||
else out <= ~inp;
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp, out);
|
||||
(* this_is_the_master_clock *)
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output wire out;
|
||||
|
||||
bar bar_instance (clk, rst, inp, out);
|
||||
endmodule
|
||||
|
28
tests/simple/attrib03_parameter.v
Normal file
28
tests/simple/attrib03_parameter.v
Normal file
|
@ -0,0 +1,28 @@
|
|||
module bar(clk, rst, inp, out);
|
||||
|
||||
(* bus_width *)
|
||||
parameter WIDTH = 2;
|
||||
|
||||
(* an_attribute_on_localparam = 55 *)
|
||||
localparam INCREMENT = 5;
|
||||
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire [WIDTH-1:0] inp;
|
||||
output reg [WIDTH-1:0] out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 0;
|
||||
else out <= inp + INCREMENT;
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire [7:0] inp;
|
||||
output wire [7:0] out;
|
||||
|
||||
bar # (.WIDTH(8)) bar_instance (clk, rst, inp, out);
|
||||
endmodule
|
||||
|
32
tests/simple/attrib04_net_var.v
Normal file
32
tests/simple/attrib04_net_var.v
Normal file
|
@ -0,0 +1,32 @@
|
|||
module bar(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output reg out;
|
||||
|
||||
(* this_is_a_prescaler *)
|
||||
reg [7:0] counter;
|
||||
|
||||
(* temp_wire *)
|
||||
wire out_val;
|
||||
|
||||
always @(posedge clk)
|
||||
counter <= counter + 1;
|
||||
|
||||
assign out_val = inp ^ counter[4];
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 1'd0;
|
||||
else out <= out_val;
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output wire out;
|
||||
|
||||
bar bar_instance (clk, rst, inp, out);
|
||||
endmodule
|
||||
|
21
tests/simple/attrib05_port_conn.v.DISABLED
Normal file
21
tests/simple/attrib05_port_conn.v.DISABLED
Normal file
|
@ -0,0 +1,21 @@
|
|||
module bar(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output reg out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 1'd0;
|
||||
else out <= ~inp;
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output wire out;
|
||||
|
||||
bar bar_instance ( (* clock_connected *) clk, rst, (* this_is_the_input *) inp, out);
|
||||
endmodule
|
||||
|
23
tests/simple/attrib06_operator_suffix.v
Normal file
23
tests/simple/attrib06_operator_suffix.v
Normal file
|
@ -0,0 +1,23 @@
|
|||
module bar(clk, rst, inp_a, inp_b, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire [7:0] inp_a;
|
||||
input wire [7:0] inp_b;
|
||||
output reg [7:0] out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 0;
|
||||
else out <= inp_a + (* ripple_adder *) inp_b;
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp_a, inp_b, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire [7:0] inp_a;
|
||||
input wire [7:0] inp_b;
|
||||
output wire [7:0] out;
|
||||
|
||||
bar bar_instance (clk, rst, inp_a, inp_b, out);
|
||||
endmodule
|
||||
|
21
tests/simple/attrib07_func_call.v.DISABLED
Normal file
21
tests/simple/attrib07_func_call.v.DISABLED
Normal file
|
@ -0,0 +1,21 @@
|
|||
function [7:0] do_add;
|
||||
input [7:0] inp_a;
|
||||
input [7:0] inp_b;
|
||||
|
||||
do_add = inp_a + inp_b;
|
||||
|
||||
endfunction
|
||||
|
||||
module foo(clk, rst, inp_a, inp_b, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire [7:0] inp_a;
|
||||
input wire [7:0] inp_b;
|
||||
output wire [7:0] out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 0;
|
||||
else out <= do_add (* combinational_adder *) (inp_a, inp_b);
|
||||
|
||||
endmodule
|
||||
|
22
tests/simple/attrib08_mod_inst.v
Normal file
22
tests/simple/attrib08_mod_inst.v
Normal file
|
@ -0,0 +1,22 @@
|
|||
module bar(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output reg out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 1'd0;
|
||||
else out <= ~inp;
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output wire out;
|
||||
|
||||
(* my_module_instance = 99 *)
|
||||
bar bar_instance (clk, rst, inp, out);
|
||||
endmodule
|
||||
|
26
tests/simple/attrib09_case.v
Normal file
26
tests/simple/attrib09_case.v
Normal file
|
@ -0,0 +1,26 @@
|
|||
module bar(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire [1:0] inp;
|
||||
output reg [1:0] out;
|
||||
|
||||
always @(inp)
|
||||
(* full_case, parallel_case *)
|
||||
case(inp)
|
||||
2'd0: out <= 2'd3;
|
||||
2'd1: out <= 2'd2;
|
||||
2'd2: out <= 2'd1;
|
||||
2'd3: out <= 2'd0;
|
||||
endcase
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire [1:0] inp;
|
||||
output wire [1:0] out;
|
||||
|
||||
bar bar_instance (clk, rst, inp, out);
|
||||
endmodule
|
||||
|
|
@ -40,3 +40,15 @@ module dff1a_test(n1, n1_inv, clk);
|
|||
n1 <= n1_inv;
|
||||
assign n1_inv = ~n1;
|
||||
endmodule
|
||||
|
||||
module dff_test_997 (y, clk, wire4);
|
||||
// https://github.com/YosysHQ/yosys/issues/997
|
||||
output wire [1:0] y;
|
||||
input clk;
|
||||
input signed wire4;
|
||||
reg [1:0] reg10 = 0;
|
||||
always @(posedge clk) begin
|
||||
reg10 <= wire4;
|
||||
end
|
||||
assign y = reg10;
|
||||
endmodule
|
||||
|
|
25
tests/simple/forloops.v
Normal file
25
tests/simple/forloops.v
Normal file
|
@ -0,0 +1,25 @@
|
|||
module forloops01 (input clk, a, b, output reg [3:0] p, q, x, y);
|
||||
integer k;
|
||||
always @(posedge clk) begin
|
||||
for (k=0; k<2; k=k+1)
|
||||
p[2*k +: 2] = {a, b} ^ {2{k}};
|
||||
x <= k + {a, b};
|
||||
end
|
||||
always @* begin
|
||||
for (k=0; k<4; k=k+1)
|
||||
q[k] = {~a, ~b, a, b} >> k[1:0];
|
||||
y = k - {a, b};
|
||||
end
|
||||
endmodule
|
||||
|
||||
module forloops02 (input clk, a, b, output reg [3:0] q, x, output [3:0] y);
|
||||
integer k;
|
||||
always @* begin
|
||||
for (k=0; k<4; k=k+1)
|
||||
q[k] = {~a, ~b, a, b} >> k[1:0];
|
||||
end
|
||||
always @* begin
|
||||
x = k + {a, b};
|
||||
end
|
||||
assign y = k - {a, b};
|
||||
endmodule
|
16
tests/simple/implicit_ports.v
Normal file
16
tests/simple/implicit_ports.v
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Test implicit port connections
|
||||
module alu (input [2:0] a, input [2:0] b, input cin, output cout, output [2:0] result);
|
||||
assign cout = cin;
|
||||
assign result = a + b;
|
||||
endmodule
|
||||
|
||||
module named_ports(input [2:0] a, b, output [2:0] alu_result, output cout);
|
||||
wire cin = 1;
|
||||
alu alu (
|
||||
.a(a),
|
||||
.b, // Implicit connection is equivalent to .b(b)
|
||||
.cin(), // Explicitely unconnected
|
||||
.cout(cout),
|
||||
.result(alu_result)
|
||||
);
|
||||
endmodule
|
11
tests/simple/localparam_attr.v
Normal file
11
tests/simple/localparam_attr.v
Normal file
|
@ -0,0 +1,11 @@
|
|||
module uut_localparam_attr (I, O);
|
||||
|
||||
(* LOCALPARAM_ATTRIBUTE = "attribute_content" *)
|
||||
localparam WIDTH = 1;
|
||||
|
||||
input wire [WIDTH-1:0] I;
|
||||
output wire [WIDTH-1:0] O;
|
||||
|
||||
assign O = I;
|
||||
|
||||
endmodule
|
|
@ -92,3 +92,25 @@ module mem2reg_test5(input ctrl, output out);
|
|||
assign out = bar[foo[0]];
|
||||
endmodule
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
module mem2reg_test6 (din, dout);
|
||||
input wire [3:0] din;
|
||||
output reg [3:0] dout;
|
||||
|
||||
reg [1:0] din_array [1:0];
|
||||
reg [1:0] dout_array [1:0];
|
||||
|
||||
always @* begin
|
||||
din_array[0] = din[0 +: 2];
|
||||
din_array[1] = din[2 +: 2];
|
||||
|
||||
dout_array[0] = din_array[0];
|
||||
dout_array[1] = din_array[1];
|
||||
|
||||
{dout_array[0][1], dout_array[0][0]} = dout_array[0][0] + dout_array[1][0];
|
||||
|
||||
dout[0 +: 2] = dout_array[0];
|
||||
dout[2 +: 2] = dout_array[1];
|
||||
end
|
||||
endmodule
|
||||
|
|
11
tests/simple/param_attr.v
Normal file
11
tests/simple/param_attr.v
Normal file
|
@ -0,0 +1,11 @@
|
|||
module uut_param_attr (I, O);
|
||||
|
||||
(* PARAMETER_ATTRIBUTE = "attribute_content" *)
|
||||
parameter WIDTH = 1;
|
||||
|
||||
input wire [WIDTH-1:0] I;
|
||||
output wire [WIDTH-1:0] O;
|
||||
|
||||
assign O = I;
|
||||
|
||||
endmodule
|
13
tests/simple/peepopt.v
Normal file
13
tests/simple/peepopt.v
Normal file
|
@ -0,0 +1,13 @@
|
|||
module peepopt_shiftmul_0 #(parameter N=3, parameter W=3) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output [W-1:0] o);
|
||||
assign o = i[s*W+:W];
|
||||
endmodule
|
||||
|
||||
module peepopt_shiftmul_1 (output y, input [2:0] w);
|
||||
assign y = 1'b1 >> (w * (3'b110));
|
||||
endmodule
|
||||
|
||||
module peepopt_muldiv_0(input [1:0] i, output [1:0] o);
|
||||
wire [3:0] t;
|
||||
assign t = i * 3;
|
||||
assign o = t / 3;
|
||||
endmodule
|
|
@ -17,4 +17,5 @@ if ! which iverilog > /dev/null ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.v
|
||||
shopt -s nullglob
|
||||
exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.{sv,v}
|
||||
|
|
36
tests/simple/wandwor.v
Normal file
36
tests/simple/wandwor.v
Normal file
|
@ -0,0 +1,36 @@
|
|||
module wandwor_test0 (A, B, C, D, X, Y, Z);
|
||||
input A, B, C, D;
|
||||
output wor X;
|
||||
output wand Y;
|
||||
output Z;
|
||||
|
||||
assign X = A, X = B, Y = C, Y = D;
|
||||
foo foo_0 (C, D, X);
|
||||
foo foo_1 (A, B, Y);
|
||||
foo foo_2 (X, Y, Z);
|
||||
endmodule
|
||||
|
||||
module wandwor_test1 (A, B, C, D, X, Y, Z);
|
||||
input [3:0] A, B, C, D;
|
||||
output wor [3:0] X;
|
||||
output wand [3:0] Y;
|
||||
output Z;
|
||||
|
||||
bar bar_inst (
|
||||
.I0({A, B}),
|
||||
.I1({B, A}),
|
||||
.O({X, Y})
|
||||
);
|
||||
|
||||
assign X = C, X = D;
|
||||
assign Y = C, Y = D;
|
||||
assign Z = ^{X,Y};
|
||||
endmodule
|
||||
|
||||
module foo(input I0, I1, output O);
|
||||
assign O = I0 ^ I1;
|
||||
endmodule
|
||||
|
||||
module bar(input [7:0] I0, I1, output [7:0] O);
|
||||
assign O = I0 + I1;
|
||||
endmodule
|
|
@ -16,6 +16,7 @@ operators.v $pow
|
|||
partsel.v drops modules
|
||||
process.v drops modules
|
||||
realexpr.v drops modules
|
||||
retime.v Initial value (11110101) for (retime_test.ff) not supported
|
||||
scopes.v original verilog issues ( -x where x isn't declared signed)
|
||||
sincos.v $adff
|
||||
specify.v no code (empty module generates error
|
||||
|
|
|
@ -11,13 +11,13 @@ echo "" > $STDERRFILE
|
|||
|
||||
echo -n "Test: ${TESTNAME} -> "
|
||||
|
||||
$PWD/../../yosys -p "read_verilog -sv ${TESTNAME}.sv ; hierarchy -check -top TopModule ; synth ; write_verilog ${TESTNAME}_syn.v" >> $STDOUTFILE >> $STDERRFILE
|
||||
$PWD/../../yosys -p "read_verilog -sv ${TESTNAME}_ref.v ; hierarchy -check -top TopModule ; synth ; write_verilog ${TESTNAME}_ref_syn.v" >> $STDOUTFILE >> $STDERRFILE
|
||||
set -e
|
||||
|
||||
$PWD/../../yosys -p "read_verilog -sv ${TESTNAME}.sv ; hierarchy -check -top TopModule ; synth ; write_verilog ${TESTNAME}_syn.v" >> $STDOUTFILE 2>> $STDERRFILE
|
||||
$PWD/../../yosys -p "read_verilog -sv ${TESTNAME}_ref.v ; hierarchy -check -top TopModule ; synth ; write_verilog ${TESTNAME}_ref_syn.v" >> $STDOUTFILE 2>> $STDERRFILE
|
||||
|
||||
rm -f a.out reference_result.txt dut_result.txt
|
||||
|
||||
set -e
|
||||
|
||||
iverilog -g2012 ${TESTNAME}_syn.v
|
||||
iverilog -g2012 ${TESTNAME}_ref_syn.v
|
||||
|
||||
|
|
|
@ -89,6 +89,13 @@ done
|
|||
|
||||
compile_and_run() {
|
||||
exe="$1"; output="$2"; shift 2
|
||||
ext=${1##*.}
|
||||
if [ "$ext" == "sv" ]; then
|
||||
language_gen="-g2012"
|
||||
else
|
||||
language_gen="-g2005"
|
||||
fi
|
||||
|
||||
if $use_modelsim; then
|
||||
altver=$( ls -v /opt/altera/ | grep '^[0-9]' | tail -n1; )
|
||||
/opt/altera/$altver/modelsim_ase/bin/vlib work
|
||||
|
@ -99,7 +106,7 @@ compile_and_run() {
|
|||
/opt/Xilinx/Vivado/$xilver/bin/xvlog $xinclude_opts -d outfile=\"$output\" "$@"
|
||||
/opt/Xilinx/Vivado/$xilver/bin/xelab -R work.testbench
|
||||
else
|
||||
iverilog $include_opts -Doutfile=\"$output\" -s testbench -o "$exe" "$@"
|
||||
iverilog $language_gen $include_opts -Doutfile=\"$output\" -s testbench -o "$exe" "$@"
|
||||
vvp -n "$exe"
|
||||
fi
|
||||
}
|
||||
|
@ -110,7 +117,7 @@ for fn
|
|||
do
|
||||
bn=${fn%.*}
|
||||
ext=${fn##*.}
|
||||
if [[ "$ext" != "v" ]] && [[ "$ext" != "aag" ]] && [[ "$ext" != "aig" ]]; then
|
||||
if [[ "$ext" != "v" ]] && [[ "$ext" != "sv" ]] && [[ "$ext" != "aag" ]] && [[ "$ext" != "aig" ]]; then
|
||||
echo "Invalid argument: $fn" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
@ -123,6 +130,10 @@ do
|
|||
echo -n "Test: $bn "
|
||||
fi
|
||||
|
||||
if [ "$ext" == sv ]; then
|
||||
frontend="$frontend -sv"
|
||||
fi
|
||||
|
||||
rm -f ${bn}.{err,log,skip}
|
||||
mkdir -p ${bn}.out
|
||||
rm -rf ${bn}.out/*
|
||||
|
@ -134,9 +145,10 @@ do
|
|||
|
||||
if [[ "$ext" == "v" ]]; then
|
||||
egrep -v '^\s*`timescale' ../$fn > ${bn}_ref.${ext}
|
||||
elif [[ "$ext" == "aig" ]] || [[ "$ext" == "aag" ]]; then
|
||||
"$toolsdir"/../../yosys-abc -c "read_aiger ../${fn}; write ${bn}_ref.v"
|
||||
else
|
||||
"$toolsdir"/../../yosys -f "$frontend $include_opts" -b "verilog" -o ${bn}_ref.v ../${fn}
|
||||
frontend="verilog -noblackbox"
|
||||
cp ../${fn} ${bn}_ref.${ext}
|
||||
fi
|
||||
rm -f ${bn}_ref.fir
|
||||
|
||||
|
@ -147,7 +159,8 @@ do
|
|||
fi
|
||||
if $genvcd; then sed -i 's,// \$dump,$dump,g' ${bn}_tb.v; fi
|
||||
compile_and_run ${bn}_tb_ref ${bn}_out_ref ${bn}_tb.v ${bn}_ref.v $libs \
|
||||
"$toolsdir"/../../techlibs/common/simlib.v
|
||||
"$toolsdir"/../../techlibs/common/simlib.v \
|
||||
"$toolsdir"/../../techlibs/common/simcells.v
|
||||
if $genvcd; then mv testbench.vcd ${bn}_ref.vcd; fi
|
||||
|
||||
test_count=0
|
||||
|
|
21
tests/various/attrib05_port_conn.v
Normal file
21
tests/various/attrib05_port_conn.v
Normal file
|
@ -0,0 +1,21 @@
|
|||
module bar(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output reg out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 1'd0;
|
||||
else out <= ~inp;
|
||||
|
||||
endmodule
|
||||
|
||||
module foo(clk, rst, inp, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire inp;
|
||||
output wire out;
|
||||
|
||||
bar bar_instance ( (* clock_connected *) clk, rst, (* this_is_the_input *) inp, out);
|
||||
endmodule
|
||||
|
2
tests/various/attrib05_port_conn.ys
Normal file
2
tests/various/attrib05_port_conn.ys
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Read and parse Verilog file
|
||||
read_verilog attrib05_port_conn.v
|
21
tests/various/attrib07_func_call.v
Normal file
21
tests/various/attrib07_func_call.v
Normal file
|
@ -0,0 +1,21 @@
|
|||
function [7:0] do_add;
|
||||
input [7:0] inp_a;
|
||||
input [7:0] inp_b;
|
||||
|
||||
do_add = inp_a + inp_b;
|
||||
|
||||
endfunction
|
||||
|
||||
module foo(clk, rst, inp_a, inp_b, out);
|
||||
input wire clk;
|
||||
input wire rst;
|
||||
input wire [7:0] inp_a;
|
||||
input wire [7:0] inp_b;
|
||||
output wire [7:0] out;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst) out <= 0;
|
||||
else out <= do_add (* combinational_adder *) (inp_a, inp_b);
|
||||
|
||||
endmodule
|
||||
|
2
tests/various/attrib07_func_call.ys
Normal file
2
tests/various/attrib07_func_call.ys
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Read and parse Verilog file
|
||||
read_verilog attrib07_func_call.v
|
52
tests/various/chparam.sh
Normal file
52
tests/various/chparam.sh
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
|
||||
trap 'echo "ERROR in chparam.sh" >&2; exit 1' ERR
|
||||
|
||||
cat > chparam1.sv << "EOT"
|
||||
module top #(
|
||||
parameter [31:0] X = 0
|
||||
) (
|
||||
input [31:0] din,
|
||||
output [31:0] dout
|
||||
);
|
||||
assign dout = X-din;
|
||||
endmodule
|
||||
|
||||
module top_props #(
|
||||
parameter [31:0] X = 0
|
||||
) (
|
||||
input [31:0] dout
|
||||
);
|
||||
always @* assert (dout != X);
|
||||
endmodule
|
||||
|
||||
bind top top_props #(.X(123456789)) props (.*);
|
||||
EOT
|
||||
|
||||
cat > chparam2.sv << "EOT"
|
||||
module top #(
|
||||
parameter [31:0] X = 0
|
||||
) (
|
||||
input [31:0] din,
|
||||
output [31:0] dout
|
||||
);
|
||||
assign dout = X-din;
|
||||
always @* assert (dout != 123456789);
|
||||
endmodule
|
||||
EOT
|
||||
|
||||
if ../../yosys -q -p 'verific -sv chparam1.sv'; then
|
||||
../../yosys -q -p 'verific -sv chparam1.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \
|
||||
-p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \
|
||||
-p 'sat -falsify -prove-asserts -show-ports -set din[0] 0'
|
||||
|
||||
../../yosys -q -p 'verific -sv chparam2.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \
|
||||
-p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \
|
||||
-p 'sat -falsify -prove-asserts -show-ports -set din[0] 0'
|
||||
fi
|
||||
../../yosys -q -p 'read_verilog -sv chparam2.sv; hierarchy -chparam X 123123123 -top top; prep -flatten' \
|
||||
-p 'sat -verify -prove-asserts -show-ports -set din[0] 1' \
|
||||
-p 'sat -falsify -prove-asserts -show-ports -set din[0] 0'
|
||||
|
||||
rm chparam1.sv
|
||||
rm chparam2.sv
|
30
tests/various/elab_sys_tasks.sv
Normal file
30
tests/various/elab_sys_tasks.sv
Normal file
|
@ -0,0 +1,30 @@
|
|||
module test;
|
||||
localparam X=1;
|
||||
genvar i;
|
||||
generate
|
||||
if (X == 1)
|
||||
$info("X is 1");
|
||||
if (X == 1)
|
||||
$warning("X is 1");
|
||||
else
|
||||
$error("X is not 1");
|
||||
case (X)
|
||||
1: $info("X is 1 in a case statement");
|
||||
endcase
|
||||
//case (X-1)
|
||||
// 1: $warn("X is 2");
|
||||
// default: $warn("X might be anything in a case statement");
|
||||
//endcase
|
||||
for (i = 0; i < 3; i = i + 1)
|
||||
begin
|
||||
case(i)
|
||||
0: $info;
|
||||
1: $warning;
|
||||
default: $info("default case statemnent");
|
||||
endcase
|
||||
end
|
||||
|
||||
$info("This is a standalone $info(). Next $info has no parameters");
|
||||
$info;
|
||||
endgenerate
|
||||
endmodule
|
1
tests/various/elab_sys_tasks.ys
Normal file
1
tests/various/elab_sys_tasks.ys
Normal file
|
@ -0,0 +1 @@
|
|||
read_verilog -sv elab_sys_tasks.sv
|
50
tests/various/opt_rmdff.v
Normal file
50
tests/various/opt_rmdff.v
Normal file
|
@ -0,0 +1,50 @@
|
|||
module opt_rmdff_test (input C, input D, input E, output [29:0] Q);
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) remove0 (.CLK(C), .D(D), .EN(1'b0), .Q(Q[0])); // EN is never active
|
||||
(* init = "1'b1" *) wire Q1; assign Q[1] = Q1;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) remove1 (.CLK(C), .D(D), .EN(1'b0), .Q(Q1)); // EN is never active
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) remove2 (.CLK(C), .D(D), .EN(1'bx), .Q(Q[2])); // EN is don't care
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) keep3 (.CLK(C), .D(D), .EN(1'b1), .Q(Q[3])); // EN is always active
|
||||
(* init = "1'b0" *) wire Q4; assign Q[4] = Q4;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(0), .EN_POLARITY(1)) keep4 (.CLK(C), .D(D), .EN(1'b1), .Q(Q4)); // EN is always active
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(0)) remove5 (.CLK(C), .D(D), .EN(1'b1), .Q(Q[5])); // EN is never active
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(0)) remove6 (.CLK(C), .D(D), .EN(1'bx), .Q(Q[6])); // EN is don't care
|
||||
(* init = "1'b0" *) wire Q7; assign Q[7] = Q7;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(0), .EN_POLARITY(0)) keep7 (.CLK(C), .D(D), .EN(E), .Q(Q7)); // EN is non constant
|
||||
|
||||
\$_DFFE_PP_ remove8 (.C(C), .D(D), .E(1'b0), .Q(Q[8])); // EN is never active
|
||||
(* init = "1'b1" *) wire Q9; assign Q[9] = Q9;
|
||||
\$_DFFE_PP_ remove9 (.C(C), .D(D), .E(1'b0), .Q(Q9)); // EN is never active
|
||||
\$_DFFE_PP_ remove10 (.C(C), .D(D), .E(1'bx), .Q(Q[10])); // EN is don't care
|
||||
\$_DFFE_PP_ keep11 (.C(C), .D(D), .E(1'b1), .Q(Q[11])); // EN is always active
|
||||
(* init = "1'b0" *) wire Q12; assign Q[12] = Q12;
|
||||
\$_DFFE_PP_ keep12 (.C(C), .D(D), .E(1'b1), .Q(Q12)); // EN is always active
|
||||
|
||||
\$_DFFE_NN_ remove13 (.C(C), .D(D), .E(1'b1), .Q(Q[13])); // EN is never active
|
||||
(* init = "1'b1" *) wire Q14; assign Q[14] = Q14;
|
||||
\$_DFFE_NN_ remove14 (.C(C), .D(D), .E(1'b1), .Q(Q14)); // EN is never active
|
||||
\$_DFFE_NN_ remove15 (.C(C), .D(D), .E(1'bx), .Q(Q[15])); // EN is don't care
|
||||
\$_DFFE_NN_ keep16 (.C(C), .D(D), .E(1'b0), .Q(Q[16])); // EN is always active
|
||||
(* init = "1'b0" *) wire Q17; assign Q[17] = Q17;
|
||||
\$_DFFE_NN_ keep17 (.C(C), .D(D), .E(1'b0), .Q(Q17)); // EN is always active
|
||||
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) remove18 (.CLK(1'b0), .D(D), .EN(E), .Q(Q[18])); // CLK is constant
|
||||
(* init = "1'b1" *) wire Q19; assign Q[19] = Q19;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) remove19 (.CLK(1'b1), .D(D), .EN(E), .Q(Q19)); // CLK is constant
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) remove20 (.CLK(C), .D(1'bx), .EN(E), .Q(Q[20])); // D is undriven, Q has no initial value
|
||||
(* init = "1'b0" *) wire Q21; assign Q[21] = Q21;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) keep21 (.CLK(C), .D(1'bx), .EN(E), .Q(Q21)); // D is undriven, Q has initial value
|
||||
//\$dffe #(.WIDTH(1), .CLK_POLARITY(0), .EN_POLARITY(1)) remove22 (.CLK(C), .D(1'b0), .EN(1'b1), .Q(Q[22])); // D is constant, no initial Q value, EN is always active
|
||||
// // (TODO, Q starts with 1'bx and becomes 1'b0)
|
||||
(* init = "1'b0" *) wire Q23; assign Q[23] = Q23;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) noenable23 (.CLK(C), .D(1'b0), .EN(1'b1), .Q(Q23)); // D is constant, initial Q value same as D, EN is always active
|
||||
(* init = "1'b1" *) wire Q24; assign Q[24] = Q24;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(0)) keep24 (.CLK(C), .D(1'b0), .EN(1'b0), .Q(Q24)); // D is constant, initial Q value NOT same as D, EN is always active
|
||||
(* init = "1'b1" *) wire Q25; assign Q[25] = Q25;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(0)) remove25 (.CLK(C), .D(1'b0), .EN(1'b1), .Q(Q25)); // D is constant, EN is never active
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) remove26 (.CLK(C), .D(Q[26]), .EN(1'b1), .Q(Q[26])); // D is Q, EN is always active
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(0)) remove27 (.CLK(C), .D(Q[27]), .EN(1'b1), .Q(Q[27])); // D is Q, EN is never active, but no initial value
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(0)) remove28 (.CLK(C), .D(Q[28]), .EN(E), .Q(Q[28])); // EN is nonconst, but no initial value
|
||||
(* init = "1'b1" *) wire Q29; assign Q[29] = Q29;
|
||||
\$dffe #(.WIDTH(1), .CLK_POLARITY(1), .EN_POLARITY(1)) keep29 (.CLK(C), .D(Q[29]), .EN(1'b1), .Q(Q29)); // EN is always active, but with initial value
|
||||
|
||||
endmodule
|
26
tests/various/opt_rmdff.ys
Normal file
26
tests/various/opt_rmdff.ys
Normal file
|
@ -0,0 +1,26 @@
|
|||
read_verilog -icells opt_rmdff.v
|
||||
prep
|
||||
design -stash gold
|
||||
read_verilog -icells opt_rmdff.v
|
||||
proc
|
||||
opt_rmdff
|
||||
|
||||
select -assert-count 0 c:remove*
|
||||
select -assert-min 7 c:keep*
|
||||
select -assert-count 0 t:$dffe 7:$_DFFE_* %u c:noenable* %i
|
||||
|
||||
design -stash gate
|
||||
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
|
||||
equiv_make gold gate equiv
|
||||
hierarchy -top equiv
|
||||
equiv_simple -undef
|
||||
equiv_status -assert
|
||||
|
||||
design -load gold
|
||||
stat
|
||||
|
||||
design -load gate
|
||||
stat
|
30
tests/various/specify.v
Normal file
30
tests/various/specify.v
Normal file
|
@ -0,0 +1,30 @@
|
|||
module test (
|
||||
input EN, CLK,
|
||||
input [3:0] D,
|
||||
output reg [3:0] Q
|
||||
);
|
||||
always @(posedge CLK)
|
||||
if (EN) Q <= D;
|
||||
|
||||
specify
|
||||
if (EN) (CLK *> (Q : D)) = (1, 2:3:4);
|
||||
$setup(D, posedge CLK &&& EN, 5);
|
||||
$hold(posedge CLK, D &&& EN, 6);
|
||||
endspecify
|
||||
endmodule
|
||||
|
||||
module test2 (
|
||||
input A, B,
|
||||
output Q
|
||||
);
|
||||
xor (Q, A, B);
|
||||
specify
|
||||
//specparam T_rise = 1;
|
||||
//specparam T_fall = 2;
|
||||
`define T_rise 1
|
||||
`define T_fall 2
|
||||
(A => Q) = (`T_rise,`T_fall);
|
||||
//(B => Q) = (`T_rise+`T_fall)/2.0;
|
||||
(B => Q) = 1.5;
|
||||
endspecify
|
||||
endmodule
|
56
tests/various/specify.ys
Normal file
56
tests/various/specify.ys
Normal file
|
@ -0,0 +1,56 @@
|
|||
read_verilog -specify specify.v
|
||||
prep
|
||||
cd test
|
||||
select t:$specify2 -assert-count 0
|
||||
select t:$specify3 -assert-count 1
|
||||
select t:$specrule -assert-count 2
|
||||
cd test2
|
||||
select t:$specify2 -assert-count 2
|
||||
select t:$specify3 -assert-count 0
|
||||
select t:$specrule -assert-count 0
|
||||
cd
|
||||
write_verilog specify.out
|
||||
design -stash gold
|
||||
|
||||
read_verilog -specify specify.out
|
||||
prep
|
||||
cd test
|
||||
select t:$specify2 -assert-count 0
|
||||
select t:$specify3 -assert-count 1
|
||||
select t:$specrule -assert-count 2
|
||||
cd test2
|
||||
select t:$specify2 -assert-count 2
|
||||
select t:$specify3 -assert-count 0
|
||||
select t:$specrule -assert-count 0
|
||||
cd
|
||||
design -stash gate
|
||||
|
||||
design -copy-from gold -as gold test
|
||||
design -copy-from gate -as gate test
|
||||
rename -hide
|
||||
rename -enumerate -pattern A_% t:$specify3
|
||||
rename -enumerate -pattern B_% t:$specrule r:TYPE=$setup %i
|
||||
rename -enumerate -pattern C_% t:$specrule r:TYPE=$hold %i
|
||||
select n:A_* -assert-count 2
|
||||
select n:B_* -assert-count 2
|
||||
select n:C_* -assert-count 2
|
||||
equiv_make gold gate equiv
|
||||
hierarchy -top equiv
|
||||
equiv_struct
|
||||
equiv_induct -seq 5
|
||||
equiv_status -assert
|
||||
design -reset
|
||||
|
||||
design -copy-from gold -as gold test2
|
||||
design -copy-from gate -as gate test2
|
||||
rename -hide
|
||||
rename -enumerate -pattern A_% t:$specify2 r:T_RISE_TYP=1 %i
|
||||
rename -enumerate -pattern B_% t:$specify2 n:A_* %d
|
||||
select n:A_* -assert-count 2
|
||||
select n:B_* -assert-count 2
|
||||
equiv_make gold gate equiv
|
||||
hierarchy -top equiv
|
||||
equiv_struct
|
||||
equiv_induct -seq 5
|
||||
equiv_status -assert
|
||||
design -reset
|
Loading…
Add table
Add a link
Reference in a new issue