Skip to content

Commit

Permalink
treewide: Add post-layout simulation flow
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca committed Nov 5, 2024
1 parent 54df35f commit df4054d
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 204 deletions.
16 changes: 8 additions & 8 deletions Bender.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ packages:
dependencies:
- common_cells
axi:
revision: 4e54ac6766b160217a83a74d5a23af9bbf59e6ee
version: null
revision: 853ede23b2a9837951b74dbdc6d18c3eef5bac7d
version: 0.39.5
source:
Git: https://github.com/pulp-platform/axi
dependencies:
Expand All @@ -32,8 +32,8 @@ packages:
dependencies:
- common_cells
cluster_icache:
revision: 0e1fb6751d9684d968ba7fb40836e6118b448ecd
version: 0.1.1
revision: 8b7ed9eea7dafa92bb3222c6204508bfe8be2ea7
version: null
source:
Git: https://github.com/pulp-platform/cluster_icache.git
dependencies:
Expand All @@ -42,8 +42,8 @@ packages:
- scm
- tech_cells_generic
common_cells:
revision: c27bce39ebb2e6bae52f60960814a2afca7bd4cb
version: 1.37.0
revision: 842753eabe166818bde831908c865872d115528d
version: null
source:
Git: https://github.com/pulp-platform/common_cells
dependencies:
Expand Down Expand Up @@ -91,8 +91,8 @@ packages:
- common_cells
- common_verification
register_interface:
revision: ae616e5a1ec2b41e72d200e5ab09c65e94aebd3d
version: 0.4.4
revision: 5daa85d164cf6b54ad061ea1e4c6f3624556e467
version: 0.4.5
source:
Git: https://github.com/pulp-platform/register_interface
dependencies:
Expand Down
28 changes: 20 additions & 8 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package:
- Matheus Cavalcante <matheusd@iis.ee.ethz.ch>

dependencies:
axi: { git: https://github.com/pulp-platform/axi, rev: 4e54ac6766b160217a83a74d5a23af9bbf59e6ee }
axi_riscv_atomics: { git: https://github.com/pulp-platform/axi_riscv_atomics, version: 0.6.0 }
common_cells: { git: https://github.com/pulp-platform/common_cells, version: 1.35.0 }
FPnew: { git: "https://github.com/pulp-platform/cvfpu.git", rev: pulp-v0.1.3 }
register_interface: { git: https://github.com/pulp-platform/register_interface, version: 0.4.2 }
tech_cells_generic: { git: https://github.com/pulp-platform/tech_cells_generic, version: 0.2.11 }
riscv-dbg: { git: https://github.com/pulp-platform/riscv-dbg, version: 0.8.0 }
cluster_icache: { git: https://github.com/pulp-platform/cluster_icache.git, version: 0.1.0 }
axi: { git: https://github.com/pulp-platform/axi, version: 0.39.5 }
axi_riscv_atomics: { git: https://github.com/pulp-platform/axi_riscv_atomics, version: 0.6.0 }
common_cells: { git: https://github.com/pulp-platform/common_cells, rev: remove-ffnr }
FPnew: { git: https://github.com/pulp-platform/cvfpu.git, rev: pulp-v0.1.3 }
register_interface: { git: https://github.com/pulp-platform/register_interface, version: 0.4.2 }
tech_cells_generic: { git: https://github.com/pulp-platform/tech_cells_generic, version: 0.2.11 }
riscv-dbg: { git: https://github.com/pulp-platform/riscv-dbg, version: 0.8.0 }
cluster_icache: { git: https://github.com/pulp-platform/cluster_icache.git, rev: remove-ffnr }
idma: { git: https://github.com/pulp-platform/iDMA, rev: __deploy__9cbcd30__snitch-tracing }

export_include_dirs:
Expand All @@ -35,6 +35,7 @@ export_include_dirs:
- hw/tcdm_interface/include
- hw/snitch/include
- hw/snitch_ssr/include
- target/snitch_cluster/generated

sources:
# reqrsp_interface
Expand Down Expand Up @@ -185,8 +186,19 @@ sources:

# target/snitch_cluster
- target: snitch_cluster
files:
- target/snitch_cluster/generated/snitch_cluster_pkg.sv
- target: all(snitch_cluster, not(postlayout))
files:
- target/snitch_cluster/generated/snitch_cluster_wrapper.sv
- target: all(snitch_cluster, postlayout)
files:
- nonfree/gf12/fusion/runs/0/out/15/snitch_cluster_wrapper.v
- target: all(snitch_cluster, any(simulation, verilator))
files:
- target/snitch_cluster/test/testharness.sv

- target: gf12
files:
- nonfree/gf12/mems/tc_sram.sv
- nonfree/gf12/sourcecode/tc_clk.sv
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
############

NONFREE_REMOTE ?= git@iis-git.ee.ethz.ch:pulp-restricted/snitch-cluster-nonfree.git
NONFREE_COMMIT ?= e30961e20a23a76442da27d2ba07c9fe20f3b575
NONFREE_COMMIT ?= synth
NONFREE_DIR = $(ROOT)/nonfree

all: nonfree
Expand Down
218 changes: 218 additions & 0 deletions hw/snitch_cluster/src/snitch_cluster_pkg.sv.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
// Copyright 2021 ETH Zurich and University of Bologna.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51

${disclaimer}

<%def name="icache_cfg(prop)">
% for lw in cfg['hives']:
${lw['icache'][prop]}${',' if not loop.last else ''}
% endfor
</%def>

<%def name="core_cfg(prop)">\
% for c in cfg['cores']:
${c[prop]}${', ' if not loop.last else ''}\
% endfor
</%def>\

<%def name="core_cfg_flat(prop)">\
${cfg['nr_cores']}'b\
% for c in cfg['cores'][::-1]:
${int(c[prop])}\
% endfor
</%def>\

<%def name="core_isa(isa)">\
${cfg['nr_cores']}'b\
% for c in cfg['cores'][::-1]:
${int(getattr(c['isa_parsed'], isa))}\
% endfor
</%def>\

<%def name="ssr_cfg(core, ssr_fmt_str, none_str, inner_sep)">\
% for core in cfg['cores']:
% for s in list(reversed(core['ssrs'] + [None]*(cfg['num_ssrs_max']-len(core['ssrs'])))):
${(" '{" if loop.first else ' ') + \
(ssr_fmt_str.format(**s) if s is not None else none_str) \
+ (inner_sep if not loop.last else '}')}\
% endfor
${',' if not loop.last else ''}
% endfor
</%def>\

`include "axi/typedef.svh"

// verilog_lint: waive-start package-filename
package ${cfg['pkg_name']};

localparam int unsigned NrCores = ${cfg['nr_cores']};
localparam int unsigned NrHives = ${cfg['nr_hives']};

localparam int unsigned AddrWidth = ${cfg['addr_width']};
localparam int unsigned NarrowDataWidth = ${cfg['data_width']};
localparam int unsigned WideDataWidth = ${cfg['dma_data_width']};

localparam int unsigned NarrowIdWidthIn = ${cfg['id_width_in']};
localparam int unsigned NrNarrowMasters = 3;
localparam int unsigned NarrowIdWidthOut = $clog2(NrNarrowMasters) + NarrowIdWidthIn;

localparam int unsigned NrWideMasters = 1 + ${cfg['dma_nr_channels']} + ${cfg['nr_hives']};
localparam int unsigned WideIdWidthIn = ${cfg['dma_id_width_in']};
localparam int unsigned WideIdWidthOut = $clog2(NrWideMasters) + WideIdWidthIn;

localparam int unsigned NarrowUserWidth = ${cfg['user_width']};
localparam int unsigned WideUserWidth = ${cfg['dma_user_width']};

localparam int unsigned ICacheLineWidth [NrHives] = '{${icache_cfg('cacheline')}};
localparam int unsigned ICacheLineCount [NrHives] = '{${icache_cfg('depth')}};
localparam int unsigned ICacheWays [NrHives] = '{${icache_cfg('ways')}};

localparam int unsigned Hive [NrCores] = '{${core_cfg('hive')}};

typedef struct packed {
% for field, width in cfg['sram_cfg_fields'].items():
logic [${width-1}:0] ${field};
% endfor
} sram_cfg_t;

typedef struct packed {
sram_cfg_t icache_tag;
sram_cfg_t icache_data;
sram_cfg_t tcdm;
} sram_cfgs_t;

typedef logic [AddrWidth-1:0] addr_t;
typedef logic [NarrowDataWidth-1:0] data_t;
typedef logic [NarrowDataWidth/8-1:0] strb_t;
typedef logic [WideDataWidth-1:0] data_dma_t;
typedef logic [WideDataWidth/8-1:0] strb_dma_t;
typedef logic [NarrowIdWidthIn-1:0] narrow_in_id_t;
typedef logic [NarrowIdWidthOut-1:0] narrow_out_id_t;
typedef logic [WideIdWidthIn-1:0] wide_in_id_t;
typedef logic [WideIdWidthOut-1:0] wide_out_id_t;
typedef logic [NarrowUserWidth-1:0] user_t;
typedef logic [WideUserWidth-1:0] user_dma_t;

`AXI_TYPEDEF_ALL(narrow_in, addr_t, narrow_in_id_t, data_t, strb_t, user_t)
`AXI_TYPEDEF_ALL(narrow_out, addr_t, narrow_out_id_t, data_t, strb_t, user_t)
`AXI_TYPEDEF_ALL(wide_in, addr_t, wide_in_id_t, data_dma_t, strb_dma_t, user_dma_t)
`AXI_TYPEDEF_ALL(wide_out, addr_t, wide_out_id_t, data_dma_t, strb_dma_t, user_dma_t)

function automatic snitch_pma_pkg::rule_t [snitch_pma_pkg::NrMaxRules-1:0] get_cached_regions();
automatic snitch_pma_pkg::rule_t [snitch_pma_pkg::NrMaxRules-1:0] cached_regions;
cached_regions = '{default: '0};
% for i, cp in enumerate(cfg['pmas']['cached']):
cached_regions[${i}] = '{base: ${to_sv_hex(cp[0], cfg['addr_width'])}, mask: ${to_sv_hex(cp[1], cfg['addr_width'])}};
% endfor
return cached_regions;
endfunction

localparam snitch_pma_pkg::snitch_pma_t SnitchPMACfg = '{
NrCachedRegionRules: ${len(cfg['pmas']['cached'])},
CachedRegion: get_cached_regions(),
default: 0
};

localparam fpnew_pkg::fpu_implementation_t FPUImplementation [${cfg['nr_cores']}] = '{
% for c in cfg['cores']:
'{
PipeRegs: // FMA Block
'{
'{ ${cfg['timing']['lat_comp_fp32']}, // FP32
${cfg['timing']['lat_comp_fp64']}, // FP64
${cfg['timing']['lat_comp_fp16']}, // FP16
${cfg['timing']['lat_comp_fp8']}, // FP8
${cfg['timing']['lat_comp_fp16_alt']}, // FP16alt
${cfg['timing']['lat_comp_fp8_alt']} // FP8alt
},
'{1, 1, 1, 1, 1, 1}, // DIVSQRT
'{${cfg['timing']['lat_noncomp']},
${cfg['timing']['lat_noncomp']},
${cfg['timing']['lat_noncomp']},
${cfg['timing']['lat_noncomp']},
${cfg['timing']['lat_noncomp']},
${cfg['timing']['lat_noncomp']}}, // NONCOMP
'{${cfg['timing']['lat_conv']},
${cfg['timing']['lat_conv']},
${cfg['timing']['lat_conv']},
${cfg['timing']['lat_conv']},
${cfg['timing']['lat_conv']},
${cfg['timing']['lat_conv']}}, // CONV
'{${cfg['timing']['lat_sdotp']},
${cfg['timing']['lat_sdotp']},
${cfg['timing']['lat_sdotp']},
${cfg['timing']['lat_sdotp']},
${cfg['timing']['lat_sdotp']},
${cfg['timing']['lat_sdotp']}} // DOTP
},
UnitTypes: '{'{fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED}, // FMA
% if c["Xdiv_sqrt"]:
'{fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED}, // DIVSQRT
% else:
'{fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED}, // DIVSQRT
% endif
'{fpnew_pkg::PARALLEL,
fpnew_pkg::PARALLEL,
fpnew_pkg::PARALLEL,
fpnew_pkg::PARALLEL,
fpnew_pkg::PARALLEL,
fpnew_pkg::PARALLEL}, // NONCOMP
'{fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED}, // CONV
% if c["xfdotp"]:
'{fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED,
fpnew_pkg::MERGED}}, // DOTP
% else:
'{fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED,
fpnew_pkg::DISABLED}}, // DOTP
% endif
PipeConfig: fpnew_pkg::${cfg['timing']['fpu_pipe_config']}
}${',\n' if not loop.last else '\n'}\
% endfor
};

localparam snitch_ssr_pkg::ssr_cfg_t [${cfg['num_ssrs_max']}-1:0] SsrCfgs [${cfg['nr_cores']}] = '{
${ssr_cfg(core, "'{{{indirection:d}, {isect_master:d}, {isect_master_idx:d}, {isect_slave:d}, "\
"{isect_slave_spill:d}, {indir_out_spill:d}, {num_loops}, {index_width}, {pointer_width}, "\
"{shift_width}, {rpt_width}, {index_credits}, {isect_slave_credits}, {data_credits}, "\
"{mux_resp_depth}}}", "/*None*/ '0", ',\n ')}\
};

localparam logic [${cfg['num_ssrs_max']}-1:0][4:0] SsrRegs [${cfg['nr_cores']}] = '{
${ssr_cfg(core, '{reg_idx}', '/*None*/ 0', ',')}\
};

// Forward potentially optional configuration parameters
localparam logic [9:0] CfgBaseHartId = (${to_sv_hex(cfg['cluster_base_hartid'], 10)});
localparam addr_t CfgClusterBaseAddr = (${to_sv_hex(cfg['cluster_base_addr'], cfg['addr_width'])});

endpackage
// verilog_lint: waive-stop package-filename
Loading

0 comments on commit df4054d

Please sign in to comment.