Permalink
Browse files

Remove tuples nulls (#88)

Removed the ability to make tuples of nulls. (now there are no 0 width signals). Upgraded to latest version of Terra.
  • Loading branch information...
jameshegarty committed Dec 6, 2017
1 parent 6df2336 commit fd808866339caf4dd9a15e9e226dce535e321875
Showing with 266 additions and 99 deletions.
  1. +6 −3 .travis.yml
  2. +49 −32 examples/harnessTerra.t
  3. +16 −7 rigel.lua
  4. +1 −1 src/fpgamodules.lua
  5. +74 −20 src/modules.lua
  6. +108 −33 src/modulesTerra.t
  7. +8 −3 src/systolic.lua
  8. +4 −0 src/types.lua
View
@@ -13,9 +13,12 @@ before_install:
#terra
- wget https://github.com/zdevito/terra/releases/download/release-2016-02-26/terra-Linux-x86_64-2fa8d0a.zip
- unzip terra-Linux-x86_64-2fa8d0a.zip
- sudo ln -s /home/travis/build/jameshegarty/rigel/terra-Linux-x86_64-2fa8d0a/bin/terra /usr/bin/terra
# - wget https://github.com/zdevito/terra/releases/download/release-2016-02-26/terra-Linux-x86_64-2fa8d0a.zip
# - unzip terra-Linux-x86_64-2fa8d0a.zip
# - sudo ln -s /home/travis/build/jameshegarty/rigel/terra-Linux-x86_64-2fa8d0a/bin/terra /usr/bin/terra
- wget https://github.com/zdevito/terra/releases/download/release-2016-03-25/terra-Linux-x86_64-332a506.zip
- unzip terra-Linux-x86_64-332a506.zip
- sudo ln -s /home/travis/build/jameshegarty/rigel/terra-Linux-x86_64-332a506/bin/terra /usr/bin/terra
# this installs correct version of glibc for terra binary
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
View
@@ -6,45 +6,29 @@ local fixed = require "fixed"
local types = require("types")
local J = require "common"
local terraWrapper = J.memoize(function(fn,inputFilename,inputType,tapType,outputFilename,outputType,id,harnessoption,ramFile)
local terraWrapper = J.memoize(function(fn,inputFilename,inputType,tapType,tapValue,outputFilename,outputType,id,harnessoption,ramFile)
local out
local inpSymb
local instances = {}
local dram, dramAddr
if inputType~=types.null() then
local fixedTapInputType = tapType
if tapType==nil then fixedTapInputType = types.null() end
local ITYPE = types.tuple{types.null(),fixedTapInputType}
inpSymb = R.input( R.Handshake(ITYPE) )
local inpL, inpR = inpSymb, inpSymb
if tapType~=nil then
local O = R.apply("bstream",RM.broadcastStream(ITYPE,2),inpSymb)
inpL = R.selectStream("b0",O,0)
inpR = R.selectStream("b1",O,1)
end
inpSymb = R.input(R.HandshakeTrigger)
local inpdata = R.apply("inpdata", RM.makeHandshake(C.index(types.tuple{types.null(),fixedTapInputType},0),nil,true), inpL)
local inptaps = R.apply("inptaps", RM.makeHandshake(C.index(types.tuple{types.null(),fixedTapInputType},1)), inpR)
out = R.apply("fread",RM.makeHandshake(RM.freadSeq(inputFilename,R.extractData(inputType)),nil,true),inpdata)
out = R.apply( "fread", RM.makeHandshake(RM.freadSeq(inputFilename,R.extractData(inputType)),nil,true), inpSymb )
local hsfninp = out
if tapType~=nil then
hsfninp = R.apply("HFN",RM.packTuple({inputType,tapType}), R.concat("hsfninp",{out,inptaps}))
local tapv = R.apply("tap",RM.makeHandshake(RM.constSeq({tapValue},tapType,1,1,1)))
tapv = R.apply("tapidx",RM.makeHandshake(C.index(types.array2d(tapType,1,1),0)),tapv)
hsfninp = R.apply("HFN",RM.packTuple({inputType,tapType}), R.concat("hsfninp",{out,tapv}))
end
if harnessoption==2 then
dram = R.instantiateRegistered("dram", RM.dram( R.extractData(fn.inputType.list[2]),10,ramFile))
table.insert(instances,dram)
local dramData = R.applyMethod("dramData", dram, "load" )
hsfninp = R.concat("hsfninp2",{out,dramData})
--
end
out = R.apply("HARNESS_inner", fn, hsfninp )
@@ -58,13 +42,15 @@ local terraWrapper = J.memoize(function(fn,inputFilename,inputType,tapType,outpu
out = R.apply("HARNESS_inner", fn )
end
out = R.apply("fwrite", RM.makeHandshake(RM.fwriteSeq(outputFilename,outputType),nil,true), out )
out = R.apply("fwrite", RM.makeHandshake(RM.fwriteSeq(outputFilename,outputType,nil,false),nil,true), out )
if harnessoption==2 then
out = R.statements{out,dramAddr}
end
return RM.lambda( "harness"..id..tostring(fn):gsub('%W','_'), inpSymb, out, instances )
local res = RM.lambda( "harness"..id..tostring(fn):gsub('%W','_'), inpSymb, out, instances )
return res
end)
return function(filename, hsfn, inputFilename, tapType, tapValue, inputType, inputT, inputW, inputH, outputType, outputT, outputW, outputH, underflowTest, earlyOverride, doHalfTest, simCycles, harnessoption, ramFile, X)
@@ -80,19 +66,50 @@ return function(filename, hsfn, inputFilename, tapType, tapValue, inputType, inp
for i=1,bound do
local ext=""
if i==2 then ext="_half" end
--local f = harnessWrapperFn( hsfn, inputFilename, inputType, tapType, "out/"..filename, "out/"..filename..ext..".terra.raw", outputType, i, inputCount, outputCount, 1, underflowTest, earlyOverride, true )
--local f = terraWrapper{fn=hsfn, inputFilename=inputFilename, outputFilename="out/"..filename..ext..".terra.raw",tapType=tapType, inputType=inputType, outputType=outputType,id=i}
local f = terraWrapper(hsfn,inputFilename,inputType,tapType,"out/"..filename..ext..".terra.raw",outputType,i, harnessoption, ramFile)
f = RM.seqMapHandshake( f, inputType, tapType, tapValue, inputCount, outputCount, false, i, simCycles )
local f = terraWrapper(hsfn,inputFilename,inputType,tapType,tapValue,"out/"..filename..ext..".terra.raw",outputType,i, harnessoption, ramFile)
local Module = f:compile()
local m = symbol(&Module)
local valid_in = symbol(bool)
local valid_out = symbol(bool)
local incnt = symbol(int)
local callQ, incQ
if inputType==types.null() then
callQ = quote m:process(&[valid_out]) end
incQ = quote end
else
callQ = quote m:process(&[valid_in],&[valid_out]) end
incQ = quote if m.ready then incnt = incnt+1 end end
end
local terra dosim()
if DARKROOM_VERBOSE then cstdio.printf("Start CPU Sim\n") end
var m:&Module = [&Module](cstdlib.malloc(sizeof(Module)));
var [m] = [&Module](cstdlib.malloc(sizeof(Module)));
m:init()
m:reset();
m:process(nil,nil);
if DARKROOM_VERBOSE then m:stats(); end
m:reset();
var [incnt] = 0
var cnt = 0
var cycles = 0
while(cnt<outputCount) do
m:calculateReady(true)
var [valid_in] = (incnt < inputCount)
--[J.sel(inputType==types.null(),quote end, quote if m.ready then incnt = incnt+1 end end)]
incQ
var [valid_out]= false
-- [if inputType==types.null() then return quote m:process(&outValid) end else return quote m:process(&inValid,&outValid) end end]
-- m:process(&inValid,&outValid)
callQ
if valid_out then cnt=cnt+1 end
--cstdio.printf("SIM %d %d %d %d\n",valid_in,valid_out,incnt,cnt)
-- if inValid then cstdio.printf("IN_VALID\n") end
cycles = cycles+1
end
if DARKROOM_VERBOSE then m:stats("TOP"); end
m:free()
cstdlib.free(m)
end
View
@@ -28,6 +28,8 @@ local function getloc()
return debug.getinfo(3).source..":"..debug.getinfo(3).currentline.."\n"..debug.traceback()
end
darkroom.VTrigger = types.named("VTrigger", types.bool(), "VTrigger",{})
darkroom.HandshakeTrigger = types.named("HandshakeTrigger", types.bool(), "HandshakeTrigger",{})
function darkroom.V(A)
err(types.isType(A),"V: argument should be type");
@@ -94,6 +96,7 @@ function darkroom.isHandshakeTmuxed(a)
end
function darkroom.isHandshake( a ) return a:isNamed() and a.generator=="Handshake" end
function darkroom.isHandshakeTrigger( a ) return a:isNamed() and a.generator=="HandshakeTrigger" end
function darkroom.isHandshakeArray( a ) return a:isNamed() and a.generator=="HandshakeArray" end
function darkroom.isHandshakeTuple( a ) return a:isNamed() and a.generator=="HandshakeTuple" end
@@ -103,7 +106,12 @@ function darkroom.isBasic(A)
assert(types.isType(A))
if A:isArray() then return darkroom.isBasic(A:arrayOver()) end
if A:isTuple() then for _,v in ipairs(A.list) do if darkroom.isBasic(v)==false then return false end end return true end
return darkroom.isV(A)==false and darkroom.isRV(A)==false and darkroom.isHandshake(A)==false and darkroom.isHandshakeArrayOneHot(A)==false and darkroom.isHandshakeTmuxed(A)==false and darkroom.isHandshakeArray(A)==false and darkroom.isHandshakeTuple(A)==false
if darkroom.isV(A) or darkroom.isRV(A) or darkroom.isHandshake(A) or darkroom.isHandshakeTrigger(A) or darkroom.isHandshakeArrayOneHot(A) or darkroom.isHandshakeTmuxed(A) or darkroom.isHandshakeArray(A) or darkroom.isHandshakeTuple(A) then
return false
end
return true
end
function darkroom.expectBasic( A ) err( darkroom.isBasic(A), "type should be basic but is "..tostring(A) ) end
function darkroom.expectV( A, er ) if darkroom.isV(A)==false then error(er or "type should be V but is "..tostring(A)) end end
@@ -117,11 +125,12 @@ function darkroom.expectHandshake( A, er ) if darkroom.isHandshake(A)==false the
-- Handshake(A) => {A,bool}
function darkroom.lower( a, loc )
assert(types.isType(a))
if darkroom.isHandshake(a) or darkroom.isRV(a) or darkroom.isV(a) or darkroom.isHandshakeArray(a) or darkroom.isHandshakeArrayOneHot(a) or darkroom.isHandshakeTmuxed(a) or darkroom.isHandshakeTuple(a) then
if darkroom.isHandshake(a) or darkroom.isHandshakeTrigger(a) or darkroom.isRV(a) or darkroom.isV(a) or darkroom.isHandshakeArray(a) or darkroom.isHandshakeArrayOneHot(a) or darkroom.isHandshakeTmuxed(a) or darkroom.isHandshakeTuple(a) then
return a.structure
elseif darkroom.isBasic(a) then
return a
end
print("rigel.lower: unknown type? ",a)
assert(false)
end
@@ -136,7 +145,7 @@ function darkroom.extractData(a)
end
function darkroom.hasReady(a)
if darkroom.isHandshake(a) or darkroom.isRV(a) or darkroom.isHandshakeArray(a) or darkroom.isHandshakeTuple(a) or darkroom.isHandshakeArrayOneHot(a) or darkroom.isHandshakeTmuxed(a) then
if darkroom.isHandshake(a) or darkroom.isHandshakeTrigger(a) or darkroom.isRV(a) or darkroom.isHandshakeArray(a) or darkroom.isHandshakeTuple(a) or darkroom.isHandshakeArrayOneHot(a) or darkroom.isHandshakeTmuxed(a) then
return true
elseif darkroom.isBasic(a) or darkroom.isV(a) then
return false
@@ -147,7 +156,7 @@ function darkroom.hasReady(a)
end
function darkroom.extractReady(a)
if darkroom.isHandshake(a) then return types.bool()
if darkroom.isHandshake(a) or darkroom.isHandshakeTrigger(a) then return types.bool()
elseif darkroom.isV(a) then return types.bool()
elseif darkroom.isRV(a) then return types.bool()
elseif darkroom.isHandshakeTuple(a) then
@@ -170,7 +179,7 @@ end
function darkroom.streamCount(A)
if darkroom.isBasic(A) or darkroom.isV(A) or darkroom.isRV(A) then
return 0
elseif darkroom.isHandshake(A) then
elseif darkroom.isHandshake(A) or darkroom.isHandshakeTrigger(A) then
return 1
elseif darkroom.isHandshakeArray(A) then
return A.params.W*A.params.H
@@ -185,7 +194,7 @@ end
-- is this type any type of handshake type?
function darkroom.isStreaming(A)
if darkroom.isHandshake(A) or darkroom.isHandshakeArray(A) or darkroom.isHandshakeTuple(A) or darkroom.isHandshakeTmuxed(A) or darkroom.isHandshakeArrayOneHot(A) then
if darkroom.isHandshake(A) or darkroom.isHandshakeTrigger(A) or darkroom.isHandshakeArray(A) or darkroom.isHandshakeTuple(A) or darkroom.isHandshakeTmuxed(A) or darkroom.isHandshakeArrayOneHot(A) then
return true
end
return false
@@ -586,7 +595,7 @@ function darkroomIRFunctions:codegenSystolic( module )
local I = module:lookupInstance(n.inst.name)
if n.fnname=="load" then
module:lookupFunction("reset"):addPipeline( I:load_reset(nil,module:lookupFunction("reset"):getValid()) )
return {I:load(S.tuple{S.null(),S.constant(true,types.bool())})}
return {I:load()}
elseif n.fnname=="store" then
module:lookupFunction("reset"):addPipeline( I:store_reset(nil,module:lookupFunction("reset"):getValid()) )
return {I:store(inputs[1][1])}
View
@@ -259,7 +259,7 @@ modules.fifonoop = memoize(function(ty)
local pushBack_ready = fifo:addFunction( systolic.lambda("store_ready",S.parameter("SRNIL",types.null()),internalReady,"store_ready",{} ) )
-- popFront
local popFront = fifo:addFunction( S.lambda("load",S.parameter("pfnil",types.tuple{types.null(),types.bool()}),internalData,"load_output") )
local popFront = fifo:addFunction( S.lambda("load",S.parameter("pfnil",types.null()),internalData,"load_output") )
local popFront_ready = fifo:addFunction( S.lambda("load_ready",internalReady,nil,"load_ready") )
-- size
Oops, something went wrong.

0 comments on commit fd80886

Please sign in to comment.