Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
93850422bThis 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)
{
Task.Run(async () =>
{
using (var hastlayer = await Hastlayer.Create())
{
#region Configuration
var configuration = new HardwareGenerationConfiguration("Nexys4 DDR");
configuration.AddHardwareEntryPointType<ParallelAlgorithm>();
configuration.VhdlTransformerConfiguration().VhdlGenerationConfiguration = VhdlGenerationConfiguration.Debug;
hastlayer.ExecutedOnHardware += (sender, e) =>
{
Console.WriteLine(
"Executing " +
e.MemberFullName +
" on hardware took " +
e.HardwareExecutionInformation.HardwareExecutionTimeMilliseconds +
" milliseconds (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);
var sw = System.Diagnostics.Stopwatch.StartNew();
var cpuOutput = new ParallelAlgorithm().Run(234234);
sw.Stop();
Console.WriteLine("On CPU it took " + sw.ElapsedMilliseconds + "ms.");
#endregion
}
}).Wait();
Console.ReadKey();
}
}
}