Skip to content

Commit

Permalink
Merge 59023eb into b2b12d1
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshegarty committed Mar 1, 2019
2 parents b2b12d1 + 59023eb commit cd0641b
Show file tree
Hide file tree
Showing 89 changed files with 2,751 additions and 1,605 deletions.
9 changes: 6 additions & 3 deletions examples/conv_wide_handshake_taps.lua
Expand Up @@ -33,17 +33,20 @@ local STTYPE = types.array2d( types.uint(8), ConvWidth, ConvWidth )

local tapValue = range(ConvArea)

soc.taps = R.newGlobal("taps","input",STTYPE,tapValue)
--soc.taps = R.newGlobal("taps","input",STTYPE,tapValue)
local regs = soc.regStub{taps={STTYPE,tapValue}}:instantiate("taps")
regs.extern = true

local ITYPE = STTYPE
inp = R.input( ITYPE )
local tapv = R.readGlobal("tg",soc.taps)
packed = R.apply( "packedtup", C.SoAtoAoS(ConvWidth,ConvWidth,{types.uint(8),types.uint(8)}), R.concat("tc",{inp,tapv}) )
--local tapv = R.readGlobal("tg",regs.coeffs)
packed = R.apply( "packedtup", C.SoAtoAoS(ConvWidth,ConvWidth,{types.uint(8),types.uint(8)}), R.concat("tc",{inp,regs.taps()}) )
conv = R.apply( "partial", RM.map( partial, ConvWidth, ConvWidth ), packed )
conv = R.apply( "sum", RM.reduce( reduceSumInt32, ConvWidth, ConvWidth ), conv )
conv = R.apply( "touint8", touint8, conv )

convolve = RM.lambda( "convolve", inp, conv )
print(convolve)
-------------
BASE_TYPE = types.array2d( types.uint(8), T )
ITYPE = BASE_TYPE
Expand Down
6 changes: 4 additions & 2 deletions examples/convpadcrop_wide_handshake_4_1.lua
Expand Up @@ -42,7 +42,9 @@ function MAKE(T,ConvWidth,size1080p,NOSTALL)
local outputH = inputH

local TAP_TYPE = types.array2d( types.uint(8), ConvWidth, ConvWidth )
soc.taps = R.newGlobal("taps","input",TAP_TYPE,J.range(ConvWidth*ConvWidth))
--soc.taps = R.newGlobal("taps","input",TAP_TYPE,J.range(ConvWidth*ConvWidth))
local taps = soc.regStub{taps={TAP_TYPE,J.range(ConvWidth*ConvWidth)}}:instantiate("taps")
taps.extern = true
-------------
-------------
local convKernel = C.convolveTaps( types.uint(8), ConvWidth, J.sel(ConvWidth==4,7,11))
Expand Down Expand Up @@ -73,7 +75,7 @@ function MAKE(T,ConvWidth,size1080p,NOSTALL)
out1 = R.apply("out1fifo",C.fifo(BASE_TYPE,128),out1)

local trig = R.apply("trig", RM.makeHandshake(C.valueToTrigger(BASE_TYPE),nil,true), out0)
local tapinp = R.apply("RT", RM.makeHandshake(C.readTap(soc.taps),nil,true), trig)
local tapinp = R.apply("RT", RM.makeHandshake(taps.taps,nil,true), trig)

local convpipeinp = R.apply("CPI", RM.packTuple({BASE_TYPE,TAP_TYPE}), R.concat("CONVPIPEINP",{out1,tapinp}))

Expand Down
6 changes: 4 additions & 2 deletions examples/edge.lua
Expand Up @@ -23,7 +23,9 @@ OTYPE = types.array2d( types.array2d(types.uint(8),4), 2 )
--local TTYPE = types.array2d( types.uint(32), 4 ):makeConst()
local TTYPE = types.uint(32)
local TAPVALUE =10
soc.taps = R.newGlobal("taps","input",TTYPE,TAPVALUE)
--soc.taps = R.newGlobal("taps","input",TTYPE,TAPVALUE)
local taps = soc.regStub{taps={TTYPE,TAPVALUE}}:instantiate("taps")
taps.extern = true

TAPS = false

Expand Down Expand Up @@ -107,7 +109,7 @@ local out = R.apply("bf",blurfn,out)
local out = R.apply("ef",edgefn,out)

if TAPS then
out = R.apply("oack",RM.makeHandshake(C.packTapBroad(types.array2d(types.uint(8),T),TTYPE,soc.taps,T)),out)
out = R.apply("oack",RM.makeHandshake(C.packTapBroad(types.array2d(types.uint(8),T),TTYPE,taps.taps,T)),out)
out = R.apply("SOS",RM.makeHandshake(RM.SoAtoAoS(2,1,{types.uint(8),TTYPE})),out)
end

Expand Down
2 changes: 1 addition & 1 deletion examples/gold/soc_15x15.terra.cycles.txt
@@ -1 +1 @@
292
293
2 changes: 1 addition & 1 deletion examples/gold/soc_15x15x15.terra.cycles.txt
@@ -1 +1 @@
422
423
2 changes: 1 addition & 1 deletion examples/gold/soc_2in.terra.cycles.txt
@@ -1 +1 @@
1035
1036
2 changes: 1 addition & 1 deletion examples/gold/soc_arbiter.terra.cycles.txt
@@ -1 +1 @@
1034
1035
2 changes: 1 addition & 1 deletion examples/gold/soc_convgen.terra.cycles.txt
@@ -1 +1 @@
2092822
2092823
2 changes: 1 addition & 1 deletion examples/gold/soc_convgenTaps.regout.lua
@@ -1 +1 @@
return {coeffs=4}
return {regs_coeffs=4}
2 changes: 1 addition & 1 deletion examples/gold/soc_convgenTaps.terra.cycles.txt
@@ -1 +1 @@
2092822
2092823
2 changes: 1 addition & 1 deletion examples/gold/soc_convtest.terra.cycles.txt
@@ -1 +1 @@
7144
7145
2 changes: 1 addition & 1 deletion examples/gold/soc_filterseq.terra.cycles.txt
@@ -1 +1 @@
8038
8039
2 changes: 1 addition & 1 deletion examples/gold/soc_filterseq8.terra.cycles.txt
@@ -1 +1 @@
1294
1295
2 changes: 1 addition & 1 deletion examples/gold/soc_flip.terra.cycles.txt
@@ -1 +1 @@
1040
1041
2 changes: 1 addition & 1 deletion examples/gold/soc_parread.terra.cycles.txt
@@ -1 +1 @@
537
538
2 changes: 1 addition & 1 deletion examples/gold/soc_read.terra.cycles.txt
@@ -1 +1 @@
3900
3901
2 changes: 1 addition & 1 deletion examples/gold/soc_redu1024.terra.cycles.txt
@@ -1 +1 @@
1045
1046
2 changes: 1 addition & 1 deletion examples/gold/soc_redu16384.terra.cycles.txt
@@ -1 +1 @@
16459
16460
2 changes: 1 addition & 1 deletion examples/gold/soc_redu2048.terra.cycles.txt
@@ -1 +1 @@
2080
2081
2 changes: 1 addition & 1 deletion examples/gold/soc_redu32768.terra.cycles.txt
@@ -1 +1 @@
32843
32844
2 changes: 1 addition & 1 deletion examples/gold/soc_redu4096.terra.cycles.txt
@@ -1 +1 @@
4142
4143
2 changes: 1 addition & 1 deletion examples/gold/soc_redu8192.terra.cycles.txt
@@ -1 +1 @@
8266
8267
2 changes: 1 addition & 1 deletion examples/gold/soc_regin.regout.lua
@@ -1 +1 @@
return {offset=200}
return {regs_offset=200}
2 changes: 1 addition & 1 deletion examples/gold/soc_regin.terra.cycles.txt
@@ -1 +1 @@
1034
1035
2 changes: 1 addition & 1 deletion examples/gold/soc_regout.regout.lua
@@ -1 +1 @@
return {lastPx=33,offset=200}
return {regs_lastPx=33,regs_offset=200}
2 changes: 1 addition & 1 deletion examples/gold/soc_regout.terra.cycles.txt
@@ -1 +1 @@
8206
8207
2 changes: 1 addition & 1 deletion examples/gold/soc_simple.terra.cycles.txt
@@ -1 +1 @@
1043
1044
2 changes: 1 addition & 1 deletion examples/gold/soc_simple_uniform.regout.lua
@@ -1 +1 @@
return {readAddress=805339136,writeAddress=805347328}
return {regs_readAddress=805339136,regs_writeAddress=805347328}
2 changes: 1 addition & 1 deletion examples/gold/soc_simple_uniform.terra.cycles.txt
@@ -1 +1 @@
1038
1039
2 changes: 1 addition & 1 deletion examples/gold/soc_sort.terra.cycles.txt
@@ -1 +1 @@
1045
1046
2 changes: 1 addition & 1 deletion examples/gold/soc_tokencounter.regout.lua
@@ -1 +1 @@
return {startCnt=16384,endCnt=4096}
return {regs_startCnt=16384,regs_endCnt=4096}
2 changes: 1 addition & 1 deletion examples/gold/soc_tokencounter.terra.cycles.txt
@@ -1 +1 @@
8077
8078
2 changes: 1 addition & 1 deletion examples/gold/soc_unaligned.terra.cycles.txt
@@ -1 +1 @@
156
157
2 changes: 1 addition & 1 deletion examples/gold/soc_underflow.terra.cycles.txt
@@ -1 +1 @@
8342
8343
5 changes: 3 additions & 2 deletions examples/pyramid_core.lua
Expand Up @@ -71,10 +71,11 @@ end
local convolvefntaps = C.convolveTaps( types.uint(8), TConvWidth, 6 )

-- DUMB_DOWNSAMPLE: instead of doing the convolution at internalT/4 throughput when downsampling, do it at internalT throughput.
function P.pyramidIterTaps(i,doDownsample,internalT,W,H,ConvWidth,nofifo,DUMB_DOWNSAMPLE,X)
function P.pyramidIterTaps(i,doDownsample,internalT,W,H,ConvWidth,nofifo,DUMB_DOWNSAMPLE,taps,X)
assert(type(ConvWidth)=="number")
assert(type(nofifo)=="boolean")
assert(type(DUMB_DOWNSAMPLE)=="boolean")
assert(R.isFunction(taps))
assert(X==nil)

local DATA_TYPE = types.array2d(A,internalT)
Expand Down Expand Up @@ -134,7 +135,7 @@ function P.pyramidIterTaps(i,doDownsample,internalT,W,H,ConvWidth,nofifo,DUMB_DO
--local st_tap_inp = R.apply( "broad", RM.makeHandshake(C.broadcast(TAP_TYPE,convT)), tapinp )
--st_tap_inp = R.concat("sttapinp",{out,st_tap_inp})
--st_tap_inp = R.apply("ST",C.SoAtoAoSHandshake(convT,1,{st_type,TAP_TYPE}),st_tap_inp)
out = R.apply("PT", RM.makeHandshake(C.packTapBroad(types.array2d(st_type,convT),TAP_TYPE,soc.taps,convT)), out)
out = R.apply("PT", RM.makeHandshake(C.packTapBroad(types.array2d(st_type,convT),TAP_TYPE,taps,convT)), out)
out = R.apply("SOA",RM.makeHandshake(RM.SoAtoAoS(convT,1,{st_type,TAP_TYPE})),out)
out = R.apply("conv_", RM.makeHandshake(RM.map(convolvefntaps,convT)), out)

Expand Down
8 changes: 5 additions & 3 deletions examples/pyramid_taps_1.lua
Expand Up @@ -9,7 +9,7 @@ local SDFRate = require "sdfrate"
local J = require "common"
local soc = require "soc"

R.SDF=false
--R.SDF=false

internalT = 4 -- internal throughput
outputT = 8
Expand Down Expand Up @@ -38,7 +38,9 @@ end

--local TAP_TYPE = types.array2d( types.uint(8), ConvWidth, ConvWidth ):makeConst() XXX
local TAP_TYPE = types.array2d( types.uint(8), ConvWidth, ConvWidth )
soc.taps = R.newGlobal("taps","input",TAP_TYPE,P.G)
--soc.taps = R.newGlobal("taps","input",TAP_TYPE,P.G)
local taps = soc.regStub{taps={TAP_TYPE,P.G}}:instantiate("taps")
taps.extern = true

local DATA_TYPE = types.array2d(A,8)
local HST = DATA_TYPE
Expand All @@ -64,7 +66,7 @@ local statements = {}

for depth=1,TARGET_DEPTH do

local PI = P.pyramidIterTaps( depth, depth>1, internalT, curW, curH, ConvWidth, NOFIFO, true )
local PI = P.pyramidIterTaps( depth, depth>1, internalT, curW, curH, ConvWidth, NOFIFO, true, taps.taps )

-- local out0, out1 = RS.fanOut{input=out,branches=2}

Expand Down
6 changes: 4 additions & 2 deletions examples/pyramid_tr_1.lua
Expand Up @@ -34,7 +34,9 @@ if LARGE then
end

local TAP_TYPE = types.array2d( types.uint(8), ConvWidth, ConvWidth )
soc.taps = R.newGlobal("taps","input",TAP_TYPE,P.G)
--soc.taps = R.newGlobal("taps","input",TAP_TYPE,P.G)
local taps = soc.regStub{taps={TAP_TYPE,P.G}}:instantiate("taps")
taps.extern = true

local DATA_TYPE = types.array2d(A,8)
--local HST = types.tuple{DATA_TYPE,TAP_TYPE}
Expand Down Expand Up @@ -77,7 +79,7 @@ for depth=1,TARGET_DEPTH do
local PI

if curT>1 then
PI = P.pyramidIterTaps(depth,depth>1,curT,curW,curH,ConvWidth,NOFIFO,false)
PI = P.pyramidIterTaps(depth,depth>1,curT,curW,curH,ConvWidth,NOFIFO,false,taps.taps)
--local piinp = R.apply("CPI"..depth, RM.packTuple({types.array2d(A,curT),TAP_TYPE}), R.concat("CONVPIPEINP"..depth,out))
out = R.apply("p"..depth, PI, out)
else
Expand Down
13 changes: 8 additions & 5 deletions examples/soc_15x15.lua
Expand Up @@ -8,8 +8,11 @@ local RM = require "modules"
require "types".export()
local types = require "types"
local SDF = require "sdf"
local Zynq = require "zynq"

regs = SOC.axiRegs({},SDF{1,256}):instantiate()
noc = Zynq.SimpleNOC():instantiate("ZynqNOC")
noc.extern=true
regs = SOC.axiRegs({},SDF{1,256},noc.readSource,noc.readSink,noc.writeSource,noc.writeSink):instantiate("regs")

------------
inp = R.input( types.uint(8) )
Expand All @@ -19,9 +22,9 @@ p200 = RM.lambda( "p200", inp, b )
------------
hsfn = RM.makeHandshake(p200)

harness{
harness({
regs.start,
SOC.readBurst("15x15.raw",15,15,u(8),0),
SOC.readBurst("15x15.raw",15,15,u(8),0,nil,nil,noc.read),
hsfn,
SOC.writeBurst("out/soc_15x15",15,15,u(8),0),
regs.done}
SOC.writeBurst("out/soc_15x15",15,15,u(8),0,nil,noc.write),
regs.done},nil,{regs})
11 changes: 7 additions & 4 deletions examples/soc_15x15x15.lua
Expand Up @@ -8,8 +8,11 @@ local RM = require "modules"
require "types".export()
local types = require "types"
local SDF = require "sdf"
local Zynq = require "zynq"

regs = SOC.axiRegs({},SDF{1,240}):instantiate()
noc = Zynq.SimpleNOC():instantiate("ZynqNOC")
noc.extern=true
regs = SOC.axiRegs({},SDF{1,240},noc.readSource,noc.readSink,noc.writeSource,noc.writeSink):instantiate("regs")

------------
inp = R.input( types.uint(8) )
Expand All @@ -21,7 +24,7 @@ p200 = RM.lambda( "p200", inp, b )

harness({
regs.start,
SOC.readBurst("15x15.raw",15,15,u(8),15),
SOC.readBurst("15x15.raw",15,15,u(8),15,nil,nil,noc.read),
G.HS{G.Map{p200}},
SOC.writeBurst("out/soc_15x15x15",15,15,u(8),15),
regs.done},{cycles=800})
SOC.writeBurst("out/soc_15x15x15",15,15,u(8),15,nil,noc.write),
regs.done},{cycles=800},{regs})
13 changes: 8 additions & 5 deletions examples/soc_2in.lua
Expand Up @@ -7,18 +7,21 @@ local RM = require "modules"
local G = require "generators"
require "types".export()
local SDF = require "sdf"
local Zynq = require "zynq"

regs = SOC.axiRegs({},SDF{1,1024}):instantiate()
noc = Zynq.SimpleNOC(2):instantiate("ZynqNOC")
noc.extern=true
regs = SOC.axiRegs({},SDF{1,1024},noc.readSource,noc.readSink,noc.writeSource,noc.writeSink):instantiate()

local inp = R.input(R.HandshakeTrigger)
local inp0, inp1 = RS.fanOut{input=inp,branches=2}
local a = SOC.readBurst("frame_128.raw",128,64,u(8),8)(inp0)
local bb = SOC.readBurst("frame_128_inv.raw",128,64,u(8),8)(inp1)
local a = SOC.readBurst("frame_128.raw",128,64,u(8),8,nil,nil,noc.read)(inp0)
local bb = SOC.readBurst("frame_128_inv.raw",128,64,u(8),8,nil,nil,noc.read1)(inp1)
local out = G.FanIn{true}(a,bb)
out = RS.HS(RM.SoAtoAoS(8,1,{u(8),u(8)}))(out)
out = RS.HS(RM.map(C.sum(u(8),u(8),u(8)),8))(out)
--out = RS.HS(C.cast(ar(u(8),8),b(64)))(out)
out = SOC.writeBurst("out/soc_2in",128,64,u(8),8)(out)
out = SOC.writeBurst("out/soc_2in",128,64,u(8),8,nil,noc.write)(out)

local fn = RM.lambda("FN",inp,out)
harness{regs.start,fn,regs.done}
harness({regs.start,fn,regs.done},nil,{regs})
13 changes: 8 additions & 5 deletions examples/soc_arbiter.lua
Expand Up @@ -7,18 +7,21 @@ local RS = require "rigelSimple"
local types = require "types"
local SDF = require "sdf"
types.export()
local Zynq = require "zynq"

regs = SOC.axiRegs({},SDF{1,1024}):instantiate()
noc = Zynq.SimpleNOC():instantiate("ZynqNOC")
noc.extern=true
local regs = SOC.axiRegs({},SDF{1,1024},noc.readSource,noc.readSink,noc.writeSource,noc.writeSink):instantiate("regs")

OffsetModule = G.Module{ "OffsetModule", R.HandshakeTrigger,
local OffsetModule = G.Module{ "OffsetModule", R.HandshakeTrigger,
function(i)
local readStream = G.AXIReadBurst{"frame_128.raw",{128,64},u(8),8}(i)
local readStream = G.AXIReadBurst{"frame_128.raw",{128,64},u(8),8,noc.read}(i)
local rb = G.FanOut{2}(readStream)
local rb0 = G.HS{G.Crop{{0,96,0,0}}}(rb[0])
local rb1 = G.HS{G.Crop{{96,0,0,0}}}(rb[1])
local arb = G.Arbitrate(R.concatArray2d("cca2",{G.StripFramed(rb0),G.StripFramed(rb1)},2))
return G.AXIWriteBurstSeq{"out/soc_arbiter",{64,64},8}(arb)
return G.AXIWriteBurstSeq{"out/soc_arbiter",{64,64},8,noc.write}(arb)
end}


harness{regs.start, OffsetModule, regs.done}
harness({regs.start, OffsetModule, regs.done},nil,{regs})
13 changes: 8 additions & 5 deletions examples/soc_convgen.lua
Expand Up @@ -7,14 +7,17 @@ local C = require "examplescommon"
local SDF = require "sdf"
require "generators".export()
require "types".export()
local Zynq = require "zynq"

local ConvWidth = 4
local ConvRadius = ConvWidth/2

inSize = { 1920, 1080 }
padSize = { 1920+16, 1080+3 }

regs = SOC.axiRegs({},SDF{1,padSize[1]*padSize[2]}):instantiate()
noc = Zynq.SimpleNOC():instantiate("ZynqNOC")
noc.extern=true
regs = SOC.axiRegs({},SDF{1,padSize[1]*padSize[2]},noc.readSource,noc.readSink,noc.writeSource,noc.writeSink):instantiate("regs")

local conv = Module{ ar(u(8),ConvWidth,ConvWidth),
function(inp)
Expand All @@ -29,13 +32,13 @@ function(inp)
return RemoveMSBs{24}(Rshift{8}(res))
end}

harness{
harness({
regs.start,
SOC.readBurst("1080p.raw",1920,1080,u(8),1),
SOC.readBurst("1080p.raw",1920,1080,u(8),1,nil,nil,noc.read),
HS{Pad{inSize,1,{8,8,2,1}}},
-- RS.HS(C.print(ar(u(8),1))),
HS{Linebuffer{padSize,1,{3,0,3,0}}},
HS{Map{conv}},
HS{CropSeq{padSize,1,{9,7,3,0}}},
SOC.writeBurst("out/soc_convgen",1920,1080,u(8),1),
regs.done}
SOC.writeBurst("out/soc_convgen",1920,1080,u(8),1,nil,noc.write),
regs.done},nil,{regs})

0 comments on commit cd0641b

Please sign in to comment.