From 6bf116914c36c98e7f76ec9c20f993cd847a7ee8 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 29 Jan 2009 11:42:50 +0100 Subject: [PATCH] Add a uniqueName function. This function appends a unique number to names to make the names unique. --- Translator.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Translator.hs b/Translator.hs index ad4feeb..713698c 100644 --- a/Translator.hs +++ b/Translator.hs @@ -287,6 +287,15 @@ getHWFunc name = do (error $ "Function " ++ name ++ "is unknown? This should not happen!") (lookup name fs) +-- Makes the given name unique by appending a unique number. +-- This does not do any checking against existing names, so it only guarantees +-- uniqueness with other names generated by uniqueName. +uniqueName :: String -> VHDLState String +uniqueName name = do + count <- State.gets nameCount -- Get the funcs element from the session + State.modify (\s -> s {nameCount = count + 1}) + return $ name ++ "-" ++ (show count) + builtin_funcs = [ ("hwxor", HWFunction [Port "a", Port "b"] (Port "o")), -- 2.30.2