Permalink
Browse files

Arbiter test / HandshakeVR / globals implementation fixes (#133)

  • Loading branch information...
jameshegarty committed Jan 9, 2019
1 parent e3fec5b commit 9f2568330c7ca8f2160a1b4723c64332ab20f841
Binary file not shown.
@@ -0,0 +1 @@
return {}
@@ -0,0 +1 @@
1034
@@ -1 +1 @@
1038
1039
@@ -1,7 +1,7 @@
BUILDDIR ?= out

# soc_flipWrite.lua
SRCS_SOC = soc_simple.lua soc_simple_uniform.lua soc_2in.lua soc_convgen.lua soc_convgenTaps.lua soc_flip.lua soc_15x15.lua soc_15x15x15.lua soc_flipWrite.lua soc_regin.lua soc_regout.lua soc_convtest.lua soc_read.lua soc_redu1024.lua soc_redu2048.lua soc_redu4096.lua soc_redu8192.lua soc_redu16384.lua soc_redu32768.lua soc_sort.lua soc_filterseq.lua soc_filterseq8.lua soc_unaligned.lua soc_underflow.lua soc_parread.lua soc_tokencounter.lua
SRCS_SOC = soc_simple.lua soc_simple_uniform.lua soc_2in.lua soc_convgen.lua soc_convgenTaps.lua soc_flip.lua soc_15x15.lua soc_15x15x15.lua soc_flipWrite.lua soc_regin.lua soc_regout.lua soc_convtest.lua soc_read.lua soc_redu1024.lua soc_redu2048.lua soc_redu4096.lua soc_redu8192.lua soc_redu16384.lua soc_redu32768.lua soc_sort.lua soc_filterseq.lua soc_filterseq8.lua soc_unaligned.lua soc_underflow.lua soc_parread.lua soc_tokencounter.lua soc_arbiter.lua

VERILATOR_SOC = $(patsubst %.lua,$(BUILDDIR)/%.verilatorSOC.bit,$(SRCS_SOC))
VERILATOR_SOC += $(patsubst %.lua,$(BUILDDIR)/%.verilatorSOC.raw,$(SRCS_SOC))
@@ -0,0 +1,23 @@
local R = require "rigel"
local SOC = require "soc"
local C = require "examplescommon"
local harness = require "harnessSOC"
local G = require "generators"
local RS = require "rigelSimple"
local types = require "types"
types.export()

regs = SOC.axiRegs{}:instantiate()

OffsetModule = G.Module{ "OffsetModule", R.HandshakeTrigger,
function(i)
local readStream = G.AXIReadBurst{"frame_128.raw",{128,64},u(8),8}(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)
end}


harness{regs.start, OffsetModule, regs.done}
@@ -8,7 +8,7 @@ local types = require "types"
local SDF = require "sdf"
types.export()

local Regs = SOC.axiRegs{offset={u(8),200},lastPx={u(8),0,"out"}}
local Regs = SOC.axiRegs{offset={u(8),200},lastPx={u(8),0,"input"}}
regs = Regs:instantiate(SDF{1,8192})

local AddReg = G.Module{"AddReg",function(i) return G.Add(i,Regs.offset) end}
@@ -8,7 +8,7 @@ local types = require "types"
local SDF = require "sdf"
types.export()

local Regs = SOC.axiRegs{startCnt={u32,0,"out"},endCnt={u32,0,"out"}}
local Regs = SOC.axiRegs{startCnt={u32,0,"input"},endCnt={u32,0,"input"}}
regs = Regs:instantiate(SDF{1,8192})

local RegInOut = G.Module{
@@ -1013,20 +1013,22 @@ C.stencilLinebufferPartialOffsetOverlap = memoize(function( A, w, h, T, xmin, xm
end)

-------------
C.fifo = memoize(function(ty,size,nostall,csimOnly,X)
-- VRLoad: if true, make the load function be HandshakeVR
C.fifo = memoize(function(ty,size,nostall,csimOnly,VRLoad,X)
err( types.isType(ty), "C.fifo: type must be a type" )
err( R.isBasic(ty), "C.fifo: type must be basic type, but is: "..tostring(ty) )
err( type(size)=="number" and size>0, "C.fifo: size must be number > 0" )
err( nostall==nil or type(nostall)=="boolean", "C.fifo: nostall must be boolean")
err( csimOnly==nil or type(csimOnly)=="boolean", "C.fifo: csimOnly must be boolean")
err( VRLoad==nil or type(VRLoad)=="boolean","C.fifo: VRLoad should be boolean")
err( X==nil, "C.fifo: too many arguments" )
err( ty~=types.null(), "C.fifo: NYI - FIFO of 0 bit type" )

local inp = R.input(R.Handshake(ty))
local regs = {R.instantiateRegistered("f1",RM.fifo(ty,size,nostall,nil,nil,nil,csimOnly))}
local regs = {R.instantiateRegistered("f1",RM.fifo(ty,size,nostall,nil,nil,nil,csimOnly,VRLoad))}
local st = R.applyMethod("s1",regs[1],"store",inp)
local ld = R.applyMethod("l1",regs[1],"load")
return RM.lambda("C_FIFO_"..tostring(ty).."_size"..tostring(size).."_nostall"..tostring(nostall), inp, R.statements{ld,st}, regs, "C.fifo", {size=size} )
return RM.lambda("C_FIFO_"..tostring(ty).."_size"..tostring(size).."_nostall"..tostring(nostall).."_VR"..tostring(VRLoad), inp, R.statements{ld,st}, regs, "C.fifo", {size=size} )
end)

-------------
@@ -1707,6 +1709,41 @@ C.handshakeToHandshakeFramed = memoize(
return rigel.newFunction(res)
end)

C.stripFramed = memoize(
function( A, X)
err(A:is("HandshakeFramed") or A:is("HandshakeArrayFramed"),"StripFramed: input should be framed, but is: "..tostring(A) )
assert(X==nil)


local res = {inputType=A,sdfInput=SDF{1,1},sdfOutput=SDF{1,1},stateful=false}

if A:is("HandshakeFramed") then
res.outputType = types.Handshake(A.params.A)
elseif A:is("HandshakeArrayFramed") then
res.outputType = types.HandshakeArray(A.params.A,A.params.W,A.params.H)
else
assert(false)
end

res.name=J.sanitize("StripFramed_"..tostring(A))

function res.makeSystolic()
local sm = Ssugar.moduleConstructor(res.name):onlyWire(true)
local r = S.parameter("ready_downstream",types.bool())
sm:addFunction( S.lambda("ready", r, r, "ready") )
local I = S.parameter("process_input", R.lower(A) )
sm:addFunction( S.lambda("process",I,I,"process_output") )

return sm
end
function res.makeTerra()
return CT.stripFramed(res,A)
end

return rigel.newFunction(res)

end)

-- if ser==true, takes A[W,H]->A[W*H/ratio,W,H}
-- if ser==false, takes A[W*H/ratio,W,H}->A[W,H]
C.changeRateFramed = memoize(function(A, W, H, ratio, ser, X)
@@ -352,4 +352,13 @@ function CT.handshakeToHandshakeFramed(res,A,mixed,dims)
return MT.new(HandshakeToHandshakeFramed)
end

function CT.stripFramed(res,A)
local struct StripFramed {ready:bool}
terra StripFramed:process( inp:&rigel.lower(res.inputType):toTerraType(), out:&rigel.lower(res.outputType):toTerraType())
@out = @inp
end
terra StripFramed:calculateReady(readyDownstream:bool) self.ready = readyDownstream end
return MT.new(StripFramed)
end

return CT
@@ -259,7 +259,7 @@ function(args)

return RM.cropSeq(pixelType,size[1],size[2],V,args.bounds[1],args.bounds[2],args.bounds[3],args.bounds[4],true)
else
err(false,"generators.Crop: unsupported input type: "..tostring(args.type))
J.err(false,"generators.Crop: unsupported input type: "..tostring(args.type))
end
end)

@@ -603,10 +603,15 @@ end)

generators.Arbitrate = R.newGenerator("generators","Arbitrate",{"type","rate"},{},
function(args)
J.err( types.isHandshakeArray(args.type), "generators.Arbitrate: input should be HandshakeArray" )
J.err( types.isHandshakeArray(args.type), "generators.Arbitrate: input should be HandshakeArray, but is: "..tostring(args.type) )
return RM.arbitrate(args.type.params.A,args.rate)
end)

generators.StripFramed = R.newGenerator("generators","StripFramed",{"type","rate"},{},
function(args)
return C.stripFramed(args.type)
end)

function generators.export(t)
if t==nil then t=_G end
for k,v in pairs(generators) do rawset(t,k,v) end
Oops, something went wrong.

0 comments on commit 9f25683

Please sign in to comment.