From: Bernhard Urban Date: Fri, 21 May 2010 01:25:02 +0000 (+0200) Subject: parser: overflow fix X-Git-Tag: abgabe~76 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=hwmod.git;a=commitdiff_plain;h=2a30006fc558b9224ab54b4f68025d1b0149e071 parser: overflow fix --- diff --git a/src/beh_alu_tb.vhd b/src/beh_alu_tb.vhd index 632896f..aba54cb 100644 --- a/src/beh_alu_tb.vhd +++ b/src/beh_alu_tb.vhd @@ -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; diff --git a/src/parser.test b/src/parser.test index 12699fd..afd7d9a 100644 --- a/src/parser.test +++ b/src/parser.test @@ -108,3 +108,9 @@ # t36 341212 / -0*2 > Fehler: Division durch Null +# t37 +0--2147483648 + > Fehler: Over- bzw. Underflow +# t38 +5--2147483648 + > Fehler: Over- bzw. Underflow diff --git a/src/parser.vhd b/src/parser.vhd index 616555e..c74b4cb 100644 --- a/src/parser.vhd +++ b/src/parser.vhd @@ -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