parser: overflow fix
authorBernhard Urban <lewurm@gmail.com>
Fri, 21 May 2010 01:25:02 +0000 (03:25 +0200)
committerBernhard Urban <lewurm@gmail.com>
Fri, 21 May 2010 01:25:02 +0000 (03:25 +0200)
src/beh_alu_tb.vhd
src/parser.test
src/parser.vhd

index 632896f74bd884b7f404512e83e195b271eaf59b..aba54cb514cb1fdde1edd792e4c49ed0e6206323 100644 (file)
@@ -49,7 +49,7 @@ begin
                end record alu_testv;
 
                -- ggf. groesse des arrays erhoehen
-               type alu_testv_array is array (natural range 0 to 60) of alu_testv;
+               type alu_testv_array is array (natural range 0 to 65) of alu_testv;
 
                variable testmatrix : alu_testv_array :=
                        ( 0 => (-5, ALU_DIV, 3, 2, -1, false),
@@ -114,6 +114,8 @@ begin
                          54 => (0, ALU_DIV, 10, 0, 0, false),
                          55 => (10, ALU_DIV, 10, 0, 1, false),
                          56 => (5134123, ALU_DIV, 358015, 121913, 14, false),
+                         -- extra
+                         60 => (5, ALU_SUB, -2147483648, 0, 0, true),
                          others => (0, ALU_ADD, 0, 0, 0, false)
                        );
                variable checkall : boolean := true;
index 12699fd6d17dafdcf951aeed22d728fa6b0fa77e..afd7d9ac9126e9b2b9740421e95b63f9f84c09b2 100644 (file)
 # t36
 341212 /                 -0*2
  > Fehler:                             Division durch Null             
+# t37
+0--2147483648
+ > Fehler:                             Over- bzw. Underflow            
+# t38
+5--2147483648
+ > Fehler:                             Over- bzw. Underflow            
index 616555e21ef154677c5f92fe67c931c963c2f176..c74b4cb1e801dacda11a7121a545b145bc64cd7c 100644 (file)
@@ -463,7 +463,15 @@ begin
                                case opp_int is
                                        when ALU_NOP | ALU_ADD | ALU_SUB =>
                                                case opp_int  is
-                                                       when ALU_SUB => op1_next <= (not tmp) + 1;
+                                                       when ALU_SUB =>
+                                                               -- xst (xilinx) workaround
+                                                               if x"80000000" = tmp then
+                                                                       -- vgl. testfall 37 und 38
+                                                                       err_next <= 3;
+                                                                       op1_next <= tmp;
+                                                               else
+                                                                       op1_next <= (not tmp) + 1;
+                                                               end if;
                                                        when others => op1_next <= tmp;
                                                end case;
                                                case aktop_int is
@@ -519,6 +527,7 @@ begin
                                                                punkt_next <= op3;
                                                        when others => assert (false) report "SCALC_2/1: shouldn't happen!";
                                                end case;
+                                       when ALU_DONE => null;
                                        when others => assert (false) report "SCALC_2/2: shouldn't happen!";
                                end case;
                                -- aktuelle rechenoperation fuer naechste 'runde' uebernehmen