--
-- VHDL Architecture Morse_test.charToMorseController_tb.struct
--
-- Created:
--          by - axel.amand.UNKNOWN (WE7860)
--          at - 14:50:43 28.04.2023
--
-- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5)
--
LIBRARY ieee;
  USE ieee.std_logic_1164.all;
  USE ieee.numeric_std.ALL;

LIBRARY Morse;
LIBRARY Morse_test;

ARCHITECTURE struct OF charToMorseController_tb IS

    -- Architecture declarations
    constant characterBitNb: positive := 7;
    constant unitCountBitNb: positive := 3;
    constant unitDuration: real := 50.0E-6;
    constant clockFrequency: real := 60.0E6;
    --constant clockFrequency: real := 66.0E6;

    -- Internal signal declarations
    SIGNAL char         : std_ulogic_vector(characterBitNb-1 DOWNTO 0);
    SIGNAL charNotReady : std_ulogic;
    SIGNAL clock        : std_ulogic;
    SIGNAL done         : std_ulogic;
    SIGNAL morseOut     : std_ulogic;
    SIGNAL readChar     : std_ulogic;
    SIGNAL reset        : std_ulogic;
    SIGNAL startCounter : std_ulogic;
    SIGNAL unitNb       : unsigned(unitCountBitNb-1 DOWNTO 0);


    -- Component Declarations
    COMPONENT charToMorseController
    GENERIC (
        characterBitNb : positive := 8;
        unitCountBitNb : positive := 3
    );
    PORT (
        morseOut     : OUT    std_ulogic ;
        clock        : IN     std_ulogic ;
        reset        : IN     std_ulogic ;
        charNotReady : IN     std_ulogic ;
        char         : IN     std_ulogic_vector (characterBitNb-1 DOWNTO 0);
        startCounter : OUT    std_ulogic ;
        unitNb       : OUT    unsigned (unitCountBitNb-1 DOWNTO 0);
        counterDone  : IN     std_ulogic ;
        readChar     : OUT    std_ulogic 
    );
    END COMPONENT;
    COMPONENT unitCounter
    GENERIC (
        unitCountDivide : positive := 10E3;
        unitCountBitNb  : positive := 3
    );
    PORT (
        clock        : IN     std_ulogic ;
        reset        : IN     std_ulogic ;
        startCounter : IN     std_ulogic ;
        unitNb       : IN     unsigned (unitCountBitNb-1 DOWNTO 0);
        done         : OUT    std_ulogic 
    );
    END COMPONENT;
    COMPONENT charToMorseController_tester
    GENERIC (
        clockFrequency : real;
        characterBitNb : positive
    );
    PORT (
        morseOut     : IN     std_ulogic ;
        readChar     : IN     std_ulogic ;
        char         : OUT    std_ulogic_vector (characterBitNb-1 DOWNTO 0);
        charNotReady : OUT    std_ulogic ;
        clock        : OUT    std_ulogic ;
        reset        : OUT    std_ulogic 
    );
    END COMPONENT;

    -- Optional embedded configurations
    -- pragma synthesis_off
    FOR ALL : charToMorseController USE ENTITY Morse.charToMorseController;
    FOR ALL : charToMorseController_tester USE ENTITY Morse_test.charToMorseController_tester;
    FOR ALL : unitCounter USE ENTITY Morse.unitCounter;
    -- pragma synthesis_on


BEGIN

    -- Instance port mappings.
    I_DUT : charToMorseController
        GENERIC MAP (
            characterBitNb => characterBitNb,
            unitCountBitNb => unitCountBitNb
        )
        PORT MAP (
            morseOut     => morseOut,
            clock        => clock,
            reset        => reset,
            charNotReady => charNotReady,
            char         => char,
            startCounter => startCounter,
            unitNb       => unitNb,
            counterDone  => done,
            readChar     => readChar
        );
    I_cnt : unitCounter
        GENERIC MAP (
            unitCountDivide => integer(clockFrequency*unitDuration + 0.5),
            unitCountBitNb  => unitCountBitNb
        )
        PORT MAP (
            clock        => clock,
            reset        => reset,
            startCounter => startCounter,
            unitNb       => unitNb,
            done         => done
        );
    I_tester : charToMorseController_tester
        GENERIC MAP (
            clockFrequency => clockFrequency,
            characterBitNb => characterBitNb
        )
        PORT MAP (
            morseOut     => morseOut,
            readChar     => readChar,
            char         => char,
            charNotReady => charNotReady,
            clock        => clock,
            reset        => reset
        );

END struct;
