Repository: Qiskit/qiskit

Issue:
Can create a delay gate with negative time
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: latest
- **Python version**:
- **Operating system**:

### What is the current behavior?
It is possible to make this:
```
        ┌───┐┌──────────────────┐ ░ ┌─┐
   q_0: ┤ X ├┤ DELAY(-1000[dt]) ├─░─┤M├
        └───┘└──────────────────┘ ░ └╥┘
meas: 1/═════════════════════════════╩═
                                     0 
```


### Steps to reproduce the problem



### What is the expected behavior?
Negative times should be caught.  It does however work on IBM HW but gives odd results.


### Suggested solutions
A simple if and raise would likely solve this.




Discussion:
This can be handled in the `validate_parameter` method for `Delay`: https://github.com/Qiskit/qiskit-terra/blob/db3b35e/qiskit/circuit/delay.py#L69

Resolving patch:
diff --git a/qiskit/circuit/delay.py b/qiskit/circuit/delay.py
--- a/qiskit/circuit/delay.py
+++ b/qiskit/circuit/delay.py
@@ -69,8 +69,16 @@ def __repr__(self):
     def validate_parameter(self, parameter):
         """Delay parameter (i.e. duration) must be int, float or ParameterExpression."""
         if isinstance(parameter, int):
+            if parameter < 0:
+                raise CircuitError(
+                    f"Duration for Delay instruction must be positive. Found {parameter}"
+                )
             return parameter
         elif isinstance(parameter, float):
+            if parameter < 0:
+                raise CircuitError(
+                    f"Duration for Delay instruction must be positive. Found {parameter}"
+                )
             if self.unit == "dt":
                 parameter_int = int(parameter)
                 if parameter != parameter_int:
@@ -83,6 +91,8 @@ def validate_parameter(self, parameter):
             if not parameter.is_real():
                 raise CircuitError(f"Bound parameter expression is complex in delay {self.name}")
             fval = float(parameter)
+            if fval < 0:
+                raise CircuitError(f"Duration for Delay instruction must be positive. Found {fval}")
             if self.unit == "dt":
                 ival = int(parameter)
                 rounding_error = abs(fval - ival)


Test patch:
diff --git a/test/python/circuit/test_delay.py b/test/python/circuit/test_delay.py
--- a/test/python/circuit/test_delay.py
+++ b/test/python/circuit/test_delay.py
@@ -47,6 +47,13 @@ def test_fail_if_unknown_unit_is_supplied(self):
         with self.assertRaises(CircuitError):
             qc.delay(100, 0, unit="my_unit")
 
+    def test_fail_if_negative_duration_is_supplied(self):
+        qc = QuantumCircuit(1)
+        with self.assertRaises(CircuitError):
+            qc.delay(-1, 0, unit="dt")
+        with self.assertRaises(CircuitError):
+            qc.delay(-1.5, 0, unit="s")
+
     def test_add_delay_on_single_qubit_to_circuit(self):
         qc = QuantumCircuit(1)
         qc.h(0)
@@ -109,6 +116,8 @@ def test_fail_if_assign_invalid_duration_parameters(self):
             qc.assign_parameters({dur: 1 + 1j}, inplace=True)
         with self.assertRaises(CircuitError):
             qc.assign_parameters({dur: 0.5}, inplace=True)
+        with self.assertRaises(CircuitError):
+            qc.assign_parameters({dur: -1}, inplace=True)
 
     def test_can_assign_multiple_duration_parameters(self):
         durs = ParameterVector("dur", 2)