diff --git a/src/main/resources/verilog/DIG_Neg.v b/src/main/resources/verilog/DIG_Neg.v new file mode 100644 index 000000000..0ba3f1568 --- /dev/null +++ b/src/main/resources/verilog/DIG_Neg.v @@ -0,0 +1,12 @@ + +module DIG_Neg #( + parameter Bits = 1 +) +( + input signed [(Bits-1):0] in, + output signed [(Bits-1):0] out +); + assign out = -in; +endmodule diff --git a/src/main/resources/vhdl/DIG_Neg.tem b/src/main/resources/vhdl/DIG_Neg.tem new file mode 100644 index 000000000..1f5e0f8f2 --- /dev/null +++ b/src/main/resources/vhdl/DIG_Neg.tem @@ -0,0 +1,15 @@ +LIBRARY ieee; +USE ieee.std_logic_1164.all; +USE ieee.numeric_std.all; + +entity DIG_Neg is + generic ( Bits: integer ); + port ( + p_in: in std_logic_vector ((Bits-1) downto 0); + p_out: out std_logic_vector ((Bits-1) downto 0) ); +end DIG_Neg; + +architecture Behavioral of DIG_Neg is +begin + p_out <= std_logic_vector(-signed(p_in)); +end Behavioral; \ No newline at end of file diff --git a/src/test/java/de/neemann/digital/hdl/verilog2/VerilogSimulatorTest.java b/src/test/java/de/neemann/digital/hdl/verilog2/VerilogSimulatorTest.java index 4e24b457f..a1dcf9cba 100644 --- a/src/test/java/de/neemann/digital/hdl/verilog2/VerilogSimulatorTest.java +++ b/src/test/java/de/neemann/digital/hdl/verilog2/VerilogSimulatorTest.java @@ -51,8 +51,8 @@ public class VerilogSimulatorTest extends TestCase { File examples = new File(Resources.getRoot(), "/dig/test/vhdl"); try { int tested = new FileScanner(this::checkVerilogExport).noOutput().scan(examples); - assertEquals(57, tested); - assertEquals(51, testBenches); + assertEquals(58, tested); + assertEquals(52, testBenches); } catch (FileScanner.SkipAllException e) { // if iverilog is not installed its also ok } diff --git a/src/test/java/de/neemann/digital/hdl/vhdl2/VHDLSimulatorTest.java b/src/test/java/de/neemann/digital/hdl/vhdl2/VHDLSimulatorTest.java index b04de66e4..55152be14 100644 --- a/src/test/java/de/neemann/digital/hdl/vhdl2/VHDLSimulatorTest.java +++ b/src/test/java/de/neemann/digital/hdl/vhdl2/VHDLSimulatorTest.java @@ -43,8 +43,8 @@ public class VHDLSimulatorTest extends TestCase { File examples = new File(Resources.getRoot(), "/dig/test/vhdl"); try { int tested = new FileScanner(this::checkVHDLExport).noOutput().scan(examples); - assertEquals(57, tested); - assertEquals(51, testBenches); + assertEquals(58, tested); + assertEquals(52, testBenches); } catch (FileScanner.SkipAllException e) { // if ghdl is not installed its also ok } diff --git a/src/test/java/de/neemann/digital/integration/TestExamples.java b/src/test/java/de/neemann/digital/integration/TestExamples.java index 248f05b98..6ad6d2caa 100644 --- a/src/test/java/de/neemann/digital/integration/TestExamples.java +++ b/src/test/java/de/neemann/digital/integration/TestExamples.java @@ -44,8 +44,8 @@ public class TestExamples extends TestCase { */ public void testTestExamples() throws Exception { File examples = new File(Resources.getRoot(), "/dig/test"); - assertEquals(192, new FileScanner(this::check).scan(examples)); - assertEquals(181, testCasesInFiles); + assertEquals(193, new FileScanner(this::check).scan(examples)); + assertEquals(182, testCasesInFiles); } /** diff --git a/src/test/resources/dig/test/vhdl/neg.dig b/src/test/resources/dig/test/vhdl/neg.dig new file mode 100644 index 000000000..641daecfd --- /dev/null +++ b/src/test/resources/dig/test/vhdl/neg.dig @@ -0,0 +1,83 @@ + + + 1 + + + + In + + + Label + a + + + Bits + 4 + + + intFormat + decSigned + + + + + + Testcase + + + Testdata + + a y + +0 0 +1 15 +2 14 +14 2 +15 1 +8 8 + + + + + + + Neg + + + Bits + 4 + + + + + + Out + + + Label + y + + + intFormat + decSigned + + + Bits + 4 + + + + + + + + + + + + + + + + + \ No newline at end of file