modify
This commit is contained in:
parent
4382e0ffc4
commit
abd20774f5
|
@ -108,6 +108,15 @@ def generate_files(xls_path, sheet_name=None):
|
|||
wtsel = WTsel ,
|
||||
output_dir = output_dir
|
||||
)
|
||||
|
||||
gen_config_txt(
|
||||
sram_name = row[col_map['name']],
|
||||
compiler = row[col_map['CompilerName']],
|
||||
compile_depth = int(row[col_map['CompileDepth']]),
|
||||
compile_width = int(row[col_map['CompileWidth']]),
|
||||
mux = int(row[col_map['MUX']]) if col_map['MUX'] != -1 else 1,
|
||||
output_dir = output_dir
|
||||
)
|
||||
|
||||
# scan the all files of the directory/ to be inclued into xxx.lst
|
||||
lst_path = os.path.join(output_dir, f"{output_dir}.lst")
|
||||
|
@ -120,8 +129,7 @@ def generate_files(xls_path, sheet_name=None):
|
|||
with open(lst_path, 'w') as f:
|
||||
f.write('\n'.join(sorted(v_files)))
|
||||
|
||||
# TODO generate .sh
|
||||
|
||||
gen_sram_sh(rb, sheet.name, output_dir)
|
||||
|
||||
|
||||
def generate_sram_wrapper(template_file, sram_name, width, depth, ref_name,\
|
||||
|
@ -153,7 +161,6 @@ def get_mem_ctrl_bus_fields(i_compilerName,mux,width, depth):
|
|||
# get WTSEL
|
||||
wtsel = '[45:44]'
|
||||
if compilerName == 'tsn12ffcllspsram':
|
||||
print(f"Compiler Name: {compilerName}, Mux: {mux}, Width: {width}, Depth: {depth}")
|
||||
if (mux == 4 and (depth>1024 and depth <= 4096)) or \
|
||||
(mux == 8 and (depth>2048 and depth <= 8192)) or \
|
||||
(mux == 16 and (depth>4096 and depth <= 16384)):
|
||||
|
@ -161,6 +168,54 @@ def get_mem_ctrl_bus_fields(i_compilerName,mux,width, depth):
|
|||
|
||||
return wtsel
|
||||
|
||||
def gen_sram_sh(rb,sheet_name, output_dir):
|
||||
"""生成SRAM相关的Shell脚本"""
|
||||
config_dir = os.path.join(output_dir, "config")
|
||||
os.makedirs(config_dir, exist_ok=True)
|
||||
try:
|
||||
sheet = rb.sheet_by_name(sheet_name)
|
||||
headers = sheet.row_values(1)
|
||||
|
||||
# 获取关键列索引
|
||||
name_col = headers.index('SramWrapName')
|
||||
compiler_col = headers.index('CompilerName') if 'CompilerName' in headers else -1
|
||||
|
||||
if compiler_col == -1:
|
||||
print(f"[Error] Missing 'CompilerName' column in sheet {sheet_name}")
|
||||
return
|
||||
|
||||
commands = []
|
||||
for row_idx in range(2, sheet.nrows):
|
||||
row = sheet.row_values(row_idx)
|
||||
sram_name = row[name_col]
|
||||
compiler = row[compiler_col]
|
||||
|
||||
if sram_name and compiler: # 空值检查
|
||||
cmd = f"../{compiler}.pl -file {sram_name}_{compiler}_config.txt -ColRed -NonBist"
|
||||
commands.append(cmd)
|
||||
else:
|
||||
print(f"[Warning] Missing data in row {row_idx} for SRAM '{sram_name}' with compiler '{compiler}', skipping.")
|
||||
|
||||
|
||||
# 写入bash文件
|
||||
sh_path = os.path.join(config_dir, f"run_{sheet_name}.sh")
|
||||
with open(sh_path, 'w') as f:
|
||||
f.write("#!/bin/bash\n")
|
||||
f.write("\n".join(sorted(commands)))
|
||||
|
||||
except Exception as e:
|
||||
print(f"Generate shell script failed: {str(e)}")
|
||||
|
||||
def gen_config_txt(sram_name, compiler, compile_depth, compile_width, mux, output_dir):
|
||||
"""生成SRAM配置文本文件到config子目录"""
|
||||
config_dir = os.path.join(output_dir, "config")
|
||||
os.makedirs(config_dir, exist_ok=True)
|
||||
|
||||
config_content = f"{compile_depth}x{compile_width}m{mux}scp ulvt"
|
||||
|
||||
config_path = os.path.join(config_dir, f"{sram_name}_{compiler}_config.txt")
|
||||
with open(config_path, 'w') as f:
|
||||
f.write(config_content)
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_args()
|
||||
|
|
|
@ -25,7 +25,7 @@ wire [ADDR_WIDTH-1:0] sram_addr;
|
|||
wire [WIDTH-1:0] sram_rdata;
|
||||
wire [WIDTH-1:0] sram_wdata;
|
||||
|
||||
wire [2-1:0] WTSEL = mem_ctrl_bus[45:44];
|
||||
wire [2-1:0] WTSEL = mem_ctrl_bus[47:46];
|
||||
|
||||
|
||||
`ifdef USE_N12_TSMC_SRAM
|
||||
|
|
|
@ -25,7 +25,7 @@ wire [ADDR_WIDTH-1:0] sram_addr;
|
|||
wire [WIDTH-1:0] sram_rdata;
|
||||
wire [WIDTH-1:0] sram_wdata;
|
||||
|
||||
wire [2-1:0] WTSEL = mem_ctrl_bus[45:44];
|
||||
wire [2-1:0] WTSEL = mem_ctrl_bus[47:46];
|
||||
|
||||
|
||||
`ifdef USE_N12_TSMC_SRAM
|
||||
|
|
Loading…
Reference in New Issue