Bitfile.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 List<DMA> DMA { get; } = new List<DMA>();
  66. }
  67. public class NiFpga
  68. {
  69. public int BaseAddressOnDevice { get; set; }
  70. }
  71. public class DMA
  72. {
  73. public string Name { get; set; } = string.Empty;
  74. public string BaseAddressTag { get; set; } = string.Empty;
  75. public uint ControlSet { get; set; }
  76. public Datatype Datatype { get; set; }
  77. public NiFpga_FxpTypeInfo FxpTypeInfo;
  78. public string Direction { get; set; } = string.Empty;
  79. public string Implementation { get; set; } = string.Empty;
  80. public int Number { get; set; }
  81. public UInt32 NumberOfElements { get; set; }
  82. public Boolean UserVisible { get; set; }
  83. public override string ToString() => Name;
  84. }
  85. public enum Datatype
  86. {
  87. [DataType("Boolean")]
  88. Boolean,
  89. [DataType("I8","EnumI8")]
  90. Int8,
  91. [DataType("U8","EnumU8")]
  92. Uint8,
  93. [DataType("I16","EnumI16")]
  94. Int16,
  95. [DataType("U16","EnumU16")]
  96. Uint16,
  97. [DataType("I32","EnumI32")]
  98. Int32,
  99. [DataType("U32","EnumU32")]
  100. Uint32,
  101. [DataType("I64","EnumI64")]
  102. Int64,
  103. [DataType("U64","EnumU64")]
  104. Uint64,
  105. [DataType("SGL")]
  106. Float,
  107. [DataType("DBL")]
  108. Double,
  109. [DataType("FXP")]
  110. FXP,
  111. [DataType("Array")]
  112. Array,
  113. }
  114. [AttributeUsage(AttributeTargets.Field)]
  115. internal class DataTypeAttribute:Attribute
  116. {
  117. private List<string> names = new List<string>();
  118. public IReadOnlyList<string> Name => names.AsReadOnly();
  119. public DataTypeAttribute(params string[] name)
  120. {
  121. if (name == null || name.Length == 0) return;
  122. names.AddRange(name);
  123. }
  124. }
  125. }