data/full_repos/permissive/521867481/src/BaudRateGenerator.v
1: b'%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:4: Cannot find include file: inc/Defines.vh\n`include "inc/Defines.vh" \n         ^~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/521867481/src,data/full_repos/permissive/521867481/inc/Defines.vh\n             data/full_repos/permissive/521867481/src,data/full_repos/permissive/521867481/inc/Defines.vh.v\n             data/full_repos/permissive/521867481/src,data/full_repos/permissive/521867481/inc/Defines.vh.sv\n             inc/Defines.vh\n             inc/Defines.vh.v\n             inc/Defines.vh.sv\n             obj_dir/inc/Defines.vh\n             obj_dir/inc/Defines.vh.v\n             obj_dir/inc/Defines.vh.sv\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:7: Define or directive not defined: \'`CLOCK_RATE_100MHZ\'\n        parameter CLOCK_RATE    = `CLOCK_RATE_100MHZ,  \n                                  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:7: syntax error, unexpected \',\', expecting TYPE-IDENTIFIER\n        parameter CLOCK_RATE    = `CLOCK_RATE_100MHZ,  \n                                                    ^\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:8: Define or directive not defined: \'`BAUD_RATE_115200\'\n        parameter BAUD_RATE     = `BAUD_RATE_115200,   \n                                  ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:8: syntax error, unexpected \',\', expecting TYPE-IDENTIFIER\n        parameter BAUD_RATE     = `BAUD_RATE_115200,   \n                                                   ^\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:9: Define or directive not defined: \'`OVERSAMPLING_16\'\n        parameter OVERSAMPLING  = `OVERSAMPLING_16     \n                                  ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:10: syntax error, unexpected \')\', expecting TYPE-IDENTIFIER\n    )(\n    ^\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:12: syntax error, unexpected output, expecting IDENTIFIER or do or final\n        output reg rxClk,  \n        ^~~~~~\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:13: syntax error, unexpected output, expecting IDENTIFIER or \'=\' or do or final\n        output reg txClk   \n        ^~~~~~\n%Error: data/full_repos/permissive/521867481/src/BaudRateGenerator.v:24: syntax error, unexpected initial\n    initial begin\n    ^~~~~~~\n%Error: Exiting due to 10 error(s)\n'
module BaudRateGenerator #(
        parameter CLOCK_RATE    = `CLOCK_RATE_100MHZ,
        parameter BAUD_RATE     = `BAUD_RATE_115200,
        parameter OVERSAMPLING  = `OVERSAMPLING_16
    )(
        input wire clk,
        output reg rxClk,
        output reg txClk
    );

    localparam MAX_RATE_RX  = CLOCK_RATE / (2 * BAUD_RATE * OVERSAMPLING);
    localparam MAX_RATE_TX  = CLOCK_RATE / (2 * BAUD_RATE);
    localparam RX_CNT_WIDTH = $clog2(MAX_RATE_RX);
    localparam TX_CNT_WIDTH = $clog2(MAX_RATE_TX);

    reg [RX_CNT_WIDTH - 1:0] rxCnt = 0;
    reg [TX_CNT_WIDTH - 1:0] txCnt = 0;

    initial begin
        rxClk = 1'b0;
        txClk = 1'b0;
    end

    always @ (posedge clk) begin

        if (rxCnt == MAX_RATE_RX) begin
            rxCnt <= 0;
            rxClk <= ~rxClk;
        end else begin
            rxCnt <= rxCnt + 1'b1;
        end


        if (txCnt == MAX_RATE_TX) begin
            txCnt <= 0;
            txClk <= ~txClk;
        end else begin
            txCnt <= txCnt + 1'b1;
        end
    end

endmodule
module BaudRateGenerator #(
        parameter CLOCK_RATE    = `CLOCK_RATE_100MHZ,
        parameter BAUD_RATE     = `BAUD_RATE_115200,
        parameter OVERSAMPLING  = `OVERSAMPLING_16
    )(
        input wire clk,
        output reg rxClk,
        output reg txClk
    );


    localparam MAX_RATE_RX  = CLOCK_RATE / (2 * BAUD_RATE * OVERSAMPLING);
    localparam MAX_RATE_TX  = CLOCK_RATE / (2 * BAUD_RATE);
    localparam RX_CNT_WIDTH = $clog2(MAX_RATE_RX);
    localparam TX_CNT_WIDTH = $clog2(MAX_RATE_TX);

    reg [RX_CNT_WIDTH - 1:0] rxCnt = 0;
    reg [TX_CNT_WIDTH - 1:0] txCnt = 0;

    initial begin
        rxClk = 1'b0;
        txClk = 1'b0;
    end

    always @ (posedge clk) begin

        if (rxCnt == MAX_RATE_RX) begin
            rxCnt <= 0;
            rxClk <= ~rxClk;
        end else begin
            rxCnt <= rxCnt + 1'b1;
        end


        if (txCnt == MAX_RATE_TX) begin
            txCnt <= 0;
            txClk <= ~txClk;
        end else begin
            txCnt <= txCnt + 1'b1;
        end
    end

endmodule