mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-27 19:05:52 +00:00
Move (most of) ExOth and ExAdv slides
This commit is contained in:
parent
7ab051778e
commit
8ade2182b0
49 changed files with 828 additions and 1027 deletions
2
docs/resources/PRESENTATION_ExAdv/.gitignore
vendored
Normal file
2
docs/resources/PRESENTATION_ExAdv/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.dot
|
||||
*.pdf
|
29
docs/resources/PRESENTATION_ExAdv/Makefile
Normal file
29
docs/resources/PRESENTATION_ExAdv/Makefile
Normal file
|
@ -0,0 +1,29 @@
|
|||
YOSYS = ../../../yosys
|
||||
|
||||
all: select.pdf red_or3x1.pdf sym_mul.pdf mymul.pdf mulshift.pdf addshift.pdf \
|
||||
macc_simple_xmap.pdf macc_xilinx_xmap.pdf
|
||||
|
||||
select.pdf: select.v select.ys
|
||||
$(YOSYS) select.ys
|
||||
|
||||
red_or3x1.pdf: red_or3x1_*
|
||||
$(YOSYS) red_or3x1_test.ys
|
||||
|
||||
sym_mul.pdf: sym_mul_*
|
||||
$(YOSYS) sym_mul_test.ys
|
||||
|
||||
mymul.pdf: mymul_*
|
||||
$(YOSYS) mymul_test.ys
|
||||
|
||||
mulshift.pdf: mulshift_*
|
||||
$(YOSYS) mulshift_test.ys
|
||||
|
||||
addshift.pdf: addshift_*
|
||||
$(YOSYS) addshift_test.ys
|
||||
|
||||
macc_simple_xmap.pdf: macc_simple_*.v macc_simple_test.ys
|
||||
$(YOSYS) macc_simple_test.ys
|
||||
|
||||
macc_xilinx_xmap.pdf: macc_xilinx_*.v macc_xilinx_test.ys
|
||||
$(YOSYS) macc_xilinx_test.ys
|
||||
|
20
docs/resources/PRESENTATION_ExAdv/addshift_map.v
Normal file
20
docs/resources/PRESENTATION_ExAdv/addshift_map.v
Normal file
|
@ -0,0 +1,20 @@
|
|||
module \$add (A, B, Y);
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
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] Y;
|
||||
|
||||
parameter _TECHMAP_BITS_CONNMAP_ = 0;
|
||||
parameter _TECHMAP_CONNMAP_A_ = 0;
|
||||
parameter _TECHMAP_CONNMAP_B_ = 0;
|
||||
|
||||
wire _TECHMAP_FAIL_ = A_WIDTH != B_WIDTH || B_WIDTH < Y_WIDTH ||
|
||||
_TECHMAP_CONNMAP_A_ != _TECHMAP_CONNMAP_B_;
|
||||
|
||||
assign Y = A << 1;
|
||||
endmodule
|
5
docs/resources/PRESENTATION_ExAdv/addshift_test.v
Normal file
5
docs/resources/PRESENTATION_ExAdv/addshift_test.v
Normal file
|
@ -0,0 +1,5 @@
|
|||
module test (A, B, X, Y);
|
||||
input [7:0] A, B;
|
||||
output [7:0] X = A + B;
|
||||
output [7:0] Y = A + A;
|
||||
endmodule
|
6
docs/resources/PRESENTATION_ExAdv/addshift_test.ys
Normal file
6
docs/resources/PRESENTATION_ExAdv/addshift_test.ys
Normal file
|
@ -0,0 +1,6 @@
|
|||
read_verilog addshift_test.v
|
||||
hierarchy -check -top test
|
||||
|
||||
techmap -map addshift_map.v;;
|
||||
|
||||
show -prefix addshift -format pdf -notitle
|
6
docs/resources/PRESENTATION_ExAdv/macc_simple_test.v
Normal file
6
docs/resources/PRESENTATION_ExAdv/macc_simple_test.v
Normal file
|
@ -0,0 +1,6 @@
|
|||
module test(a, b, c, d, y);
|
||||
input [15:0] a, b;
|
||||
input [31:0] c, d;
|
||||
output [31:0] y;
|
||||
assign y = a * b + c + d;
|
||||
endmodule
|
37
docs/resources/PRESENTATION_ExAdv/macc_simple_test.ys
Normal file
37
docs/resources/PRESENTATION_ExAdv/macc_simple_test.ys
Normal file
|
@ -0,0 +1,37 @@
|
|||
read_verilog macc_simple_test.v
|
||||
hierarchy -check -top test;;
|
||||
|
||||
show -prefix macc_simple_test_00a -format pdf -notitle -lib macc_simple_xmap.v
|
||||
|
||||
extract -constports -map macc_simple_xmap.v;;
|
||||
show -prefix macc_simple_test_00b -format pdf -notitle -lib macc_simple_xmap.v
|
||||
|
||||
#################################################
|
||||
|
||||
design -reset
|
||||
read_verilog macc_simple_test_01.v
|
||||
hierarchy -check -top test;;
|
||||
|
||||
show -prefix macc_simple_test_01a -format pdf -notitle -lib macc_simple_xmap.v
|
||||
|
||||
extract -map macc_simple_xmap.v;;
|
||||
show -prefix macc_simple_test_01b -format pdf -notitle -lib macc_simple_xmap.v
|
||||
|
||||
#################################################
|
||||
|
||||
design -reset
|
||||
read_verilog macc_simple_test_02.v
|
||||
hierarchy -check -top test;;
|
||||
|
||||
show -prefix macc_simple_test_02a -format pdf -notitle -lib macc_simple_xmap.v
|
||||
|
||||
extract -map macc_simple_xmap.v;;
|
||||
show -prefix macc_simple_test_02b -format pdf -notitle -lib macc_simple_xmap.v
|
||||
|
||||
#################################################
|
||||
|
||||
design -reset
|
||||
read_verilog macc_simple_xmap.v
|
||||
hierarchy -check -top macc_16_16_32;;
|
||||
|
||||
show -prefix macc_simple_xmap -format pdf -notitle
|
6
docs/resources/PRESENTATION_ExAdv/macc_simple_test_01.v
Normal file
6
docs/resources/PRESENTATION_ExAdv/macc_simple_test_01.v
Normal file
|
@ -0,0 +1,6 @@
|
|||
module test(a, b, c, d, x, y);
|
||||
input [15:0] a, b, c, d;
|
||||
input [31:0] x;
|
||||
output [31:0] y;
|
||||
assign y = a*b + c*d + x;
|
||||
endmodule
|
6
docs/resources/PRESENTATION_ExAdv/macc_simple_test_02.v
Normal file
6
docs/resources/PRESENTATION_ExAdv/macc_simple_test_02.v
Normal file
|
@ -0,0 +1,6 @@
|
|||
module test(a, b, c, d, x, y);
|
||||
input [15:0] a, b, c, d;
|
||||
input [31:0] x;
|
||||
output [31:0] y;
|
||||
assign y = a*b + (c*d + x);
|
||||
endmodule
|
6
docs/resources/PRESENTATION_ExAdv/macc_simple_xmap.v
Normal file
6
docs/resources/PRESENTATION_ExAdv/macc_simple_xmap.v
Normal file
|
@ -0,0 +1,6 @@
|
|||
module macc_16_16_32(a, b, c, y);
|
||||
input [15:0] a, b;
|
||||
input [31:0] c;
|
||||
output [31:0] y;
|
||||
assign y = a*b + c;
|
||||
endmodule
|
28
docs/resources/PRESENTATION_ExAdv/macc_xilinx_swap_map.v
Normal file
28
docs/resources/PRESENTATION_ExAdv/macc_xilinx_swap_map.v
Normal file
|
@ -0,0 +1,28 @@
|
|||
(* techmap_celltype = "$mul" *)
|
||||
module mul_swap_ports (A, B, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
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] Y;
|
||||
|
||||
wire _TECHMAP_FAIL_ = A_WIDTH <= B_WIDTH;
|
||||
|
||||
\$mul #(
|
||||
.A_SIGNED(B_SIGNED),
|
||||
.B_SIGNED(A_SIGNED),
|
||||
.A_WIDTH(B_WIDTH),
|
||||
.B_WIDTH(A_WIDTH),
|
||||
.Y_WIDTH(Y_WIDTH)
|
||||
) _TECHMAP_REPLACE_ (
|
||||
.A(B),
|
||||
.B(A),
|
||||
.Y(Y)
|
||||
);
|
||||
|
||||
endmodule
|
13
docs/resources/PRESENTATION_ExAdv/macc_xilinx_test.v
Normal file
13
docs/resources/PRESENTATION_ExAdv/macc_xilinx_test.v
Normal file
|
@ -0,0 +1,13 @@
|
|||
module test1(a, b, c, d, e, f, y);
|
||||
input [19:0] a, b, c;
|
||||
input [15:0] d, e, f;
|
||||
output [41:0] y;
|
||||
assign y = a*b + c*d + e*f;
|
||||
endmodule
|
||||
|
||||
module test2(a, b, c, d, e, f, y);
|
||||
input [19:0] a, b, c;
|
||||
input [15:0] d, e, f;
|
||||
output [41:0] y;
|
||||
assign y = a*b + (c*d + e*f);
|
||||
endmodule
|
43
docs/resources/PRESENTATION_ExAdv/macc_xilinx_test.ys
Normal file
43
docs/resources/PRESENTATION_ExAdv/macc_xilinx_test.ys
Normal file
|
@ -0,0 +1,43 @@
|
|||
read_verilog macc_xilinx_test.v
|
||||
read_verilog -lib -icells macc_xilinx_unwrap_map.v
|
||||
read_verilog -lib -icells macc_xilinx_xmap.v
|
||||
hierarchy -check ;;
|
||||
|
||||
show -prefix macc_xilinx_test1a -format pdf -notitle test1
|
||||
show -prefix macc_xilinx_test2a -format pdf -notitle test2
|
||||
|
||||
techmap -map macc_xilinx_swap_map.v;;
|
||||
|
||||
show -prefix macc_xilinx_test1b -format pdf -notitle test1
|
||||
show -prefix macc_xilinx_test2b -format pdf -notitle test2
|
||||
|
||||
techmap -map macc_xilinx_wrap_map.v
|
||||
|
||||
connwrappers -unsigned $__mul_wrapper Y Y_WIDTH \
|
||||
-unsigned $__add_wrapper Y Y_WIDTH;;
|
||||
|
||||
show -prefix macc_xilinx_test1c -format pdf -notitle test1
|
||||
show -prefix macc_xilinx_test2c -format pdf -notitle test2
|
||||
|
||||
design -push
|
||||
read_verilog macc_xilinx_xmap.v
|
||||
techmap -map macc_xilinx_swap_map.v
|
||||
techmap -map macc_xilinx_wrap_map.v;;
|
||||
design -save __macc_xilinx_xmap
|
||||
design -pop
|
||||
|
||||
extract -constports -ignore_parameters \
|
||||
-map %__macc_xilinx_xmap \
|
||||
-swap $__add_wrapper A,B ;;
|
||||
|
||||
show -prefix macc_xilinx_test1d -format pdf -notitle test1
|
||||
show -prefix macc_xilinx_test2d -format pdf -notitle test2
|
||||
|
||||
techmap -map macc_xilinx_unwrap_map.v;;
|
||||
|
||||
show -prefix macc_xilinx_test1e -format pdf -notitle test1
|
||||
show -prefix macc_xilinx_test2e -format pdf -notitle test2
|
||||
|
||||
design -load __macc_xilinx_xmap
|
||||
show -prefix macc_xilinx_xmap -format pdf -notitle
|
||||
|
61
docs/resources/PRESENTATION_ExAdv/macc_xilinx_unwrap_map.v
Normal file
61
docs/resources/PRESENTATION_ExAdv/macc_xilinx_unwrap_map.v
Normal file
|
@ -0,0 +1,61 @@
|
|||
module \$__mul_wrapper (A, B, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
parameter A_WIDTH = 1;
|
||||
parameter B_WIDTH = 1;
|
||||
parameter Y_WIDTH = 1;
|
||||
|
||||
input [17:0] A;
|
||||
input [24:0] B;
|
||||
output [47:0] Y;
|
||||
|
||||
wire [A_WIDTH-1:0] A_ORIG = A;
|
||||
wire [B_WIDTH-1:0] B_ORIG = B;
|
||||
wire [Y_WIDTH-1:0] Y_ORIG;
|
||||
assign Y = Y_ORIG;
|
||||
|
||||
\$mul #(
|
||||
.A_SIGNED(A_SIGNED),
|
||||
.B_SIGNED(B_SIGNED),
|
||||
.A_WIDTH(A_WIDTH),
|
||||
.B_WIDTH(B_WIDTH),
|
||||
.Y_WIDTH(Y_WIDTH)
|
||||
) _TECHMAP_REPLACE_ (
|
||||
.A(A_ORIG),
|
||||
.B(B_ORIG),
|
||||
.Y(Y_ORIG)
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
||||
module \$__add_wrapper (A, B, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
parameter A_WIDTH = 1;
|
||||
parameter B_WIDTH = 1;
|
||||
parameter Y_WIDTH = 1;
|
||||
|
||||
input [47:0] A;
|
||||
input [47:0] B;
|
||||
output [47:0] Y;
|
||||
|
||||
wire [A_WIDTH-1:0] A_ORIG = A;
|
||||
wire [B_WIDTH-1:0] B_ORIG = B;
|
||||
wire [Y_WIDTH-1:0] Y_ORIG;
|
||||
assign Y = Y_ORIG;
|
||||
|
||||
\$add #(
|
||||
.A_SIGNED(A_SIGNED),
|
||||
.B_SIGNED(B_SIGNED),
|
||||
.A_WIDTH(A_WIDTH),
|
||||
.B_WIDTH(B_WIDTH),
|
||||
.Y_WIDTH(Y_WIDTH)
|
||||
) _TECHMAP_REPLACE_ (
|
||||
.A(A_ORIG),
|
||||
.B(B_ORIG),
|
||||
.Y(Y_ORIG)
|
||||
);
|
||||
|
||||
endmodule
|
89
docs/resources/PRESENTATION_ExAdv/macc_xilinx_wrap_map.v
Normal file
89
docs/resources/PRESENTATION_ExAdv/macc_xilinx_wrap_map.v
Normal file
|
@ -0,0 +1,89 @@
|
|||
(* techmap_celltype = "$mul" *)
|
||||
module mul_wrap (A, B, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
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] Y;
|
||||
|
||||
wire [17:0] A_18 = A;
|
||||
wire [24:0] B_25 = B;
|
||||
wire [47:0] Y_48;
|
||||
assign Y = Y_48;
|
||||
|
||||
wire [1023:0] _TECHMAP_DO_ = "proc; clean";
|
||||
|
||||
reg _TECHMAP_FAIL_;
|
||||
initial begin
|
||||
_TECHMAP_FAIL_ <= 0;
|
||||
if (A_SIGNED || B_SIGNED)
|
||||
_TECHMAP_FAIL_ <= 1;
|
||||
if (A_WIDTH < 4 || B_WIDTH < 4)
|
||||
_TECHMAP_FAIL_ <= 1;
|
||||
if (A_WIDTH > 18 || B_WIDTH > 25)
|
||||
_TECHMAP_FAIL_ <= 1;
|
||||
if (A_WIDTH*B_WIDTH < 100)
|
||||
_TECHMAP_FAIL_ <= 1;
|
||||
end
|
||||
|
||||
\$__mul_wrapper #(
|
||||
.A_SIGNED(A_SIGNED),
|
||||
.B_SIGNED(B_SIGNED),
|
||||
.A_WIDTH(A_WIDTH),
|
||||
.B_WIDTH(B_WIDTH),
|
||||
.Y_WIDTH(Y_WIDTH)
|
||||
) _TECHMAP_REPLACE_ (
|
||||
.A(A_18),
|
||||
.B(B_25),
|
||||
.Y(Y_48)
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
||||
(* techmap_celltype = "$add" *)
|
||||
module add_wrap (A, B, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
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] Y;
|
||||
|
||||
wire [47:0] A_48 = A;
|
||||
wire [47:0] B_48 = B;
|
||||
wire [47:0] Y_48;
|
||||
assign Y = Y_48;
|
||||
|
||||
wire [1023:0] _TECHMAP_DO_ = "proc; clean";
|
||||
|
||||
reg _TECHMAP_FAIL_;
|
||||
initial begin
|
||||
_TECHMAP_FAIL_ <= 0;
|
||||
if (A_SIGNED || B_SIGNED)
|
||||
_TECHMAP_FAIL_ <= 1;
|
||||
if (A_WIDTH < 10 && B_WIDTH < 10)
|
||||
_TECHMAP_FAIL_ <= 1;
|
||||
end
|
||||
|
||||
\$__add_wrapper #(
|
||||
.A_SIGNED(A_SIGNED),
|
||||
.B_SIGNED(B_SIGNED),
|
||||
.A_WIDTH(A_WIDTH),
|
||||
.B_WIDTH(B_WIDTH),
|
||||
.Y_WIDTH(Y_WIDTH)
|
||||
) _TECHMAP_REPLACE_ (
|
||||
.A(A_48),
|
||||
.B(B_48),
|
||||
.Y(Y_48)
|
||||
);
|
||||
|
||||
endmodule
|
10
docs/resources/PRESENTATION_ExAdv/macc_xilinx_xmap.v
Normal file
10
docs/resources/PRESENTATION_ExAdv/macc_xilinx_xmap.v
Normal file
|
@ -0,0 +1,10 @@
|
|||
module DSP48_MACC (a, b, c, y);
|
||||
|
||||
input [17:0] a;
|
||||
input [24:0] b;
|
||||
input [47:0] c;
|
||||
output [47:0] y;
|
||||
|
||||
assign y = a*b + c;
|
||||
|
||||
endmodule
|
26
docs/resources/PRESENTATION_ExAdv/mulshift_map.v
Normal file
26
docs/resources/PRESENTATION_ExAdv/mulshift_map.v
Normal file
|
@ -0,0 +1,26 @@
|
|||
module MYMUL(A, B, Y);
|
||||
parameter WIDTH = 1;
|
||||
input [WIDTH-1:0] A, B;
|
||||
output reg [WIDTH-1:0] Y;
|
||||
|
||||
parameter _TECHMAP_CONSTVAL_A_ = WIDTH'bx;
|
||||
parameter _TECHMAP_CONSTVAL_B_ = WIDTH'bx;
|
||||
|
||||
reg _TECHMAP_FAIL_;
|
||||
wire [1023:0] _TECHMAP_DO_ = "proc; clean";
|
||||
|
||||
integer i;
|
||||
always @* begin
|
||||
_TECHMAP_FAIL_ <= 1;
|
||||
for (i = 0; i < WIDTH; i=i+1) begin
|
||||
if (_TECHMAP_CONSTVAL_A_ === WIDTH'd1 << i) begin
|
||||
_TECHMAP_FAIL_ <= 0;
|
||||
Y <= B << i;
|
||||
end
|
||||
if (_TECHMAP_CONSTVAL_B_ === WIDTH'd1 << i) begin
|
||||
_TECHMAP_FAIL_ <= 0;
|
||||
Y <= A << i;
|
||||
end
|
||||
end
|
||||
end
|
||||
endmodule
|
5
docs/resources/PRESENTATION_ExAdv/mulshift_test.v
Normal file
5
docs/resources/PRESENTATION_ExAdv/mulshift_test.v
Normal file
|
@ -0,0 +1,5 @@
|
|||
module test (A, X, Y);
|
||||
input [7:0] A;
|
||||
output [7:0] X = A * 8'd 6;
|
||||
output [7:0] Y = A * 8'd 8;
|
||||
endmodule
|
7
docs/resources/PRESENTATION_ExAdv/mulshift_test.ys
Normal file
7
docs/resources/PRESENTATION_ExAdv/mulshift_test.ys
Normal file
|
@ -0,0 +1,7 @@
|
|||
read_verilog mulshift_test.v
|
||||
hierarchy -check -top test
|
||||
|
||||
techmap -map sym_mul_map.v \
|
||||
-map mulshift_map.v;;
|
||||
|
||||
show -prefix mulshift -format pdf -notitle -lib sym_mul_cells.v
|
15
docs/resources/PRESENTATION_ExAdv/mymul_map.v
Normal file
15
docs/resources/PRESENTATION_ExAdv/mymul_map.v
Normal file
|
@ -0,0 +1,15 @@
|
|||
module MYMUL(A, B, Y);
|
||||
parameter WIDTH = 1;
|
||||
input [WIDTH-1:0] A, B;
|
||||
output reg [WIDTH-1:0] Y;
|
||||
|
||||
wire [1023:0] _TECHMAP_DO_ = "proc; clean";
|
||||
|
||||
integer i;
|
||||
always @* begin
|
||||
Y = 0;
|
||||
for (i = 0; i < WIDTH; i=i+1)
|
||||
if (A[i])
|
||||
Y = Y + (B << i);
|
||||
end
|
||||
endmodule
|
4
docs/resources/PRESENTATION_ExAdv/mymul_test.v
Normal file
4
docs/resources/PRESENTATION_ExAdv/mymul_test.v
Normal file
|
@ -0,0 +1,4 @@
|
|||
module test(A, B, Y);
|
||||
input [1:0] A, B;
|
||||
output [1:0] Y = A * B;
|
||||
endmodule
|
15
docs/resources/PRESENTATION_ExAdv/mymul_test.ys
Normal file
15
docs/resources/PRESENTATION_ExAdv/mymul_test.ys
Normal file
|
@ -0,0 +1,15 @@
|
|||
read_verilog mymul_test.v
|
||||
hierarchy -check -top test
|
||||
|
||||
techmap -map sym_mul_map.v \
|
||||
-map mymul_map.v;;
|
||||
|
||||
rename test test_mapped
|
||||
read_verilog mymul_test.v
|
||||
miter -equiv test test_mapped miter
|
||||
flatten miter
|
||||
|
||||
sat -verify -prove trigger 0 miter
|
||||
|
||||
splitnets -ports test_mapped/A
|
||||
show -prefix mymul -format pdf -notitle test_mapped
|
5
docs/resources/PRESENTATION_ExAdv/red_or3x1_cells.v
Normal file
5
docs/resources/PRESENTATION_ExAdv/red_or3x1_cells.v
Normal file
|
@ -0,0 +1,5 @@
|
|||
module OR3X1(A, B, C, Y);
|
||||
input A, B, C;
|
||||
output Y;
|
||||
assign Y = A | B | C;
|
||||
endmodule
|
48
docs/resources/PRESENTATION_ExAdv/red_or3x1_map.v
Normal file
48
docs/resources/PRESENTATION_ExAdv/red_or3x1_map.v
Normal file
|
@ -0,0 +1,48 @@
|
|||
module \$reduce_or (A, Y);
|
||||
|
||||
parameter A_SIGNED = 0;
|
||||
parameter A_WIDTH = 0;
|
||||
parameter Y_WIDTH = 0;
|
||||
|
||||
input [A_WIDTH-1:0] A;
|
||||
output [Y_WIDTH-1:0] Y;
|
||||
|
||||
function integer min;
|
||||
input integer a, b;
|
||||
begin
|
||||
if (a < b)
|
||||
min = a;
|
||||
else
|
||||
min = b;
|
||||
end
|
||||
endfunction
|
||||
|
||||
genvar i;
|
||||
generate begin
|
||||
if (A_WIDTH == 0) begin
|
||||
assign Y = 0;
|
||||
end
|
||||
if (A_WIDTH == 1) begin
|
||||
assign Y = A;
|
||||
end
|
||||
if (A_WIDTH == 2) begin
|
||||
wire ybuf;
|
||||
OR3X1 g (.A(A[0]), .B(A[1]), .C(1'b0), .Y(ybuf));
|
||||
assign Y = ybuf;
|
||||
end
|
||||
if (A_WIDTH == 3) begin
|
||||
wire ybuf;
|
||||
OR3X1 g (.A(A[0]), .B(A[1]), .C(A[2]), .Y(ybuf));
|
||||
assign Y = ybuf;
|
||||
end
|
||||
if (A_WIDTH > 3) begin
|
||||
localparam next_stage_sz = (A_WIDTH+2) / 3;
|
||||
wire [next_stage_sz-1:0] next_stage;
|
||||
for (i = 0; i < next_stage_sz; i = i+1) begin
|
||||
localparam bits = min(A_WIDTH - 3*i, 3);
|
||||
assign next_stage[i] = |A[3*i +: bits];
|
||||
end
|
||||
assign Y = |next_stage;
|
||||
end
|
||||
end endgenerate
|
||||
endmodule
|
5
docs/resources/PRESENTATION_ExAdv/red_or3x1_test.v
Normal file
5
docs/resources/PRESENTATION_ExAdv/red_or3x1_test.v
Normal file
|
@ -0,0 +1,5 @@
|
|||
module test (A, Y);
|
||||
input [6:0] A;
|
||||
output Y;
|
||||
assign Y = |A;
|
||||
endmodule
|
7
docs/resources/PRESENTATION_ExAdv/red_or3x1_test.ys
Normal file
7
docs/resources/PRESENTATION_ExAdv/red_or3x1_test.ys
Normal file
|
@ -0,0 +1,7 @@
|
|||
read_verilog red_or3x1_test.v
|
||||
hierarchy -check -top test
|
||||
|
||||
techmap -map red_or3x1_map.v;;
|
||||
|
||||
splitnets -ports
|
||||
show -prefix red_or3x1 -format pdf -notitle -lib red_or3x1_cells.v
|
15
docs/resources/PRESENTATION_ExAdv/select.v
Normal file
15
docs/resources/PRESENTATION_ExAdv/select.v
Normal file
|
@ -0,0 +1,15 @@
|
|||
module test(clk, s, a, y);
|
||||
input clk, s;
|
||||
input [15:0] a;
|
||||
output [15:0] y;
|
||||
reg [15:0] b, c;
|
||||
|
||||
always @(posedge clk) begin
|
||||
b <= a;
|
||||
c <= b;
|
||||
end
|
||||
|
||||
wire [15:0] state_a = (a ^ b) + c;
|
||||
wire [15:0] state_b = (a ^ b) - c;
|
||||
assign y = !s ? state_a : state_b;
|
||||
endmodule
|
10
docs/resources/PRESENTATION_ExAdv/select.ys
Normal file
10
docs/resources/PRESENTATION_ExAdv/select.ys
Normal file
|
@ -0,0 +1,10 @@
|
|||
read_verilog select.v
|
||||
hierarchy -check -top test
|
||||
proc; opt
|
||||
cd test
|
||||
select -set cone_a state_a %ci*:-$dff
|
||||
select -set cone_b state_b %ci*:-$dff
|
||||
select -set cone_ab @cone_a @cone_b %i
|
||||
show -prefix select -format pdf -notitle \
|
||||
-color red @cone_ab -color magenta @cone_a \
|
||||
-color blue @cone_b
|
6
docs/resources/PRESENTATION_ExAdv/sym_mul_cells.v
Normal file
6
docs/resources/PRESENTATION_ExAdv/sym_mul_cells.v
Normal file
|
@ -0,0 +1,6 @@
|
|||
module MYMUL(A, B, Y);
|
||||
parameter WIDTH = 1;
|
||||
input [WIDTH-1:0] A, B;
|
||||
output [WIDTH-1:0] Y;
|
||||
assign Y = A * B;
|
||||
endmodule
|
15
docs/resources/PRESENTATION_ExAdv/sym_mul_map.v
Normal file
15
docs/resources/PRESENTATION_ExAdv/sym_mul_map.v
Normal file
|
@ -0,0 +1,15 @@
|
|||
module \$mul (A, B, Y);
|
||||
parameter A_SIGNED = 0;
|
||||
parameter B_SIGNED = 0;
|
||||
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] Y;
|
||||
|
||||
wire _TECHMAP_FAIL_ = A_WIDTH != B_WIDTH || B_WIDTH != Y_WIDTH;
|
||||
|
||||
MYMUL #( .WIDTH(Y_WIDTH) ) g ( .A(A), .B(B), .Y(Y) );
|
||||
endmodule
|
5
docs/resources/PRESENTATION_ExAdv/sym_mul_test.v
Normal file
5
docs/resources/PRESENTATION_ExAdv/sym_mul_test.v
Normal file
|
@ -0,0 +1,5 @@
|
|||
module test(A, B, C, Y1, Y2);
|
||||
input [7:0] A, B, C;
|
||||
output [7:0] Y1 = A * B;
|
||||
output [15:0] Y2 = A * C;
|
||||
endmodule
|
6
docs/resources/PRESENTATION_ExAdv/sym_mul_test.ys
Normal file
6
docs/resources/PRESENTATION_ExAdv/sym_mul_test.ys
Normal file
|
@ -0,0 +1,6 @@
|
|||
read_verilog sym_mul_test.v
|
||||
hierarchy -check -top test
|
||||
|
||||
techmap -map sym_mul_map.v;;
|
||||
|
||||
show -prefix sym_mul -format pdf -notitle -lib sym_mul_cells.v
|
3
docs/resources/PRESENTATION_ExOth/.gitignore
vendored
Normal file
3
docs/resources/PRESENTATION_ExOth/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*.dot
|
||||
*.pdf
|
||||
*.log
|
17
docs/resources/PRESENTATION_ExOth/Makefile
Normal file
17
docs/resources/PRESENTATION_ExOth/Makefile
Normal file
|
@ -0,0 +1,17 @@
|
|||
YOSYS = ../../../yosys
|
||||
|
||||
all: scrambler_p01.pdf scrambler_p02.pdf equiv.log axis_test.log
|
||||
|
||||
scrambler_p01.pdf: scrambler.ys scrambler.v
|
||||
$(YOSYS) scrambler.ys
|
||||
|
||||
scrambler_p02.pdf: scrambler_p01.pdf
|
||||
|
||||
equiv.log: equiv.ys
|
||||
$(YOSYS) -l equiv.log_new equiv.ys
|
||||
mv equiv.log_new equiv.log
|
||||
|
||||
axis_test.log: axis_test.ys axis_master.v axis_test.v
|
||||
$(YOSYS) -l axis_test.log_new axis_test.ys
|
||||
mv axis_test.log_new axis_test.log
|
||||
|
27
docs/resources/PRESENTATION_ExOth/axis_master.v
Normal file
27
docs/resources/PRESENTATION_ExOth/axis_master.v
Normal file
|
@ -0,0 +1,27 @@
|
|||
module axis_master(aclk, aresetn, tvalid, tready, tdata);
|
||||
input aclk, aresetn, tready;
|
||||
output reg tvalid;
|
||||
output reg [7:0] tdata;
|
||||
|
||||
reg [31:0] state;
|
||||
always @(posedge aclk) begin
|
||||
if (!aresetn) begin
|
||||
state <= 314159265;
|
||||
tvalid <= 0;
|
||||
tdata <= 'bx;
|
||||
end else begin
|
||||
if (tvalid && tready)
|
||||
tvalid <= 0;
|
||||
if (!tvalid || !tready) begin
|
||||
// ^- should not be inverted!
|
||||
state = state ^ state << 13;
|
||||
state = state ^ state >> 7;
|
||||
state = state ^ state << 17;
|
||||
if (state[9:8] == 0) begin
|
||||
tvalid <= 1;
|
||||
tdata <= state;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
endmodule
|
27
docs/resources/PRESENTATION_ExOth/axis_test.v
Normal file
27
docs/resources/PRESENTATION_ExOth/axis_test.v
Normal file
|
@ -0,0 +1,27 @@
|
|||
module axis_test(aclk, tready);
|
||||
input aclk, tready;
|
||||
wire aresetn, tvalid;
|
||||
wire [7:0] tdata;
|
||||
|
||||
integer counter = 0;
|
||||
reg aresetn = 0;
|
||||
|
||||
axis_master uut (aclk, aresetn, tvalid, tready, tdata);
|
||||
|
||||
always @(posedge aclk) begin
|
||||
if (aresetn && tready && tvalid) begin
|
||||
if (counter == 0) assert(tdata == 19);
|
||||
if (counter == 1) assert(tdata == 99);
|
||||
if (counter == 2) assert(tdata == 1);
|
||||
if (counter == 3) assert(tdata == 244);
|
||||
if (counter == 4) assert(tdata == 133);
|
||||
if (counter == 5) assert(tdata == 209);
|
||||
if (counter == 6) assert(tdata == 241);
|
||||
if (counter == 7) assert(tdata == 137);
|
||||
if (counter == 8) assert(tdata == 176);
|
||||
if (counter == 9) assert(tdata == 6);
|
||||
counter <= counter + 1;
|
||||
end
|
||||
aresetn <= 1;
|
||||
end
|
||||
endmodule
|
5
docs/resources/PRESENTATION_ExOth/axis_test.ys
Normal file
5
docs/resources/PRESENTATION_ExOth/axis_test.ys
Normal file
|
@ -0,0 +1,5 @@
|
|||
read_verilog -sv axis_master.v axis_test.v
|
||||
hierarchy -top axis_test
|
||||
|
||||
proc; flatten;;
|
||||
sat -falsify -seq 50 -prove-asserts
|
17
docs/resources/PRESENTATION_ExOth/equiv.ys
Normal file
17
docs/resources/PRESENTATION_ExOth/equiv.ys
Normal file
|
@ -0,0 +1,17 @@
|
|||
# read test design
|
||||
read_verilog ../PRESENTATION_ExSyn/techmap_01.v
|
||||
hierarchy -top test
|
||||
|
||||
# create two version of the design: test_orig and test_mapped
|
||||
copy test test_orig
|
||||
rename test test_mapped
|
||||
|
||||
# apply the techmap only to test_mapped
|
||||
techmap -map ../PRESENTATION_ExSyn/techmap_01_map.v test_mapped
|
||||
|
||||
# create a miter circuit to test equivalence
|
||||
miter -equiv -make_assert -make_outputs test_orig test_mapped miter
|
||||
flatten miter
|
||||
|
||||
# run equivalence check
|
||||
sat -verify -prove-asserts -show-inputs -show-outputs miter
|
14
docs/resources/PRESENTATION_ExOth/scrambler.v
Normal file
14
docs/resources/PRESENTATION_ExOth/scrambler.v
Normal file
|
@ -0,0 +1,14 @@
|
|||
module scrambler(
|
||||
input clk, rst, in_bit,
|
||||
output reg out_bit
|
||||
);
|
||||
reg [31:0] xs;
|
||||
always @(posedge clk) begin
|
||||
if (rst)
|
||||
xs = 1;
|
||||
xs = xs ^ (xs << 13);
|
||||
xs = xs ^ (xs >> 17);
|
||||
xs = xs ^ (xs << 5);
|
||||
out_bit <= in_bit ^ xs[0];
|
||||
end
|
||||
endmodule
|
23
docs/resources/PRESENTATION_ExOth/scrambler.ys
Normal file
23
docs/resources/PRESENTATION_ExOth/scrambler.ys
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
read_verilog scrambler.v
|
||||
|
||||
hierarchy; proc;;
|
||||
|
||||
cd scrambler
|
||||
submod -name xorshift32 xs %c %ci %D %c %ci:+[D] %D %ci*:-$dff xs %co %ci %d
|
||||
cd ..
|
||||
|
||||
show -prefix scrambler_p01 -format pdf -notitle scrambler
|
||||
show -prefix scrambler_p02 -format pdf -notitle xorshift32
|
||||
|
||||
echo on
|
||||
|
||||
cd xorshift32
|
||||
rename n2 in
|
||||
rename n1 out
|
||||
|
||||
eval -set in 1 -show out
|
||||
eval -set in 270369 -show out
|
||||
|
||||
sat -set out 632435482
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue