fix sign-extension bug, add test
authoradam <adam@megacz.com>
Fri, 16 Feb 2007 17:56:57 +0000 (18:56 +0100)
committeradam <adam@megacz.com>
Fri, 16 Feb 2007 17:56:57 +0000 (18:56 +0100)
ships/Iscratch.ship
tests/literals/negative-absolute-literals.fleet [new file with mode: 0644]

index 4d89911..267ff17 100644 (file)
@@ -190,12 +190,12 @@ module iscratch (clk,
            end
         2: begin
             dhorn_full            <= 1;
-            `packet_data(dhorn_d) <= command[23:0];
+            `packet_data(dhorn_d) <= { {(`DATAWIDTH-24){command[23]}}, command[23:0] };
             `packet_dest(dhorn_d) <= command[34:24];
            end
         3: begin
             dhorn_full            <= 1;
-            `packet_data(dhorn_d) <= command[23:0] + current_instruction_read_from;
+            `packet_data(dhorn_d) <= { {(`DATAWIDTH-24){command[23]}}, command[23:0] } + current_instruction_read_from;
             `packet_dest(dhorn_d) <= command[34:24];
            end
       endcase
diff --git a/tests/literals/negative-absolute-literals.fleet b/tests/literals/negative-absolute-literals.fleet
new file mode 100644 (file)
index 0000000..5428482
--- /dev/null
@@ -0,0 +1,7 @@
+#expect -1
+#ship debug : Debug
+
+-1: sendto debug.in;
+debug.in: take, deliver;
+
+