data/full_repos/permissive/159830616/YJ431_PL.srcs/sources_1/new/FB_3poPID.v
'utf-8' codec can't decode byte 0xb7 in position 1507: invalid start byte
1: b'%Warning-MULTITOP: data/full_repos/permissive/159830616/YJ431_PL.srcs/sources_1/new/FB_3poPID.v:520: Multiple top level modules\n                                                                                                   : ... Suggest see manual; fix the duplicates, or use --top-module to select top.\n                   ... Use "/* verilator lint_off MULTITOP */" and lint_on around source to disable this message.\n                                                                                                   : ... Top module \'FB_po3PIDREG\'\nmodule FB_po3PIDREG(\n       ^~~~~~~~~~~~\n                                                                                                   : ... Top module \'po3PID\'\nmodule po3PID(\n       ^~~~~~\n%Error: Exiting due to 1 warning(s)\n'
module FB_po3PIDREG(
	RST_n,
	BUS_ADDR,
	BUS_DATA,
	BUS_CS,

	BUS_read,
	BUS_write,

	po3PID_BASE,


	CTL_FREQ_REG,
	PID_AIM_REG,
	PID_CUR_REG,

	PID_ERS_REG,
	PID_KPS_REG,

	PID_KDS_REG,

	PID_ERM_REG,
	PID_KPM_REG,

	PID_KDM_REG,

	PID_ERB_REG,
	PID_KPB_REG,

	PID_KDB_REG,

	PID_OUT_REG
    );



input RST_n;
input [31:0] BUS_ADDR;
inout [31:0] BUS_DATA;
input BUS_CS;

input BUS_read;
input BUS_write;

input [9:0] po3PID_BASE;


output reg [31:0] CTL_FREQ_REG;
output reg [31:0] PID_AIM_REG;
output reg [31:0] PID_CUR_REG;

output reg [31:0] PID_ERS_REG;
output reg [31:0] PID_KPS_REG;

output reg [31:0] PID_KDS_REG;

output reg [31:0] PID_ERM_REG;
output reg [31:0] PID_KPM_REG;

output reg [31:0] PID_KDM_REG;

output reg [31:0] PID_ERB_REG;
output reg [31:0] PID_KPB_REG;

output reg [31:0] PID_KDB_REG;

input [31:0] PID_OUT_REG;

wire AD_TRI_n;
wire ADD_COMF;

reg [31:0] BUS_DATA_REG = 32'b0;

assign ADD_COMF = ( BUS_ADDR[31:22] == po3PID_BASE[9:0] ) ? 1'b1:1'b0;
assign AD_TRI_n = ADD_COMF & ~BUS_CS & BUS_read ;


      
assign BUS_DATA = AD_TRI_n ? BUS_DATA_REG : 32'bz;
    


always@( posedge BUS_CS or negedge RST_n )
    if ( !RST_n ) begin
		CTL_FREQ_REG <= 32'd0;
		PID_AIM_REG <= 32'd0;
		PID_CUR_REG <= 32'd0;

		PID_ERS_REG <= 32'd0;
		PID_KPS_REG <= 32'd0;

		PID_KDS_REG <= 32'd0;

		PID_ERM_REG <= 32'd0;
		PID_KPM_REG <= 32'd0;

		PID_KDM_REG <= 32'd0;

		PID_ERB_REG <= 32'd0;
		PID_KPB_REG <= 32'd0;

		PID_KDB_REG <= 32'd0;
    end
    
    else begin
        if ( ADD_COMF ) begin
            if ( BUS_write == 1'b1 ) begin
                case(BUS_ADDR[21:0])
                    22'b0000000: begin    
                    	if ( BUS_DATA[31:0] > 32'd100 ) begin
							CTL_FREQ_REG[31:0] <= BUS_DATA[31:0];
						end 	
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end                
                    22'b0000100: begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG[31:0] <= BUS_DATA[31:0];
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                    22'b0001000: begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG[31:0] <= BUS_DATA[31:0];

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                    
                    22'b0001100: begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG[31:0] <= BUS_DATA[31:0];
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                           
                    22'b0010000: begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG[31:0] <= BUS_DATA[31:0];

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                           
                    22'b0010100:begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                           
                    22'b0011000:begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG[31:0] <= BUS_DATA[31:0];

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;                   	
                    end
                           
                    22'b0011100:begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG[31:0] <= BUS_DATA[31:0];
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
                    end
                           
					22'b0100000:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG[31:0] <= BUS_DATA[31:0];

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG; 
					end 

					22'b0100100:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0101000:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG[31:0] <= BUS_DATA[31:0];

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0101100:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG[31:0] <= BUS_DATA[31:0];
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0110000:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG[31:0] <= BUS_DATA[31:0];

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0110100:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0111000:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG [31:0] <= BUS_DATA [31:0];  
					end
                endcase
            end
        end
    end



always@( negedge BUS_CS or negedge RST_n )
    if ( !RST_n ) begin
        BUS_DATA_REG <= 32'b0;
    end
    
    else begin
        if ( ADD_COMF ) begin
            if ( BUS_read == 1'b1 ) begin
                case(BUS_ADDR[21:0])
                	22'b0000000:begin 
						BUS_DATA_REG[31:0] <= CTL_FREQ_REG[31:0];
					end
					22'b0000100:begin
						BUS_DATA_REG[31:0] <= PID_AIM_REG[31:0];
					end
					22'b0001000:begin
						BUS_DATA_REG[31:0] <= PID_CUR_REG[31:0];
					end
					22'b0001100:begin
						BUS_DATA_REG[31:0] <= PID_ERS_REG[31:0];
					end
					22'b0010000:begin
						BUS_DATA_REG[31:0] <= PID_KPS_REG[31:0];
					end
					22'b0010100:begin

					end
					22'b0011000:begin
						BUS_DATA_REG[31:0] <= PID_KDS_REG[31:0];
					end
					22'b0011100:begin
						BUS_DATA_REG[31:0] <= PID_ERM_REG[31:0];
					end
					22'b0100000:begin
						BUS_DATA_REG[31:0] <= PID_KPM_REG[31:0];
					end
					22'b0100100:begin

					end
					22'b0101000:begin
						BUS_DATA_REG[31:0] <= PID_KDM_REG[31:0];
					end
					22'b0101100:begin
						BUS_DATA_REG[31:0] <= PID_ERB_REG[31:0];
					end
					22'b0110000:begin
						BUS_DATA_REG[31:0] <= PID_KPB_REG[31:0];
					end
					22'b0110100:begin

					end
					22'b0111000:begin
						BUS_DATA_REG[31:0] <= PID_KDB_REG[31:0];
					end
					22'b0111100:begin
					   BUS_DATA_REG[31:0] <= PID_OUT_REG[31:0];
					end
                    default:
                        BUS_DATA_REG[31:0] <= 32'hffffffff;
                endcase
            end
        end
    end

endmodule
module FB_po3PIDREG(
	RST_n,
	BUS_ADDR,
	BUS_DATA,
	BUS_CS,

	BUS_read,
	BUS_write,

	po3PID_BASE,


	CTL_FREQ_REG,
	PID_AIM_REG,
	PID_CUR_REG,

	PID_ERS_REG,
	PID_KPS_REG,

	PID_KDS_REG,

	PID_ERM_REG,
	PID_KPM_REG,

	PID_KDM_REG,

	PID_ERB_REG,
	PID_KPB_REG,

	PID_KDB_REG,

	PID_OUT_REG
    );




input RST_n;
input [31:0] BUS_ADDR;
inout [31:0] BUS_DATA;
input BUS_CS;

input BUS_read;
input BUS_write;

input [9:0] po3PID_BASE;


output reg [31:0] CTL_FREQ_REG;
output reg [31:0] PID_AIM_REG;
output reg [31:0] PID_CUR_REG;

output reg [31:0] PID_ERS_REG;
output reg [31:0] PID_KPS_REG;

output reg [31:0] PID_KDS_REG;

output reg [31:0] PID_ERM_REG;
output reg [31:0] PID_KPM_REG;

output reg [31:0] PID_KDM_REG;

output reg [31:0] PID_ERB_REG;
output reg [31:0] PID_KPB_REG;

output reg [31:0] PID_KDB_REG;

input [31:0] PID_OUT_REG;

wire AD_TRI_n;
wire ADD_COMF;

reg [31:0] BUS_DATA_REG = 32'b0;

assign ADD_COMF = ( BUS_ADDR[31:22] == po3PID_BASE[9:0] ) ? 1'b1:1'b0;
assign AD_TRI_n = ADD_COMF & ~BUS_CS & BUS_read ;


      
assign BUS_DATA = AD_TRI_n ? BUS_DATA_REG : 32'bz;
    


always@( posedge BUS_CS or negedge RST_n )
    if ( !RST_n ) begin
		CTL_FREQ_REG <= 32'd0;
		PID_AIM_REG <= 32'd0;
		PID_CUR_REG <= 32'd0;

		PID_ERS_REG <= 32'd0;
		PID_KPS_REG <= 32'd0;

		PID_KDS_REG <= 32'd0;

		PID_ERM_REG <= 32'd0;
		PID_KPM_REG <= 32'd0;

		PID_KDM_REG <= 32'd0;

		PID_ERB_REG <= 32'd0;
		PID_KPB_REG <= 32'd0;

		PID_KDB_REG <= 32'd0;
    end
    
    else begin
        if ( ADD_COMF ) begin
            if ( BUS_write == 1'b1 ) begin
                case(BUS_ADDR[21:0])
                    22'b0000000: begin    
                    	if ( BUS_DATA[31:0] > 32'd100 ) begin
							CTL_FREQ_REG[31:0] <= BUS_DATA[31:0];
						end 	
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end                
                    22'b0000100: begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG[31:0] <= BUS_DATA[31:0];
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                    22'b0001000: begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG[31:0] <= BUS_DATA[31:0];

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                    
                    22'b0001100: begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG[31:0] <= BUS_DATA[31:0];
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                           
                    22'b0010000: begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG[31:0] <= BUS_DATA[31:0];

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                           
                    22'b0010100:begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;
                    end
                           
                    22'b0011000:begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG[31:0] <= BUS_DATA[31:0];

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;                   	
                    end
                           
                    22'b0011100:begin
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG[31:0] <= BUS_DATA[31:0];
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
                    end
                           
					22'b0100000:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG[31:0] <= BUS_DATA[31:0];

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG; 
					end 

					22'b0100100:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0101000:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG[31:0] <= BUS_DATA[31:0];

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0101100:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG[31:0] <= BUS_DATA[31:0];
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0110000:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG[31:0] <= BUS_DATA[31:0];

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0110100:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG <= PID_KDB_REG;  
					end

					22'b0111000:begin 
						CTL_FREQ_REG <= CTL_FREQ_REG;
						PID_AIM_REG <= PID_AIM_REG;
						PID_CUR_REG <= PID_CUR_REG;

						PID_ERS_REG <= PID_ERS_REG;
						PID_KPS_REG <= PID_KPS_REG;

						PID_KDS_REG <= PID_KDS_REG;

						PID_ERM_REG <= PID_ERM_REG;
						PID_KPM_REG <= PID_KPM_REG;

						PID_KDM_REG <= PID_KDM_REG;

						PID_ERB_REG <= PID_ERB_REG;
						PID_KPB_REG <= PID_KPB_REG;

						PID_KDB_REG [31:0] <= BUS_DATA [31:0];  
					end
                endcase
            end
        end
    end



always@( negedge BUS_CS or negedge RST_n )
    if ( !RST_n ) begin
        BUS_DATA_REG <= 32'b0;
    end
    
    else begin
        if ( ADD_COMF ) begin
            if ( BUS_read == 1'b1 ) begin
                case(BUS_ADDR[21:0])
                	22'b0000000:begin 
						BUS_DATA_REG[31:0] <= CTL_FREQ_REG[31:0];
					end
					22'b0000100:begin
						BUS_DATA_REG[31:0] <= PID_AIM_REG[31:0];
					end
					22'b0001000:begin
						BUS_DATA_REG[31:0] <= PID_CUR_REG[31:0];
					end
					22'b0001100:begin
						BUS_DATA_REG[31:0] <= PID_ERS_REG[31:0];
					end
					22'b0010000:begin
						BUS_DATA_REG[31:0] <= PID_KPS_REG[31:0];
					end
					22'b0010100:begin

					end
					22'b0011000:begin
						BUS_DATA_REG[31:0] <= PID_KDS_REG[31:0];
					end
					22'b0011100:begin
						BUS_DATA_REG[31:0] <= PID_ERM_REG[31:0];
					end
					22'b0100000:begin
						BUS_DATA_REG[31:0] <= PID_KPM_REG[31:0];
					end
					22'b0100100:begin

					end
					22'b0101000:begin
						BUS_DATA_REG[31:0] <= PID_KDM_REG[31:0];
					end
					22'b0101100:begin
						BUS_DATA_REG[31:0] <= PID_ERB_REG[31:0];
					end
					22'b0110000:begin
						BUS_DATA_REG[31:0] <= PID_KPB_REG[31:0];
					end
					22'b0110100:begin

					end
					22'b0111000:begin
						BUS_DATA_REG[31:0] <= PID_KDB_REG[31:0];
					end
					22'b0111100:begin
					   BUS_DATA_REG[31:0] <= PID_OUT_REG[31:0];
					end
                    default:
                        BUS_DATA_REG[31:0] <= 32'hffffffff;
                endcase
            end
        end
    end

endmodule