Bitfile.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using FxpConvert.Common;
  7. namespace NIFPGA.lvbitx
  8. {
  9. public class Bitfile
  10. {
  11. public string FilePath { get; set; } = string.Empty;
  12. public string BitfileVersion { get; set; } =string.Empty;
  13. public string SignatureRegister { get; set; } = string.Empty;
  14. public string SignatureGuids { get; set; } = string.Empty;
  15. public string SignatureNames { get; set; } = string.Empty;
  16. public string BitstreamVersion { get; set; } = string.Empty;
  17. public string BitstreamMD5 { get; set; } = string.Empty;
  18. public VI VI { get; } = new VI();
  19. public Project Project { get; } = new Project();
  20. }
  21. public class VI
  22. {
  23. public string Name { get; set; } = string.Empty;
  24. public List<Register> Registers { get; } = new List<Register>();
  25. }
  26. public class Register
  27. {
  28. /// <summary>
  29. /// 寄存器名字
  30. /// </summary>
  31. public string Name { get; set; } = string.Empty;
  32. public Boolean Hidden { get; set; }
  33. /// <summary>
  34. /// <see cref="true"/>为写
  35. /// <see cref="false"/>为读
  36. /// </summary>
  37. public Boolean Indicator { get; set; }
  38. /// <summary>
  39. /// 数据类型
  40. /// </summary>
  41. public Datatype Datatype { get; set; }
  42. public string FlattenedType { get; set; } = string.Empty;
  43. /// <summary>
  44. /// 寄存器地址
  45. /// </summary>
  46. public uint Offset { get; set; }
  47. public uint SizeInBits { get; set; }
  48. public uint Class { get; set; }
  49. public bool Internal { get; set; }
  50. public uint ID { get; set; }
  51. public bool Bidirectional { get; set; }
  52. public bool Synchronous { get; set; }
  53. public string MechanicalAction { get; set; }=string.Empty;
  54. public bool AccessMayTimeout { get; set; }
  55. public bool RegisterNode { get; set; }
  56. public NiFpga_FxpTypeInfo FxpTypeInfo;
  57. public uint Size { get; set; }
  58. public Datatype ArrayValueType { get; set; }
  59. public override string ToString() => Name;
  60. }
  61. public class Project
  62. {
  63. public string TargetClass { get; set; }= string.Empty;
  64. public bool AutoRunWhenDownloaded { get; set; }
  65. public uint BaseAddressOnDevice { get; set; }
  66. public List<DMA> DMA { get; } = new List<DMA>();
  67. }
  68. public class DMA
  69. {
  70. public string Name { get; set; } = string.Empty;
  71. public string BaseAddressTag { get; set; } = string.Empty;
  72. public uint ControlSet { get; set; }
  73. public Datatype Datatype { get; set; }
  74. public NiFpga_FxpTypeInfo FxpTypeInfo;
  75. public string Direction { get; set; } = string.Empty;
  76. public string Implementation { get; set; } = string.Empty;
  77. public int Number { get; set; }
  78. public UInt32 NumberOfElements { get; set; }
  79. public Boolean UserVisible { get; set; }
  80. public override string ToString() => Name;
  81. }
  82. public enum Datatype
  83. {
  84. [DataType("Boolean")]
  85. Boolean,
  86. [DataType("I8","EnumI8")]
  87. Int8,
  88. [DataType("U8","EnumU8")]
  89. Uint8,
  90. [DataType("I16","EnumI16")]
  91. Int16,
  92. [DataType("U16","EnumU16")]
  93. Uint16,
  94. [DataType("I32","EnumI32")]
  95. Int32,
  96. [DataType("U32","EnumU32")]
  97. Uint32,
  98. [DataType("I64","EnumI64")]
  99. Int64,
  100. [DataType("U64","EnumU64")]
  101. Uint64,
  102. [DataType("SGL")]
  103. Float,
  104. [DataType("DBL")]
  105. Double,
  106. [DataType("FXP")]
  107. FXP,
  108. [DataType("Array")]
  109. Array,
  110. }
  111. [AttributeUsage(AttributeTargets.Field)]
  112. internal class DataTypeAttribute:Attribute
  113. {
  114. private List<string> names = new List<string>();
  115. public IReadOnlyList<string> Name => names.AsReadOnly();
  116. public DataTypeAttribute(params string[] name)
  117. {
  118. if (name == null || name.Length == 0) return;
  119. names.AddRange(name);
  120. }
  121. }
  122. }