data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv
1: b"%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:226: Cannot find file containing module: 'clk_skew_adjust'\nclk_skew_adjust u_skew_pinmux\n^~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/504248338/verilog/rtl/pinmux/src,data/full_repos/permissive/504248338/clk_skew_adjust\n             data/full_repos/permissive/504248338/verilog/rtl/pinmux/src,data/full_repos/permissive/504248338/clk_skew_adjust.v\n             data/full_repos/permissive/504248338/verilog/rtl/pinmux/src,data/full_repos/permissive/504248338/clk_skew_adjust.sv\n             clk_skew_adjust\n             clk_skew_adjust.v\n             clk_skew_adjust.sv\n             obj_dir/clk_skew_adjust\n             obj_dir/clk_skew_adjust.v\n             obj_dir/clk_skew_adjust.sv\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:237: Cannot find file containing module: 'reset_sync'\nreset_sync  u_rst_sync (\n^~~~~~~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:244: Cannot find file containing module: 'gpio_intr_gen'\ngpio_intr_gen u_gpio_intr (\n^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:266: Cannot find file containing module: 'pulse_gen_type2'\npulse_gen_type2  #(.WD(10)) u_pulse_1us (\n^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:276: Cannot find file containing module: 'pulse_gen_type1'\npulse_gen_type1 u_pulse_1ms (\n^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:286: Cannot find file containing module: 'pulse_gen_type1'\npulse_gen_type1 u_pulse_1s (\n^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:302: Cannot find file containing module: 'timer'\ntimer  u_timer_0\n^~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:322: Cannot find file containing module: 'timer'\ntimer  u_timer_1\n^~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:342: Cannot find file containing module: 'timer'\ntimer  u_timer_2\n^~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:359: Cannot find file containing module: 'pinmux_reg'\npinmux_reg u_pinmux_reg(\n^~~~~~~~~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:439: Cannot find file containing module: 'pwm'\npwm  u_pwm_0 (\n^~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:449: Cannot find file containing module: 'pwm'\npwm  u_pwm_1 (\n^~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:459: Cannot find file containing module: 'pwm'\npwm  u_pwm_2 (\n^~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:469: Cannot find file containing module: 'pwm'\npwm  u_pwm_3 (\n^~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:478: Cannot find file containing module: 'pwm'\npwm  u_pwm_4 (\n^~~\n%Error: data/full_repos/permissive/504248338/verilog/rtl/pinmux/src/pinmux.sv:487: Cannot find file containing module: 'pwm'\npwm  u_pwm_5 (\n^~~\n%Error: Exiting due to 16 error(s)\n"
module pinmux (
                    `ifdef USE_POWER_PINS
                       input logic         vccd1,
                       input logic         vssd1,
                    `endif

                       input logic [3:0]        cfg_cska_pinmux,
                       input logic	        wbd_clk_int,
                       output logic	        wbd_clk_pinmux,


		       input logic             mclk,
                       input logic             h_reset_n,


                       output logic  [1:0]     cpu_core_rst_n   ,
                       output logic            cpu_intf_rst_n   ,
                       output logic            qspim_rst_n      ,
                       output logic            sspim_rst_n      ,
                       output logic [1:0]      uart_rst_n       ,
                       output logic            i2cm_rst_n       ,
                       output logic            usb_rst_n        ,

		       output logic [15:0]     cfg_riscv_ctrl,


                       input logic             reg_cs,
                       input logic             reg_wr,
                       input logic [7:0]       reg_addr,
                       input logic [31:0]      reg_wdata,
                       input logic [3:0]       reg_be,


                       output logic [31:0]     reg_rdata,
                       output logic            reg_ack,


                       output logic [15:0]     irq_lines,
                       output logic            soft_irq,
                       output logic [2:0]      user_irq,
		       input  logic            usb_intr,
		       input  logic            i2cm_intr,


                       output logic [37:0]     digital_io_out,
                       output logic [37:0]     digital_io_oen,
                       input  logic [37:0]     digital_io_in,


		       input  logic            sflash_sck,
		       input  logic [3:0]      sflash_ss,
		       input  logic [3:0]      sflash_oen,
		       input  logic [3:0]      sflash_do,
		       output logic [3:0]      sflash_di,









		       input   logic           usb_dp_o,
		       input   logic           usb_dn_o,
		       input   logic           usb_oen,
		       output   logic          usb_dp_i,
		       output   logic          usb_dn_i,


		       input   logic  [1:0]    uart_txd,
		       output  logic  [1:0]    uart_rxd,


		       input   logic           i2cm_clk_o,
		       output  logic           i2cm_clk_i,
		       input   logic           i2cm_clk_oen,
		       input   logic           i2cm_data_oen,
		       input   logic           i2cm_data_o,
		       output  logic           i2cm_data_i,


		       input   logic           spim_sck,
		       input   logic [3:0]     spim_ssn,
		       input   logic           spim_miso,
		       output  logic           spim_mosi,


                       output  logic            uartm_rxd ,
                       input logic              uartm_txd  ,       

		       output  logic           pulse1m_mclk,
	               output  logic [31:0]    pinmux_debug,

		       input   logic           dbg_clk_mon

   ); 



logic sreset_n;
   

/

assign      cfg_pwm_enb          = cfg_multi_func_sel[5:0];
wire [1:0]  cfg_int_enb          = cfg_multi_func_sel[7:6];
wire [1:0]  cfg_uart_enb         = cfg_multi_func_sel[9:8];
wire [3:0]  cfg_spim_enb         = cfg_multi_func_sel[13:10];
wire        cfg_i2cm_enb         = cfg_multi_func_sel[14];

wire [7:0]  cfg_port_a_dir_sel   = cfg_gpio_dir_sel[7:0];
wire [7:0]  cfg_port_b_dir_sel   = cfg_gpio_dir_sel[15:8];
wire [7:0]  cfg_port_c_dir_sel   = cfg_gpio_dir_sel[23:16];
wire [7:0]  cfg_port_d_dir_sel   = cfg_gpio_dir_sel[31:24];



always_comb begin
     port_a_in = 'h0;
     port_b_in = 'h0;
     port_c_in = 'h0;
     port_d_in = 'h0;
     uart_rxd   = 'h0;
     ext_intr_in= 'h0;
     spim_mosi  = 'h0;
     i2cm_data_i= 'h0;
     i2cm_clk_i = 'h0;


     port_c_in[6] = digital_io_in[0];


     port_d_in[0] = digital_io_in[1];
     if(cfg_uart_enb[0])  uart_rxd[0]   = digital_io_in[1];
  

     port_d_in[1] = digital_io_in[2];



     port_d_in[2] = digital_io_in[3];
     if(cfg_uart_enb[1])     uart_rxd[1]    = digital_io_in[3];
     else if(cfg_int_enb[0]) ext_intr_in[0] = digital_io_in[3];


     port_d_in[3] = digital_io_in[4];
     if(cfg_int_enb[1]) ext_intr_in[1] = digital_io_in[4];


     port_d_in[4] = digital_io_in[5];


     port_b_in[6] = digital_io_in[6];


     port_b_in[7] = digital_io_in[7];


     port_d_in[5] = digital_io_in[8];


     port_d_in[6] = digital_io_in[9];


     port_d_in[7] = digital_io_in[10];
     

     port_b_in[0] =  digital_io_in[11];


     port_b_in[1] = digital_io_in[12];


     port_b_in[2] = digital_io_in[13];


     port_b_in[3] = digital_io_in[14];
     if(cfg_spim_enb[0]) spim_mosi = digital_io_in[14];


     port_b_in[4] = digital_io_in[15];


     port_b_in[5]= digital_io_in[16];
     

     port_c_in[0] = digital_io_in[18];


     port_c_in[1] = digital_io_in[19];


     port_c_in[2] = digital_io_in[20];


     port_c_in[3] = digital_io_in[21];


     port_c_in[4] = digital_io_in[22];
     if(cfg_i2cm_enb)  i2cm_data_i = digital_io_in[22];


     port_c_in[5] = digital_io_in[23];
     if(cfg_i2cm_enb)  i2cm_clk_i = digital_io_in[23];

     sflash_di[0] = digital_io_in[29];
     sflash_di[1] = digital_io_in[30];
     sflash_di[2] = digital_io_in[31];
     sflash_di[3] = digital_io_in[32];


     uartm_rxd    = digital_io_in[34];

     usb_dp_i    = digital_io_in[36];
     usb_dn_i    = digital_io_in[37];
end


always_comb begin
     digital_io_out = 'h0;

     if(cfg_port_c_dir_sel[6])       digital_io_out[0]   = port_c_out[6];


     if(cfg_port_d_dir_sel[0])       digital_io_out[1]   = port_d_out[0];
  

     if     (cfg_uart_enb[0])        digital_io_out[2]   = uart_txd[0];
     else if(cfg_port_d_dir_sel[1])  digital_io_out[2]   = port_d_out[1];



     if(cfg_port_d_dir_sel[2])       digital_io_out[3]   = port_d_out[2];


     if(cfg_pwm_enb[0])              digital_io_out[4]   = pwm_wfm[0];
     else if(cfg_port_d_dir_sel[3])  digital_io_out[4]   = port_d_out[3];


     if   (cfg_uart_enb[1])               digital_io_out[5]   = uart_txd[1];
     else if(cfg_port_d_dir_sel[4])       digital_io_out[5]   = port_d_out[4];


     if(cfg_port_b_dir_sel[6])       digital_io_out[6]   = port_b_out[6];



     if(cfg_port_b_dir_sel[7])       digital_io_out[7]   = port_b_out[7];


     if(cfg_pwm_enb[1])              digital_io_out[8]   = pwm_wfm[1];
     else if(cfg_spim_enb[3])        digital_io_out[8]  = spim_ssn[3];
     else if(cfg_port_d_dir_sel[5])  digital_io_out[8]   = port_d_out[5];


     if(cfg_pwm_enb[2])              digital_io_out[9]   = pwm_wfm[2];
     else if(cfg_spim_enb[2])        digital_io_out[9]   = spim_ssn[2];
     else if(cfg_port_d_dir_sel[6])  digital_io_out[9]   = port_d_out[6];



     if(cfg_port_d_dir_sel[7])       digital_io_out[10]  = port_d_out[7];
     

     if(cfg_port_b_dir_sel[0])       digital_io_out[11]  = port_b_out[0];


     if(cfg_pwm_enb[3])              digital_io_out[12]  = pwm_wfm[3];
     else if(cfg_spim_enb[1])        digital_io_out[12]  = spim_ssn[1];
     else if(cfg_port_b_dir_sel[1])  digital_io_out[12]  = port_b_out[1];


     if(cfg_pwm_enb[4])              digital_io_out[13]  = pwm_wfm[4];
     else if(cfg_spim_enb[0])        digital_io_out[13]  = spim_ssn[0];
     else if(cfg_port_b_dir_sel[2])  digital_io_out[13]  = port_b_out[2];


     if(cfg_pwm_enb[5])              digital_io_out[14]  = pwm_wfm[5];
     else if(cfg_port_b_dir_sel[3])  digital_io_out[14]  = port_b_out[3];


     if(cfg_spim_enb[0])             digital_io_out[15]  = spim_miso;
     else if(cfg_port_b_dir_sel[4])  digital_io_out[15]  = port_b_out[4];


     if(cfg_spim_enb[0])             digital_io_out[16]  = spim_sck;
     else if(cfg_port_b_dir_sel[5])  digital_io_out[16]  = port_b_out[5];
     

     if(cfg_port_c_dir_sel[0])       digital_io_out[18]  = port_c_out[0];


     if(cfg_port_c_dir_sel[1])       digital_io_out[19]  = port_c_out[1];


     if(cfg_port_c_dir_sel[2])       digital_io_out[20]  = port_c_out[2];


     if(cfg_port_c_dir_sel[3])       digital_io_out[21]  = port_c_out[3];


     if(cfg_i2cm_enb)                digital_io_out[22]  = i2cm_data_o;
     else if(cfg_port_c_dir_sel[4])  digital_io_out[22]  = port_c_out[4];


     if(cfg_i2cm_enb)                digital_io_out[23]  = i2cm_clk_o;
     else if(cfg_port_c_dir_sel[5])  digital_io_out[23]  = port_c_out[5];


     digital_io_out[24] = sflash_sck   ;
     digital_io_out[25] = sflash_ss[0] ;
     digital_io_out[26] = sflash_ss[1] ;
     digital_io_out[27] = sflash_ss[2] ;
     digital_io_out[28] = sflash_ss[3] ;
     digital_io_out[29] = sflash_do[0] ;
     digital_io_out[30] = sflash_do[1] ;
     digital_io_out[31] = sflash_do[2] ;
     digital_io_out[32] = sflash_do[3] ;
                       

     digital_io_out[33] = dbg_clk_mon;


     digital_io_out[34] = 1'b0         ;
     digital_io_out[35] = uartm_txd    ;
                  

     digital_io_out[36] = usb_dp_o     ;
     digital_io_out[37] = usb_dn_o     ;
end


always_comb begin
     digital_io_oen = 38'h3F_FFFF_FFFF;

     if(cfg_port_c_dir_sel[6])       digital_io_oen[0]   = 1'b0;


     if     (cfg_uart_enb[0])        digital_io_oen[1]   = 1'b1;
     else if(cfg_port_d_dir_sel[0])  digital_io_oen[1]   = 1'b0;


     if     (cfg_uart_enb[0])        digital_io_oen[2]   = 1'b0;
     else if(cfg_port_d_dir_sel[1])  digital_io_oen[2]   = 1'b0;


     if   (cfg_uart_enb[1])          digital_io_oen[3]   = 1'b1;
     else if(cfg_int_enb[0])         digital_io_oen[3]   = 1'b1;
     else if(cfg_port_d_dir_sel[2])  digital_io_oen[3]   = 1'b0;


     if(cfg_pwm_enb[0])              digital_io_oen[4]   = 1'b0;
     else if(cfg_int_enb[1])         digital_io_oen[4]   = 1'b1;
     else if(cfg_port_d_dir_sel[3])  digital_io_oen[4]   = 1'b0;


     if   (cfg_uart_enb[1])          digital_io_oen[5]   = 1'b0;
     else if(cfg_port_d_dir_sel[4])  digital_io_oen[5]   = 1'b0;


     if(cfg_port_b_dir_sel[6])       digital_io_oen[6]   = 1'b0;


     if(cfg_port_b_dir_sel[7])       digital_io_oen[7]   = 1'b0;


     if(cfg_pwm_enb[1])              digital_io_oen[8]   = 1'b0;
     else if(cfg_spim_enb[3])        digital_io_oen[8]   = 1'b0;
     else if(cfg_port_d_dir_sel[5])  digital_io_oen[8]   = 1'b0;


     if(cfg_pwm_enb[2])              digital_io_oen[9]   = 1'b0;
     else if(cfg_spim_enb[2])        digital_io_oen[9]   = 1'b0;
     else if(cfg_port_d_dir_sel[6])  digital_io_oen[9]   = 1'b0;


     if(cfg_port_d_dir_sel[7])       digital_io_oen[10]  = 1'b0;
     

     if(cfg_port_b_dir_sel[0])       digital_io_oen[11]  = 1'b0;


     if(cfg_pwm_enb[3])              digital_io_oen[12]  = 1'b0;
     else if(cfg_spim_enb[1])        digital_io_oen[12]  = 1'b0;
     else if(cfg_port_b_dir_sel[1])  digital_io_oen[12]  = 1'b0;


     if(cfg_pwm_enb[4])              digital_io_oen[13]  = 1'b0;
     else if(cfg_spim_enb[0])        digital_io_oen[13]  = 1'b0;
     else if(cfg_port_b_dir_sel[2])  digital_io_oen[13]  = 1'b0;


     if(cfg_spim_enb[0])                digital_io_oen[14]  = 1'b1;
     else if(cfg_pwm_enb[5])         digital_io_oen[14]  = 1'b0;
     else if(cfg_port_b_dir_sel[3])  digital_io_oen[14]  = 1'b0;


     if(cfg_spim_enb[0])             digital_io_oen[15]  = 1'b0;
     else if(cfg_port_b_dir_sel[4])  digital_io_oen[15]  = 1'b0;


     if(cfg_spim_enb[0])                digital_io_oen[16]  = 1'b0;
     else if(cfg_port_b_dir_sel[5])  digital_io_oen[16]  = 1'b0;
     

     if(cfg_port_c_dir_sel[0])       digital_io_oen[18]  = 1'b0;


     if(cfg_port_c_dir_sel[1])       digital_io_oen[19]  = 1'b0;


     if(cfg_port_c_dir_sel[2])       digital_io_oen[20]  = 1'b0;


     if(cfg_port_c_dir_sel[3])       digital_io_oen[21]  = 1'b0;


     if(cfg_i2cm_enb)                digital_io_oen[22]  = i2cm_data_oen;
     else if(cfg_port_c_dir_sel[4])  digital_io_oen[22]  = 1'b0;


     if(cfg_i2cm_enb)                digital_io_oen[23]  = i2cm_clk_oen;
     else if(cfg_port_c_dir_sel[5])  digital_io_oen[23]  = 1'b0;


     digital_io_oen[24] = 1'b0   ;
     digital_io_oen[25] = 1'b0   ;
     digital_io_oen[26] = 1'b0   ;
     digital_io_oen[27] = 1'b0   ;
     digital_io_oen[28] = 1'b0   ;
     digital_io_oen[29] = sflash_oen[0];
     digital_io_oen[30] = sflash_oen[1];
     digital_io_oen[31] = sflash_oen[2];
     digital_io_oen[32] = sflash_oen[3];
                       

     digital_io_oen[33] = 1'b0  ;

     digital_io_oen[34] = 1'b1;
     digital_io_oen[35] = 1'b0;
                  

     digital_io_oen[36] = usb_oen;
     digital_io_oen[37] = usb_oen;
end


endmodule
module pinmux (
                    `ifdef USE_POWER_PINS
                       input logic         vccd1,
                       input logic         vssd1,
                    `endif

                       input logic [3:0]        cfg_cska_pinmux,
                       input logic	        wbd_clk_int,
                       output logic	        wbd_clk_pinmux,


		       input logic             mclk,
                       input logic             h_reset_n,


                       output logic  [1:0]     cpu_core_rst_n   ,
                       output logic            cpu_intf_rst_n   ,
                       output logic            qspim_rst_n      ,
                       output logic            sspim_rst_n      ,
                       output logic [1:0]      uart_rst_n       ,
                       output logic            i2cm_rst_n       ,
                       output logic            usb_rst_n        ,

		       output logic [15:0]     cfg_riscv_ctrl,


                       input logic             reg_cs,
                       input logic             reg_wr,
                       input logic [7:0]       reg_addr,
                       input logic [31:0]      reg_wdata,
                       input logic [3:0]       reg_be,


                       output logic [31:0]     reg_rdata,
                       output logic            reg_ack,


                       output logic [15:0]     irq_lines,
                       output logic            soft_irq,
                       output logic [2:0]      user_irq,
		       input  logic            usb_intr,
		       input  logic            i2cm_intr,


                       output logic [37:0]     digital_io_out,
                       output logic [37:0]     digital_io_oen,
                       input  logic [37:0]     digital_io_in,


		       input  logic            sflash_sck,
		       input  logic [3:0]      sflash_ss,
		       input  logic [3:0]      sflash_oen,
		       input  logic [3:0]      sflash_do,
		       output logic [3:0]      sflash_di,









		       input   logic           usb_dp_o,
		       input   logic           usb_dn_o,
		       input   logic           usb_oen,
		       output   logic          usb_dp_i,
		       output   logic          usb_dn_i,


		       input   logic  [1:0]    uart_txd,
		       output  logic  [1:0]    uart_rxd,


		       input   logic           i2cm_clk_o,
		       output  logic           i2cm_clk_i,
		       input   logic           i2cm_clk_oen,
		       input   logic           i2cm_data_oen,
		       input   logic           i2cm_data_o,
		       output  logic           i2cm_data_i,


		       input   logic           spim_sck,
		       input   logic [3:0]     spim_ssn,
		       input   logic           spim_miso,
		       output  logic           spim_mosi,


                       output  logic            uartm_rxd ,
                       input logic              uartm_txd  ,       

		       output  logic           pulse1m_mclk,
	               output  logic [31:0]    pinmux_debug,

		       input   logic           dbg_clk_mon

   );
 



logic sreset_n;
   

/

assign      cfg_pwm_enb          = cfg_multi_func_sel[5:0];
wire [1:0]  cfg_int_enb          = cfg_multi_func_sel[7:6];
wire [1:0]  cfg_uart_enb         = cfg_multi_func_sel[9:8];
wire [3:0]  cfg_spim_enb         = cfg_multi_func_sel[13:10];
wire        cfg_i2cm_enb         = cfg_multi_func_sel[14];

wire [7:0]  cfg_port_a_dir_sel   = cfg_gpio_dir_sel[7:0];
wire [7:0]  cfg_port_b_dir_sel   = cfg_gpio_dir_sel[15:8];
wire [7:0]  cfg_port_c_dir_sel   = cfg_gpio_dir_sel[23:16];
wire [7:0]  cfg_port_d_dir_sel   = cfg_gpio_dir_sel[31:24];



always_comb begin
     port_a_in = 'h0;
     port_b_in = 'h0;
     port_c_in = 'h0;
     port_d_in = 'h0;
     uart_rxd   = 'h0;
     ext_intr_in= 'h0;
     spim_mosi  = 'h0;
     i2cm_data_i= 'h0;
     i2cm_clk_i = 'h0;


     port_c_in[6] = digital_io_in[0];


     port_d_in[0] = digital_io_in[1];
     if(cfg_uart_enb[0])  uart_rxd[0]   = digital_io_in[1];
  

     port_d_in[1] = digital_io_in[2];



     port_d_in[2] = digital_io_in[3];
     if(cfg_uart_enb[1])     uart_rxd[1]    = digital_io_in[3];
     else if(cfg_int_enb[0]) ext_intr_in[0] = digital_io_in[3];


     port_d_in[3] = digital_io_in[4];
     if(cfg_int_enb[1]) ext_intr_in[1] = digital_io_in[4];


     port_d_in[4] = digital_io_in[5];


     port_b_in[6] = digital_io_in[6];


     port_b_in[7] = digital_io_in[7];


     port_d_in[5] = digital_io_in[8];


     port_d_in[6] = digital_io_in[9];


     port_d_in[7] = digital_io_in[10];
     

     port_b_in[0] =  digital_io_in[11];


     port_b_in[1] = digital_io_in[12];


     port_b_in[2] = digital_io_in[13];


     port_b_in[3] = digital_io_in[14];
     if(cfg_spim_enb[0]) spim_mosi = digital_io_in[14];


     port_b_in[4] = digital_io_in[15];


     port_b_in[5]= digital_io_in[16];
     

     port_c_in[0] = digital_io_in[18];


     port_c_in[1] = digital_io_in[19];


     port_c_in[2] = digital_io_in[20];


     port_c_in[3] = digital_io_in[21];


     port_c_in[4] = digital_io_in[22];
     if(cfg_i2cm_enb)  i2cm_data_i = digital_io_in[22];


     port_c_in[5] = digital_io_in[23];
     if(cfg_i2cm_enb)  i2cm_clk_i = digital_io_in[23];

     sflash_di[0] = digital_io_in[29];
     sflash_di[1] = digital_io_in[30];
     sflash_di[2] = digital_io_in[31];
     sflash_di[3] = digital_io_in[32];


     uartm_rxd    = digital_io_in[34];

     usb_dp_i    = digital_io_in[36];
     usb_dn_i    = digital_io_in[37];
end


always_comb begin
     digital_io_out = 'h0;

     if(cfg_port_c_dir_sel[6])       digital_io_out[0]   = port_c_out[6];


     if(cfg_port_d_dir_sel[0])       digital_io_out[1]   = port_d_out[0];
  

     if     (cfg_uart_enb[0])        digital_io_out[2]   = uart_txd[0];
     else if(cfg_port_d_dir_sel[1])  digital_io_out[2]   = port_d_out[1];



     if(cfg_port_d_dir_sel[2])       digital_io_out[3]   = port_d_out[2];


     if(cfg_pwm_enb[0])              digital_io_out[4]   = pwm_wfm[0];
     else if(cfg_port_d_dir_sel[3])  digital_io_out[4]   = port_d_out[3];


     if   (cfg_uart_enb[1])               digital_io_out[5]   = uart_txd[1];
     else if(cfg_port_d_dir_sel[4])       digital_io_out[5]   = port_d_out[4];


     if(cfg_port_b_dir_sel[6])       digital_io_out[6]   = port_b_out[6];



     if(cfg_port_b_dir_sel[7])       digital_io_out[7]   = port_b_out[7];


     if(cfg_pwm_enb[1])              digital_io_out[8]   = pwm_wfm[1];
     else if(cfg_spim_enb[3])        digital_io_out[8]  = spim_ssn[3];
     else if(cfg_port_d_dir_sel[5])  digital_io_out[8]   = port_d_out[5];


     if(cfg_pwm_enb[2])              digital_io_out[9]   = pwm_wfm[2];
     else if(cfg_spim_enb[2])        digital_io_out[9]   = spim_ssn[2];
     else if(cfg_port_d_dir_sel[6])  digital_io_out[9]   = port_d_out[6];



     if(cfg_port_d_dir_sel[7])       digital_io_out[10]  = port_d_out[7];
     

     if(cfg_port_b_dir_sel[0])       digital_io_out[11]  = port_b_out[0];


     if(cfg_pwm_enb[3])              digital_io_out[12]  = pwm_wfm[3];
     else if(cfg_spim_enb[1])        digital_io_out[12]  = spim_ssn[1];
     else if(cfg_port_b_dir_sel[1])  digital_io_out[12]  = port_b_out[1];


     if(cfg_pwm_enb[4])              digital_io_out[13]  = pwm_wfm[4];
     else if(cfg_spim_enb[0])        digital_io_out[13]  = spim_ssn[0];
     else if(cfg_port_b_dir_sel[2])  digital_io_out[13]  = port_b_out[2];


     if(cfg_pwm_enb[5])              digital_io_out[14]  = pwm_wfm[5];
     else if(cfg_port_b_dir_sel[3])  digital_io_out[14]  = port_b_out[3];


     if(cfg_spim_enb[0])             digital_io_out[15]  = spim_miso;
     else if(cfg_port_b_dir_sel[4])  digital_io_out[15]  = port_b_out[4];


     if(cfg_spim_enb[0])             digital_io_out[16]  = spim_sck;
     else if(cfg_port_b_dir_sel[5])  digital_io_out[16]  = port_b_out[5];
     

     if(cfg_port_c_dir_sel[0])       digital_io_out[18]  = port_c_out[0];


     if(cfg_port_c_dir_sel[1])       digital_io_out[19]  = port_c_out[1];


     if(cfg_port_c_dir_sel[2])       digital_io_out[20]  = port_c_out[2];


     if(cfg_port_c_dir_sel[3])       digital_io_out[21]  = port_c_out[3];


     if(cfg_i2cm_enb)                digital_io_out[22]  = i2cm_data_o;
     else if(cfg_port_c_dir_sel[4])  digital_io_out[22]  = port_c_out[4];


     if(cfg_i2cm_enb)                digital_io_out[23]  = i2cm_clk_o;
     else if(cfg_port_c_dir_sel[5])  digital_io_out[23]  = port_c_out[5];


     digital_io_out[24] = sflash_sck   ;
     digital_io_out[25] = sflash_ss[0] ;
     digital_io_out[26] = sflash_ss[1] ;
     digital_io_out[27] = sflash_ss[2] ;
     digital_io_out[28] = sflash_ss[3] ;
     digital_io_out[29] = sflash_do[0] ;
     digital_io_out[30] = sflash_do[1] ;
     digital_io_out[31] = sflash_do[2] ;
     digital_io_out[32] = sflash_do[3] ;
                       

     digital_io_out[33] = dbg_clk_mon;


     digital_io_out[34] = 1'b0         ;
     digital_io_out[35] = uartm_txd    ;
                  

     digital_io_out[36] = usb_dp_o     ;
     digital_io_out[37] = usb_dn_o     ;
end


always_comb begin
     digital_io_oen = 38'h3F_FFFF_FFFF;

     if(cfg_port_c_dir_sel[6])       digital_io_oen[0]   = 1'b0;


     if     (cfg_uart_enb[0])        digital_io_oen[1]   = 1'b1;
     else if(cfg_port_d_dir_sel[0])  digital_io_oen[1]   = 1'b0;


     if     (cfg_uart_enb[0])        digital_io_oen[2]   = 1'b0;
     else if(cfg_port_d_dir_sel[1])  digital_io_oen[2]   = 1'b0;


     if   (cfg_uart_enb[1])          digital_io_oen[3]   = 1'b1;
     else if(cfg_int_enb[0])         digital_io_oen[3]   = 1'b1;
     else if(cfg_port_d_dir_sel[2])  digital_io_oen[3]   = 1'b0;


     if(cfg_pwm_enb[0])              digital_io_oen[4]   = 1'b0;
     else if(cfg_int_enb[1])         digital_io_oen[4]   = 1'b1;
     else if(cfg_port_d_dir_sel[3])  digital_io_oen[4]   = 1'b0;


     if   (cfg_uart_enb[1])          digital_io_oen[5]   = 1'b0;
     else if(cfg_port_d_dir_sel[4])  digital_io_oen[5]   = 1'b0;


     if(cfg_port_b_dir_sel[6])       digital_io_oen[6]   = 1'b0;


     if(cfg_port_b_dir_sel[7])       digital_io_oen[7]   = 1'b0;


     if(cfg_pwm_enb[1])              digital_io_oen[8]   = 1'b0;
     else if(cfg_spim_enb[3])        digital_io_oen[8]   = 1'b0;
     else if(cfg_port_d_dir_sel[5])  digital_io_oen[8]   = 1'b0;


     if(cfg_pwm_enb[2])              digital_io_oen[9]   = 1'b0;
     else if(cfg_spim_enb[2])        digital_io_oen[9]   = 1'b0;
     else if(cfg_port_d_dir_sel[6])  digital_io_oen[9]   = 1'b0;


     if(cfg_port_d_dir_sel[7])       digital_io_oen[10]  = 1'b0;
     

     if(cfg_port_b_dir_sel[0])       digital_io_oen[11]  = 1'b0;


     if(cfg_pwm_enb[3])              digital_io_oen[12]  = 1'b0;
     else if(cfg_spim_enb[1])        digital_io_oen[12]  = 1'b0;
     else if(cfg_port_b_dir_sel[1])  digital_io_oen[12]  = 1'b0;


     if(cfg_pwm_enb[4])              digital_io_oen[13]  = 1'b0;
     else if(cfg_spim_enb[0])        digital_io_oen[13]  = 1'b0;
     else if(cfg_port_b_dir_sel[2])  digital_io_oen[13]  = 1'b0;


     if(cfg_spim_enb[0])                digital_io_oen[14]  = 1'b1;
     else if(cfg_pwm_enb[5])         digital_io_oen[14]  = 1'b0;
     else if(cfg_port_b_dir_sel[3])  digital_io_oen[14]  = 1'b0;


     if(cfg_spim_enb[0])             digital_io_oen[15]  = 1'b0;
     else if(cfg_port_b_dir_sel[4])  digital_io_oen[15]  = 1'b0;


     if(cfg_spim_enb[0])                digital_io_oen[16]  = 1'b0;
     else if(cfg_port_b_dir_sel[5])  digital_io_oen[16]  = 1'b0;
     

     if(cfg_port_c_dir_sel[0])       digital_io_oen[18]  = 1'b0;


     if(cfg_port_c_dir_sel[1])       digital_io_oen[19]  = 1'b0;


     if(cfg_port_c_dir_sel[2])       digital_io_oen[20]  = 1'b0;


     if(cfg_port_c_dir_sel[3])       digital_io_oen[21]  = 1'b0;


     if(cfg_i2cm_enb)                digital_io_oen[22]  = i2cm_data_oen;
     else if(cfg_port_c_dir_sel[4])  digital_io_oen[22]  = 1'b0;


     if(cfg_i2cm_enb)                digital_io_oen[23]  = i2cm_clk_oen;
     else if(cfg_port_c_dir_sel[5])  digital_io_oen[23]  = 1'b0;


     digital_io_oen[24] = 1'b0   ;
     digital_io_oen[25] = 1'b0   ;
     digital_io_oen[26] = 1'b0   ;
     digital_io_oen[27] = 1'b0   ;
     digital_io_oen[28] = 1'b0   ;
     digital_io_oen[29] = sflash_oen[0];
     digital_io_oen[30] = sflash_oen[1];
     digital_io_oen[31] = sflash_oen[2];
     digital_io_oen[32] = sflash_oen[3];
                       

     digital_io_oen[33] = 1'b0  ;

     digital_io_oen[34] = 1'b1;
     digital_io_oen[35] = 1'b0;
                  

     digital_io_oen[36] = usb_oen;
     digital_io_oen[37] = usb_oen;
end


endmodule