data/full_repos/permissive/175261487/src/satsu.v
data/verilator_xmls/192004cd-b9f2-47c2-8acb-11abe1bae564.xml
module satsu(in, out);
	parameter isz = 17;
	parameter osz = 12;
	parameter warn = 1;
	
	input signed [isz-1:0] in;
	output [osz-1:0] out;
	

	wire min =  in[isz-1];
	wire max = ~in[isz-1] &  |in[isz-2:osz];
	
	reg [osz-1:0] out;
	

	always @(min or max or in)
		case({max,min})
			2'b01:		out = {osz{1'b0}};
			2'b10:		out = {osz{1'b1}};
			default:	out = in[osz-1:0];
		endcase
	


		always @(min or max)
		if(warn & (min | max))
			$display("%m: saturation @ time %d (%d <> %d)", $time, in, (1<<(osz-1)));

endmodule
module satsu(in, out);

	parameter isz = 17;
	parameter osz = 12;
	parameter warn = 1;
	
	input signed [isz-1:0] in;
	output [osz-1:0] out;
	

	wire min =  in[isz-1];
	wire max = ~in[isz-1] &  |in[isz-2:osz];
	
	reg [osz-1:0] out;
	

	always @(min or max or in)
		case({max,min})
			2'b01:		out = {osz{1'b0}};
			2'b10:		out = {osz{1'b1}};
			default:	out = in[osz-1:0];
		endcase
	


		always @(min or max)
		if(warn & (min | max))
			$display("%m: saturation @ time %d (%d <> %d)", $time, in, (1<<(osz-1)));

endmodule