private void WriteCompound(EsiCompound c) { W($"typedef struct packed {{"); switch (c.Type) { case EsiCompound.CompoundType.EsiFixed: W($" logic [{c.Fractional-1}:0] frac;"); W($" logic [{c.Whole-1}:0] whole;"); break; case EsiCompound.CompoundType.EsiFloat: W($" logic [{c.Fractional-1}:0] mant;"); W($" logic [{c.Whole-1}:0] exp;"); break; default: C.Log.Error("Invalid EsiCompound type: {type}", c.Type); break; } if (c.Signed) { W(" logic sign;"); } W($"}} {c.GetSVCompoundModuleName()};"); }
public static string GetSVHeaderName(this EsiType type) { return(type switch { EsiNamedType named when(!string.IsNullOrWhiteSpace(named.Name)) => $"{named.GetFilename()}.esi.svh", EsiCompound compound => "EsiCompundTypes.esi.svh", _ => null });
public void ReadStress1Interfaces() { var types = ReadSchema("stress_tests/stress1_synth.capnp").Objects.ToList(); Assert.Greater(types.Count, 0); var structs = types.Where(t => t is EsiStruct).Select(t => t as EsiStruct); Assert.Greater(structs.Count(), 0); var poly = structs.Where(t => t.Name == "Polynomial3").First(); var shape = structs.Where(t => t.Name == "Shape").First(); var interfaces = types.Where(t => t is EsiInterface).Select(t => t as EsiInterface); Assert.AreEqual(2, interfaces.Count()); var polyComps = interfaces.Where(i => i.Name == "Polynomial3Compute"); Assert.AreEqual(1, polyComps.Count()); var polyComp = polyComps.First(); Assert.AreEqual(2, polyComp.Methods.Length); var comp = polyComp.Methods.Where(m => m.Name == "compute").First(); // Context.Log.Information("Expected model: {model}", (ComputeParam as EsiObject).GetDescriptionTree()); // Context.Log.Information("Actual model: {model}", comp.Param.GetDescriptionTree()); Assert.True(ComputeParam1Type.StructuralEquals(comp.Params[0].Type)); Assert.True(ComputeParam2Type.StructuralEquals(comp.Params[1].Type, includeNames: true)); Assert.True(comp.Returns[0].Type.StructuralEquals(EsiCompound.SingletonFor( Type: EsiCompound.CompoundType.EsiFloat, Signed: true, Whole: 8, Fractional: 23 ))); }
public static string GetSVCompoundModuleName(EsiCompound c) => c.GetSVCompoundModuleName();