Bitfile.cs 4.0 KB

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