3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-11 08:33:26 +00:00

Added opt_expr support for div/mod by power-of-two

This commit is contained in:
Clifford Wolf 2016-05-29 12:17:36 +02:00
parent 766032c5f8
commit 11f7b8a2a1
2 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,27 @@
module constmuldivmod(input [7:0] A, input [2:0] mode, output reg [7:0] Y);
always @* begin
case (mode)
0: Y = A / 8'd0;
1: Y = A % 8'd0;
2: Y = A * 8'd0;
3: Y = A / 8'd1;
4: Y = A % 8'd1;
5: Y = A * 8'd1;
6: Y = A / 8'd2;
7: Y = A % 8'd2;
8: Y = A * 8'd2;
9: Y = A / 8'd4;
10: Y = A % 8'd4;
11: Y = A * 8'd4;
12: Y = A / 8'd8;
13: Y = A % 8'd8;
14: Y = A * 8'd8;
default: Y = 8'd16 * A;
endcase
end
endmodule