kenkendk / sme

Synchronous Message Exchange
MIT License
10 stars 3 forks source link

Add pin mapping support #5

Open kenkendk opened 7 years ago

kenkendk commented 7 years ago

The TopLevelInput and TopLevelOutput busses should be map-able to pins on the target board.

This could be implemented with an attribute, like this:

[TopLevelOutput]
public interface MyBus : IBus
{
    [Pin("G32")]
    public bool StatusLED { get; set; }
}

The generated VHDL will then be augmented with a constraint file that maps the relevant pins.

This can be further simplified with a board configuration class, i.e.:

public static class ZedBoard_v1
{
    public static string LED0 = "G32";
}

The user code can then map it like this:

using static Zeboard_v1;

[TopLevelOutput]
public interface MyBus : IBus
{
    [Pin(LED0)]
    public bool StatusLED { get; set; }
}

The using static statement allows easy board switching, provided the boards have the same named components. It would also be trivial to write a bait-n-switch class that simply maps items based on compile directives, i.e.:

public static class Board
{
#if BOARDTARGET_ZEDBOARD
    public static string LED0 = "G32";
#elif BOARDTARGET_PYNQ
    public static string LED0 = "F16";
#else
#error Unsupported board
#endif
}

The board can then be used with:

[TopLevelOutput]
public interface MyBus : IBus
{
    [Pin(Board.LED0)]
    public bool StatusLED { get; set; }
}
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/48158440-add-pin-mapping-support?utm_campaign=plugin&utm_content=tracker%2F36576838&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F36576838&utm_medium=issues&utm_source=github).