Skip to content

Commit

Permalink
Merge pull request #36 from RapidSilicon/upstream
Browse files Browse the repository at this point in the history
Upstream
  • Loading branch information
tangxifan authored Nov 1, 2021
2 parents 83d859f + ff264c0 commit f86b696
Show file tree
Hide file tree
Showing 24 changed files with 156 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "yosys"]
path = yosys
url = https://github.com/QuickLogic-Corp/yosys.git
branch = quicklogic-rebased
url = https://github.com/YosysHQ/yosys
branch = release-branch-0.10
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ void print_verilog_random_testbench_fpga_instance(std::fstream& fp,
const std::string& circuit_name,
const AtomContext& atom_ctx,
const VprNetlistAnnotation& netlist_annotation,
const PinConstraints& pin_constraints,
const bool& explicit_port_mapping) {
/* Validate the file stream */
valid_file_stream(fp);
Expand All @@ -157,7 +158,7 @@ void print_verilog_random_testbench_fpga_instance(std::fstream& fp,
std::vector<std::string>(),
std::string(FPGA_PORT_POSTFIX),
atom_ctx, netlist_annotation,
PinConstraints(),
pin_constraints,
explicit_port_mapping);

print_verilog_comment(fp, std::string("----- End FPGA Fabric Instanication -------"));
Expand Down Expand Up @@ -301,6 +302,7 @@ void print_verilog_random_top_testbench(const std::string& circuit_name,
/* Call defined top-level module */
print_verilog_random_testbench_fpga_instance(fp, circuit_name,
atom_ctx, netlist_annotation,
pin_constraints,
options.explicit_port_mapping());

/* Call defined benchmark */
Expand Down
16 changes: 8 additions & 8 deletions openfpga_flow/misc/ys_tmpl_yosys_vpr_bram_dsp_dff_flow.ys
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ opt_clean
# demote inout ports to input or output port
# with follow-up optimizations to clean up AST
deminout
opt
opt -nodffe -nosdff

opt_expr
opt_clean
check
opt
opt -nodffe -nosdff
wreduce -keepdc
peepopt
pmuxtree
Expand Down Expand Up @@ -58,10 +58,10 @@ chtype -set $mul t:$__soft_mul# Extract arithmetic functions
techmap
alumacc
share
opt
opt -nodffe -nosdff
fsm
# Run a quick follow-up optimization to sweep out unused nets/signals
opt -fast
opt -fast -nodffe -nosdff
# Optimize any memory cells by merging share-able ports and collecting all the ports belonging to memorcy cells
memory -nomap
opt_clean
Expand All @@ -71,9 +71,9 @@ opt_clean
#########################
memory_bram -rules ${YOSYS_BRAM_MAP_RULES}
techmap -map ${YOSYS_BRAM_MAP_VERILOG}
opt -fast -mux_undef -undriven -fine
opt -fast -mux_undef -undriven -fine -nodffe -nosdff
memory_map
opt -undriven -fine
opt -undriven -fine -nodffe -nosdff

#########################
# Map flip-flops
Expand All @@ -83,9 +83,9 @@ opt_expr -mux_undef
simplemap
opt_expr
opt_merge
opt_rmdff
opt_dff -nodffe -nosdff
opt_clean
opt
opt -nodffe -nosdff

#########################
# Map LUTs
Expand Down
17 changes: 9 additions & 8 deletions openfpga_flow/misc/ys_tmpl_yosys_vpr_bram_dsp_flow.ys
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ opt_clean
# demote inout ports to input or output port
# with follow-up optimizations to clean up AST
deminout
opt
opt -nodffe -nosdff

opt_expr
opt_clean
check
opt
opt -nodffe -nosdff
wreduce -keepdc
peepopt
pmuxtree
Expand Down Expand Up @@ -58,10 +58,10 @@ chtype -set $mul t:$__soft_mul# Extract arithmetic functions
techmap
alumacc
share
opt
opt -nodffe -nosdff
fsm
# Run a quick follow-up optimization to sweep out unused nets/signals
opt -fast
opt -fast -nodffe -nosdff
# Optimize any memory cells by merging share-able ports and collecting all the ports belonging to memorcy cells
memory -nomap
opt_clean
Expand All @@ -71,21 +71,22 @@ opt_clean
#########################
memory_bram -rules ${YOSYS_BRAM_MAP_RULES}
techmap -map ${YOSYS_BRAM_MAP_VERILOG}
opt -fast -mux_undef -undriven -fine
opt -fast -mux_undef -undriven -fine -nodffe -nosdff
memory_map
opt -undriven -fine
opt -undriven -fine -nodffe -nosdff

#########################
# Map flip-flops
#########################
dfflegalize -cell $_DFF_P_ 0
techmap -map +/adff2dff.v
opt_expr -mux_undef
simplemap
opt_expr
opt_merge
opt_rmdff
opt_dff -nodffe -nosdff
opt_clean
opt
opt -nodffe -nosdff

#########################
# Map LUTs
Expand Down
18 changes: 10 additions & 8 deletions openfpga_flow/misc/ys_tmpl_yosys_vpr_bram_flow.ys
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ opt_clean
# demote inout ports to input or output port
# with follow-up optimizations to clean up AST
deminout
opt
opt -nodffe -nosdff

opt_expr
opt_clean
check
opt
opt -nodffe -nosdff
wreduce -keepdc
peepopt
pmuxtree
Expand All @@ -42,10 +42,11 @@ opt_clean
# Extract arithmetic functions
alumacc
share
opt
opt -nodffe -nosdff
fsm
# Run a quick follow-up optimization to sweep out unused nets/signals
opt -fast
# FIXME: In Yosys v0.10, when options '-nodffe' and '-nosdff' is on, some dual-port ram cannot be inferred correctly
opt -fast #-nodffe -nosdff
# Optimize any memory cells by merging share-able ports and collecting all the ports belonging to memorcy cells
memory -nomap
opt_clean
Expand All @@ -55,21 +56,22 @@ opt_clean
#########################
memory_bram -rules ${YOSYS_BRAM_MAP_RULES}
techmap -map ${YOSYS_BRAM_MAP_VERILOG}
opt -fast -mux_undef -undriven -fine
opt -fast -mux_undef -undriven -fine -nodffe -nosdff
memory_map
opt -undriven -fine
opt -undriven -fine -nodffe -nosdff

#########################
# Map flip-flops
#########################
dfflegalize -cell $_DFF_P_ 0
techmap -map +/adff2dff.v
opt_expr -mux_undef
simplemap
opt_expr
opt_merge
opt_rmdff
opt_dff -nodffe -nosdff
opt_clean
opt
opt -nodffe -nosdff

#########################
# Map LUTs
Expand Down
19 changes: 18 additions & 1 deletion openfpga_flow/misc/ys_tmpl_yosys_vpr_dff_flow.ys
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,24 @@ proc
techmap -D NO_LUT -map ${YOSYS_DFF_MAP_VERILOG}

# Synthesis
synth -top ${TOP_MODULE} -flatten
flatten
opt_expr
opt_clean
check
opt -nodffe -nosdff
fsm
opt -nodffe -nosdff
wreduce
peepopt
opt_clean
opt -nodffe -nosdff
memory -nomap
opt_clean
opt -fast -full -nodffe -nosdff
memory_map
opt -full -nodffe -nosdff
techmap
opt -fast -nodffe -nosdff
clean

# LUT mapping
Expand Down
15 changes: 8 additions & 7 deletions openfpga_flow/misc/ys_tmpl_yosys_vpr_dsp_flow.ys
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ opt_clean
# demote inout ports to input or output port
# with follow-up optimizations to clean up AST
deminout
opt
opt -nodffe -nosdff

opt_expr
opt_clean
check
opt
opt -nodffe -nosdff
wreduce -keepdc
peepopt
pmuxtree
Expand Down Expand Up @@ -58,25 +58,26 @@ chtype -set $mul t:$__soft_mul# Extract arithmetic functions
techmap
alumacc
share
opt
opt -nodffe -nosdff
fsm
# Run a quick follow-up optimization to sweep out unused nets/signals
opt -fast
opt -fast -nodffe -nosdff
# Optimize any memory cells by merging share-able ports and collecting all the ports belonging to memorcy cells
memory -nomap
opt_clean

#########################
# Map flip-flops
#########################
dfflegalize -cell $_DFF_P_ 0
techmap -map +/adff2dff.v
opt_expr -mux_undef
simplemap
opt_expr
opt_merge
opt_rmdff
opt_dff -nodffe -nosdff
opt_clean
opt
opt -nodffe -nosdff

#########################
# Map LUTs
Expand All @@ -93,4 +94,4 @@ stat
# Output netlists
#########################
opt_clean -purge
write_blif ${OUTPUT_BLIF}
write_blif ${OUTPUT_BLIF}
19 changes: 18 additions & 1 deletion openfpga_flow/misc/ys_tmpl_yosys_vpr_flow.ys
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@ proc
techmap -D NO_LUT -map +/adff2dff.v

# Synthesis
synth -top ${TOP_MODULE} -flatten
flatten
opt_expr
opt_clean
check
opt -nodffe -nosdff
fsm
opt -nodffe -nosdff
wreduce
peepopt
opt_clean
opt -nodffe -nosdff
memory -nomap
opt_clean
opt -fast -full -nodffe -nosdff
memory_map
opt -full -nodffe -nosdff
techmap
opt -fast -nodffe -nosdff
clean

# LUT mapping
Expand Down
21 changes: 20 additions & 1 deletion openfpga_flow/misc/ys_tmpl_yosys_vpr_flow_with_rewrite.ys
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,26 @@ proc
techmap -D NO_LUT -map +/adff2dff.v

# Synthesis
synth -top ${TOP_MODULE} -flatten
flatten
opt_expr
opt_clean
check
opt -nodffe -nosdff
fsm
opt -nodffe -nosdff
wreduce
peepopt
opt_clean
opt -nodffe -nosdff
memory -nomap
opt_clean
opt -fast -full -nodffe -nosdff
memory_map
opt -full -nodffe -nosdff
techmap
opt -fast -nodffe -nosdff
clean

clean

# LUT mapping
Expand Down
4 changes: 2 additions & 2 deletions openfpga_flow/openfpga_cell_library/verilog/dff.v
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ module MULTI_MODE_DFFSRQ (
);

wire post_set = mode[1] ? ~SET : SET;
wire post_reset = mode[0] ? ~RST : RST;
wire post_rst = mode[0] ? ~RST : RST;

DFFSRQ FF_CORE (.SET(post_set),
.RST(post_rst),
Expand All @@ -284,7 +284,7 @@ module MULTI_MODE_DFFRQ (
input mode // mode-selection bits: bit0 for reset polarity; bit1 for set polarity
);

wire post_reset = mode ? ~RST : RST;
wire post_rst = mode ? ~RST : RST;

DFFRQ FF_CORE (.RST(post_rst),
.CK(CK),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Run VPR for the 'and' design
#--write_rr_graph example_rr_graph.xml
vpr ${VPR_ARCH_FILE} ${VPR_TESTBENCH_BLIF} --clock_modeling route --route_chan_width ${OPENFPGA_VPR_ROUTE_CHAN_WIDTH} --device ${OPENFPGA_VPR_DEVICE_LAYOUT}
vpr ${VPR_ARCH_FILE} ${VPR_TESTBENCH_BLIF} --clock_modeling ideal --route_chan_width ${OPENFPGA_VPR_ROUTE_CHAN_WIDTH} --device ${OPENFPGA_VPR_DEVICE_LAYOUT}

# Read OpenFPGA architecture definition
read_openfpga_arch -f ${OPENFPGA_ARCH_FILE}
Expand All @@ -10,7 +10,7 @@ read_openfpga_simulation_setting -f ${OPENFPGA_SIM_SETTING_FILE}

# Annotate the OpenFPGA architecture to VPR data base
# to debug use --verbose options
link_openfpga_arch --activity_file ${ACTIVITY_FILE} --sort_gsb_chan_node_in_edges
link_openfpga_arch --sort_gsb_chan_node_in_edges

# Check and correct any naming conflicts in the BLIF netlist
check_netlist_naming_conflict --fix --report ./netlist_renaming.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ read_openfpga_simulation_setting -f ${OPENFPGA_SIM_SETTING_FILE}

# Annotate the OpenFPGA architecture to VPR data base
# to debug use --verbose options
link_openfpga_arch --activity_file ${ACTIVITY_FILE} --sort_gsb_chan_node_in_edges
link_openfpga_arch --sort_gsb_chan_node_in_edges

# Check and correct any naming conflicts in the BLIF netlist
check_netlist_naming_conflict --fix --report ./netlist_renaming.xml
Expand Down
18 changes: 10 additions & 8 deletions openfpga_flow/regression_test_scripts/quicklogic_reg_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ PYTHON_EXEC=python3.8
##############################################
echo -e "QuickLogic regression tests";

echo -e "Testing yosys flow using custom ys script for running quicklogic device";
run-task quicklogic_tests/flow_test --debug --show_thread_logs
# TODO: Disabled all the tests here because Quicklogic's synthesis script is not in Yosys v0.10 release. Will bring back once Quicklogic manages to merge their contribution to Yosys upstream

echo -e "Testing yosys flow using custom ys script for running multi-clock quicklogic device";
run-task quicklogic_tests/counter_5clock_test --debug --show_thread_logs
run-task quicklogic_tests/sdc_controller_test --debug --show_thread_logs

echo -e "Testing yosys flow using custom ys script for adders in quicklogic device";
run-task quicklogic_tests/lut_adder_test --debug --show_thread_logs
##echo -e "Testing yosys flow using custom ys script for running quicklogic device";
##run-task quicklogic_tests/flow_test --debug --show_thread_logs
##
##echo -e "Testing yosys flow using custom ys script for running multi-clock quicklogic device";
##run-task quicklogic_tests/counter_5clock_test --debug --show_thread_logs
##run-task quicklogic_tests/sdc_controller_test --debug --show_thread_logs
##
##echo -e "Testing yosys flow using custom ys script for adders in quicklogic device";
##run-task quicklogic_tests/lut_adder_test --debug --show_thread_logs
Loading

0 comments on commit f86b696

Please sign in to comment.