private ComplexEnumeration ParseEnumeration(string portEnumeration) { var newEnumeration = new ComplexEnumeration(); var to = "(downto|to)"; var directionStr = Regex.Match(portEnumeration, to).Value; EnumerationDirections direction; if (!EnumerationDirections.TryParse(directionStr, true, out direction)) { return(null); } newEnumeration.Direction = direction; var leftNumber = Num + "(?=" + MFS + to + ")"; var rightNumber = "(?<=" + to + MFS + ")" + Num; int left, right; var leftStr = Regex.Match(portEnumeration, leftNumber).Value; var rightStr = Regex.Match(portEnumeration, rightNumber).Value; if (!int.TryParse(leftStr, out left)) { throw new Exception("!!!"); } if (!int.TryParse(rightStr, out right)) { throw new Exception("!!!"); } newEnumeration.From = left; newEnumeration.To = right; return(newEnumeration); }
public SignalDefenition BuildSignal() { if (_wires.Any()) { var min = _wires.Min(x => x.Enumeration.Bottom); var max = _wires.Max(x => x.Enumeration.Bottom); EnumerationBase enumeration = null; string valueType; if (min == max) { valueType = "STD_LOGIC"; } else { valueType = "STD_LOGIC_VECTOR"; enumeration = new ComplexEnumeration(max, min, EnumerationDirections.Downto); } _defenition.ValueType = valueType; _defenition.Enumeration = enumeration; Router.InserSignalDefenition(_defenition.Name, valueType, enumeration); _wires.ForEach(x => Router.AddSignal(x)); return(_defenition); } return(null); }
public static EnumerationBase Parse(string text) { var enumeration = SimpleIndex.Parse(text); if (enumeration != null) { return(enumeration); } return(ComplexEnumeration.Parse(text)); }
public static Port Parse(Entity entity, string x) { Match pTypeMatch = Regex.Match(x, PC.PortType); var remainngWithValueType = x.Substring(pTypeMatch.Index + pTypeMatch.Length); var vTypeM = Regex.Match(remainngWithValueType, VHDLName); var remaining = remainngWithValueType.Substring(vTypeM.Index + vTypeM.Length); var defaultPart = Regex.Match(remaining, PC.Default).Value; var portEnumeration = Regex.Match(remaining, PC.Enumeration).Value; var port = new Port(entity) { Name = Regex.Match(x, PC.PortName).Value, PortType = ParsePortType(pTypeMatch.Value), ValueType = Regex.Match(remainngWithValueType, VHDLName).Value, DefaultValue = defaultPart != String.Empty ? Regex.Match(defaultPart, PC.DefaultValue).Value : null, Enumeration = !String.IsNullOrWhiteSpace(portEnumeration) ? ComplexEnumeration.Parse(portEnumeration) : null }; return(port); }