#!/bin/csh -f

alias BEGIN 'cat <<END'

set vbase = "/im/cam8/vsim"
set vsource = release
set dotv = "/sim"
foreach arg ($*)
  if ($arg =~ td) then
    set vsource = td
  else if ($arg =~ df) then
    set vsource = df
  else if ($arg =~ nhm) then
    set vsource = nhm
  endif
end


BEGIN

-v $vbase/$vsource/sys_hdr.v
-v $vbase/$vsource/sys_halt.v
-v $vbase/$vsource/sbreva.v
-v $vbase/$vsource/sbrevad.v
-v $dotv/iboard.v

-v $vbase/$vsource/prom.v
-v $vbase/$vsource/test.v
-v $vbase/$vsource/sbutil.v
-v $vbase/$vsource/slaveout.v
-v $vbase/$vsource/sbmemout.v
-v $vbase/$vsource/pull_slow.v
END

foreach arg ($*)
  if ($arg =~ "+idebug") then

BEGIN

-v $dotv/ifcout.v
-v $dotv/camout.v
END

  break
  endif
end


BEGIN

-v $dotv/cammod.v
END


foreach arg ($*)
  if ( ($arg =~ "sram") || ($1 > 3) ) then
BEGIN

-v $vbase/$vsource/sram.v
END

  break
  endif
end


foreach arg ($*)
  if ($arg =~ "+ivectors") then
BEGIN

-v $vbase/$vsource/ivout.v
END

  break
  endif
end


foreach arg ($*)
  if ( ($arg =~ "+vectors") && ($1 > 1) ) then
BEGIN

-v $vbase/$vsource/cvout4.v
END

  break
  else if ( ($arg =~ "+vectors") && ($1 < 2) ) then
BEGIN

-v $vbase/$vsource/cvout1.v
END

  break
  endif
end


# check whether to include behavioral models in
#   cam chip
set chipmod = "$vbase/$vsource/chip1.edf.v"
foreach arg ($*)
  if ($arg =~ [Bb]) then
    set chipmod = "$vbase/$vsource/chip1.edf.v.b"
    break
  else if ($arg =~ fullcam) then
    set chipmod = "$vbase/$vsource/chip.edf.v"
    break
  endif
end

# insert the appropriate cam module name
BEGIN
-v $chipmod
END


# check for full chip models
set ctlsvchip = "-v $vbase/$vsource/ctlsvchip.edf.v"
set ftop = "-v $vbase/$vsource/fsmtop.v"
set fsmchip = "-v $vbase/$vsource/fsmchip.edf.v"
set dataregs = "-v $vbase/$vsource/dataregs.edf.v"
foreach arg ($*)
  if ($arg =~ fullctlsv[ab]) then
    set ctlsvchip = "-v $vbase/$vsource/chip.edf.v"
    set fsmchip = ""
    set dataregs = ""
  else if ($arg =~ fullfsm) then
    set ftop = ""
    set ctlsvchip = ""
    set fsmchip = "-v $vbase/$vsource/chip.edf.v"
    set dataregs = ""
  else if ($arg =~ fulldata[ab]) then
    set ctlsvchip = ""
    set fsmchip = ""
    set dataregs = "-v $vbase/$vsource/chip.edf.v"
  endif
end


BEGIN

-v $vbase/$vsource/ctlsvtop.v
$ctlsvchip

$ftop
$fsmchip

-v $vbase/$vsource/datatop.v
$dataregs
END


# check for frame grabber
foreach arg ($*)
  if ($arg =~ grab) then

BEGIN

-v $vbase/$vsource/grab.v
-v $vbase/$vsource/sync_decode.v
-v $vbase/$vsource/vram.v
END

  break
  endif
end


BEGIN

-v $vbase/$vsource/ifc.v
-v /im/verilog/lai_mods.v
-y /im/verilog/vlsi/vlsi_1.0u/verilog/vgt300 +libext+.vmd+
-v /im/verilog/vlsi/vlsi_1.0u/udp/vlsi_udps.vmd

END

