Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
using System;
using System.Threading.Tasks;
using Hast.Layer;
using Hast.Samples.SampleAssembly;
using Hast.Transformer.Abstractions.Configuration;
using Hast.Transformer.Vhdl.Abstractions.Configuration;
namespace Hast.Samples.Demo
{
class Program
{
static void Main(string[] args)
{
var sw = System.Diagnostics.Stopwatch.StartNew();
var cpuOutput = new ParallelAlgorithm().Run(234234);
sw.Stop();
Console.WriteLine("ParallelAlgorithm took " + sw.ElapsedMilliseconds + "ms.");
Console.ReadKey();
Task.Run(async () =>
{
using (var hastlayer = await Hastlayer.Create())
{
#region Configuration
var configuration = new HardwareGenerationConfiguration("Nexys4 DDR");
configuration.AddHardwareEntryPointType<ParallelAlgorithm>();
configuration.TransformerConfiguration().AddMemberInvocationInstanceCountConfiguration(
new MemberInvocationInstanceCountConfigurationForMethod<ParallelAlgorithm>(p => p.Run(null), 0)
{
MaxDegreeOfParallelism = ParallelAlgorithm.MaxDegreeOfParallelism
});
configuration.VhdlTransformerConfiguration().VhdlGenerationMode = VhdlGenerationMode.Debug;
hastlayer.ExecutedOnHardware += (sender, e) =>
{
Console.WriteLine(
"Executing " +
e.MemberFullName +
" on hardware took " +
e.HardwareExecutionInformation.HardwareExecutionTimeMilliseconds +
"ms (net) " +
e.HardwareExecutionInformation.FullExecutionTimeMilliseconds +
" milliseconds (all together)");
};
#endregion
#region HardwareGeneration
Console.WriteLine("Hardware generation starts.");
var hardwareRepresentation = await hastlayer.GenerateHardware(
new[]
{
typeof(ParallelAlgorithm).Assembly
},
configuration);
await hardwareRepresentation.HardwareDescription.WriteSource("Hast_IP.vhd");
#endregion
#region Execution
Console.WriteLine("Starting hardware execution.");
var parallelAlgorithm = await hastlayer.GenerateProxy(hardwareRepresentation, new ParallelAlgorithm());
var output1 = parallelAlgorithm.Run(234234);
var output2 = parallelAlgorithm.Run(123);
var output3 = parallelAlgorithm.Run(9999);
#endregion
}
}).Wait();
Console.ReadKey();
}
}
}
e02336faeThis file is pinned to the selected release. Download the original to open it in your design tool.