data/full_repos/permissive/423958267/lab06/lab06.srcs/sources_1/new/transmitter.v
data/verilator_xmls/c1b9e58b-d599-459c-8eab-edde797d5e24.xml
module transmitter (
    output reg dout,
    output reg sent,
    input [7:0] din,
    input en,
    input clk
);

    reg last;
    reg sending;
    reg [7:0] data;
    reg [7:0] count;

    initial begin
        sending <= 0;
        count <= 0;
        dout <= 1;
    end

    always @(posedge clk) begin
        if(!sending && !last && en) begin
            data <= din;
            sending <= 1;
            sent <= 0;
            count <= 0;
        end

        last <= en;

        if(sending) count <= count+1;

        case (count)
            8'd8: dout <= 0;
            8'd24: dout <= din[0];
            8'd40: dout <= din[1];
            8'd56: dout <= din[2];
            8'd72: dout <= din[3];
            8'd88: dout <= din[4];
            8'd104: dout <= din[5];
            8'd120: dout <= din[6];
            8'd136: dout <= din[7];
            8'd152: begin sent <= 1; sending <= 0; dout <= 1; end
        endcase
    end
endmodule
module transmitter (
    output reg dout,
    output reg sent,
    input [7:0] din,
    input en,
    input clk
);


    reg last;
    reg sending;
    reg [7:0] data;
    reg [7:0] count;

    initial begin
        sending <= 0;
        count <= 0;
        dout <= 1;
    end

    always @(posedge clk) begin
        if(!sending && !last && en) begin
            data <= din;
            sending <= 1;
            sent <= 0;
            count <= 0;
        end

        last <= en;

        if(sending) count <= count+1;

        case (count)
            8'd8: dout <= 0;
            8'd24: dout <= din[0];
            8'd40: dout <= din[1];
            8'd56: dout <= din[2];
            8'd72: dout <= din[3];
            8'd88: dout <= din[4];
            8'd104: dout <= din[5];
            8'd120: dout <= din[6];
            8'd136: dout <= din[7];
            8'd152: begin sent <= 1; sending <= 0; dout <= 1; end
        endcase
    end
endmodule