logic-circuit-design / practice / 03_Roulette / rtl / ROULETTE.v
ROULETTE.v
Raw

// Top module
module ROULETTE_TOP (
    CLK_50,  // 50MHz CLOCK
    RSTB,    // Asynchronous RESET (Negative logic)
    oSEG     // 7SEG output
);

    input          CLK_50;
    input          RSTB;
    output [6:0]   oSEG;
    wire   [3:0]   CNT;     // Counter OUTPUT

    
    SCLK_GEN U0(
        .CLK_IN(CLK_50),
        .CLK_OUT(SCLK)
    );

    SENARY_COUNTER U1(
        .CLK(SCLK), 
        .RSTB(RSTB), 
        .oCNT(CNT)
    );

    SEG7_LUT U2(
        .iDIG(CNT), 
        .oSEG(oSEG)
    );

endmodule


// Senary (base-6) Counter
module SENARY_COUNTER (
    CLK, 
    RSTB, 
    oCNT
);
    
    input          CLK;
    input          RSTB;
    output [3:0]   oCNT;
    
    reg [2:0]      CNT;
    
    assign oCNT = {1'b0,CNT};
    
    always @( posedge CLK or negedge RSTB )
        if ( !RSTB )
            CNT <= 0;
        else if ( CNT == 3'd5 ) // Fill the BLANK!
            CNT <= 0;
        else
            CNT <= CNT + 3'd1;

endmodule