data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v
1: b'%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:88: Cannot find include file: mc_defines.v\n`include "mc_defines.v" \n         ^~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl,data/full_repos/permissive/137416811/mc_defines.v\n             data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl,data/full_repos/permissive/137416811/mc_defines.v.v\n             data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl,data/full_repos/permissive/137416811/mc_defines.v.sv\n             mc_defines.v\n             mc_defines.v.v\n             mc_defines.v.sv\n             obj_dir/mc_defines.v\n             obj_dir/mc_defines.v.v\n             obj_dir/mc_defines.v.sv\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:149: Define or directive not defined: \'`MC_MEM_TYPE_SDRAM\'\n if(mem_type == `MC_MEM_TYPE_SDRAM)  mc_addr_d = {9\'h0, sdram_adr};\n                ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:149: syntax error, unexpected \')\', expecting TYPE-IDENTIFIER\n if(mem_type == `MC_MEM_TYPE_SDRAM)  mc_addr_d = {9\'h0, sdram_adr};\n                                  ^\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:151: Define or directive not defined: \'`MC_MEM_TYPE_ACS\'\n if(mem_type == `MC_MEM_TYPE_ACS)  mc_addr_d = acs_addr;\n                ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:153: Define or directive not defined: \'`MC_MEM_TYPE_SRAM\'\n if((mem_type == `MC_MEM_TYPE_SRAM) & wr_hold) mc_addr_d = sram_addr;\n                 ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:173: Define or directive not defined: \'`MC_BW_8\'\n     `MC_BW_8: acs_addr <= #1 wb_addr_i[23:0];\n     ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:173: syntax error, unexpected \':\', expecting endcase\n     `MC_BW_8: acs_addr <= #1 wb_addr_i[23:0];\n             ^\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:174: Define or directive not defined: \'`MC_BW_16\'\n     `MC_BW_16: acs_addr <= #1 wb_addr_i[24:1];\n     ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:175: Define or directive not defined: \'`MC_BW_32\'\n     `MC_BW_32: acs_addr <= #1 wb_addr_i[25:2];\n     ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:194: Define or directive not defined: \'`MC_BW_8\'\n    {`MC_BW_8, `MC_MEM_SIZE_64}:  col_adr <= #1 {1\'h0, wb_addr_i[10:2]};\n     ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:194: syntax error, unexpected \',\', expecting TYPE-IDENTIFIER\n    {`MC_BW_8, `MC_MEM_SIZE_64}:  col_adr <= #1 {1\'h0, wb_addr_i[10:2]};\n             ^\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:194: Define or directive not defined: \'`MC_MEM_SIZE_64\'\n    {`MC_BW_8, `MC_MEM_SIZE_64}:  col_adr <= #1 {1\'h0, wb_addr_i[10:2]};\n               ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:195: Define or directive not defined: \'`MC_BW_8\'\n    {`MC_BW_8, `MC_MEM_SIZE_128}: col_adr <= #1        wb_addr_i[11:2];\n     ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:195: Define or directive not defined: \'`MC_MEM_SIZE_128\'\n    {`MC_BW_8, `MC_MEM_SIZE_128}: col_adr <= #1        wb_addr_i[11:2];\n               ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:196: Define or directive not defined: \'`MC_BW_8\'\n    {`MC_BW_8, `MC_MEM_SIZE_256}: col_adr <= #1        wb_addr_i[11:2];\n     ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:196: Define or directive not defined: \'`MC_MEM_SIZE_256\'\n    {`MC_BW_8, `MC_MEM_SIZE_256}: col_adr <= #1        wb_addr_i[11:2];\n               ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:198: Define or directive not defined: \'`MC_BW_16\'\n    {`MC_BW_16, `MC_MEM_SIZE_64}: col_adr <= #1 {2\'h0, wb_addr_i[09:2]};\n     ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:198: Define or directive not defined: \'`MC_MEM_SIZE_64\'\n    {`MC_BW_16, `MC_MEM_SIZE_64}: col_adr <= #1 {2\'h0, wb_addr_i[09:2]};\n                ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:199: Define or directive not defined: \'`MC_BW_16\'\n    {`MC_BW_16, `MC_MEM_SIZE_128}: col_adr <= #1 {1\'h0, wb_addr_i[10:2]};\n     ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:199: Define or directive not defined: \'`MC_MEM_SIZE_128\'\n    {`MC_BW_16, `MC_MEM_SIZE_128}: col_adr <= #1 {1\'h0, wb_addr_i[10:2]};\n                ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:200: Define or directive not defined: \'`MC_BW_16\'\n    {`MC_BW_16, `MC_MEM_SIZE_256}: col_adr <= #1 {1\'h0, wb_addr_i[10:2]};\n     ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:200: Define or directive not defined: \'`MC_MEM_SIZE_256\'\n    {`MC_BW_16, `MC_MEM_SIZE_256}: col_adr <= #1 {1\'h0, wb_addr_i[10:2]};\n                ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:202: Define or directive not defined: \'`MC_BW_32\'\n    {`MC_BW_32, `MC_MEM_SIZE_64}: col_adr <= #1 {2\'h0, wb_addr_i[09:2]};\n     ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:202: Define or directive not defined: \'`MC_MEM_SIZE_64\'\n    {`MC_BW_32, `MC_MEM_SIZE_64}: col_adr <= #1 {2\'h0, wb_addr_i[09:2]};\n                ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:203: Define or directive not defined: \'`MC_BW_32\'\n    {`MC_BW_32, `MC_MEM_SIZE_128}: col_adr <= #1 {2\'h0, wb_addr_i[09:2]};\n     ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:203: Define or directive not defined: \'`MC_MEM_SIZE_128\'\n    {`MC_BW_32, `MC_MEM_SIZE_128}: col_adr <= #1 {2\'h0, wb_addr_i[09:2]};\n                ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:204: Define or directive not defined: \'`MC_BW_32\'\n    {`MC_BW_32, `MC_MEM_SIZE_256}: col_adr <= #1 {2\'h0, wb_addr_i[09:2]};\n     ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:204: Define or directive not defined: \'`MC_MEM_SIZE_256\'\n    {`MC_BW_32, `MC_MEM_SIZE_256}: col_adr <= #1 {2\'h0, wb_addr_i[09:2]};\n                ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:212: Define or directive not defined: \'`MC_BW_8\'\n     {`MC_BW_8, `MC_MEM_SIZE_64}:  row_adr <= #1 {1\'h0, wb_addr_i[24:13]};\n      ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:212: Define or directive not defined: \'`MC_MEM_SIZE_64\'\n     {`MC_BW_8, `MC_MEM_SIZE_64}:  row_adr <= #1 {1\'h0, wb_addr_i[24:13]};\n                ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:213: Define or directive not defined: \'`MC_BW_8\'\n     {`MC_BW_8, `MC_MEM_SIZE_128}: row_adr <= #1 {1\'h0, wb_addr_i[25:14]};\n      ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:213: Define or directive not defined: \'`MC_MEM_SIZE_128\'\n     {`MC_BW_8, `MC_MEM_SIZE_128}: row_adr <= #1 {1\'h0, wb_addr_i[25:14]};\n                ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:214: Define or directive not defined: \'`MC_BW_8\'\n     {`MC_BW_8, `MC_MEM_SIZE_256}: row_adr <= #1        wb_addr_i[26:14];\n      ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:214: Define or directive not defined: \'`MC_MEM_SIZE_256\'\n     {`MC_BW_8, `MC_MEM_SIZE_256}: row_adr <= #1        wb_addr_i[26:14];\n                ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:216: Define or directive not defined: \'`MC_BW_16\'\n     {`MC_BW_16, `MC_MEM_SIZE_64}: row_adr <= #1 {1\'h0, wb_addr_i[23:12]};\n      ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:216: Define or directive not defined: \'`MC_MEM_SIZE_64\'\n     {`MC_BW_16, `MC_MEM_SIZE_64}: row_adr <= #1 {1\'h0, wb_addr_i[23:12]};\n                 ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:217: Define or directive not defined: \'`MC_BW_16\'\n     {`MC_BW_16, `MC_MEM_SIZE_128}: row_adr <= #1 {1\'h0, wb_addr_i[24:13]};\n      ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:217: Define or directive not defined: \'`MC_MEM_SIZE_128\'\n     {`MC_BW_16, `MC_MEM_SIZE_128}: row_adr <= #1 {1\'h0, wb_addr_i[24:13]};\n                 ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:218: Define or directive not defined: \'`MC_BW_16\'\n     {`MC_BW_16, `MC_MEM_SIZE_256}: row_adr <= #1        wb_addr_i[25:13];\n      ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:218: Define or directive not defined: \'`MC_MEM_SIZE_256\'\n     {`MC_BW_16, `MC_MEM_SIZE_256}: row_adr <= #1        wb_addr_i[25:13];\n                 ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:220: Define or directive not defined: \'`MC_BW_32\'\n     {`MC_BW_32, `MC_MEM_SIZE_64}: row_adr <= #1 {2\'h0, wb_addr_i[22:12]};\n      ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:220: Define or directive not defined: \'`MC_MEM_SIZE_64\'\n     {`MC_BW_32, `MC_MEM_SIZE_64}: row_adr <= #1 {2\'h0, wb_addr_i[22:12]};\n                 ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:221: Define or directive not defined: \'`MC_BW_32\'\n     {`MC_BW_32, `MC_MEM_SIZE_128}: row_adr <= #1 {1\'h0, wb_addr_i[23:12]};\n      ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:221: Define or directive not defined: \'`MC_MEM_SIZE_128\'\n     {`MC_BW_32, `MC_MEM_SIZE_128}: row_adr <= #1 {1\'h0, wb_addr_i[23:12]};\n                 ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:222: Define or directive not defined: \'`MC_BW_32\'\n     {`MC_BW_32, `MC_MEM_SIZE_256}: row_adr <= #1        wb_addr_i[24:12];\n      ^~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:222: Define or directive not defined: \'`MC_MEM_SIZE_256\'\n     {`MC_BW_32, `MC_MEM_SIZE_256}: row_adr <= #1        wb_addr_i[24:12];\n                 ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:226: Define or directive not defined: \'`MC_BW_8\'\n     {`MC_BW_8, `MC_MEM_SIZE_64}:  row_adr <= #1 {1\'h0, wb_addr_i[22:11]};\n      ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:226: Define or directive not defined: \'`MC_MEM_SIZE_64\'\n     {`MC_BW_8, `MC_MEM_SIZE_64}:  row_adr <= #1 {1\'h0, wb_addr_i[22:11]};\n                ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:227: Define or directive not defined: \'`MC_BW_8\'\n     {`MC_BW_8, `MC_MEM_SIZE_128}: row_adr <= #1 {1\'h0, wb_addr_i[23:12]};\n      ^~~~~~~~\n%Error: data/full_repos/permissive/137416811/openfpga_flow/benchmarks/iwls2005/mem_ctrl/rtl/mc_adr_sel.v:227: Define or directive not defined: \'`MC_MEM_SIZE_128\'\n     {`MC_BW_8, `MC_MEM_SIZE_128}: row_adr <= #1 {1\'h0, wb_addr_i[23:12]};\n                ^~~~~~~~~~~~~~~~\n%Error: Exiting due to too many errors encountered; --error-limit=50\n'
module mc_adr_sel(clk, csc, tms, wb_ack_o, wb_stb_i, wb_addr_i, wb_we_i,
		wb_write_go, wr_hold, cas_,
		mc_addr, row_adr, bank_adr, rfr_ack,
		cs_le, cmd_a10, row_sel, lmr_sel, next_adr, wr_cycle,
		page_size);

input		clk;
input	[31:0]	csc;
input	[31:0]	tms;
input		wb_ack_o, wb_stb_i;
input	[31:0]	wb_addr_i;
input		wb_we_i;
input		wb_write_go;
input		wr_hold;
input		cas_;
output	[23:0]	mc_addr;
output	[12:0]	row_adr;
output	[1:0]	bank_adr;
input		rfr_ack;
input		cs_le;
input		cmd_a10;
input		row_sel;
input		lmr_sel;
input		next_adr;
input		wr_cycle;
output	[10:0]	page_size;






reg	[23:0]	mc_addr_d;
reg	[23:0]	acs_addr;
wire	[23:0]	acs_addr_pl1;
reg	[23:0]	sram_addr;
wire	[14:0]	sdram_adr;
reg	[12:0]	row_adr;
reg	[9:0]	col_adr;
reg	[1:0]	bank_adr;
reg	[10:0]	page_size;

wire	[2:0]	mem_type;
wire	[1:0]	bus_width;
wire	[1:0]	mem_size;
wire		bas;


assign mem_type  = csc[3:1];
assign bus_width = csc[5:4];
assign mem_size  = csc[7:6];
assign bas       = csc[9];






always @(mem_type or wr_hold or sdram_adr or acs_addr or sram_addr or wb_addr_i)
	if(mem_type == `MC_MEM_TYPE_SDRAM)		mc_addr_d = {9'h0, sdram_adr};
	else
	if(mem_type == `MC_MEM_TYPE_ACS)		mc_addr_d = acs_addr;
	else
	if((mem_type == `MC_MEM_TYPE_SRAM) & wr_hold)	mc_addr_d = sram_addr;
	else						mc_addr_d = wb_addr_i[25:2];

assign mc_addr = rfr_ack ? {mc_addr_d[23:11], 1'b1, mc_addr_d[9:0]} : mc_addr_d;






mc_incn_r #(24) u0(	.clk(		clk		),
			.inc_in(	acs_addr	),
			.inc_out(	acs_addr_pl1	) );

always @(posedge clk)
	if(wb_stb_i)	sram_addr <= #1 wb_addr_i[25:2];

always @(posedge clk)
	if(cs_le | wb_we_i)
		case(bus_width)
		   `MC_BW_8:	acs_addr <= #1 wb_addr_i[23:0];
		   `MC_BW_16:	acs_addr <= #1 wb_addr_i[24:1];
		   `MC_BW_32:	acs_addr <= #1 wb_addr_i[25:2];
		endcase
	else
	if(next_adr)		acs_addr <= #1 acs_addr_pl1;






assign sdram_adr[12:0] =	(lmr_sel & !cas_) ? tms[12:0] :
				row_sel ? row_adr :
				{2'h0, cmd_a10, col_adr};

assign sdram_adr[14:13] = bank_adr;

always @(posedge clk)
   if(wr_cycle ? wb_ack_o : wb_stb_i)	
	casex({bus_width, mem_size})
	   {`MC_BW_8, `MC_MEM_SIZE_64}:		col_adr <= #1 {1'h0, wb_addr_i[10:2]};
	   {`MC_BW_8, `MC_MEM_SIZE_128}:	col_adr <= #1        wb_addr_i[11:2];
	   {`MC_BW_8, `MC_MEM_SIZE_256}:	col_adr <= #1        wb_addr_i[11:2];

	   {`MC_BW_16, `MC_MEM_SIZE_64}:	col_adr <= #1 {2'h0, wb_addr_i[09:2]};
	   {`MC_BW_16, `MC_MEM_SIZE_128}:	col_adr <= #1 {1'h0, wb_addr_i[10:2]};
	   {`MC_BW_16, `MC_MEM_SIZE_256}:	col_adr <= #1 {1'h0, wb_addr_i[10:2]};

	   {`MC_BW_32, `MC_MEM_SIZE_64}:	col_adr <= #1 {2'h0, wb_addr_i[09:2]};
	   {`MC_BW_32, `MC_MEM_SIZE_128}:	col_adr <= #1 {2'h0, wb_addr_i[09:2]};
	   {`MC_BW_32, `MC_MEM_SIZE_256}:	col_adr <= #1 {2'h0, wb_addr_i[09:2]};
	endcase

always @(posedge clk)
   if(cs_le)
     begin
	if(!bas)
		casex({bus_width, mem_size})
		   {`MC_BW_8, `MC_MEM_SIZE_64}:		row_adr <= #1 {1'h0, wb_addr_i[24:13]};
		   {`MC_BW_8, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[25:14]};
		   {`MC_BW_8, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[26:14];
	
		   {`MC_BW_16, `MC_MEM_SIZE_64}:	row_adr <= #1 {1'h0, wb_addr_i[23:12]};
		   {`MC_BW_16, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[24:13]};
		   {`MC_BW_16, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[25:13];
	
		   {`MC_BW_32, `MC_MEM_SIZE_64}:	row_adr <= #1 {2'h0, wb_addr_i[22:12]};
		   {`MC_BW_32, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[23:12]};
		   {`MC_BW_32, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[24:12];
		endcase
	else
		casex({bus_width, mem_size})
		   {`MC_BW_8, `MC_MEM_SIZE_64}:		row_adr <= #1 {1'h0, wb_addr_i[22:11]};
		   {`MC_BW_8, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[23:12]};
		   {`MC_BW_8, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[24:12];
	
		   {`MC_BW_16, `MC_MEM_SIZE_64}:	row_adr <= #1 {1'h0, wb_addr_i[21:10]};
		   {`MC_BW_16, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[22:11]};
		   {`MC_BW_16, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[23:11];
	
		   {`MC_BW_32, `MC_MEM_SIZE_64}:	row_adr <= #1 {2'h0, wb_addr_i[20:10]};
		   {`MC_BW_32, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[21:10]};
		   {`MC_BW_32, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[22:10];
		endcase
     end


always @(posedge clk)
   if(cs_le)
     begin
	if(!bas)
		casex({bus_width, mem_size})
		   {`MC_BW_8, `MC_MEM_SIZE_64}:		bank_adr <= #1 wb_addr_i[12:11];
		   {`MC_BW_8, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[13:12];
		   {`MC_BW_8, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[13:12];
	
		   {`MC_BW_16, `MC_MEM_SIZE_64}:	bank_adr <= #1 wb_addr_i[11:10];
		   {`MC_BW_16, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[12:11];
		   {`MC_BW_16, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[12:11];
	
		   {`MC_BW_32, `MC_MEM_SIZE_64}:	bank_adr <= #1 wb_addr_i[11:10];
		   {`MC_BW_32, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[11:10];
		   {`MC_BW_32, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[11:10];
		endcase
	else
		casex({bus_width, mem_size})
		   {`MC_BW_8, `MC_MEM_SIZE_64}:		bank_adr <= #1 wb_addr_i[24:23];
		   {`MC_BW_8, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[25:24];
		   {`MC_BW_8, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[26:25];
	
		   {`MC_BW_16, `MC_MEM_SIZE_64}:	bank_adr <= #1 wb_addr_i[23:22];
		   {`MC_BW_16, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[24:23];
		   {`MC_BW_16, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[25:24];
	
		   {`MC_BW_32, `MC_MEM_SIZE_64}:	bank_adr <= #1 wb_addr_i[22:21];
		   {`MC_BW_32, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[23:22];
		   {`MC_BW_32, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[24:23];
		endcase
     end

always @(bus_width or mem_size)
	casex({bus_width, mem_size})
	   {`MC_BW_8, `MC_MEM_SIZE_64}:		page_size = 11'd512;
	   {`MC_BW_8, `MC_MEM_SIZE_128}:	page_size = 11'd1024;
	   {`MC_BW_8, `MC_MEM_SIZE_256}:	page_size = 11'd1024;

	   {`MC_BW_16, `MC_MEM_SIZE_64}:	page_size = 11'd256;
	   {`MC_BW_16, `MC_MEM_SIZE_128}:	page_size = 11'd512;
	   {`MC_BW_16, `MC_MEM_SIZE_256}:	page_size = 11'd512;

	   {`MC_BW_32, `MC_MEM_SIZE_64}:	page_size = 11'd256;
	   {`MC_BW_32, `MC_MEM_SIZE_128}:	page_size = 11'd256;
	   {`MC_BW_32, `MC_MEM_SIZE_256}:	page_size = 11'd256;
	endcase

endmodule
module mc_adr_sel(clk, csc, tms, wb_ack_o, wb_stb_i, wb_addr_i, wb_we_i,
		wb_write_go, wr_hold, cas_,
		mc_addr, row_adr, bank_adr, rfr_ack,
		cs_le, cmd_a10, row_sel, lmr_sel, next_adr, wr_cycle,
		page_size);


input		clk;
input	[31:0]	csc;
input	[31:0]	tms;
input		wb_ack_o, wb_stb_i;
input	[31:0]	wb_addr_i;
input		wb_we_i;
input		wb_write_go;
input		wr_hold;
input		cas_;
output	[23:0]	mc_addr;
output	[12:0]	row_adr;
output	[1:0]	bank_adr;
input		rfr_ack;
input		cs_le;
input		cmd_a10;
input		row_sel;
input		lmr_sel;
input		next_adr;
input		wr_cycle;
output	[10:0]	page_size;






reg	[23:0]	mc_addr_d;
reg	[23:0]	acs_addr;
wire	[23:0]	acs_addr_pl1;
reg	[23:0]	sram_addr;
wire	[14:0]	sdram_adr;
reg	[12:0]	row_adr;
reg	[9:0]	col_adr;
reg	[1:0]	bank_adr;
reg	[10:0]	page_size;

wire	[2:0]	mem_type;
wire	[1:0]	bus_width;
wire	[1:0]	mem_size;
wire		bas;


assign mem_type  = csc[3:1];
assign bus_width = csc[5:4];
assign mem_size  = csc[7:6];
assign bas       = csc[9];






always @(mem_type or wr_hold or sdram_adr or acs_addr or sram_addr or wb_addr_i)
	if(mem_type == `MC_MEM_TYPE_SDRAM)		mc_addr_d = {9'h0, sdram_adr};
	else
	if(mem_type == `MC_MEM_TYPE_ACS)		mc_addr_d = acs_addr;
	else
	if((mem_type == `MC_MEM_TYPE_SRAM) & wr_hold)	mc_addr_d = sram_addr;
	else						mc_addr_d = wb_addr_i[25:2];

assign mc_addr = rfr_ack ? {mc_addr_d[23:11], 1'b1, mc_addr_d[9:0]} : mc_addr_d;






mc_incn_r #(24) u0(	.clk(		clk		),
			.inc_in(	acs_addr	),
			.inc_out(	acs_addr_pl1	) );

always @(posedge clk)
	if(wb_stb_i)	sram_addr <= #1 wb_addr_i[25:2];

always @(posedge clk)
	if(cs_le | wb_we_i)
		case(bus_width)
		   `MC_BW_8:	acs_addr <= #1 wb_addr_i[23:0];
		   `MC_BW_16:	acs_addr <= #1 wb_addr_i[24:1];
		   `MC_BW_32:	acs_addr <= #1 wb_addr_i[25:2];
		endcase
	else
	if(next_adr)		acs_addr <= #1 acs_addr_pl1;






assign sdram_adr[12:0] =	(lmr_sel & !cas_) ? tms[12:0] :
				row_sel ? row_adr :
				{2'h0, cmd_a10, col_adr};

assign sdram_adr[14:13] = bank_adr;

always @(posedge clk)
   if(wr_cycle ? wb_ack_o : wb_stb_i)	
	casex({bus_width, mem_size})
	   {`MC_BW_8, `MC_MEM_SIZE_64}:		col_adr <= #1 {1'h0, wb_addr_i[10:2]};
	   {`MC_BW_8, `MC_MEM_SIZE_128}:	col_adr <= #1        wb_addr_i[11:2];
	   {`MC_BW_8, `MC_MEM_SIZE_256}:	col_adr <= #1        wb_addr_i[11:2];

	   {`MC_BW_16, `MC_MEM_SIZE_64}:	col_adr <= #1 {2'h0, wb_addr_i[09:2]};
	   {`MC_BW_16, `MC_MEM_SIZE_128}:	col_adr <= #1 {1'h0, wb_addr_i[10:2]};
	   {`MC_BW_16, `MC_MEM_SIZE_256}:	col_adr <= #1 {1'h0, wb_addr_i[10:2]};

	   {`MC_BW_32, `MC_MEM_SIZE_64}:	col_adr <= #1 {2'h0, wb_addr_i[09:2]};
	   {`MC_BW_32, `MC_MEM_SIZE_128}:	col_adr <= #1 {2'h0, wb_addr_i[09:2]};
	   {`MC_BW_32, `MC_MEM_SIZE_256}:	col_adr <= #1 {2'h0, wb_addr_i[09:2]};
	endcase

always @(posedge clk)
   if(cs_le)
     begin
	if(!bas)
		casex({bus_width, mem_size})
		   {`MC_BW_8, `MC_MEM_SIZE_64}:		row_adr <= #1 {1'h0, wb_addr_i[24:13]};
		   {`MC_BW_8, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[25:14]};
		   {`MC_BW_8, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[26:14];
	
		   {`MC_BW_16, `MC_MEM_SIZE_64}:	row_adr <= #1 {1'h0, wb_addr_i[23:12]};
		   {`MC_BW_16, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[24:13]};
		   {`MC_BW_16, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[25:13];
	
		   {`MC_BW_32, `MC_MEM_SIZE_64}:	row_adr <= #1 {2'h0, wb_addr_i[22:12]};
		   {`MC_BW_32, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[23:12]};
		   {`MC_BW_32, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[24:12];
		endcase
	else
		casex({bus_width, mem_size})
		   {`MC_BW_8, `MC_MEM_SIZE_64}:		row_adr <= #1 {1'h0, wb_addr_i[22:11]};
		   {`MC_BW_8, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[23:12]};
		   {`MC_BW_8, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[24:12];
	
		   {`MC_BW_16, `MC_MEM_SIZE_64}:	row_adr <= #1 {1'h0, wb_addr_i[21:10]};
		   {`MC_BW_16, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[22:11]};
		   {`MC_BW_16, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[23:11];
	
		   {`MC_BW_32, `MC_MEM_SIZE_64}:	row_adr <= #1 {2'h0, wb_addr_i[20:10]};
		   {`MC_BW_32, `MC_MEM_SIZE_128}:	row_adr <= #1 {1'h0, wb_addr_i[21:10]};
		   {`MC_BW_32, `MC_MEM_SIZE_256}:	row_adr <= #1        wb_addr_i[22:10];
		endcase
     end


always @(posedge clk)
   if(cs_le)
     begin
	if(!bas)
		casex({bus_width, mem_size})
		   {`MC_BW_8, `MC_MEM_SIZE_64}:		bank_adr <= #1 wb_addr_i[12:11];
		   {`MC_BW_8, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[13:12];
		   {`MC_BW_8, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[13:12];
	
		   {`MC_BW_16, `MC_MEM_SIZE_64}:	bank_adr <= #1 wb_addr_i[11:10];
		   {`MC_BW_16, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[12:11];
		   {`MC_BW_16, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[12:11];
	
		   {`MC_BW_32, `MC_MEM_SIZE_64}:	bank_adr <= #1 wb_addr_i[11:10];
		   {`MC_BW_32, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[11:10];
		   {`MC_BW_32, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[11:10];
		endcase
	else
		casex({bus_width, mem_size})
		   {`MC_BW_8, `MC_MEM_SIZE_64}:		bank_adr <= #1 wb_addr_i[24:23];
		   {`MC_BW_8, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[25:24];
		   {`MC_BW_8, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[26:25];
	
		   {`MC_BW_16, `MC_MEM_SIZE_64}:	bank_adr <= #1 wb_addr_i[23:22];
		   {`MC_BW_16, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[24:23];
		   {`MC_BW_16, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[25:24];
	
		   {`MC_BW_32, `MC_MEM_SIZE_64}:	bank_adr <= #1 wb_addr_i[22:21];
		   {`MC_BW_32, `MC_MEM_SIZE_128}:	bank_adr <= #1 wb_addr_i[23:22];
		   {`MC_BW_32, `MC_MEM_SIZE_256}:	bank_adr <= #1 wb_addr_i[24:23];
		endcase
     end

always @(bus_width or mem_size)
	casex({bus_width, mem_size})
	   {`MC_BW_8, `MC_MEM_SIZE_64}:		page_size = 11'd512;
	   {`MC_BW_8, `MC_MEM_SIZE_128}:	page_size = 11'd1024;
	   {`MC_BW_8, `MC_MEM_SIZE_256}:	page_size = 11'd1024;

	   {`MC_BW_16, `MC_MEM_SIZE_64}:	page_size = 11'd256;
	   {`MC_BW_16, `MC_MEM_SIZE_128}:	page_size = 11'd512;
	   {`MC_BW_16, `MC_MEM_SIZE_256}:	page_size = 11'd512;

	   {`MC_BW_32, `MC_MEM_SIZE_64}:	page_size = 11'd256;
	   {`MC_BW_32, `MC_MEM_SIZE_128}:	page_size = 11'd256;
	   {`MC_BW_32, `MC_MEM_SIZE_256}:	page_size = 11'd256;
	endcase

endmodule