mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 00:55:32 +00:00
Merge remote-tracking branch 'origin/eddie/muxpack' into xc7mux
This commit is contained in:
commit
eaee250a6e
23 changed files with 819 additions and 12 deletions
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
|
||||
|
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
|
112
tests/various/muxpack.v
Normal file
112
tests/various/muxpack.v
Normal file
|
@ -0,0 +1,112 @@
|
|||
module mux_if_unbal_4_1 #(parameter N=4, parameter W=1) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @*
|
||||
if (s == 0) o <= i[0*W+:W];
|
||||
else if (s == 1) o <= i[1*W+:W];
|
||||
else if (s == 2) o <= i[2*W+:W];
|
||||
else if (s == 3) o <= i[3*W+:W];
|
||||
else o <= {W{1'bx}};
|
||||
endmodule
|
||||
|
||||
module mux_if_unbal_5_3 #(parameter N=5, parameter W=3) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @* begin
|
||||
o <= {W{1'bx}};
|
||||
if (s == 0) o <= i[0*W+:W];
|
||||
if (s == 1) o <= i[1*W+:W];
|
||||
if (s == 2) o <= i[2*W+:W];
|
||||
if (s == 3) o <= i[3*W+:W];
|
||||
if (s == 4) o <= i[4*W+:W];
|
||||
end
|
||||
endmodule
|
||||
|
||||
module mux_if_unbal_5_3_invert #(parameter N=5, parameter W=3) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @*
|
||||
if (s != 0)
|
||||
if (s != 1)
|
||||
if (s != 2)
|
||||
if (s != 3)
|
||||
if (s != 4) o <= i[4*W+:W];
|
||||
else o <= i[0*W+:W];
|
||||
else o <= i[3*W+:W];
|
||||
else o <= i[2*W+:W];
|
||||
else o <= i[1*W+:W];
|
||||
else o <= {W{1'bx}};
|
||||
endmodule
|
||||
|
||||
module mux_if_unbal_5_3_width_mismatch #(parameter N=5, parameter W=3) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @* begin
|
||||
o <= {W{1'bx}};
|
||||
if (s == 0) o <= i[0*W+:W];
|
||||
if (s == 1) o <= i[1*W+:W];
|
||||
if (s == 2) o[W-2:0] <= i[2*W+:W-1];
|
||||
if (s == 3) o <= i[3*W+:W];
|
||||
if (s == 4) o <= i[4*W+:W];
|
||||
end
|
||||
endmodule
|
||||
|
||||
module mux_if_unbal_4_1_missing #(parameter N=5, parameter W=3) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @* begin
|
||||
if (s == 0) o <= i[0*W+:W];
|
||||
// else if (s == 1) o <= i[1*W+:W];
|
||||
// else if (s == 2) o <= i[2*W+:W];
|
||||
else if (s == 3) o <= i[3*W+:W];
|
||||
else o <= {W{1'bx}};
|
||||
end
|
||||
endmodule
|
||||
|
||||
module mux_if_unbal_5_3_order #(parameter N=5, parameter W=3) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @* begin
|
||||
o <= {W{1'bx}};
|
||||
if (s == 3) o <= i[3*W+:W];
|
||||
if (s == 2) o <= i[2*W+:W];
|
||||
if (s == 1) o <= i[1*W+:W];
|
||||
if (s == 4) o <= i[4*W+:W];
|
||||
if (s == 0) o <= i[0*W+:W];
|
||||
end
|
||||
endmodule
|
||||
|
||||
module mux_if_unbal_4_1_nonexcl #(parameter N=4, parameter W=1) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @*
|
||||
if (s == 0) o <= i[0*W+:W];
|
||||
else if (s == 1) o <= i[1*W+:W];
|
||||
else if (s == 2) o <= i[2*W+:W];
|
||||
else if (s == 3) o <= i[3*W+:W];
|
||||
else if (s == 0) o <= {W{1'b0}};
|
||||
else o <= {W{1'bx}};
|
||||
endmodule
|
||||
|
||||
module mux_if_unbal_5_3_nonexcl #(parameter N=5, parameter W=3) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @* begin
|
||||
o <= {W{1'bx}};
|
||||
if (s == 0) o <= i[0*W+:W];
|
||||
if (s == 1) o <= i[1*W+:W];
|
||||
if (s == 2) o <= i[2*W+:W];
|
||||
if (s == 3) o <= i[3*W+:W];
|
||||
if (s == 4) o <= i[4*W+:W];
|
||||
if (s == 0) o <= i[2*W+:W];
|
||||
end
|
||||
endmodule
|
||||
|
||||
module mux_case_unbal_8_7#(parameter N=8, parameter W=7) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o);
|
||||
always @* begin
|
||||
o <= {W{1'bx}};
|
||||
case (s)
|
||||
0: o <= i[0*W+:W];
|
||||
default:
|
||||
case (s)
|
||||
1: o <= i[1*W+:W];
|
||||
2: o <= i[2*W+:W];
|
||||
default:
|
||||
case (s)
|
||||
3: o <= i[3*W+:W];
|
||||
4: o <= i[4*W+:W];
|
||||
5: o <= i[5*W+:W];
|
||||
default:
|
||||
case (s)
|
||||
6: o <= i[6*W+:W];
|
||||
default: o <= i[7*W+:W];
|
||||
endcase
|
||||
endcase
|
||||
endcase
|
||||
endcase
|
||||
end
|
||||
endmodule
|
135
tests/various/muxpack.ys
Normal file
135
tests/various/muxpack.ys
Normal file
|
@ -0,0 +1,135 @@
|
|||
read_verilog muxpack.v
|
||||
design -save read
|
||||
hierarchy -top mux_if_unbal_4_1
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 1 t:$pmux
|
||||
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 miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top mux_if_unbal_5_3
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 1 t:$pmux
|
||||
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 miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top mux_if_unbal_5_3_invert
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 1 t:$pmux
|
||||
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 miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top mux_if_unbal_5_3_width_mismatch
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 2 t:$pmux
|
||||
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 miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top mux_if_unbal_4_1_missing
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 1 t:$pmux
|
||||
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 miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top mux_if_unbal_5_3_order
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 1 t:$pmux
|
||||
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 miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top mux_if_unbal_4_1_nonexcl
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 1 t:$pmux
|
||||
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 miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top mux_if_unbal_5_3_nonexcl
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 1 t:$pmux
|
||||
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 miter
|
||||
|
||||
design -load read
|
||||
hierarchy -top mux_case_unbal_8_7
|
||||
prep
|
||||
design -save gold
|
||||
muxpack
|
||||
opt
|
||||
stat
|
||||
select -assert-count 0 t:$mux
|
||||
select -assert-count 1 t:$pmux
|
||||
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 miter
|
Loading…
Add table
Add a link
Reference in a new issue