Permalink
Browse files

merge

  • Loading branch information...
jameshegarty committed Dec 20, 2017
2 parents f8a6776 + 1946f3b commit 310511b1ecba1cee941177d210bc2e1a3d9bb3b5
View
@@ -1,6 +1,5 @@
SRCS = $(wildcard *.lua)
SRCS := $(filter-out harness.lua examplescommon.lua pyramid_core.lua harris_core.lua sift_core.lua sift_core_hw.lua campipe_core.lua descriptor_core.lua stereo_core.lua stereo_tr_core.lua lk_core.lua lk_tr_core.lua,$(SRCS))
METADATA = $(patsubst %.lua,out/%.metadata.lua,$(SRCS))
RIGEL_VERILATOR_INCLUDE ?= $(shell pkg-config --variable=includedir verilator)
@@ -261,20 +260,6 @@ out/%.axi.v: %.lua
out/%.verilator: out/%.v out/%.metadata.lua ../platform/verilator/harness.cpp
../platform/verilator/compile out/$*.v out/$*.metadata.lua out/$*_verilator $@
out/%.verilator.raw: out/%.verilator
$(eval $@_INPUT := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua inputImage))
$(eval $@_OUTW := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua outputWidth))
$(eval $@_OUTH := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua outputHeight))
$(eval $@_OUTBPP := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua outputBitsPerPixel))
$(eval $@_OUTP := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua outputP))
$(eval $@_INW := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua inputWidth))
$(eval $@_INH := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua inputHeight))
$(eval $@_INBPP := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua inputBitsPerPixel))
$(eval $@_INP := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua inputP))
$(eval $@_TAPBITS := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua tapBits))
$(eval $@_TAPVALUE := $(shell $(LUA) ../misc/extractMetadata.lua out/$*.metadata.lua tapValue))
./out/$*.verilator $($@_INPUT) $@ $($@_INW) $($@_INH) $($@_INBPP) $($@_INP) $($@_OUTW) $($@_OUTH) $($@_OUTBPP) $($@_OUTP) $($@_TAPBITS) $($@_TAPVALUE)
out/%.hz.txt: out/%.axi.bit
$(eval $@_HZl := $(shell grep Maximum out/build_$*/OUT_trce.txt | grep -P -o "[0-9.]+" | tail -1 | tr -d '\n' | awk '{print $$1" * 1000000"}' | bc -l | xargs printf "%d"))
echo $($@_HZl) > out/$*.hz.txt
View
@@ -276,14 +276,14 @@ local function siftKernel(dxdyType)
local descFn, descType = siftDescriptor(dxdyType)
local desc = R.apply("desc",RM.makeHandshake(descFn),dxdy)
local desc = R.apply("rseq",RM.liftHandshake(RM.liftDecimate(RM.reduceSeq(bucketReduce(descType,8),1/16)),"BUCKET"),desc)
local desc = R.apply("rseq",RM.liftHandshake(RM.liftDecimate(RM.reduceSeq(bucketReduce(descType,8),1/16))),desc)
-- it seems like we shouldn't need a FIFO here, but we do: the changeRate downstream will only be ready every 1/8 cycles.
-- We need a tiny fifo to hold the reduceseq output, to keep it from stalling. (the scheduling isn't smart enough to know
-- that reduceSeq only has an output every 16 cycles, so it can't overlap them)
local desc = C.fifoLoop(fifos,statements,types.array2d(descType,8),desc,1,"lol",true)
local desc = R.apply("up",RM.liftHandshake(RM.changeRate(descType,1,8,1),"CR"),desc)
local desc = R.apply("up",RM.liftHandshake(RM.changeRate(descType,1,8,1)),desc)
local desc = R.apply("upidx",RM.makeHandshake(C.index(types.array2d(descType,1),0,0)), desc)
-- sum and normalize the descriptors
@@ -326,14 +326,14 @@ function sift.siftKernel(dxdyType)
local descType = types.float(32)
local desc = R.apply("desc",RM.makeHandshake(descFn),dxdy)
local desc = R.apply("rseq",RM.liftHandshake(RM.liftDecimate(RM.reduceSeq( sift.bucketReduce(descTypeRed,8),1/16)),"BUCKET"),desc)
local desc = R.apply("rseq",RM.liftHandshake(RM.liftDecimate(RM.reduceSeq( sift.bucketReduce(descTypeRed,8),1/16))),desc)
-- it seems like we shouldn't need a FIFO here, but we do: the changeRate downstream will only be ready every 1/8 cycles.
-- We need a tiny fifo to hold the reduceseq output, to keep it from stalling. (the scheduling isn't smart enough to know
-- that reduceSeq only has an output every 16 cycles, so it can't overlap them)
local desc = C.fifoLoop(fifos,statements,types.array2d(descTypeRed,8),desc,128,"lol",false) -- fifo size can also be 1 (tested in SW)
local desc = R.apply("up",RM.liftHandshake(RM.changeRate(descTypeRed,1,8,1),"CR"),desc)
local desc = R.apply("up",RM.liftHandshake(RM.changeRate(descTypeRed,1,8,1)),desc)
local desc = R.apply("upidx",RM.makeHandshake(C.index(types.array2d(descTypeRed,1),0,0)), desc)
-- sum and normalize the descriptors
@@ -1,5 +1,5 @@
ffi = require "ffi"
require "common"
local ffi = require "ffi"
local J = require "common"
ffi.cdef[[
typedef struct {} FILE;
@@ -44,7 +44,7 @@ function loadRigelImage(rawfile, metafile)
if string.find(metadata.type,"_")~=nil then
-- this is a fixed type
bitstring = explode("_",bitstring)
bitstring = J.explode("_",bitstring)
bits = tonumber(bitstring[1])
shift = tonumber(bitstring[2])
else
@@ -53,16 +53,16 @@ function loadRigelImage(rawfile, metafile)
if bits<=8 then
bytes = 1
FFIDATATYPE = sel(signed,"char","unsigned char")
FFIDATATYPE = J.sel(signed,"char","unsigned char")
elseif bits <=16 then
bytes = 2
FFIDATATYPE = sel(signed,"short","unsigned short")
FFIDATATYPE = J.sel(signed,"short","unsigned short")
elseif bits <=32 then
bytes = 4
FFIDATATYPE = sel(signed,"int","unsigned int")
FFIDATATYPE = J.sel(signed,"int","unsigned int")
elseif bits <=64 then
bytes = 8
FFIDATATYPE = sel(signed,"long","unsigned long")
FFIDATATYPE = J.sel(signed,"long","unsigned long")
else
assert(false)
end
View
@@ -1,3 +1,4 @@
local ffi = require "ffi"
require "comparecommon"
if type(arg[4])~="string" then
@@ -124,6 +124,7 @@ int main(int argc, char *argv[]) {
unsigned int lenOutRaw = outputW*outputH*outputBytesPerPixel+128;
unsigned int lenOut = lenOutRaw;
// HW pads to next largest axi burst size (128 bytes)
if (lenIn%(8*16)!=0){
lenIn = lenInRaw + (8*16-(lenInRaw % (8*16)));
}
@@ -175,7 +176,7 @@ int main(int argc, char *argv[]) {
//usleep(10000);
sleep(2); // this sleep needs to be 2 for the z100, but 1 for the z20
saveImage(argv[3],ptr+lenIn,lenOut);
saveImage(argv[3],ptr+lenIn,lenOutRaw);
munmap( gpioptr, page_size );
munmap( ptr, lenIn+lenOut );
View
@@ -76,15 +76,27 @@ return fn
if R.extractData(fn.inputType):isArray()==false then out = R.apply("harnessPW",RM.makeHandshake(C.index(types.array2d(iover,1),0)),out) end
out = R.apply("HarnessHSFN",fn,out) --{input=out, toModule=fn}
if R.extractData(fn.outputType):isArray()==false then out = R.apply("harnessPW0",RM.makeHandshake(C.arrayop(oover,1)),out) end
local targetOutputP = (64/oover:verilogBits())
J.err( targetOutputP==math.floor(targetOutputP), "axiRateWrapper error: output type does not divide evenly into axi bus size")
if outputP==1 and oover:verilogBits()>64 then
-- we're writing a huge sized output
J.err( oover:verilogBits()%64==0, "output bitwidth is not divisible by bus width (64)")
local divs = oover:verilogBits() / 64
if fn.outputType:verilogBits()~=64 then
out = R.apply("harnessCREnd", RM.liftHandshake(RM.changeRate(oover,1,outputP,targetOutputP)),out)
end
-- out = R.apply("cast1",RM.makeHandshake(C.cast(oover,types.bits(oover:verilogBits()))), out)
out = R.apply("cast",RM.makeHandshake(C.cast(types.bits(oover:verilogBits()),types.array2d(types.bits(64),divs))), out)
out = R.apply("down",RM.liftHandshake(RM.changeRate(types.bits(64),1,divs,1)),out)
else
if R.extractData(fn.outputType):isArray()==false then out = R.apply("harnessPW0",RM.makeHandshake(C.arrayop(oover,1)),out) end
local targetOutputP = (64/oover:verilogBits())
J.err( targetOutputP==math.floor(targetOutputP), "axiRateWrapper error: output type ("..tostring(fn.outputType)..") does not divide evenly into axi bus size")
if fn.outputType:verilogBits()~=64 then
out = R.apply("harnessCREnd", RM.liftHandshake(RM.changeRate(oover,1,outputP,targetOutputP)),out)
end
end
local outFn = RM.lambda("hsfnAxiRateWrapper",inp,out)
J.err( R.extractData(outFn.inputType):verilogBits()==64, "axi rate wrapper: failed to make input type 64 bit (originally "..tostring(fn.inputType)..")")
@@ -93,13 +105,16 @@ return fn
return outFn
end
local function harnessAxi( hsfn, inputCount, outputCount, underflowTest, inputType, earlyOverride)
local outputBytes = J.upToNearest(128,outputCount*8) -- round to axi burst
local inputBytes = J.upToNearest(128,inputCount*8) -- round to axi burst
local function harnessAxi( hsfn, inputCountArg, outputCountArg, underflowTest, inputType, earlyOverride)
local outputBytes = J.upToNearest(128,outputCountArg*8) -- round to axi burst
local inputBytes = J.upToNearest(128,inputCountArg*8) -- round to axi burst
J.err(outputBytes==outputCount*8, "NYI - non-burst-aligned output counts, "..tostring(outputCount))
J.err(inputBytes==inputCount*8, "NYI - non-burst-aligned input counts")
--J.err(outputBytes==outputCount*8, "NYI - non-burst-aligned output counts, "..tostring(outputCount))
--J.err(inputBytes==inputCount*8, "NYI - non-burst-aligned input counts, "..tostring(inputCount))
local inputCount = inputBytes/8
local outputCount = outputBytes/8
local ITYPE = inputType
local inpSymb = R.input( R.Handshake(R.extractData(ITYPE)) )
@@ -177,9 +192,9 @@ end
-- add axi harness
local globals = {}
if metadata.tapBits>0 then
globals[R.newGlobal("taps","input",types.uint(metadata.tapBits),0)] = 1
globals[R.newGlobal("taps","input",types.bits(metadata.tapBits),0)] = 1
end
local hsfnorig = RM.liftVerilog( metadata.topModule, R.Handshake(types.uint(metadata.inputBitsPerPixel*metadata.inputP)), R.Handshake(types.uint(metadata.outputBitsPerPixel*metadata.outputP)), readAll(VERILOGFILE), globals, {{metadata.sdfInputN,metadata.sdfInputD}}, {{metadata.sdfOutputN,metadata.sdfOutputD}})
local hsfnorig = RM.liftVerilog( metadata.topModule, R.Handshake(types.bits(metadata.inputBitsPerPixel*metadata.inputP)), R.Handshake(types.bits(metadata.outputBitsPerPixel*metadata.outputP)), readAll(VERILOGFILE), globals, {{metadata.sdfInputN,metadata.sdfInputD}}, {{metadata.sdfOutputN,metadata.sdfOutputD}})
local hsfn = axiRateWrapper(hsfnorig)
local iRatio, oRatio = R.extractData(hsfn.inputType):verilogBits()/R.extractData(hsfnorig.inputType):verilogBits(), R.extractData(hsfn.outputType):verilogBits()/R.extractData(hsfnorig.outputType):verilogBits()
--print("IRATIO",iRatio,oRatio,metadata.inputP,metadata.outputP)
@@ -197,7 +212,7 @@ hsfn, inputBytes, outputBytes = harnessAxi( hsfn, inputCount, outputCount, metad
J.err(R.extractData(hsfn.inputType):verilogBits()==64, "axi input must be 64 bits")
J.err(R.extractData(hsfn.outputType):verilogBits()==64, "axi output must be 64 bits")
local axiv = readAll("../platform/axi/axi.v")
local axiv = readAll(PLATFORMDIR.."/axi/axi.v")
axiv = string.gsub(axiv,"___PIPELINE_MODULE_NAME","harnessaxi")
--local inputCount = (metadata.inputWidth*metadata.inputHeight)/metadata.inputP
@@ -230,7 +245,7 @@ else
axiv = string.gsub(axiv,"___PIPELINE_TAPINPUT","")
end
verilogStr = (hsfn:toVerilog())..readAll("../platform/axi/ict106_axilite_conv.v")..readAll("../platform/axi/conf.v")..readAll("../platform/axi/dramreader.v")..readAll("../platform/axi/dramwriter.v")..axiv
verilogStr = (hsfn:toVerilog())..readAll(PLATFORMDIR.."/axi/ict106_axilite_conv.v")..readAll(PLATFORMDIR.."/axi/conf.v")..readAll(PLATFORMDIR.."/axi/dramreader.v")..readAll(PLATFORMDIR.."/axi/dramwriter.v")..axiv
io.output(OUTFILE)
io.write(verilogStr)
View
@@ -0,0 +1,25 @@
#!/bin/bash
BITFILE=$1
BITFILE_BASE=$(basename $1)
METAFILE=$2
OUTFILE=$3
OUTPATH=$4
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LUA=$DIR/../../rigelLuajit
INPUT=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputImage)
OUTW=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE outputWidth)
OUTH=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE outputHeight)
OUTBPP=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE outputBitsPerPixel)
OUTP=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE outputP)
INW=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputWidth)
INH=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputHeight)
INBPP=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputBitsPerPixel)
INP=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputP)
TAPBITS=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE tapBits)
TAPVALUE=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE tapValue)
$BITFILE $INPUT $OUTFILE $INW $INH $INBPP $INP $OUTW $OUTH $OUTBPP $OUTP $TAPBITS $TAPVALUE
View
@@ -10,17 +10,18 @@ METAFILE=$2
OUTFILE=$3
OUTPATH=$4
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LUA=../rigelLuajit
LUA=$DIR/../../rigelLuajit
#out/%.axi.raw: out/%.axi.bit out/%.hz.txt out/%.axi.metadata.lua
IMG=$($LUA ../misc/extractMetadata.lua $METAFILE inputImage)
INW=$($LUA ../misc/extractMetadata.lua $METAFILE inputWidth)
INH=$($LUA ../misc/extractMetadata.lua $METAFILE inputHeight)
BPP_IN=$($LUA ../misc/extractMetadata.lua $METAFILE inputBitsPerPixel)
BPP_OUT=$($LUA ../misc/extractMetadata.lua $METAFILE outputBitsPerPixel)
OUTW=$($LUA ../misc/extractMetadata.lua $METAFILE outputWidth)
OUTH=$($LUA ../misc/extractMetadata.lua $METAFILE outputHeight)
IMG=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputImage)
INW=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputWidth)
INH=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputHeight)
BPP_IN=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE inputBitsPerPixel)
BPP_OUT=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE outputBitsPerPixel)
OUTW=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE outputWidth)
OUTH=$($LUA $DIR/../../misc/extractMetadata.lua $METAFILE outputHeight)
###### SET THE CLOCK
#HZ=$(cat $OUTPATH.hz.txt)
#lockfile /tmp/zynq10lock
@@ -30,7 +31,7 @@ OUTH=$($LUA ../misc/extractMetadata.lua $METAFILE outputHeight)
# sshpass -p 'root' ssh root@$ZYNQ_ADDR "cat /sys/class/fclk/fclk0/set_rate" > out/$*.realhz.txt
###### CLOCK STUFF END
sshpass -p 'root' scp ../platform/axi/processimage $BITFILE $IMG root@$ZYNQ_ADDR:$ZYNQ_WRITE_PATH
sshpass -p 'root' scp $DIR/../axi/processimage $BITFILE $IMG root@$ZYNQ_ADDR:$ZYNQ_WRITE_PATH
sshpass -p 'root' ssh root@$ZYNQ_ADDR "cat $ZYNQ_WRITE_PATH/$BITFILE_BASE > /dev/xdevcfg"
sshpass -p 'root' ssh root@$ZYNQ_ADDR "$ZYNQ_WRITE_PATH/processimage 805339136 $ZYNQ_WRITE_PATH/$IMG $ZYNQ_WRITE_PATH/out.raw $INW $INH $BPP_IN $OUTW $OUTH $BPP_OUT "
sshpass -p 'root' scp root@$ZYNQ_ADDR:$ZYNQ_WRITE_PATH/out.raw $OUTFILE
@@ -5,12 +5,14 @@ METADATA_FILE=$2
BUILDDIR=$3
OUTFILE=$4
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
mkdir -p $BUILDDIR
../rigelLuajit ../platform/axi/wrapper.lua $VERILOG_FILE $METADATA_FILE $VERILOG_FILE.wrapper.v ../../platform/
$DIR/../../rigelLuajit $DIR/../../platform/axi/wrapper.lua $VERILOG_FILE $METADATA_FILE $VERILOG_FILE.wrapper.v $DIR/../../platform/
cd $BUILDDIR
echo "read_verilog $VERILOG_FILE.wrapper.v" > system.tcl
echo "read_xdc ../../../platform/zynq10vivado/zybo.xdc" >> system.tcl
echo "read_xdc ../../../platform/vivado/ps7_constraints.xdc" >> system.tcl
echo "read_xdc $DIR/../zynq10vivado/zybo.xdc" >> system.tcl
echo "read_xdc $DIR/../vivado/ps7_constraints.xdc" >> system.tcl
echo "synth_design -top stage -part xc7z010clg400-1" >> system.tcl
echo "opt_design" >> system.tcl
echo "place_design" >> system.tcl
@@ -22,6 +24,6 @@ echo "report_timing_summary" >> system.tcl
echo "report_utilization -hierarchical -file utilization_h.txt" >> system.tcl
echo "report_utilization -file utilization.txt" >> system.tcl
vivado -mode batch -source 'system.tcl' -nojournal -log 'vivado.log' > /dev/null
bootgen -image ../../../platform/axi/boot.bif -w -process_bitstream bin
bootgen -image $DIR/../axi/boot.bif -w -process_bitstream bin
cp system.bit.bin $OUTFILE
View
@@ -335,8 +335,8 @@ function darkroom.newFunction(tab)
err( types.isType(tab.inputType), "rigel.newFunction: input type must be type" )
err( types.isType(tab.outputType), "rigel.newFunction: output type must be type ("..tab.kind..")" )
if tab.inputType:isArray() or tab.inputType:isTuple() then assert(darkroom.isBasic(tab.inputType)) end
if tab.outputType:isArray() or tab.outputType:isTuple() then assert(darkroom.isBasic(tab.outputType)) end
if tab.inputType:isArray() or tab.inputType:isTuple() then err(darkroom.isBasic(tab.inputType),"array/tup module input is not over a basic type?") end
if tab.outputType:isArray() or tab.outputType:isTuple() then err(darkroom.isBasic(tab.outputType)) end
if tab.globals==nil then tab.globals={} end
if tab.globalMetadata==nil then tab.globalMetadata={} end
Oops, something went wrong.

0 comments on commit 310511b

Please sign in to comment.