Skip to content

Commit

Permalink
Merge pull request f4pga#2127 from kkumar23/master
Browse files Browse the repository at this point in the history
Adding support for the quicklogic toolchain
  • Loading branch information
mkurc-ant committed Apr 20, 2021
2 parents c7bfbe7 + 6eb424c commit 6e287cd
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 41 deletions.
5 changes: 5 additions & 0 deletions quicklogic/common/cmake/quicklogic_install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ function(DEFINE_QL_TOOLCHAIN_TARGET)
install(FILES ${VPR_CONFIG}
DESTINATION share/symbiflow/scripts/${FAMILY})

# Example design to run through the flow
install(FILES ${symbiflow-arch-defs_SOURCE_DIR}/quicklogic/${FAMILY}/tests/counter_16bit/*.v
DESTINATION share/symbiflow/tests/counter_16bit
PERMISSIONS WORLD_READ OWNER_WRITE OWNER_READ GROUP_READ)

# install python scripts
install(FILES ${symbiflow-arch-defs_SOURCE_DIR}/utils/split_inouts.py
DESTINATION bin/python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ CONDA_FLAGS="-y --override-channels -c defaults -c conda-forge"
conda update $CONDA_FLAGS -q conda
curl https://storage.googleapis.com/symbiflow-arch-defs-install/quicklogic-arch-defs-63c3d8f9.tar.gz --output arch.tar.gz
tar -C $INSTALL_DIR -xvf arch.tar.gz && rm arch.tar.gz
conda install $CONDA_FLAGS -c quicklogic-corp/label/ql yosys="0.8.0_0002_gc3b38fdc 20200901_073908" python=3.7
conda install $CONDA_FLAGS -c quicklogic-corp/label/ql yosys-plugins="1.2.0_0009_g9ab211c 20201001_121833"
conda install $CONDA_FLAGS -c quicklogic-corp/label/ql vtr="v8.0.0_rc2_2894_gdadca7ecf 20201008_140004"
conda install $CONDA_FLAGS -c quicklogic-corp iverilog
conda install $CONDA_FLAGS -c litex-hub/label/main yosys="0.9_5266_g0fb4224e 20210301_104249_py37"
conda install $CONDA_FLAGS -c litex-hub/label/main symbiflow-yosys-plugins="1.0.0_7_284_gb6c5f5d 20210318_102115"
conda install $CONDA_FLAGS -c litex-hub/label/main vtr-optimized="8.0.0_3452_ge7d45e013 20210318_102115"
conda install $CONDA_FLAGS -c litex-hub iverilog
conda install $CONDA_FLAGS -c tfors gtkwave
conda install $CONDA_FLAGS make lxml simplejson intervaltree git pip
conda activate
Expand Down
50 changes: 23 additions & 27 deletions quicklogic/common/toolchain_wrappers/ql_symbiflow
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ BUILDDIR=build

source ${MYPATH}/env
source ${VPRPATH}/vpr_common
VERSION="v1.3.1"
VERSION="v1.3.3"

if [ ! -n $1 ]; then
echo "Please enter a valid command: Refer help ql_symbiflow --help"
Expand All @@ -18,9 +18,9 @@ echo -e "----------------- \n"
elif [[ $1 == "-h" || $1 == "--help" ]];then
echo -e "\nBelow are the supported commands: \n\
To synthesize and dump a eblif file:\n\
\t>ql_symbiflow -synth -src <source_dir path> -d <device> -t <top> -v <verilog file/files> -p <pcf file>\n\
\t>ql_symbiflow -synth -src <source_dir path> -d <device> -P <pinmap csv file> -t <top module name> -v <verilog file/files> -p <pcf file>\n\
To run synthesis, pack, place and route:\n\
\t>ql_symbiflow -compile -src <source_dir path> -d <device> -t <top> -v <verilog file/files> -p <pcf file> \n\
\t>ql_symbiflow -compile -src <source_dir path> -d <device> -P <pinmap csv file> -t <top module name> -v <verilog file/files> -p <pcf file> \n\
Device supported:qlf_k4n8" || exit
elif [[ $1 == "-v" || $1 == "--version" ]];then
echo "Symbiflow Tool Version : ${VERSION}"
Expand Down Expand Up @@ -202,7 +202,6 @@ for arg_v in $@; do
TOP=$arg_v
elif [ $DEVICENAME -eq 1 ]; then
DEVICE="${arg_v}"
#DEVICE="${DEVICE,,}"
case ${DEVICE} in
qlf_k4n8)
DEVICE="${DEVICE}_${DEVICE}"
Expand All @@ -224,7 +223,6 @@ for arg_v in $@; do
OUT+="$arg_v "
elif [ $PARTNAME -eq 1 ]; then
PART="${arg_v}"
# PART="${PART^^}"
else
echo "Refer help for more details: ql_symbiflow -h "
exit 1
Expand Down Expand Up @@ -273,7 +271,7 @@ fi
fi

if [[ $1 == "-compile" || $1 == "-post_verilog" ]]; then
# FIXME: Allow no PCF/pinmap for some devices
# Allow no PCF/pinmap for some devices
if [[ ! "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]]; then
if [ -z "$PCF" ]; then
echo "PCF file option is missing. Refer -h/--help"
Expand All @@ -294,15 +292,14 @@ if [[ $1 == "-compile" || $1 == "-post_verilog" ]]; then
echo "TOP module name is missing. Refer -h/--help"
exit 1
fi
# FIXME: Allow no PCF/pinmap for some devices
if [[ ! "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]]; then
if [ -z "$PART" ]; then
echo "PART name is missing. Refer -h/--help"
exit 1
else
PINMAPCSV="pinmap_${PART}.csv"
fi
if [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]]; then
if [ -z "$PART" ]; then
if [ -n "$PCF" ];then
echo "Error: pcf file cannot be used without declaring PINMAP CSV file"
exit 1
fi
fi
fi
if [ -z "$ROUTE_FLAG0" ]; then
MAX_CRITICALITY="0.0"
elif ! [[ "$ROUTE_FLAG0" =~ ^(timing|congestion)$ ]]; then
Expand Down Expand Up @@ -351,20 +348,8 @@ else
HAVE_FASM2BELS=1
fi

# Some devices have only single part. If the part is not explicitly provided
# try infering it from the device name
if [ -z $PART ]; then
if [[ "$DEVICE" =~ ^(qlf_k4n8.*)$ ]]; then
PART=qlf_k4n8_umc22
else
echo "Please provide part with the -P option"
exit 1
fi
fi

export PCF_FILE=$PCF
export TOP_F=$TOP
export PART=$PART
export PINMAP_FILE=$PINMAPCSV
export MAX_CRITICALITY=$MAX_CRITICALITY
##### Create Makefile #####
Expand All @@ -375,6 +360,17 @@ else
CURR_DIR="${PWD}/${SOURCE}"
fi

if [[ -f $SOURCE/$PART ]];then
CSV_PATH=`realpath $SOURCE/$PART`
elif [[ -f $PART ]];then
CSV_PATH=`realpath $PART`
else
echo "invalid csv file/path"
exit 1
fi

export PART=${CSV_PATH}

MAKE_FILE=${CURR_DIR}/Makefile.symbiflow
LOG_FILE=${CURR_DIR}/${BUILDDIR}/${TOP}.log

Expand Down Expand Up @@ -414,7 +410,7 @@ all: \${BUILDDIR}/\${TOP}.route\n\
ifneq (\"\$(wildcard \$(HEX_FILES))\",\"\")\n\
\$(shell cp \${current_dir}/*.hex \${BUILDDIR})\n\
endif\n\
cd \${BUILDDIR} && symbiflow_synth -t \${TOP} -v \${VERILOG} -f \${FAMILY} -d \${DEVICE} -p \${PCF} -P \${PART} 2>&1 > $LOG_FILE\n\
cd \${BUILDDIR} && symbiflow_synth -t \${TOP} -v \${VERILOG} -f \${FAMILY} -d \${DEVICE} -p \${PCF} 2>&1 > $LOG_FILE\n\
\n\
\${BUILDDIR}/\${TOP}.net: \${BUILDDIR}/\${TOP}.eblif\n\
cd \${BUILDDIR} && symbiflow_pack -e \${TOP}.eblif -f \${FAMILY} -d \${DEVICE} -s \${SDC} 2>&1 > $LOG_FILE\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,14 @@ ARCH_DEF=$6

if [[ "$DEVICE" =~ ^(qlf_k4n8_qlf_k4n8)$ ]];then
DEVICE_1="qlf_k4n8-qlf_k4n8_umc22"
PINMAPXML="pinmap_${PART}.xml"
PINMAPXML="pinmap_qlf_k4n8_umc22.xml"
else
DEVICE_1=${DEVICE}
fi

PINMAPCSV="pinmap_${PART}.csv"
CLKMAPCSV="clkmap_${PART}.csv"

echo "PINMAP FILE : $PINMAPCSV"
echo "CLKMAP FILE : $CLKMAPCSV"

PINMAP=`realpath ${MYPATH}/../share/symbiflow/arch/${DEVICE_1}_${DEVICE_1}/${PINMAPCSV}`
PINMAP_XML=`realpath ${MYPATH}/../share/symbiflow/arch/${DEVICE_1}_${DEVICE_1}/${PINMAPXML}`
CLKMAP=`realpath ${MYPATH}/../share/symbiflow/arch/${DEVICE_1}_${DEVICE_1}/${CLKMAPCSV}`
IOGEN=`realpath ${MYPATH}/python/create_ioplace.py`
PROJECT=$(basename -- "$EBLIF")
IOPLACE_FILE="${PROJECT%.*}_io.place"

python3 ${IOGEN} --pcf $PCF --blif $EBLIF --pinmap_xml $PINMAP_XML --csv_file $PINMAP --net $NET > ${IOPLACE_FILE}
python3 ${IOGEN} --pcf $PCF --blif $EBLIF --pinmap_xml $PINMAP_XML --csv_file $PART --net $NET > ${IOPLACE_FILE}
1 change: 1 addition & 0 deletions quicklogic/qlf_k4n8/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ add_custom_target(all_qlf_k4n8_tests_no_adder)
add_custom_target(all_qlf_k4n8_tests_adder)

add_subdirectory(counter)
add_subdirectory(counter_16bit)
add_subdirectory(adder_8)

add_dependencies(all_quicklogic_tests all_qlf_k4n8_tests_no_adder)
Expand Down
19 changes: 19 additions & 0 deletions quicklogic/qlf_k4n8/tests/counter_16bit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_file_target(FILE counter_16bit.v SCANNER_TYPE verilog)

add_fpga_target(
NAME counter_16bit-umc22-no-adder
BOARD qlf_k4n8-qlf_k4n8_umc22_board
SOURCES counter_16bit.v
EXPLICIT_ADD_FILE_TARGET
DEFINES SYNTH_OPTS=-no_adder
)

add_fpga_target(
NAME counter_16bit-umc22-adder
BOARD qlf_k4n8-qlf_k4n8_umc22_board
SOURCES counter_16bit.v
EXPLICIT_ADD_FILE_TARGET
)

add_dependencies(all_qlf_k4n8_tests_no_adder counter_16bit-umc22-no-adder_route)
add_dependencies(all_qlf_k4n8_tests_adder counter_16bit-umc22-adder_route)
2 changes: 2 additions & 0 deletions quicklogic/qlf_k4n8/tests/counter_16bit/counter_16bit.sdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
create_clock -period 20 clk
set_clock_uncertainty 2.0
18 changes: 18 additions & 0 deletions quicklogic/qlf_k4n8/tests/counter_16bit/counter_16bit.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Description :
// Example of asimple 16 bit up counter in Verilog HDL
//
// Version 1.0 : Initial Creation
//
module counter_16bit_top (clk, reset, enable, count);
input clk, reset, enable;
output [15:0] count;
reg [15:0] count;

always @ (posedge clk)
if (reset == 1'b1) begin
count <= 0;
end else if ( enable == 1'b1) begin
count <= count + 1;
end

endmodule
64 changes: 64 additions & 0 deletions quicklogic/qlf_k4n8/tests/counter_16bit/counter_16bit_tb.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Description :
// testbench for simple 16 bit up counter in Verilog HDL
//
//

`timescale 10ns /10ps
`define GSIM 1
module counter_16bit_tb;
reg clk, reset, enable;
wire [15:0] count;
reg status;

reg [15:0] count_compare;

top DUT (.clk(clk), .reset(reset), .enable(enable), .count(count));

event terminate_sim;
initial begin
@ (terminate_sim);
$display("FAIL");
#5 $fatal;
end

always @ (posedge clk)
if (reset == 1'b1) begin
count_compare <= 0;
end else if ( enable == 1'b1) begin
count_compare <= count_compare + 1;
end

initial begin
clk = 0;
reset = 1;
enable = 0;
#50 reset = 0;
#50 enable = 1;
#10 status = 0;
end

always
#15 clk = !clk;

always @ (posedge clk)
if (count_compare != count) begin
$display ("DUT Error at time %d", $time);
$display (" Expected value %d, Got Value %d", count_compare, count);
status =1;
#5 -> terminate_sim;
end

initial begin
$dumpfile("counter_16bit_tb.vcd");
$dumpvars(0,counter_16bit_tb);
$display("\t\ttime,\tclk,\treset,\tenable,\tcount");
$monitor("%d,\t%b,\t%b,\t%b,\t%d",$time, clk,reset,enable,count);
if(status == 1'b0)
$display("PASS");
end

initial
#3000 $finish;

endmodule

0 comments on commit 6e287cd

Please sign in to comment.