/*
 * Exercise M4 on Tiny Tapeout: an 8-bit adder made of two 4-bit adders.
 *
 * Add adder8.sv to source_files in info.yaml next to project.v.
 * Rename the module to tt_um_<your GitHub name>_<project name> and use the
 * same name as top_module in info.yaml.
 */

`default_nettype none

module tt_um_example (
    input  wire [7:0] ui_in,    // DIP switches, INPUT Pmod, RP2350 GPIO17-24
    output wire [7:0] uo_out,   // 7-segment display, OUTPUT Pmod, RP2350 GPIO33-40
    input  wire [7:0] uio_in,   // BIDIR Pmod, RP2350 GPIO25-32
    output wire [7:0] uio_out,  //   (same pins)
    output wire [7:0] uio_oe,   //   1 = your design drives the pin
    input  wire       ena,      // set by the on-chip project mux, not a board pin
    input  wire       clk,      // RP2350 GPIO16
    input  wire       rst_n     // RP2350 GPIO14
);

    // DIP switches 0-7 are A, BIDIR pins 0-7 are B.  The circuit has no
    // clock and no reset.

    wire [7:0] sum;
    wire       carry;

    adder8 i_adder8 (
        .a     ( ui_in  ),
        .b     ( uio_in ),
        .sum   ( sum    ),
        .carry ( carry  )
    );

    // The sum on the 7-segment display and the OUTPUT Pmod: bit k lights
    // segment k, bit 7 the dot.  All 24 pins are taken, so the carry out has
    // no pin: a + b > 255 shows as a small sum.

    assign uo_out  = sum;

    assign uio_out = 8'b0;
    assign uio_oe  = 8'b0;

    // List all unused inputs to prevent warnings

    wire _unused = & { ena, clk, rst_n, carry, 1'b0 };

endmodule
