diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2017-01-08 19:58:32 -0600 |
---|---|---|
committer | Bobby Bingham <koorogi@koorogi.info> | 2017-01-08 22:02:28 -0600 |
commit | 21442e752f6198f6343755c05a95b8dbdf87a234 (patch) | |
tree | f763313f733fc1004213039957ee4147520cf6f9 /shifter.v | |
parent | e601b9315384792b82517ba3ab30cee316295558 (diff) |
Make shifter double-width instead of triple-width
Diffstat (limited to 'shifter.v')
-rw-r--r-- | shifter.v | 68 |
1 files changed, 32 insertions, 36 deletions
@@ -6,18 +6,14 @@ module shifter ( output [15:0] result ); - wire [47:0] x; - - assign x = { - extend == 2'b00 ? 16'h0 : - extend == 2'b01 ? 16'hFFFF : - extend == 2'b10 ? {16{v[15]}} : v, + wire [31:0] x; + assign x = { v, extend == 2'b00 ? 16'h0 : extend == 2'b01 ? 16'hFFFF : - extend == 2'b10 ? {16{v[0]}} : v + extend == 2'b10 ? {16{v[dir == 1'b0 ? 0 : 15]}} : v }; wire [15:0] barrelResult; @@ -25,24 +21,24 @@ module shifter ( wire [4:0] dirAndAmount; assign dirAndAmount = {dir, by[3:0]}; - + assign barrelResult = - |(by[15:4]) ? (dir == 1'b1 ? x[47:32] : x[15:0]) : - dirAndAmount == 5'h1F ? x[46:31] : - dirAndAmount == 5'h1E ? x[45:30] : - dirAndAmount == 5'h1D ? x[44:29] : - dirAndAmount == 5'h1C ? x[43:28] : - dirAndAmount == 5'h1B ? x[42:27] : - dirAndAmount == 5'h1A ? x[41:26] : - dirAndAmount == 5'h19 ? x[40:25] : - dirAndAmount == 5'h18 ? x[39:24] : - dirAndAmount == 5'h17 ? x[38:23] : - dirAndAmount == 5'h16 ? x[37:22] : - dirAndAmount == 5'h15 ? x[36:21] : - dirAndAmount == 5'h14 ? x[35:20] : - dirAndAmount == 5'h13 ? x[34:19] : - dirAndAmount == 5'h12 ? x[33:18] : - dirAndAmount == 5'h11 ? x[32:17] : + |(by[15:4]) ? x[15:0] : + dirAndAmount == 5'h1F ? {x[14:0], x[31 ]} : + dirAndAmount == 5'h1E ? {x[13:0], x[31:30]} : + dirAndAmount == 5'h1D ? {x[12:0], x[31:29]} : + dirAndAmount == 5'h1C ? {x[11:0], x[31:28]} : + dirAndAmount == 5'h1B ? {x[10:0], x[31:27]} : + dirAndAmount == 5'h1A ? {x[ 9:0], x[31:26]} : + dirAndAmount == 5'h19 ? {x[ 8:0], x[31:25]} : + dirAndAmount == 5'h18 ? {x[ 7:0], x[31:24]} : + dirAndAmount == 5'h17 ? {x[ 6:0], x[31:23]} : + dirAndAmount == 5'h16 ? {x[ 5:0], x[31:22]} : + dirAndAmount == 5'h15 ? {x[ 4:0], x[31:21]} : + dirAndAmount == 5'h14 ? {x[ 3:0], x[31:20]} : + dirAndAmount == 5'h13 ? {x[ 2:0], x[31:19]} : + dirAndAmount == 5'h12 ? {x[ 1:0], x[31:18]} : + dirAndAmount == 5'h11 ? {x[ 0], x[31:17]} : // zero shift is handled at the bottom dirAndAmount == 5'h01 ? x[30:15] : dirAndAmount == 5'h02 ? x[29:14] : @@ -50,19 +46,19 @@ module shifter ( dirAndAmount == 5'h04 ? x[27:12] : dirAndAmount == 5'h05 ? x[26:11] : dirAndAmount == 5'h06 ? x[25:10] : - dirAndAmount == 5'h07 ? x[24:9] : - dirAndAmount == 5'h08 ? x[23:8] : - dirAndAmount == 5'h09 ? x[22:7] : - dirAndAmount == 5'h0A ? x[21:6] : - dirAndAmount == 5'h0B ? x[20:5] : - dirAndAmount == 5'h0C ? x[19:4] : - dirAndAmount == 5'h0D ? x[18:3] : - dirAndAmount == 5'h0E ? x[17:2] : - dirAndAmount == 5'h0F ? x[16:1] : + dirAndAmount == 5'h07 ? x[24: 9] : + dirAndAmount == 5'h08 ? x[23: 8] : + dirAndAmount == 5'h09 ? x[22: 7] : + dirAndAmount == 5'h0A ? x[21: 6] : + dirAndAmount == 5'h0B ? x[20: 5] : + dirAndAmount == 5'h0C ? x[19: 4] : + dirAndAmount == 5'h0D ? x[18: 3] : + dirAndAmount == 5'h0E ? x[17: 2] : + dirAndAmount == 5'h0F ? x[16: 1] : x[31:16]; - + assign otherResult = - |(by[15:4]) ? (dir == 1'b1 ? x[47:32] : x[15:0]) : barrelResult; - + |(by[15:4]) ? x[15:0] : barrelResult; + assign result = extend == 2'b11 ? barrelResult : otherResult; endmodule |