"""Assignment."""

from . import HDLObject, HDLIntegerConstant
from .expr import HDLExpression
from .signal import HDLSignal


class HDLAssignment(HDLObject):
    """Signal assignment."""

    def __init__(self, signal, value):
        """Initialize."""
        if not isinstance(signal, HDLSignal):
            raise TypeError('only HDLSignal can be assigned')

        self.signal = signal

        if isinstance(value, (HDLIntegerConstant, HDLSignal, HDLExpression)):
            self.value = value
        elif isinstance(value, int):
            self.value = HDLIntegerConstant(value)
        else:
            raise TypeError('only integer, HDLIntegerConstant,'
                            'HDLSignal, HDLExpression allowed')

    def get_assignment_type(self):
        """Get assignment type."""
        if self.signal.sig_type == 'comb':
            return 'parallel'
        else:
            return 'series'

@@ -117,16 +117,32 @@
 DLSignal
+, HDLSignalSlice
 %0A%0A%0Aclass
@@ -293,24 +293,25 @@
 nce(signal, 
+(
 HDLSignal):%0A
@@ -307,16 +307,33 @@
 DLSignal
+, HDLSignalSlice)
 ):%0A     
@@ -370,16 +370,32 @@
 DLSignal
+, HDLSignalSlice
  can be 
@@ -418,104 +418,351 @@
     
-self.signal = signal%0A%0A        if isinstance(value, (HDLIntegerConstant, HDLSignal, HDLExpression
+if isinstance(signal, HDLSignal):%0A            self.signal = signal%0A            self._slice = None%0A        else:%0A            self.signal = signal.signal%0A            self._slice = signal.vector%0A%0A        if isinstance(value, (HDLIntegerConstant,%0A                              HDLSignal, HDLExpression,%0A                              HDLSignalSlice
 )):%0A

allow signal slice