From c4ed67289068a18863cbd0a7c970fa443b5c8413 Mon Sep 17 00:00:00 2001 From: megacz Date: Mon, 6 Apr 2009 11:44:34 -0700 Subject: [PATCH] add AND, OR, XOR opcodes to Alu.ship --- ships/Alu.ship | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/ships/Alu.ship b/ships/Alu.ship index 2588447..ddd3a4e 100644 --- a/ships/Alu.ship +++ b/ships/Alu.ship @@ -14,6 +14,9 @@ data in: inOp constant DROP1: 7 constant DROP2: 8 constant MAXMERGE: 9 + constant AND: 10 + constant OR: 11 + constant XOR: 12 data out: out @@ -123,6 +126,21 @@ public void service() { box_in2.removeDataForShip(); // DROP2 break; */ + case 10: + a = box_in1.removeDataForShip(); + b = box_in2.removeDataForShip(); + box_out.addDataFromShip(a & b); // CMP + break; + case 11: + a = box_in1.removeDataForShip(); + b = box_in2.removeDataForShip(); + box_out.addDataFromShip(a | b); // CMP + break; + case 12: + a = box_in1.removeDataForShip(); + b = box_in2.removeDataForShip(); + box_out.addDataFromShip(a ^ b); // CMP + break; default: throw new RuntimeException("invalid opcode: " + op); } @@ -142,10 +160,10 @@ public void service() { wire eq; wire cout; - wire [3:0] inOp_d_trunc; - assign inOp_d_trunc = inOp_d[3:0]; + wire [4:0] inOp_d_trunc; + assign inOp_d_trunc = inOp_d[4:0]; - assign isplus = inOp_d_trunc[2:0]==2; + assign isplus = inOp_d_trunc[4:0]==2; assign cin = isplus ? 0 : 1; assign in2_inverted = isplus ? in2_d : ~in2_d; assign sum = {in1_d,cin} + {in2_inverted,cin}; @@ -177,6 +195,9 @@ public void service() { (inOp_d_trunc==5) ? (greater ? in2_d : in1_d) : (inOp_d_trunc==6) ? {{ (`WORDWIDTH-1) {1'b0 }}, eq } : (inOp_d_trunc==9) ? (both_negative ? in1_d : (greater ? in1_d : in2_d)) : + (inOp_d_trunc==10) ? (in1_d & in2_d) : + (inOp_d_trunc==11) ? (in1_d | in2_d) : + (inOp_d_trunc==12) ? (in1_d ^ in2_d) : 0; always @(posedge clk) begin -- 1.7.10.4