diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog for the [`clash-lib`](http://hackage.haskell.org/package/clash-lib) package
 
+## 0.5.4
+* New features:
+  * Add `~COMPNAME` tag: primitives get access to the component name in which they are instantiated
+
 ## 0.5.3 *May 5th 2015*
 * New features:
   * `TopEntity` wrappers are now specified as `ANN` annotation pragmas
diff --git a/clash-lib.cabal b/clash-lib.cabal
--- a/clash-lib.cabal
+++ b/clash-lib.cabal
@@ -1,5 +1,5 @@
 Name:                 clash-lib
-Version:              0.5.3
+Version:              0.5.4
 Synopsis:             CAES Language for Synchronous Hardware - As a Library
 Description:
   CλaSH (pronounced ‘clash’) is a functional hardware description language that
diff --git a/src/CLaSH/Netlist.hs b/src/CLaSH/Netlist.hs
--- a/src/CLaSH/Netlist.hs
+++ b/src/CLaSH/Netlist.hs
@@ -77,7 +77,7 @@
   . (fmap fst . runWriterT)
   . runNetlist
   where
-    s' = NetlistState s HashMap.empty 0 (fromMaybe 0 compCntM) HashMap.empty p typeTrans tcm
+    s' = NetlistState s HashMap.empty 0 (fromMaybe 0 compCntM) HashMap.empty p typeTrans tcm Text.empty
 
 -- | Generate a component for a given function (caching)
 genComponent :: TmName -- ^ Name of the function
@@ -109,6 +109,7 @@
                      . Text.splitOn (Text.pack ".")
                      . Text.pack
                      $ name2String compName
+  curCompNm .= componentName'
 
   tcm <- Lens.use tcCache
   (arguments,binders,result) <- do { normalizedM <- splitNormalized tcm componentExpr
diff --git a/src/CLaSH/Netlist/BlackBox.hs b/src/CLaSH/Netlist/BlackBox.hs
--- a/src/CLaSH/Netlist/BlackBox.hs
+++ b/src/CLaSH/Netlist/BlackBox.hs
@@ -78,7 +78,8 @@
          then do
            templ'  <- instantiateSym templ
            templ'' <- setClocks bbCtx templ'
-           return $! templ''
+           templ3  <- instantiateCompName templ''
+           return $! templ3
          else
            error $ $(curLoc) ++ "\nCan't match template for " ++ show pNm ++ " :\n" ++ show t ++
                    "\nwith context:\n" ++ show bbCtx ++ "\ngiven errors:\n" ++
@@ -258,3 +259,9 @@
   let (l',i') = setSym i l
   varCount .= i'
   return l'
+
+instantiateCompName :: BlackBoxTemplate
+                    -> NetlistMonad BlackBoxTemplate
+instantiateCompName l = do
+  nm <- Lens.use curCompNm
+  return (setCompName nm l)
diff --git a/src/CLaSH/Netlist/BlackBox/Parser.hs b/src/CLaSH/Netlist/BlackBox/Parser.hs
--- a/src/CLaSH/Netlist/BlackBox/Parser.hs
+++ b/src/CLaSH/Netlist/BlackBox/Parser.hs
@@ -69,6 +69,7 @@
      <|> Err Nothing       <$  pToken "~ERRORO"
      <|> (Err . Just)      <$> (pToken "~ERROR" *> pBrackets pNatural)
      <|> TypElem           <$> (pToken "~TYPEL" *> pBrackets pTagE)
+     <|> CompName          <$  pToken "~COMPNAME"
      <|> SigD              <$> (pToken "~SIGD" *> pBrackets pTagE) <*> (Just <$> (pBrackets pNatural))
      <|> (`SigD` Nothing)  <$> (pToken "~SIGDO" *> pBrackets pTagE)
 
diff --git a/src/CLaSH/Netlist/BlackBox/Types.hs b/src/CLaSH/Netlist/BlackBox/Types.hs
--- a/src/CLaSH/Netlist/BlackBox/Types.hs
+++ b/src/CLaSH/Netlist/BlackBox/Types.hs
@@ -20,6 +20,8 @@
              | TypM (Maybe Int)  -- ^ Type root hole
              | Err (Maybe Int)   -- ^ Error value hole
              | TypElem Element   -- ^ Select element type from a vector type
+             | CompName          -- ^ Hole for the name of the component in which
+                                 -- the blackbox is instantiated
              | SigD Element (Maybe Int)
   deriving Show
 
diff --git a/src/CLaSH/Netlist/BlackBox/Util.hs b/src/CLaSH/Netlist/BlackBox/Util.hs
--- a/src/CLaSH/Netlist/BlackBox/Util.hs
+++ b/src/CLaSH/Netlist/BlackBox/Util.hs
@@ -77,6 +77,12 @@
                       _             -> pure e
               )
 
+setCompName :: Identifier -> BlackBoxTemplate -> BlackBoxTemplate
+setCompName nm = map setCompName'
+  where
+    setCompName' CompName = C nm
+    setCompName' e        = e
+
 setClocks :: ( MonadWriter (Set (Identifier,HWType)) m
              , Applicative m
              )
@@ -211,3 +217,4 @@
 renderTag _ (SigD _ _)      = error $ $(curLoc) ++ "Unexpected signal declaration"
 renderTag _ (Clk _)         = error $ $(curLoc) ++ "Unexpected clock"
 renderTag _ (Rst _)         = error $ $(curLoc) ++ "Unexpected reset"
+renderTag _ CompName        = error $ $(curLoc) ++ "Unexpected component name"
diff --git a/src/CLaSH/Netlist/Types.hs b/src/CLaSH/Netlist/Types.hs
--- a/src/CLaSH/Netlist/Types.hs
+++ b/src/CLaSH/Netlist/Types.hs
@@ -47,6 +47,7 @@
   , _primitives     :: PrimMap -- ^ Primitive Definitions
   , _typeTranslator :: HashMap TyConName TyCon -> Type -> Maybe (Either String HWType) -- ^ Hardcoded Type -> HWType translator
   , _tcCache        :: HashMap TyConName TyCon -- ^ TyCon cache
+  , _curCompNm      :: Identifier
   }
 
 -- | Signal reference
diff --git a/src/CLaSH/Netlist/Util.hs b/src/CLaSH/Netlist/Util.hs
--- a/src/CLaSH/Netlist/Util.hs
+++ b/src/CLaSH/Netlist/Util.hs
@@ -272,11 +272,16 @@
 preserveVarEnv :: NetlistMonad a
                -> NetlistMonad a
 preserveVarEnv action = do
-  vCnt <- Lens.use varCount
-  vEnv <- Lens.use varEnv
-  val  <- action
-  varCount .= vCnt
-  varEnv   .= vEnv
+  -- store state
+  vCnt  <- Lens.use varCount
+  vEnv  <- Lens.use varEnv
+  vComp <- Lens.use curCompNm
+  -- perform action
+  val <- action
+  -- restore state
+  varCount  .= vCnt
+  varEnv    .= vEnv
+  curCompNm .= vComp
   return val
 
 dcToLiteral :: HWType -> Int -> Expr
diff --git a/src/CLaSH/Normalize/Transformations.hs b/src/CLaSH/Normalize/Transformations.hs
--- a/src/CLaSH/Normalize/Transformations.hs
+++ b/src/CLaSH/Normalize/Transformations.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TypeFamilies    #-}
 {-# LANGUAGE ViewPatterns    #-}
 
 -- | Transformations of the Normalization process
