Skip to content

Instantly share code, notes, and snippets.

@Ravenslofty
Last active April 6, 2020 11:14
Show Gist options
  • Save Ravenslofty/d2637aadb16ef4e2ffa35e94d017aa4c to your computer and use it in GitHub Desktop.
Save Ravenslofty/d2637aadb16ef4e2ffa35e94d017aa4c to your computer and use it in GitHub Desktop.
module expression_00033(a0, a1, a2, a3, a4, a5, b0, b1, b2, b3, b4, b5, y);
input [3:0] a0;
input [4:0] a1;
input [5:0] a2;
input signed [3:0] a3;
input signed [4:0] a4;
input signed [5:0] a5;
input [3:0] b0;
input [4:0] b1;
input [5:0] b2;
input signed [3:0] b3;
input signed [4:0] b4;
input signed [5:0] b5;
wire [3:0] y0;
wire [4:0] y1;
wire [5:0] y2;
wire signed [3:0] y3;
wire signed [4:0] y4;
wire signed [5:0] y5;
wire [3:0] y6;
wire [4:0] y7;
wire [5:0] y8;
wire signed [3:0] y9;
wire signed [4:0] y10;
wire signed [5:0] y11;
wire [3:0] y12;
wire [4:0] y13;
wire [5:0] y14;
wire signed [3:0] y15;
wire signed [4:0] y16;
wire signed [5:0] y17;
output [89:0] y;
assign y = {y0,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17};
localparam [3:0] p0 = (4'sd7);
localparam [4:0] p1 = ((((5'd19)-(-2'sd1))&(~&((-3'sd1)>>(-2'sd1))))!==(5'd2 ** ((4'd13)<(2'd1))));
localparam [5:0] p2 = {((-3'sd3)?(4'd9):(4'd10))};
localparam signed [3:0] p3 = ({(-2'sd0),(3'sd0),(3'd2)}!==((2'd1)+(4'sd0)));
localparam signed [4:0] p4 = ((4'd15)!==(&{4{{2{(-3'sd3)}}}}));
localparam signed [5:0] p5 = {(((5'sd0)<<(4'd0))!=((4'd8)!==(2'd3))),(3'd1),(&((+(2'sd1))<{(-3'sd0),(4'd13),(-2'sd1)}))
};
localparam [3:0] p6 = ((((3'sd0)?(3'sd3):(5'd7))?(4'd2 ** (5'd6)):(-5'sd6))?(~&((5'd18)?(2'sd0):(2'd1))):((5'd6)
||{4{(3'd7)}}));
localparam [4:0] p7 = {((3'sd3)<(4'sd5))};
localparam [5:0] p8 = ((~^(-4'sd6))<=(-(-3'sd1)));
localparam signed [3:0] p9 = {2{{4{(2'sd1)}}}};
localparam signed [4:0] p10 = (4'sd2);
localparam signed [5:0] p11 = (~&{(4'd10)});
localparam [3:0] p12 = {1{{{{(4'd4),(2'sd0)},(!(3'sd0)),((5'd18)<(4'd6))},{(~^(-5'sd13)),{(2'd0),(5'sd8)
}},(5'd2 ** {1{(|(2'd1))}})}}};
localparam [4:0] p13 = {(4'd5),(2'd3),(2'd0)};
localparam [5:0] p14 = (-{{(5'd15),(3'd0),(2'd1)},((4'd12)?(5'd24):(-2'sd0)),((5'd26)?(-5'sd9):(4'd8))});
localparam signed [3:0] p15 = (5'd6);
localparam signed [4:0] p16 = {2{(4'sd6)}};
localparam signed [5:0] p17 = (~|(-(4'd3)));
assign y0 = (3'd2);
assign y1 = (+{1{$signed({2{(|(-4'sd0))}})}});
assign y2 = (4'd3);
assign y3 = ($unsigned((!(4'd8)))<=(~|(-(b2?p7:b4))));
assign y4 = $unsigned({1{((~|(p10&&b0))^~((p17|a0)))}});
assign y5 = (!p8);
assign y6 = ((p0?p7:p12)?(a4?a5:p0):(p9?a2:p13));
assign y7 = (~|((3'd2)<(5'd27)));
assign y8 = ({2{(p15-p3)}}<=(2'd0));
assign y9 = ((p2-p1)*(p2-p0));
assign y10 = (+(-(a1*a5)));
assign y11 = (3'sd0);
assign y12 = ((b0+a4)^{a4,b2});
assign y13 = ((|$signed(a5))<(b4?b5:a1));
assign y14 = (((~&(($signed(p7)^~$unsigned(p14)))))||{3{(b3)}});
assign y15 = (~^((a5?a4:b0)?((a3?b4:a2)<<{3{b3}}):((|(b1)))));
assign y16 = (b2?b3:a5);
assign y17 = {(|$unsigned((4'sd0))),(~|(4'd2 ** (a2>=b2)))};
endmodule
module expression_00033_tb;
reg [3:0] a0;
reg [4:0] a1;
reg [5:0] a2;
reg signed [3:0] a3;
reg signed [4:0] a4;
reg signed [5:0] a5;
reg [3:0] b0;
reg [4:0] b1;
reg [5:0] b2;
reg signed [3:0] b3;
reg signed [4:0] b4;
reg signed [5:0] b5;
wire [89:0] y;
expression_00033 uut (a0, a1, a2, a3, a4, a5, b0, b1, b2, b3, b4, b5, y);
task test_pattern;
input [5:0] index;
input [59:0] pattern;
begin
{ a0, a1, a2, a3, a4, a5, b0, b1, b2, b3, b4, b5 } <= pattern; #1;
$display("++RPT++ %d %b %b %b %b %b %b %b %b %b %b %b %b %b", index,
a0, a1, a2, a3, a4, a5, b0, b1, b2, b3, b4, b5, y);
end
endtask
initial begin
test_pattern( 0, 60'b0 );
test_pattern( 1, ~60'b0 );
test_pattern( 2, 60'b111100000000000000000000000000000100000001011100000000000000 );
test_pattern( 3, 160'he04bfe0cc807264b3bc3e5658bbbe1043166bf86 );
test_pattern( 4, 160'hde80bfb577ba1b2f6e9c6725a0508e936648d639 );
test_pattern( 5, 160'h22f50930242e41388ff91dfe2e6b7e97a99b0ad7 );
test_pattern( 6, 160'hed4e4401374099596f8252db02329ed362ffc6d8 );
test_pattern( 7, 160'h7c41372bae0a5f02711d5fbca86f7ca5fcd2b32f );
test_pattern( 8, 160'h061316e2f3020454a8d11d748812204adce16a26 );
test_pattern( 9, 160'h56a858c598007aa2f373578c89f69b7be2164284 );
test_pattern( 10, 160'h06ce43b944572e6a640e632525aabf372ddf1107 );
test_pattern( 11, 160'ha3c517bc0cf6257ee86c31301832fa796ec3e1ba );
test_pattern( 12, 160'h0df34121daba74bd27702b7358edacbbbdad3fb3 );
test_pattern( 13, 160'hb6f2a8410d135177d45d3a14bcf666900d674823 );
test_pattern( 14, 160'ha6c75c4b8b2c9129c9e9aeaa087933ca57c445f4 );
test_pattern( 15, 160'ha647518d7233bc45ca5164d8d455f10f47139341 );
test_pattern( 16, 160'hc541a53657fb7aace36d46e8c6ce35eb875e0652 );
test_pattern( 17, 160'h34762d5ce57f52c7077dfe5ff17378cbeba78f87 );
test_pattern( 18, 160'hc787234acab8c7057f39984cc08f66d47ec62d28 );
test_pattern( 19, 160'h434de5bdee46195b822f6264dd4294c0eda3a305 );
test_pattern( 20, 160'h692849249833146361f42d7f73bda09bcd33390a );
test_pattern( 21, 160'h6b535e66bcbc99c82884bd643a61f12117974c17 );
test_pattern( 22, 160'headc71de630832cc92dd93309d3e5e20a919e7be );
test_pattern( 23, 160'h7ed4a6620b242e3b05847e54ff5e82b0fef7eca7 );
test_pattern( 24, 160'h4f79719db3ed83d791fd62c9b5bfdc45f4d0d2ef );
test_pattern( 25, 160'h306f15268c0b148c4d47cc0c4961305121f8bad1 );
test_pattern( 26, 160'h38e40b552b5a4d4d378d80d884a060487b578bc6 );
test_pattern( 27, 160'hf3354520c94a63404f13b852aee81422018fc488 );
test_pattern( 28, 160'hd9d9e78ca3f9268fe3decf0874d4542e3cceadd4 );
test_pattern( 29, 160'h42fb1c1019d6363c9e1207d2d209fd930eebd070 );
test_pattern( 30, 160'h8e092805cea120cb3e1d2ed3fdf2679f24ada215 );
test_pattern( 31, 160'h668c776517156957daf3e629df6168717b226433 );
test_pattern( 32, 160'he5bf9101d21c0c9948728f024a6d42a27bd93e3f );
end
endmodule
module expression_00033(a5, b2, b3, y16);
input signed [5:0] a5;
input [5:0] b2; // b2 != 0
input signed [3:0] b3;
output signed [4:0] y16;
assign y16 = (b2?b3:a5);
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment