def test_dsn(bag_project: BagProject, dsn_specs: Dict[str, Any], gen_output: bool, run_lvs: bool) -> None: impl_lib: str = dsn_specs['impl_lib'] root_dir: str = dsn_specs['root_dir'] lay_str: str = dsn_specs.get('lay_class', '') pytest_info: Dict[str, Path] = dsn_specs['pytest'] model_type: str = dsn_specs.get('model_type', 'SYSVERILOG') root_path = Path(root_dir) mod_type: DesignOutput = DesignOutput[model_type] lay_db = bag_project.make_template_db(impl_lib) bag_project.generate_cell(dsn_specs, raw=True, gen_lay=bool(lay_str), gen_sch=True, run_drc=False, run_lvs=run_lvs, run_rcx=False, lay_db=lay_db, gen_model=True) if not gen_output: for key, expect_path in pytest_info.items(): if key == 'test_id': continue out_path = root_path / key.replace('_', '.') if not out_path.is_file(): raise ValueError(f'Cannot find output file: {out_path}') if key.endswith('yaml'): actual_dict = read_yaml(out_path) expect_dict = read_yaml(expect_path) assert actual_dict == expect_dict elif key.endswith('gds'): lay_map = get_gds_layer_map() obj_map = get_gds_object_map() grid = lay_db.grid tr_colors = lay_db.tr_colors expect_cv_list = read_gds(str(expect_path), lay_map, obj_map, grid, tr_colors) actual_cv_list = read_gds(str(out_path), lay_map, obj_map, grid, tr_colors) assert expect_cv_list == actual_cv_list else: if key.endswith('netlist'): output_type = DesignOutput.CDL else: output_type = mod_type actual = read_file(out_path) expect = read_file(expect_path) check_netlist(output_type, actual, expect)
def run_main(prj: BagProject, args: argparse.Namespace) -> None: specs = read_yaml(args.specs) lay_db = prj.make_template_db(specs['impl_lib']) if args.gen_lay else None sch_db = prj.make_module_db(specs['impl_lib']) cv_info = [] dut_params = specs['dut_params'] dut_netlist = prj.generate_cell(dut_params, lay_db=lay_db, sch_db=sch_db, gen_lay=args.gen_lay, gen_sch=args.gen_sch, cv_info_out=cv_info, run_rcx=args.run_rcx) print(f'dut_netlist: {dut_netlist}') wrapper_params = specs['wrapper_params'] prj.replace_dut_in_wrapper(wrapper_params['params'], dut_params['impl_lib'], dut_params['impl_cell']) generate_wrapper(sch_db, wrapper_params, cv_info, dut_netlist, gen_sch=args.gen_sch)