mirror of https://github.com/openXC7/prjxray.git
Merge pull request #474 from antmicro/05x-fuzzers-rework
05x fuzzers rework
This commit is contained in:
commit
dff1402dfa
|
|
@ -1,3 +1,4 @@
|
|||
MAKETODO_FLAGS=--re "^INT_[LR].IMUX(_L)?[0-9]+\.LOGIC_OUTS(_L)?[0-9]+$$"
|
||||
TODO_N=50
|
||||
include ../int_loop.mk
|
||||
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import re, os
|
||||
|
||||
from prjxray.segmaker import Segmaker
|
||||
|
||||
segmk = Segmaker("design.bits")
|
||||
|
||||
tiledata = dict()
|
||||
pipdata = dict()
|
||||
ignpip = set()
|
||||
|
||||
print("Loading tags from design.txt.")
|
||||
with open("design.txt", "r") as f:
|
||||
for line in f:
|
||||
tile, pip, src, dst, pnum, pdir = line.split()
|
||||
_, pip = pip.split(".")
|
||||
_, src = src.split("/")
|
||||
_, dst = dst.split("/")
|
||||
pnum = int(pnum)
|
||||
pdir = int(pdir)
|
||||
|
||||
if tile not in tiledata:
|
||||
tiledata[tile] = {"pips": set(), "srcs": set(), "dsts": set()}
|
||||
|
||||
if pip in pipdata:
|
||||
assert pipdata[pip] == (src, dst)
|
||||
else:
|
||||
pipdata[pip] = (src, dst)
|
||||
|
||||
tiledata[tile]["pips"].add(pip)
|
||||
tiledata[tile]["srcs"].add(src)
|
||||
tiledata[tile]["dsts"].add(dst)
|
||||
|
||||
if pdir == 0:
|
||||
tiledata[tile]["srcs"].add(dst)
|
||||
tiledata[tile]["dsts"].add(src)
|
||||
|
||||
if pnum == 1 or pdir == 0 or \
|
||||
re.match(r"^(L[HV]B?|G?CLK)(_L)?(_B)?[0-9]", src) or \
|
||||
re.match(r"^(L[HV]B?|G?CLK)(_L)?(_B)?[0-9]", dst) or \
|
||||
re.match(r"^(CTRL|GFAN)(_L)?[0-9]", dst):
|
||||
ignpip.add(pip)
|
||||
|
||||
for tile, pips_srcs_dsts in tiledata.items():
|
||||
pips = pips_srcs_dsts["pips"]
|
||||
srcs = pips_srcs_dsts["srcs"]
|
||||
dsts = pips_srcs_dsts["dsts"]
|
||||
|
||||
for pip, src_dst in pipdata.items():
|
||||
src, dst = src_dst
|
||||
if pip in ignpip:
|
||||
pass
|
||||
elif pip in pips:
|
||||
segmk.add_tile_tag(tile, "%s.%s" % (dst, src), 1)
|
||||
elif src_dst[1] not in dsts:
|
||||
segmk.add_tile_tag(tile, "%s.%s" % (dst, src), 0)
|
||||
|
||||
|
||||
def bitfilter(frame_idx, bit_idx):
|
||||
assert os.getenv("XRAY_DATABASE") in ["artix7", "kintex7"]
|
||||
if frame_idx in [30, 31]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
segmk.compile(bitfilter=bitfilter)
|
||||
segmk.write(allow_empty=True)
|
||||
|
|
@ -3,10 +3,13 @@ source "$::env(XRAY_DIR)/utils/utils.tcl"
|
|||
create_project -force -part $::env(XRAY_PART) design design
|
||||
|
||||
read_verilog $::env(FUZDIR)/top.v
|
||||
read_verilog $::env(FUZDIR)/picorv32.v
|
||||
synth_design -top top
|
||||
|
||||
set_property -dict "PACKAGE_PIN $::env(XRAY_PIN_00) IOSTANDARD LVCMOS33" [get_ports i]
|
||||
set_property -dict "PACKAGE_PIN $::env(XRAY_PIN_01) IOSTANDARD LVCMOS33" [get_ports o]
|
||||
set_property -dict "PACKAGE_PIN $::env(XRAY_PIN_00) IOSTANDARD LVCMOS33" [get_ports clk]
|
||||
set_property -dict "PACKAGE_PIN $::env(XRAY_PIN_01) IOSTANDARD LVCMOS33" [get_ports din]
|
||||
set_property -dict "PACKAGE_PIN $::env(XRAY_PIN_02) IOSTANDARD LVCMOS33" [get_ports dout]
|
||||
set_property -dict "PACKAGE_PIN $::env(XRAY_PIN_03) IOSTANDARD LVCMOS33" [get_ports stb]
|
||||
|
||||
create_pblock roi
|
||||
resize_pblock [get_pblocks roi] -add "$::env(XRAY_ROI)"
|
||||
|
|
@ -14,6 +17,8 @@ resize_pblock [get_pblocks roi] -add "$::env(XRAY_ROI)"
|
|||
set_property CFGBVS VCCO [current_design]
|
||||
set_property CONFIG_VOLTAGE 3.3 [current_design]
|
||||
set_property BITSTREAM.GENERAL.PERFRAMECRC YES [current_design]
|
||||
|
||||
set_property CLOCK_DEDICATED_ROUTE FALSE [get_nets clk_IBUF]
|
||||
set_param tcl.collectionResultDisplayLimit 0
|
||||
|
||||
place_design
|
||||
|
|
@ -21,7 +26,6 @@ route_design
|
|||
|
||||
# write_checkpoint -force design.dcp
|
||||
|
||||
|
||||
set fp [open "../../todo.txt" r]
|
||||
set todo_lines {}
|
||||
for {gets $fp line} {$line != ""} {gets $fp line} {
|
||||
|
|
@ -29,8 +33,8 @@ for {gets $fp line} {$line != ""} {gets $fp line} {
|
|||
}
|
||||
close $fp
|
||||
|
||||
set int_l_tiles [randsample_list [llength $todo_lines] [filter [pblock_tiles roi] {TYPE == INT_L}]]
|
||||
set int_r_tiles [randsample_list [llength $todo_lines] [filter [pblock_tiles roi] {TYPE == INT_R}]]
|
||||
set int_l_tiles [filter [pblock_tiles roi] {TYPE == INT_L}]]
|
||||
set int_r_tiles [filter [pblock_tiles roi] {TYPE == INT_R}]]
|
||||
|
||||
for {set idx 0} {$idx < [llength $todo_lines]} {incr idx} {
|
||||
set line [lindex $todo_lines $idx]
|
||||
|
|
@ -51,18 +55,37 @@ for {set idx 0} {$idx < [llength $todo_lines]} {incr idx} {
|
|||
set src_prefix [regsub {(.*/.).*} ${clb_src_pin} {\1}]
|
||||
set dst_prefix [regsub {(.*/.).*} ${clb_dst_pin} {\1}]
|
||||
|
||||
if {$src_prefix == $dst_prefix} {
|
||||
set slice [get_sites -of_objects $clb_dst_pin]
|
||||
set lut [regsub {.*/} $src_prefix {}]6LUT
|
||||
set slice [get_sites -of_objects $clb_dst_pin]
|
||||
set src_slice [get_sites -of_objects $clb_src_pin]
|
||||
set lut [regsub {.*/} $src_prefix {}]6LUT
|
||||
set dff [regsub {.*/} $src_prefix {}]FF
|
||||
|
||||
puts "=== $slice $lut ($clb_src_pin -> $clb_dst_pin)"
|
||||
set mynet [create_net mynet_$idx]
|
||||
set mylut [create_cell -reference LUT1 mylut_$idx]
|
||||
set lutin [regsub {.*(.)} $clb_dst_pin {A\1}]
|
||||
set_property -dict "LOC $slice BEL $lut LOCK_PINS I0:$lutin" $mylut
|
||||
|
||||
set mynet [create_net mynet_$idx]
|
||||
set mylut [create_cell -reference LUT1 mylut_$idx]
|
||||
set lutin [regsub {.*(.)} $clb_dst_pin {A\1}]
|
||||
set_property -dict "LOC $slice BEL $lut LOCK_PINS I0:$lutin" $mylut
|
||||
# some source wires may be FF outputs, in such cases
|
||||
# we need to place and route an FF
|
||||
|
||||
set src_type [regsub {.*/*(.$)} $clb_src_pin {\1}]
|
||||
if { $src_type == "Q" } {
|
||||
set mydff [create_cell -reference FDCE mydff_$idx]
|
||||
set_property -dict "LOC $src_slice BEL $dff" $mydff
|
||||
connect_net -net $mynet -objects "$mylut/I0 $mydff/Q"
|
||||
} else {
|
||||
connect_net -net $mynet -objects "$mylut/I0 $mylut/O"
|
||||
}
|
||||
|
||||
set route_list "$tile/$src_wire $tile/$dst_wire"
|
||||
puts "route_via $mynet $route_list"
|
||||
set rc [route_via $mynet $route_list 0]
|
||||
if {$rc != 0} {
|
||||
puts "SUCCESS"
|
||||
} else {
|
||||
puts "Manual routing failed"
|
||||
# TODO: We should probably fail here
|
||||
}
|
||||
}
|
||||
|
||||
proc write_txtdata {filename} {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,3 +1,93 @@
|
|||
module top (input i, output o);
|
||||
assign o = i;
|
||||
`include "setseed.vh"
|
||||
|
||||
module top(input clk, din, stb, output dout);
|
||||
reg [41:0] din_bits;
|
||||
wire [78:0] dout_bits;
|
||||
|
||||
reg [41:0] din_shr;
|
||||
reg [78:0] dout_shr;
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (stb) begin
|
||||
din_bits <= din_shr;
|
||||
dout_shr <= dout_bits;
|
||||
end else begin
|
||||
din_shr <= {din_shr, din};
|
||||
dout_shr <= {dout_shr, din_shr[41]};
|
||||
end
|
||||
end
|
||||
|
||||
assign dout = dout_shr[78];
|
||||
|
||||
roi roi (
|
||||
.clk(clk),
|
||||
.din_bits(din_bits),
|
||||
.dout_bits(dout_bits)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module roi(input clk, input [41:0] din_bits, output [78:0] dout_bits);
|
||||
picorv32 picorv32 (
|
||||
.clk(clk),
|
||||
.resetn(din_bits[0]),
|
||||
.mem_valid(dout_bits[0]),
|
||||
.mem_instr(dout_bits[1]),
|
||||
.mem_ready(din_bits[1]),
|
||||
.mem_addr(dout_bits[33:2]),
|
||||
.mem_wdata(dout_bits[66:34]),
|
||||
.mem_wstrb(dout_bits[70:67]),
|
||||
.mem_rdata(din_bits[33:2])
|
||||
);
|
||||
|
||||
randluts randluts (
|
||||
.din(din_bits[41:34]),
|
||||
.dout(dout_bits[78:71])
|
||||
);
|
||||
endmodule
|
||||
|
||||
module randluts(input [7:0] din, output [7:0] dout);
|
||||
localparam integer N =
|
||||
`SEED % 3 == 2 ? 250 :
|
||||
`SEED % 3 == 1 ? 100 : 10;
|
||||
|
||||
function [31:0] xorshift32(input [31:0] xorin);
|
||||
begin
|
||||
xorshift32 = xorin;
|
||||
xorshift32 = xorshift32 ^ (xorshift32 << 13);
|
||||
xorshift32 = xorshift32 ^ (xorshift32 >> 17);
|
||||
xorshift32 = xorshift32 ^ (xorshift32 << 5);
|
||||
end
|
||||
endfunction
|
||||
|
||||
function [63:0] lutinit(input [7:0] a, b);
|
||||
begin
|
||||
lutinit[63:32] = xorshift32(xorshift32(xorshift32(xorshift32({a, b} ^ `SEED))));
|
||||
lutinit[31: 0] = xorshift32(xorshift32(xorshift32(xorshift32({b, a} ^ `SEED))));
|
||||
end
|
||||
endfunction
|
||||
|
||||
wire [(N+1)*8-1:0] nets;
|
||||
|
||||
assign nets[7:0] = din;
|
||||
assign dout = nets[(N+1)*8-1:N*8];
|
||||
|
||||
genvar i, j;
|
||||
generate
|
||||
for (i = 0; i < N; i = i+1) begin:is
|
||||
for (j = 0; j < 8; j = j+1) begin:js
|
||||
localparam integer k = xorshift32(xorshift32(xorshift32(xorshift32((i << 20) ^ (j << 10) ^ `SEED)))) & 255;
|
||||
LUT6 #(
|
||||
.INIT(lutinit(i, j))
|
||||
) lut (
|
||||
.I0(nets[8*i+(k+0)%8]),
|
||||
.I1(nets[8*i+(k+1)%8]),
|
||||
.I2(nets[8*i+(k+2)%8]),
|
||||
.I3(nets[8*i+(k+3)%8]),
|
||||
.I4(nets[8*i+(k+4)%8]),
|
||||
.I5(nets[8*i+(k+5)%8]),
|
||||
.O(nets[8*i+8+j])
|
||||
);
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
MAKETODO_FLAGS=--re ".*" --not-endswith ".VCC_WIRE"
|
||||
GENERATE_FLAGS=--todo ../todo.txt
|
||||
include ../int_loop.mk
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,39 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from prjxray.segmaker import Segmaker
|
||||
import argparse
|
||||
|
||||
verbose = 1
|
||||
parser = argparse.ArgumentParser(description="Generate int segfiles")
|
||||
parser.add_argument(
|
||||
'--todo', action='store', default='../../todo.txt', help='todo file path')
|
||||
parser.add_argument(
|
||||
'--design',
|
||||
action='store',
|
||||
default='design.txt',
|
||||
help='design description file path')
|
||||
parser.add_argument('--verbose', action='store_true', help='')
|
||||
parser.add_argument(
|
||||
'--bits', action='store', default='design.bits', help='bits file path')
|
||||
|
||||
segmk = Segmaker("design.bits")
|
||||
args = parser.parse_args()
|
||||
segmk = Segmaker(args.bits)
|
||||
|
||||
verbose = args.verbose
|
||||
|
||||
tiledata = dict()
|
||||
pipdata = dict()
|
||||
ignpip = set()
|
||||
todo = set()
|
||||
|
||||
print("Loading todo from ../todo.txt.")
|
||||
with open("../../todo.txt", "r") as f:
|
||||
print("Loading todo from %s." % args.todo)
|
||||
with open(args.todo, "r") as f:
|
||||
for line in f:
|
||||
line = tuple(line.strip().split("."))
|
||||
verbose and print('todo', line)
|
||||
todo.add(line)
|
||||
|
||||
print("Loading tags from design.txt.")
|
||||
with open("design.txt", "r") as f:
|
||||
print("Loading tags from %s." % args.design)
|
||||
with open(args.design, "r") as f:
|
||||
for line in f:
|
||||
tile, pip, src, dst, pnum, pdir = line.split()
|
||||
_, pip = pip.split(".")
|
||||
|
|
@ -10,7 +10,6 @@ usage() {
|
|||
}
|
||||
|
||||
check_args=
|
||||
iter_pushdb=false
|
||||
end_pushdb=true
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
|
|
@ -19,11 +18,6 @@ while [[ $# -gt 0 ]]; do
|
|||
shift
|
||||
shift
|
||||
;;
|
||||
--iter-pushdb)
|
||||
iter_pushdb=true
|
||||
end_pushdb=false
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
|
|
@ -39,7 +33,6 @@ done
|
|||
# Quick solves are sloppy
|
||||
# Never push them in as they may be under solved
|
||||
if [ "$QUICK" = "Y" ] ; then
|
||||
iter_pushdb=false
|
||||
end_pushdb=false
|
||||
fi
|
||||
|
||||
|
|
@ -58,11 +51,7 @@ while true; do
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if ${MAKE} ITER=$i database; then
|
||||
if $iter_pushdb ; then
|
||||
${MAKE} pushdb
|
||||
fi
|
||||
fi;
|
||||
${MAKE} ITER=$i database
|
||||
if [ "$QUICK" = "Y" ] ; then
|
||||
break;
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ design_bits.ok: vivado.ok
|
|||
done
|
||||
touch design_bits.ok
|
||||
|
||||
generate.ok: design_bits.ok ${FUZDIR}/generate.py
|
||||
python3 ${FUZDIR}/generate.py
|
||||
generate.ok: design_bits.ok
|
||||
if [ -f ${FUZDIR}/generate.py ] ; then python3 ${FUZDIR}/generate.py ${GENERATE_FLAGS}; else python3 ${XRAY_DIR}/fuzzers/int_generate.py; fi
|
||||
touch generate.ok
|
||||
|
||||
|
|
|
|||
|
|
@ -6,5 +6,8 @@ set -ex
|
|||
|
||||
export FUZDIR=$PWD
|
||||
source ${XRAY_GENHEADER}
|
||||
|
||||
echo '`define SEED 32'"'h$(echo $1 | md5sum | cut -c1-8)" > setseed.vh
|
||||
|
||||
make -f $XRAY_DIR/utils/top_generate.mk
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue