# Add a funky comment
digraph G {
    rankdir=LR;
    subgraph cluster0 {
        Start;
        node [shape=box,style=filled,color=red];
        label = "EIC Statemachine";
        subgraph cluster1{
            node [shape=box,style=filled,color=green];
            style=filled;
            label = "Token";
            token;
        }
        subgraph cluster_eicontroller {
            label = "Enabled<EIController, Counter>";
            subgraph cluster_eicontroller {
                label = "Enabled<EIController, N>";

                subgraph cluster_sync {
                    label = "Async and Sync";
                    group = "eicontroller";

                    eic_new;

                    subgraph cluster_sync_inner {
                        label = "EIController<WithClock>";
                        sync_new_sync;
                        sync_new_async;
                        sync_new_sync_nmi [color=purple];
                        sync_new_async_nmi [color=purple];
                    }
                    eic_new -> sync_new_sync;
                    eic_new -> sync_new_async;
                    eic_new -> sync_new_sync_nmi;
                    eic_new -> sync_new_async_nmi;
                }
                subgraph cluster_async {
                    label = "Async only";
                    group = "eicontroller";

                    eic_new_only_async;

                    subgraph cluster_async_inner {
                        label = "EIController<WithoutClock>";
                        async_new_async[color=green];
                        async_new_async_nmi [color=purple];
                    }
                    eic_new_only_async -> async_new_async;
                    eic_new_only_async -> async_new_async_nmi;
                }
                subgraph cluster_eicontroller {
                    label = "Enabled<EIController, U0>";
                    group = "eicontroller";
                    swrst -> swrst;
                }
            }
        }
        subgraph cluster_extint {
            label = "ExtInt";
            subgraph cluster_mode {
                label = "Mode = ";
                Normal
                AsyncOnly
                Filtered
                Debounced;
            }

            subgraph cluster_sense {
                label = "Sense = Rise, Fall, Both";
                subgraph cluster_leveldetect {
                    label = "Async = False";
                    SyncEdgeDetect;
                }
                subgraph cluster_leveldetect_async {
                    label = "Async = True";
                    AsyncEdgeDetect [color=green];
                }
                Filtered -> SyncEdgeDetect;

                # All edges below are v7 only
                edge[style="dashed", label="v7 only"]
                Debounced -> SyncEdgeDetect;
                Debounced -> AsyncEdgeDetect;
            }
            subgraph cluster_sense_leveldetect {
                label = "Sense = High, Low";
                subgraph cluster_leveldetect {
                    label = "Async = False";
                    LevelDetect;
                }
                subgraph cluster_leveldetect_async {
                    label = "Async = True";
                    AsyncLevelDetect [color=green];
                }
                Filtered -> LevelDetect;
            }


            subgraph cluster_anyclock {
                group="clock";
                style=filled;
                label = "AnyClock =";
                WithClock;
                node [color=green];
                WithoutClock;

                WithClock -> Filtered;
                WithClock -> Normal;
                Normal -> SyncEdgeDetect;
                Normal -> LevelDetect;

                WithoutClock -> AsyncOnly;

                # All edges below are v7 only
                edge[style="dashed", label="v7 only"]
                WithClock -> Debounced;
                WithClock -> AsyncOnly;
                AsyncOnly -> AsyncEdgeDetect;
                AsyncOnly -> AsyncLevelDetect;
            }
        }



        subgraph cluster_nmiextint {
            label = "NmiExtInt";

            subgraph cluster_filtering {
                label = "Mode = Filtering";
                NMIFiltered [color=purple];
            }

            subgraph cluster_withclock_nmi {
                style=filled;
                label = "AnyClock = ";
                subgraph withclock_nmi {
                    label="WithClock"
                    WithClockNmi [color=red];
                }

                subgraph withoutclock_nmi {
                    label="WithoutClock"
                    WithoutClockNmi[color=green];
                }

                WithClockNmi -> NMIFiltered;
            }
            subgraph cluster_NMISense {
                label = "NMISense = None, Rise, Fall, Both, High, Low";
                node [shape=box,style=filled,color=purple];
                subgraph cluster_NMISense_edgedetect {
                    label = "NMISense = Rise, Fall, Both";
                    subgraph cluster_NMISense_edgedetect {
                        label = "Async = False";
                        NMIEdgeDetect;
                        WithClockNmi -> NMIEdgeDetect;
                        NMIFiltered -> NMIEdgeDetect;
                    }
                }
                subgraph cluster_NMISense_leveldetect {
                    label = "NMISense = High, Low";
                    subgraph cluster_NMISense_leveldetect_async {
                        label = "Async = True";
                        NMILevelDetectAsync;
                        WithoutClockNmi -> NMILevelDetectAsync[style="dashed", label="v7 only"];
                    }
                    subgraph cluster_NMISense_leveldetect {
                        label = "Async = False";
                        NMILevelDetect;
                        NMIFiltered -> NMILevelDetect;
                    }
                }
                subgraph cluster_NMISense_none {
                    label = "NMISense = None";
                    NMIIdle;
                    WithoutClockNmi -> NMIIdle;
                    WithClockNmi -> NMIIdle [label="via enable_async()"];
                }
            }

        }

        Start -> token;
        token -> eic_new;
        token -> eic_new_only_async [label="ok"];
        async_new_async -> WithoutClock;
        async_new_async_nmi -> WithoutClockNmi[style="dashed", label="v7 only"];
        sync_new_sync -> WithClock;
        sync_new_async -> WithoutClock[style="dashed", label="v7 only"];
        sync_new_sync_nmi -> WithClockNmi;
        sync_new_async_nmi -> WithoutClockNmi[style="dashed", label="v7 only"];
    }
}