1)Stop tracking rtl

2) added qip files from pei and changed folder structure
3) added files generic_ip, .qip and related files
This commit is contained in:
David Rodriguez 2026-04-04 20:36:57 +01:00
commit cb47323ec9
1980 changed files with 811425 additions and 82 deletions

5
.gitignore vendored
View file

@ -8,4 +8,7 @@ output_files/
*.smsg
*.sof
*.pof
*.jic
*.jic
*.cdf
*.cmp.rdb
rtl/

View file

@ -1,43 +1,63 @@
# simple_fpga_project
# pei_fpga_project_qip
Minimal Quartus project for:
- Family: Cyclone 10 LP
- Device: 10CL010YU256C8G
This package uses a cleaner Quartus flow:
## Folder structure
- `quartus/sources.qip` for RTL and generic IP source inclusion
- `quartus/create_project.tcl` to generate the project `.qpf/.qsf`
- `constraints/pei_fpga_top.sdc` as the timing constraints file
- `constraints/pei_fpga_top_assignments.qsf` for non-source assignments migrated from the original design
- `rtl/top.vhd` : top-level VHDL generated from the CSV pin list
- `constraints/pins.qsf` : pin assignments generated from the CSV file
- `quartus/create_project.tcl` : Quartus Tcl project generator
- `quartus/project_build.sh` : shell entry point for scripted project creation
- `build/` : working build directory
## Repository structure
## How to run
- `src/` for RTL
- `generic_ip/` for shared IP
- `constraints/` for SDC and assignment fragments
- `quartus/` for the build entry points
From WSL/Linux:
## Build usage
From `quartus/`:
```bash
cd quartus
chmod +x project_build.sh
./project_build.sh
./project_build.sh build
./project_build.sh clean
./project_build.sh rebuild
./project_build.sh compile
./project_build.sh full
./project_build.sh rbf
```
This creates or updates the Quartus project in `build/`.
Command summary:
- `build` : create or update the Quartus project only
- `compile` : run Analysis & Synthesis, Fitter, Assembler, and TimeQuest STA
- `full` : run the full compile flow and generate an `.rbf` from the `.sof`
- `rbf` : generate the `.rbf` from an existing `.sof`
To populate `generic_ip/` before build:
```bash
GENERIC_IP_SRC=/path/to/original/generic_ip ./project_build.sh full
```
## Output files
After a successful `full` run, the main outputs are expected in:
- `build/output_files/pei_fpga_top.sof`
- `build/output_files/pei_fpga_top.rbf`
The `.rbf` is generated from the `.sof` with:
```bash
quartus_cpf -c build/output_files/pei_fpga_top.sof build/output_files/pei_fpga_top.rbf
```
## Notes
- The top-level entity is `top`.
- The VHDL port names must match the names in `constraints/pins.qsf`.
- The generated VHDL directions are inferred from signal names and should be reviewed.
- This minimal flow creates the project and applies pin assignments. It does not run map/fit/asm/sta.
## To add full compile later
Add these commands after the Tcl step in `quartus/project_build.sh`:
```bash
quartus_map simple_fpga_project
quartus_fit simple_fpga_project
quartus_asm simple_fpga_project
quartus_sta simple_fpga_project
```
- The actual RTL and generic IP source files are not included here because they were not provided.
- Put your design files into `src/` and `generic_ip/` so that the references in `quartus/sources.qip` resolve correctly.
- Additional nested `.qip` files referenced by the original design must also be present if the compile is to succeed.
- The `.qdf` is not part of the normal user-managed project flow here. Quartus generates the project `.qpf/.qsf`; timing stays in the separate `.sdc`.
- Review `constraints/pei_fpga_top.sdc` and add the real clocks and timing exceptions.
- Review `constraints/pei_fpga_top_assignments.qsf` before first compile.

2
generic_ip/README.txt Normal file
View file

@ -0,0 +1,2 @@
Place shared generic IP files here.
The QIP file references ../generic_ip/... paths.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,678 @@
import sys
import os
import fileinput
import subprocess
import shutil
from distutils.dir_util import copy_tree
from os import listdir
from os.path import isfile, join, isdir
subst_array = dict([
('MM_interface', 'Mi' )
,('mm_interconnect', 'mi' )
,('agent_rsp_fifo', 'arf' )
,('avalon_slave', 'avas')
,('translator_avalon_universal_slave', 'taus')
,('translator_avalon_universal_master', 'taum')
])
batch = 0
def get_tool_root():
tmpPath = os.environ['QUARTUS_ROOTDIR']
newPath = tmpPath.replace('\\', '/')
return newPath
def get_dev_root():
tmpPath = os.getcwd()
tmpList = tmpPath.split("\\build")
intPath = tmpList[0]
tmpList = intPath.split("\\sim")
newPath = tmpList[0]
newPath = newPath.replace('\\', '/')
return newPath
def my_module():
firstArg = sys.argv[0]
splitList = firstArg.split(".")
return splitList[0]
def create_new_qsys():
readFileName = get_dev_root() + "/build/" + my_module() + "_system.qsys.tmp"
writeFileName = get_dev_root() + "/build/" + my_module() + "_system.qsys"
if os.path.isfile(readFileName):
os.remove(readFileName)
os.rename(writeFileName, readFileName)
readFile = open(readFileName , "r")
writeFile = open(writeFileName, "w")
for line in readFile:
newLine = line
if ("defaultValue" in line):
#newLine = newLine.replace(" elab", " elab_tb")
newLine = ''' defaultValue="101"''' + "\n"
writeFile.write(newLine)
readFile.close()
writeFile.close()
def conv2008(fileToSearch):
textToSearch = "vcom"
textToReplace = "vcom -2008"
tempFile = open( fileToSearch, 'r+' )
for line in fileinput.input( fileToSearch ):
tempFile.write( line.replace( textToSearch, textToReplace ) )
tempFile.close()
def generate_sim_files(searchPathList):
totalPath = "$"
for ip in searchPathList:
searchPath = ''.join(['../../', ip, '/src/'])
totalPath = ','.join([totalPath, searchPath])
searchPath = ''.join(['../../', ip, '/build/'])
totalPath = ','.join([totalPath, searchPath])
# Run Qsys 'generate IP'
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/ip-generate --remove-qsys-generate-warning --project-directory=_DEV_ROOT_/build --output-directory=_DEV_ROOT_/build/_MODULE_/simulation --file-set=SIM_VHDL --report-file=html:_DEV_ROOT_/build/_MODULE_/_MODULE_.html --report-file=sopcinfo:_DEV_ROOT_/build/_MODULE_.sopcinfo --report-file=csv:_DEV_ROOT_/build/_MODULE_/_MODULE_.csv --report-file=spd:_DEV_ROOT_/build/_MODULE_/_MODULE_.spd --report-file=cmp:_DEV_ROOT_/build/_MODULE_/_MODULE_.cmp --report-file=sip:_DEV_ROOT_/build/_MODULE_/simulation/_MODULE_.sip --system-info=DEVICE_FAMILY=\"Cyclone V\" --system-info=DEVICE=5CSXFC6D6F31C8ES --system-info=DEVICE_SPEEDGRADE=8_H6 --component-file=_DEV_ROOT_/build/_MODULE_.qsys --search-path=_SEARCH_PATH_'''
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
print myCmd
myCmdArray = myCmd.split(" ")
subprocess.call(myCmdArray)
# Run Qsys 'generate scripts'
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/sim-script-gen --spd=_DEV_ROOT_/build/_MODULE_/_MODULE_.spd --output-directory=_DEV_ROOT_/build/_MODULE_/simulation/ --use-relative-paths=true'''
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
print myCmd
myCmdArray = myCmd.split(" ")
subprocess.call(myCmdArray)
# Run Qsys 'generate bsf'
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/ip-generate --project-directory=_DEV_ROOT_/build --output-directory=_DEV_ROOT_/build/_MODULE_ --report-file=bsf:_DEV_ROOT_/build/_MODULE_/stripe_transform_system.bsf --system-info=DEVICE_FAMILY="Cyclone V" --system-info=DEVICE=5CSXFC6D6F31C6 --system-info=DEVICE_SPEEDGRADE=6_H6 --component-file=_DEV_ROOT_/build/_MODULE_.qsys --remove-qsys-generate-warning'''
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
print myCmd
myCmdArray = myCmd.split(" ")
subprocess.call(myCmdArray)
myCmd2 = '''_DEV_ROOT_/build/_MODULE_/simulation/mentor/msim_setup.tcl'''
myCmd2 = myCmd2.replace('_DEV_ROOT_', get_dev_root())
myCmd2 = myCmd2.replace('_MODULE_', "".join([my_module() + "_system"]))
print myCmd2
conv2008(myCmd2)
def generate_synth_files(searchPathList):
totalPath = "$"
for ip in searchPathList:
searchPath = ''.join(['../../', ip, '/src/'])
totalPath = ','.join([totalPath, searchPath])
searchPath = ''.join(['../../', ip, '/build/'])
totalPath = ','.join([totalPath, searchPath])
searchPath = '../../**/*'
totalPath = ','.join([totalPath, searchPath])
# Run Qsys 'generate'
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/ip-generate --project-directory=_DEV_ROOT_/build --output-directory=_DEV_ROOT_/build/_MODULE_ --report-file=bsf:_DEV_ROOT_/build/_MODULE_/_MODULE_.bsf --system-info=DEVICE_FAMILY="Cyclone V" --system-info=DEVICE=5CSXFC6D6F31C6 --system-info=DEVICE_SPEEDGRADE=6_H6 --component-file=_DEV_ROOT_/build/_MODULE_.qsys --remove-qsys-generate-warning --search-path=$,../../../../../**/*'''
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
print myCmd
myCmdArray = myCmd.split(" ")
subprocess.call(myCmdArray)
# Run Qsys 'generate'
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/ip-generate --project-directory=_DEV_ROOT_/build --output-directory=_DEV_ROOT_/build/_MODULE_/synthesis --file-set=QUARTUS_SYNTH --report-file=html:_DEV_ROOT_/build/_MODULE_/_MODULE_.html --report-file=sopcinfo:_DEV_ROOT_/build/_MODULE_.sopcinfo --report-file=cmp:_DEV_ROOT_/build/_MODULE_/_MODULE_.cmp --report-file=qip:_DEV_ROOT_/build/_MODULE_/synthesis/_MODULE_.qip --report-file=svd:_DEV_ROOT_/build/_MODULE_/synthesis/_MODULE_.svd --report-file=regmap:_DEV_ROOT_/build/_MODULE_/synthesis/_MODULE_.regmap --report-file=xml:_DEV_ROOT_/build/_MODULE_/_MODULE_.xml --report-file=debuginfo:_DEV_ROOT_/build/_MODULE_/synthesis/_MODULE_.debuginfo --system-info=DEVICE_FAMILY="Cyclone V" --system-info=DEVICE=5CSXFC6D6F31C6 --system-info=DEVICE_SPEEDGRADE=6_H6 --component-file=_DEV_ROOT_/build/_MODULE_.qsys --remove-qsys-generate-warning --language=VHDL --search-path=$,../../../../../**/* --component-parameter=sysid_ver_num=_VER_NUM_'''
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
myCmd = myCmd.replace('_VER_NUM_', "8")
print myCmd
myCmdArray = myCmd.split(" ")
subprocess.call(myCmdArray)
# Perform Quartus synthesis
myCmd = '''_TOOL_ROOT_/bin64/quartus_sh --flow compile _MODULE_'''
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
print myCmd
myCmdArray = myCmd.split(" ")
subprocess.call(myCmdArray)
def get_batch_mode():
for i in sys.argv:
if i == 'yesBatch':
print "yesBatch detected"
return 1
return 0
def get_qsys_build():
for i in sys.argv:
if i == 'yesQsys':
print "yesQsys detected"
return 1
return 0
def copy_files(system_name):
# Move, shorten, and then move back the generated files
curPath = os.getcwd()
srcPath = "".join(["..\\build\\" + system_name + "_system\simulation"])
print srcPath
dstPath = "c:\simulation"
# Create directories if they don't exist
if not os.path.exists(dstPath): os.makedirs(dstPath)
if not os.path.exists("".join([dstPath, "\submodules"])): os.makedirs("".join([dstPath, "\submodules"]))
if not os.path.exists("".join([dstPath, "\mentor"])): os.makedirs("".join([dstPath, "\mentor"]))
# Clear out what is currently in the temporary directory
os.chdir(dstPath)
filelist = [ f for f in os.listdir(".") if f.endswith(".vhd") ]
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".vho") ]
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".safe")]
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".sip") ]
filelist = filelist + [ f for f in os.listdir(".") if f.endswith("~") ]
for f in filelist: os.remove(f)
os.chdir("submodules")
filelist = [ f for f in os.listdir(".") if f.endswith(".vhd") ]
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".vho") ]
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".safe")]
filelist = filelist + [ f for f in os.listdir(".") if f.endswith("~") ]
for f in filelist: os.remove(f)
os.chdir(curPath)
# Perform the copy
#shutil.copyfile("\\".join([srcPath, "submodules\\print_control_system_head_1_Print_data.vhd"]),
# "\\".join([dstPath, "submodules\\print_control_system_head_1_Print_data.vhd"]))
subprocess.call(" ".join(["robocopy ", srcPath , dstPath]) , shell=True)
subprocess.call(" ".join(["robocopy ", "".join([srcPath, "\submodules"]), "".join([dstPath, "\submodules"])]), shell=True)
subprocess.call(" ".join(["robocopy ", "".join([srcPath, "\mentor"]) , "".join([dstPath, "\mentor"])]) , shell=True)
def return_files(system_name):
# Move, shorten, and then move back the generated files
srcPath = "c:/simulation"
dstPath = "".join(["..\\build\\" + system_name + "_system\simulation"])
myCmd = " ".join(["robocopy /E", srcPath, dstPath])
#print myCmd
subprocess.call(myCmd, shell=True)
def get_top_level():
searchfile = open('msim_setup.tcl', "r")
for line in searchfile:
if "set TOP_LEVEL_NAME" in line:
myList = line.split('''"''')
topLevel = myList[1]
#topLevel = "".join([myList[1], "_mm_interconnect"])
#print topLevel
searchfile.close()
return topLevel
def edit_msim_setup(longName, sub_array):
tbName = "".join([longName, "_tb -f args.txt"])
#sub_array[longerName] = "shrt"
sub_keys = sub_array.keys()
readFileName = 'msim_setup_old.tcl'
writeFileName = 'msim_setup.tcl'
if os.path.isfile(readFileName):
os.remove(readFileName)
os.rename(writeFileName, readFileName)
readFile = open('msim_setup_old.tcl', "r")
writeFile = open('msim_setup.tcl', "w")
copyNum = 0
elab_tb = 0
myAlias = ""
for line in readFile:
newLine = line
pcName = os.environ['USERDOMAIN']
# Swap in 'dev_com' edit
if ((" if " in line) and ("ModelSim" in line)):
if 'MULL' in pcName:
newLine = " if ![file isdirectory libraries/cyclonev/cyclonev_and1] {\n"
else:
newLine = " if [file isdirectory libraries/cyclonev/cyclonev_and1] {\n"
# Swap in shortened file names
for key in sub_keys:
if (elab_tb == 0): newLine = newLine.replace(key, sub_array[key])
# Check to see if we have already added the new 'elab_tb'
if ("alias elab_tb " in line):
elab_tb = 1
# Detect the 'elab' target and take a copy while creating the 'elab_tb'
if (("alias elab " in line) and (elab_tb == 0)):
copyNum = 5
elif copyNum > 0:
copyNum = copyNum - 1
if copyNum > 1:
myAlias = "".join([myAlias, newLine])
newLine = newLine.replace(" elab", " elab_tb")
newLine = newLine.replace('''$TOP_LEVEL_NAME''', tbName)
elif copyNum == 1:
writeFile.write(myAlias)
# Write back the original 'elab' target
writeFile.write(newLine)
readFile.close()
writeFile.close()
def rename_top_level(topLevel, longName, sub_array):
readFileName = "".join(["../", topLevel, "_old.vhd"])
writeFileName = "".join(["../", topLevel, ".vhd"])
sub_keys = sub_array.keys()
if os.path.isfile(readFileName):
os.remove(readFileName)
os.rename(writeFileName, readFileName)
readFile = open(readFileName, "r")
writeFile = open(writeFileName, "w")
myHeadAux = 0
entity = 1
for line in readFile:
newLine = line
# Replace all the long strings with shortened versions
for key in sub_keys:
newLine = newLine.replace(key, sub_array[key])
# Remove the std_logic_vector initialisation values as this upsets SystemC flow
if (": in " in newLine) and ("address " in newLine) and (entity == 1):
newLine = newLine.replace(":= '0'", "")
if (": in " in newLine) and (entity == 1):
newLine = newLine.replace(":= (others => '0')", "")
if ("end entity" in newLine):
entity = 0
# Correct the 1 bit address vector width issue
if ("address " in newLine) and (": in " in newLine) and (" std_logic " in newLine):
newLine = newLine.replace("std_logic", "std_logic_vector(0 downto 0)")
newLine = newLine.replace("'X'", "(others => 'X')")
newLine = newLine.replace("(0)", "")
writeFile.write(newLine)
readFile.close()
writeFile.close()
# Now fix the _rst_controller.vhd file
sub_keys = sub_array.keys()
os.chdir("..")
oldList = [ f for f in listdir("./") if isfile(join("./",f)) ]
newList = []
for f in oldList:
if isdir(f):
dummy = "me"
print "Removing: " + f
elif f.endswith("rst_controller.vhd"):
newList.append(f)
elif f.endswith("rst_controller_001.vhd"):
newList.append(f)
for f in newList:
readFileName = f + ".safe"
writeFileName = f
for key in sub_keys:
writeFileName = writeFileName.replace(key, sub_array[key])
print writeFileName
if os.path.isfile(readFileName):
os.remove(readFileName)
print '''Renaming "''' + f + '''" as "''' + readFileName
os.rename(f, readFileName)
#print "readFileName is:"+readFileName
#print "writeFileName is:"+writeFileName
readFile = open(readFileName, "r")
writeFile = open(writeFileName, "w")
for line in readFile:
newLine = line
for key in sub_keys:
newLine = newLine.replace(key, sub_array[key])
if ("address " in newLine) and (": in " in newLine) and (" std_logic " in newLine):
newLine = newLine.replace("std_logic", "std_logic_vector(0 downto 0)")
newLine = newLine.replace("'X'", "(others => 'X')")
if ("address " in newLine) and (": IN " in newLine) and (" STD_LOGIC;" in newLine):
newLine = newLine.replace("STD_LOGIC", "STD_LOGIC_VECTOR(0 DOWNTO 0)")
newLine = newLine.replace("'X'", "(others => 'X')")
if ("address\t" in newLine) and (":\tIN " in newLine) and (" STD_LOGIC;" in newLine):
newLine = newLine.replace("STD_LOGIC", "STD_LOGIC_VECTOR(0 DOWNTO 0)")
newLine = newLine.replace("'X'", "(others => 'X')")
if ("=>" in newLine):
newLine = newLine.replace("_address(0)", "_address")
if ("std_logic'" in newLine) and ("av_address" in newLine):
newLine = newLine.replace("(av_address)", "(av_address(0))")
newLine = newLine.replace("NOT av_address)", "NOT av_address(0))")
if ("av_address;" in newLine):
newLine = newLine.replace("av_address;", "av_address(0);")
if (" address " in newLine) and ("<=" in newLine) and not ("DOWNTO" in newLine):
newLine = newLine.replace(" address ", " address(0) ")
if (" address;" in newLine):
newLine = newLine.replace(" address;", " address(0);")
writeFile.write(newLine)
readFile.close()
writeFile.close()
os.chdir("mentor")
def rename_bridges(longName):
print longName
os.chdir("..")
oldList = [ f for f in listdir("./") if isfile(join("./",f)) ]
newList = []
for f in oldList:
if f.endswith("safe.safe"):
os.remove(f)
elif ("_bridge_" in f):
newList.append(f)
elif ("_translator" in f):
newList.append(f)
print newList
for f in newList:
readFileName = f + ".safe"
writeFileName = f
writeFileName = writeFileName.replace(longName, "shrt")
print writeFileName
if os.path.isfile(readFileName):
os.remove(readFileName)
print '''Renaming "''' + f + '''" as "''' + readFileName
os.rename(f, readFileName)
readFile = open(readFileName, "r")
writeFile = open(writeFileName, "w")
for line in readFile:
newLine = line
newLine = newLine.replace(longName, "shrt")
writeFile.write(newLine)
readFile.close()
writeFile.close()
os.chdir("mentor")
def rename_other_entities(longName, sub_array):
sub_keys = sub_array.keys()
os.chdir("../submodules")
oldList = [ f for f in listdir("./") if isfile(join("./",f)) ]
#oldList = ["lvds_slave_system_mm_interconnect_1_spi_0_spi_control_port_translator_avalon_universal_slave_0_agent_rsp_fifo.vho"]
#oldList = listdir(".")
#print oldList
newList = []
for f in oldList:
if isdir(f):
dummy = "me"
print "Removing: " + f
elif f.endswith("safe"):
if f.endswith("safe.safe"):
#print "Deleting: " + f
os.remove(f)
else:
dummy = "me"
#print "Not deleting: " + f
print "Removing: " + f
else:
#print "Not removing: " + f
newList.append(f)
print newList
for f in newList:
readFileName = f + ".safe"
writeFileName = f
for key in sub_keys:
writeFileName = writeFileName.replace(key, sub_array[key])
print writeFileName
if os.path.isfile(readFileName):
os.remove(readFileName)
print '''Renaming "''' + f + '''" as "''' + readFileName
os.rename(f, readFileName)
readFile = open(readFileName, "r")
writeFile = open(writeFileName, "w")
for line in readFile:
newLine = line
for key in sub_keys:
newLine = newLine.replace(key, sub_array[key])
if ("address " in newLine) and (": in " in newLine) and (" std_logic " in newLine):
newLine = newLine.replace("std_logic", "std_logic_vector(0 downto 0)")
newLine = newLine.replace("'X'", "(others => 'X')")
if ("address " in newLine) and (": IN " in newLine) and (" STD_LOGIC;" in newLine):
newLine = newLine.replace("STD_LOGIC", "STD_LOGIC_VECTOR(0 DOWNTO 0)")
newLine = newLine.replace("'X'", "(others => 'X')")
if ("address\t" in newLine) and (":\tIN " in newLine) and (" STD_LOGIC;" in newLine):
newLine = newLine.replace("STD_LOGIC", "STD_LOGIC_VECTOR(0 DOWNTO 0)")
newLine = newLine.replace("'X'", "(others => 'X')")
if ("=>" in newLine) and ("vhd" in readFileName):
newLine = newLine.replace("_address(0)", "_address")
if ("std_logic'" in newLine) and ("av_address" in newLine) and ("vhd" in readFileName):
newLine = newLine.replace("(av_address)", "(av_address(0))")
newLine = newLine.replace("NOT av_address)", "NOT av_address(0))")
if ("av_address;" in newLine) and ("vhd" in readFileName):
newLine = newLine.replace("av_address;", "av_address(0);")
if (" address " in newLine) and ("<=" in newLine) and not ("DOWNTO" in newLine) and ("vhd" in readFileName):
newLine = newLine.replace(" address ", " address(0) ")
if (" address;" in newLine) and ("vhd" in readFileName):
newLine = newLine.replace(" address;", " address(0);")
writeFile.write(newLine)
readFile.close()
writeFile.close()
def compile_test(longName):
origDir = os.getcwd()
compDir = longName.join(['../build/', '/simulation/mentor'])
os.chdir(compDir)
pcName = os.environ['USERDOMAIN']
if 'MULL' in pcName:
if ("supervisor" in longName):
subprocess.call(["C:\\modeltech_pe_10.1a\\win32pe\\vsim",
"-do", "../../../../../generic_ip/common/sim/supervisor_comp.do",
"-c", "-l", "compile.log"])
elif ("top" in longName):
subprocess.call(["C:\\modeltech_pe_10.1a\\win32pe\\vsim",
"-do", "../../../../../generic_ip/common/sim/top_comp.do",
"-c", "-l", "compile.log"])
else:
subprocess.call(["C:\\modeltech_pe_10.1a\\win32pe\\vsim",
"-do", "../../../../../generic_ip/common/sim/comp.do",
"-c", "-l", "compile.log"])
else:
vsimloc = os.environ['QUARTUS_ROOTDIR']+"\\..\\modelsim_ase\\win32aloem\\vsim"
print "about to call complie using vsim location of: {}".format(vsimloc)
subprocess.call([vsimloc,
"-do", "../../../../../generic_ip/common/sim/comp.do",
"-c", "-l", "compile.log"])
os.chdir(origDir)
def copy_artifacts(moduleName, testName):
# create directory in WORKSPACE called sim_results
tmpList = os.getcwd().split("\\firmware")
tgtDir = os.path.join(tmpList[0], "sim_results")
if not os.path.exists(tgtDir):
print "making directory at {}".format(tgtDir)
os.makedirs(tgtDir)
# create directory in there called moduleName_testName
newDirName = "_".join([moduleName,testName])
tgtDir = os.path.join(tgtDir,newDirName)
if not os.path.exists(tgtDir):
os.makedirs(tgtDir)
print "making directory at {}".format(tgtDir)
else:
for f in os.listdir(tgtDir):
fullPathF = os.path.join(tgtDir,f)
print "removing {}".format(fullPathF)
os.remove(fullPathF)
# from current location copy *.txt, *.log, *.tcl, *.vstf into the directory
localDir = os.getcwd()
print "copying relevant files from {} to {}".format(localDir,tgtDir)
extList = [".txt",".log",".tcl",".vstf"]
for f in os.listdir(localDir):
for ext in extList:
if f.endswith(ext):
fullPathF = os.path.join(localDir,f)
print "copying {}".format(fullPathF)
shutil.copy(fullPathF,tgtDir)
def run_program(moduleName, testArray):
paramNameArray = testArray.keys()
paramNameArray.remove('testName') # this is now an array of the names of the generics to be set
numParams = len(paramNameArray)
testNameArray = testArray['testName']
numTests = len(testNameArray)
print "run_program starting"
print "numParams: {} ".format(numParams)
print "testNameArray[0] {}".format(testNameArray[0])
print "numTests {}".format(numTests)
tmpStr = ""
for i in sys.argv:
tmpStr = "{},{}".format(tmpStr,i)
print "Argv items are {}".format(tmpStr)
namedTestPerformed = False
print "I running program-------------------------------------------------------"
origDir = os.getcwd()
simDir = moduleName.join(['../build/', '_system/simulation/mentor'])
os.chdir(simDir)
pcName = os.environ['USERDOMAIN']
for testName in testNameArray:
tmpStr = ""
for paramName in paramNameArray:
paramArray = testArray[paramName]
#print paramArray
#print paramArray[1]
paramValue = paramArray[testNameArray.index(testName)]
paramStr = "".join(["-G", paramName, "=", paramValue])
scParamStr = "".join(["-sc_arg \"", paramName, "=", paramValue, "\""])
if ("top" in moduleName) or ("supervisor" in moduleName):
tmpStr = " ".join([tmpStr, scParamStr])
else:
tmpStr = " ".join([tmpStr, paramStr])
print "set of parameters going to args.txt for test:{} is:{}".format(testName,tmpStr)
create_args_file(tmpStr)
logStr = "".join([testName, "_run.log"])
tbName = "".join([moduleName, "_system_tb"])
batchMode = get_batch_mode()
if 'MULL' in pcName:
if ("top" in moduleName) or ("supervisor" in moduleName):
print "Samba"
if batchMode==1:
callStr = " ".join(["C:/modeltech_pe_10.1a/win32pe/vsim", "-c",
"-do", "../../../../../generic_ip/common/sim/sc_run_batch.do", "-l", logStr])
else:
callStr = " ".join(["C:/modeltech_pe_10.1a/win32pe/vsim",
"-do", "../../../../../generic_ip/common/sim/sc_run.do", "-l", logStr])
else:
print "Not Samba"
if batchMode==1:
callStr = " ".join(["C:/modeltech_pe_10.1a/win32pe/vsim", "-c",
"-do", "../../../../../generic_ip/common/sim/run_batch.do", "-l", logStr])
else:
callStr = " ".join(["C:/modeltech_pe_10.1a/win32pe/vsim",
"-do", "../../../../../generic_ip/common/sim/run.do", "-l", logStr])
else:
if batchMode==1:
callStr = " ".join([os.environ['QUARTUS_ROOTDIR']+"\\..\\modelsim_ase\\win32aloem\\vsim", "-c",
"-do", "../../../../../generic_ip/common/sim/run_batch.do", "-l", logStr])
else:
callStr = " ".join([os.environ['QUARTUS_ROOTDIR']+"\\..\\modelsim_ase\\win32aloem\\vsim",
"-do", "../../../../../generic_ip/common/sim/run.do", "-l", logStr])
if ((sys.argv[-1]==testName) or (sys.argv[-1]=='all')):
print "current directory is {}".format(os.getcwd())
print "call String will be: {}".format(callStr)
subprocess.call(callStr, shell=True) # does the simulation
check_result(logStr)
namedTestPerformed = True
copy_artifacts(moduleName, testName)
if namedTestPerformed:
print "All requested tests performed per '{}'".format(sys.argv[-1])
else:
print "Oops!\n"
print "Test name '{}' was not found in array".format(sys.argv[-1])
os.chdir(origDir)
def create_args_file(argsString):
argsFileName = "args.txt"
argsFile = open(argsFileName, "w")
argsFile.write(argsString)
argsFile.close()
def check_result(logfile):
searchfile = open(logfile, "r")
for line in searchfile:
if "SUCCESS" in line:
print 'Test appears to have been successful, which is nice...'
return None
searchfile.close()
print 'Test appears to have NOT been successful, oops...'
sys.exit(1)
def main(myModule, testArray, ipArray):
origDir = os.getcwd()
create_new_qsys()
if (get_qsys_build()==1): generate_sim_files(ipArray)
copy_files(my_module())
os.chdir("c:/simulation/mentor")
topLevel = get_top_level()
#longName = "".join([topLevel, "_mm_interconnect"])
longName = topLevel
print "The top level is " + topLevel + " and the long name to be replaced is " + longName
edit_msim_setup(longName, subst_array)
rename_top_level(topLevel, longName, subst_array)
rename_bridges(longName)
rename_other_entities(longName, subst_array)
os.chdir(origDir)
return_files(my_module())
compile_test(longName)
run_program(myModule, testArray)

View file

@ -0,0 +1,78 @@
import sys
import os
from os import listdir
from os.path import isfile, join, isdir
# Defines which header file types we are trying to generate and support
class HeaderType:
CPP, VHDL = range(2)
# Maintains the 'Register Model' including name and address
class RegClass:
def __init__(self, vhdlLine):
lineList = vhdlLine.split()
self.regName = lineList[1]
addrList = lineList[-1].split("\"")
self.regAddr = addrList[1]
def getC(self):
myStr = "".join(["const int ", self.regName,
" = 0x", self.regAddr,";"])
print myStr
def getVhdl(self):
myStr = "".join(["constant ", self.regName,
" std_logic_vector(7 downto 0) := x\"",
self.regAddr,"\";"])
print myStr
def getRegs(self, header):
if header == HeaderType.CPP:
self.getC()
if header == HeaderType.VHDL:
self.getVhdl()
# Represents the 'IP Block' and contains instances of 'RegClass'
class IpClass:
def __init__(self, ip_name):
tmpPath = os.getcwd()
self.myPath = "".join([tmpPath, "/../../", ip_name, "/src"])
print self.myPath
self.file_list = [ f for f in os.listdir(self.myPath) if f.endswith(".vhd") ]
os.chdir(self.myPath)
readFileName = self.file_list[0]
readFile = open(readFileName, "r")
self.MyRegs = []
for line in readFile:
if (("constant" in line) and ("_ADDR" in line)):
self.MyRegs.append(RegClass(line))
def list_files(self):
print self.file_list
def getRegs(self, header):
for reg in self.MyRegs:
reg.getRegs(header)
# Represents the 'IP Library' and contains instances of 'IpClass'
class LibraryClass:
def __init__(self):
self.ip_list = [ f for f in os.listdir("../..") if f.find("generic")==0 ]
self.myIp = []
for ip in self.ip_list:
#print ip
self.myIp.append(IpClass(ip))
def getRegs(self, header):
print self.ip_list
for inst in self.myIp:
inst.getRegs(header)
# inst.list_files()
def main():
myLibrary = LibraryClass()
myLibrary.getRegs(HeaderType.VHDL)
main()

View file

@ -0,0 +1,56 @@
# Use vmap to copy modelsim.ini this directory so msim_setup.tcl doesn't
# override installation file.
vmap -c
# Load the Altera generated macros
do msim_setup.tcl
# Compile the technology specific libraries
dev_com
# Compile the constrained random related packages
vlib OSVVM
vcom -2008 -work OSVVM \
../../../../../generic_ip/common/src/test/OSVVM/RandomBasePkg.vhd \
../../../../../generic_ip/common/src/test/OSVVM/SortListPkg_int.vhd \
../../../../../generic_ip/common/src/test/OSVVM/RandomPkg.vhd \
../../../../../generic_ip/common/src/test/OSVVM/NamePkg.vhd \
../../../../../generic_ip/common/src/test/OSVVM/MessagePkg.vhd \
../../../../../generic_ip/common/src/test/OSVVM/CoveragePkg.vhd
#../../../../../generic_ip/common/src/test/OSVVM/OsvvmGlobalPkg.vhd \
#../../../../../generic_ip/common/src/test/OSVVM/OsvvmContext.vhd \
#../../../../../generic_ip/common/src/test/OSVVM/AlertLogPkg.vhd \
#../../../../../generic_ip/common/src/test/OSVVM/AlertLogPkg_body_BVUL.vhd \
# Compile the design files
com
vcom -2008 -work work ../../../../../generic_ip/common/src/test/txt_util.vhd
# Compile the VHDL packages that support bus protocols, memory mapped registers and functional procedures
vcom -2008 -work work ../../../../../generic_ip/common/src/test/avalon_verify_pkg.vhd
vcom -2008 -work work ../../../../../print_ctrl/src/test/pkg_types.vhd
vcom -2008 -work work ../../../../../top/src/test/hib_verify_pkg.vhd
vcom -2008 -work work ../../../../../top/src/test/func_verify_pkg.vhd
vcom -2008 -work work ../../../../../top/src/test/coverage_verify_pkg.vhd
vcom -2008 -work work ../../../../../soc_system/ip/hib_logic/src/pkg_functions.vhd
vcom -2008 -work work ../../../../../print_ctrl/src/test/asic_model.vhd
vcom -2008 -work work ../../../../../print_ctrl/src/test/actuator_die_model.vhd
vcom -2008 -work work ../../../../../print_ctrl/src/test/head_model.vhd
vcom -2008 -work work ../../../../../print_ctrl/src/test/memory_model2.vhd
# Compile the various printhead and circuit models
#vcom -work work ../../../../../lvds_slave/src/test/pmb_model.vhd
#vcom -work work ../../../../../print_data/src/test/data_model.vhd
#vcom -work work ../../../../../waveform_control/src/test/pzt_model.vhd
#vcom -work work ../../../../../waveform_control/src/test/waveform_circuit.vhd
#vcom -work work ../../../../../printhead/src/test/side_model.vhd
#vcom -work work ../../../../../printhead/src/test/head_model.vhd
# Compile the various block and sub-system VHDL testbenches
vcom -2008 -work work ../../../../../timing_ctrl/src/test/timing_ctrl_system_tb.vhd
vcom -2008 -work work ../../../../../image_expand/src/test/image_expand_system_tb.vhd
vcom -2008 -work work ../../../../../stripe_transform/src/test/stripe_transform_system_tb.vhd
vcom -2008 -work work ../../../../../print_ctrl/src/test/print_ctrl_system_tb.vhd
# Exit Modelsim once this is complete
quit -f

View file

@ -0,0 +1,5 @@
do msim_setup.tcl
elab_tb
when -label passed_end_of_simulation {passed == true} {echo "SUCCESS , Passed end of simulation"; stop ;}
when -label failed_end_of_simulation {failed == true} {echo "Failed end of simulation"; stop ;}
run -all

View file

@ -0,0 +1,5 @@
do msim_setup.tcl
elab_tb
when -label passed_end_of_simulation {passed == true} {echo "SUCCESS , Passed end of simulation"; quit -f -code 0 ;}
when -label failed_end_of_simulation {failed == true} {echo "Failed end of simulation"; quit -f -code 1 ;}
run -all

View file

@ -0,0 +1,5 @@
do msim_setup.tcl
elab_tb
#when -label passed_end_of_simulation {passed == true} {echo "Passed end of simulation"; quit -f -code 0 ;}
#when -label failed_end_of_simulation {failed == true} {echo "Failed end of simulation"; quit -f -code 1 ;}
#run -all

View file

@ -0,0 +1,5 @@
do msim_setup.tcl
elab_tb
#when -label passed_end_of_simulation {passed == true} {echo "Passed end of simulation"; quit -f -code 0 ;}
#when -label failed_end_of_simulation {failed == true} {echo "Failed end of simulation"; quit -f -code 1 ;}
run -all

View file

@ -0,0 +1,68 @@
# Simulation macro
.main clear
# Cleanup libraries
foreach lib [list work OSVVM] {
file delete -force -- $lib
vlib $lib
}
set COMP_ONLY 0
set TB_PATH ./../src/test
set SRC_PATH ../src
set OSVVM_PATH $TB_PATH/OSVVM
set WORKLIB work
vlib ./work
vmap work ./work
if {$COMP_ONLY == 0} {
# Compile the constrained random related packages
vlib OSVVM
vcom -2008 -work OSVVM \
$OSVVM_PATH/RandomBasePkg.vhd \
$OSVVM_PATH/SortListPkg_int.vhd \
$OSVVM_PATH/RandomPkg.vhd \
$OSVVM_PATH/NamePkg.vhd \
$OSVVM_PATH/MessagePkg.vhd \
$OSVVM_PATH/CoveragePkg.vhd
}
# compile the UUTs:
vcom -2008 -work $WORKLIB $SRC_PATH/cs_bus_itf.vhd
# Compile the testbench and the other components supporting the test
if {$COMP_ONLY == 0} {
# Test support packages
vcom -2008 -work $WORKLIB $TB_PATH/common_test_pkg.vhd
vcom -2008 -work $WORKLIB $TB_PATH/log_pkg.vhd
vcom -2008 -work $WORKLIB $TB_PATH/avalon_verify_pkg.vhd
# Testbench
vcom -2008 -work $WORKLIB $TB_PATH/cs_bus_itf_tb.vhd
vsim -t ps work.cs_bus_itf_tb
#add wave cs_bus_itf_tb/*
#add wave cs_bus_itf_tb/iUUT/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_cs_bus_itf.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 1 ms;
}

View file

@ -0,0 +1,58 @@
# Simulation macro
.main clear
# Cleanup libraries
foreach lib [list work OSVVM] {
file delete -force -- $lib
vlib $lib
}
set SRC_PATH ./../src
set TB_PATH ./../src/test
set OSVVM_PATH $TB_PATH/OSVVM
vlib ./work
vmap work ./work
# Compile the constrained random related packages
vlib OSVVM
vcom -2008 -work OSVVM $OSVVM_PATH/RandomBasePkg.vhd
vcom -2008 -work OSVVM $OSVVM_PATH/SortListPkg_int.vhd
vcom -2008 -work OSVVM $OSVVM_PATH/RandomPkg.vhd
vcom -2008 -work OSVVM $OSVVM_PATH/NamePkg.vhd
vcom -2008 -work OSVVM $OSVVM_PATH/MessagePkg.vhd
vcom -2008 -work OSVVM $OSVVM_PATH/CoveragePkg.vhd
# Compile the UUT
vcom -work work $SRC_PATH/common_pkg.vhd
vcom -work work $SRC_PATH/altera/sync_fifo.vhd
vcom -2008 -work work $SRC_PATH/queue_and_delay.vhd
# Compile the Testbench and the other components supporting the test
vcom -2008 -work work $TB_PATH/common_test_pkg.vhd
vcom -2008 -work work $TB_PATH/log_pkg.vhd
vcom -2008 -work work $TB_PATH/lfsr_6.vhd
vcom -2008 -work work $TB_PATH/queue_and_delay_tb.vhd
# Simulate
vsim -t ps work.queue_and_delay_tb
#add wave /queue_and_delay_tb/*
#add wave /queue_and_delay_tb/iUUT/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_queue_delay.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 100 us;

View file

@ -0,0 +1,40 @@
# Load the Altera generated macros
do msim_setup.tcl
# Compile the technology specific libraries
dev_com
# Compile the constrained random related packages
vlib OSVVM
vcom -work OSVVM \
../../../../../../../../../Common/src/test/OSVVM/RandomBasePkg.vhd \
../../../../../../../../../Common/src/test/OSVVM/SortListPkg_int.vhd \
../../../../../../../../../Common/src/test/OSVVM/RandomPkg.vhd \
../../../../../../../../../Common/src/test/OSVVM/NamePkg.vhd \
../../../../../../../../../Common/src/test/OSVVM/MessagePkg.vhd \
../../../../../../../../../Common/src/test/OSVVM/CoveragePkg.vhd
# Compile the design files
com
# Compile the VHDL packages that support bus protocols, memory mapped registers and functional procedures
vcom -work work ../../../../../common/src/test/avalon_verify_pkg.vhd
vcom -work work ../../../../../common/src/test/hib_verify_pkg.vhd
vcom -work work ../../../../../common/src/test/func_verify_pkg.vhd
vcom -work work ../../../../../common/src/test/coverage_verify_pkg.vhd
# Compile the various printhead and circuit models
vcom -work work ../../../../../lvds_slave/src/test/pmb_model.vhd
vcom -work work ../../../../../print_data/src/test/data_model.vhd
vcom -work work ../../../../../waveform_control/src/test/pzt_model.vhd
vcom -work work ../../../../../waveform_control/src/test/waveform_circuit.vhd
vcom -work work ../../../../../printhead/src/test/side_model.vhd
vcom -work work ../../../../../printhead/src/test/head_model.vhd
# compile and link C source files
scgenmod supervisor_system > ../../../../../supervisor/src/test/supervisor_system.h
sccom -scv -g ../../../../../supervisor/src/test/supervisor_system_tb.cpp
sccom -scv -link
# Exit Modelsim once this is complete
quit -f

View file

@ -0,0 +1,47 @@
# Load the Altera generated macros
do msim_setup.tcl
# Compile the technology specific libraries
dev_com
# Compile the constrained random related packages
vlib OSVVM
vcom -work OSVVM \
../../../../../../../../../Common/src/test/OSVVM/RandomBasePkg.vhd \
../../../../../../../../../Common/src/test/OSVVM/SortListPkg_int.vhd \
../../../../../../../../../Common/src/test/OSVVM/RandomPkg.vhd \
../../../../../../../../../Common/src/test/OSVVM/NamePkg.vhd \
../../../../../../../../../Common/src/test/OSVVM/MessagePkg.vhd \
../../../../../../../../../Common/src/test/OSVVM/CoveragePkg.vhd
# Compile the design files
com
# Compile the VHDL packages that support bus protocols, memory mapped registers and functional procedures
vcom -work work ../../../../../common/src/test/avalon_verify_pkg.vhd
vcom -work work ../../../../../common/src/test/hib_verify_pkg.vhd
vcom -work work ../../../../../common/src/test/func_verify_pkg.vhd
vcom -work work ../../../../../common/src/test/coverage_verify_pkg.vhd
# Compile the various printhead and circuit models
vcom -work work ../../../../../lvds_slave/src/test/pmb_model.vhd
vcom -work work ../../../../../print_data/src/test/data_model.vhd
vcom -work work ../../../../../waveform_control/src/test/pzt_model.vhd
vcom -work work ../../../../../waveform_control/src/test/waveform_circuit.vhd
vcom -work work ../../../../../printhead/src/test/side_model.vhd
vcom -work work ../../../../../printhead/src/test/head_model.vhd
vcom -work work ../../../../../top/src/hib_fd_1200.vhd
# compile and link C source files
scgenmod top_system > ../../../../../top/src/test/top_system.h
scgenmod hib_fd_1200 > ../../../../../top/src/test/hib_fd_1200.h
sccom -g ../../../../../top/src/test/PrintheadMessage.cpp
sccom -g ../../../../../top/src/test/PrintheadMessageReceive.cpp
sccom -g ../../../../../top/src/test/PrintheadMessageSend.cpp
#sccom -g ../../../../../top/src/test/PrintheadExtenderBase.cpp
#sccom -g ../../../../../top/src/test/PrintheadEx.cpp
sccom -scv -g ../../../../../top/src/test/top_system_tb.cpp
sccom -scv -link
# Exit Modelsim once this is complete
quit -f

View file

@ -0,0 +1,78 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /cs_bus_itf_tb/reset_n
add wave -noupdate /cs_bus_itf_tb/clk
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_address
add wave -noupdate /cs_bus_itf_tb/avs_write
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_writedata
add wave -noupdate /cs_bus_itf_tb/avs_read
add wave -noupdate /cs_bus_itf_tb/avs_waitrequest
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_readdata
add wave -noupdate /cs_bus_itf_tb/cs_addr
add wave -noupdate /cs_bus_itf_tb/cs_we
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/cs_wr_data
add wave -noupdate /cs_bus_itf_tb/cs_re
add wave -noupdate /cs_bus_itf_tb/cs_rv
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/cs_rd_data
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_m
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/avs_s
add wave -noupdate /cs_bus_itf_tb/end_of_stimuli
add wave -noupdate /cs_bus_itf_tb/test_completed
add wave -noupdate /cs_bus_itf_tb/setup
add wave -noupdate /cs_bus_itf_tb/running
add wave -noupdate /cs_bus_itf_tb/passed
add wave -noupdate /cs_bus_itf_tb/failed
add wave -noupdate /cs_bus_itf_tb/blk_0_re
add wave -noupdate /cs_bus_itf_tb/blk_0_we
add wave -noupdate /cs_bus_itf_tb/blk_0_rv
add wave -noupdate /cs_bus_itf_tb/blk_0_re_d
add wave -noupdate /cs_bus_itf_tb/blk_1_re
add wave -noupdate /cs_bus_itf_tb/blk_1_we
add wave -noupdate /cs_bus_itf_tb/blk_1_rv
add wave -noupdate /cs_bus_itf_tb/blk_1_re_d
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/blk_0_wr_data
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/blk_0_rd_data
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/blk_1_wr_data
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/blk_1_rd_data
add wave -noupdate /cs_bus_itf_tb/iUUT/rstN
add wave -noupdate /cs_bus_itf_tb/iUUT/clk
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/avs_address
add wave -noupdate /cs_bus_itf_tb/iUUT/avs_write
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/avs_writedata
add wave -noupdate /cs_bus_itf_tb/iUUT/avs_read
add wave -noupdate /cs_bus_itf_tb/iUUT/avs_waitrequest
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/avs_readdata
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_addr
add wave -noupdate /cs_bus_itf_tb/iUUT/cs_we
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_wr_data
add wave -noupdate /cs_bus_itf_tb/iUUT/cs_re
add wave -noupdate /cs_bus_itf_tb/iUUT/cs_rv
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_rd_data
add wave -noupdate -radix hexadecimal /cs_bus_itf_tb/iUUT/cs_rd_data_i
add wave -noupdate /cs_bus_itf_tb/iUUT/avs_read_d
add wave -noupdate /cs_bus_itf_tb/iUUT/avs_rd_en
add wave -noupdate /cs_bus_itf_tb/iUUT/avs_wr_en_d
add wave -noupdate /cs_bus_itf_tb/iUUT/busy
add wave -noupdate /cs_bus_itf_tb/iUUT/read_valid
add wave -noupdate /cs_bus_itf_tb/iUUT/dummy_rv
add wave -noupdate /cs_bus_itf_tb/iUUT/timeout_flag
add wave -noupdate -radix unsigned /cs_bus_itf_tb/iUUT/read_timeout_cnt
add wave -noupdate /cs_bus_itf_tb/iUUT/avs_address_i
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {515000 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 273
configure wave -valuecolwidth 187
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {0 ps} {3540224 ps}

View file

@ -0,0 +1,85 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /queue_and_delay_tb/reset_n
add wave -noupdate /queue_and_delay_tb/clk
add wave -noupdate /queue_and_delay_tb/init
add wave -noupdate /queue_and_delay_tb/cnt_dir
add wave -noupdate /queue_and_delay_tb/delay
add wave -noupdate -radix hexadecimal /queue_and_delay_tb/ext_time
add wave -noupdate /queue_and_delay_tb/wave_in
add wave -noupdate /queue_and_delay_tb/wave_out
add wave -noupdate /queue_and_delay_tb/wave_ref
add wave -noupdate /queue_and_delay_tb/ovf_error
add wave -noupdate /queue_and_delay_tb/passed
add wave -noupdate /queue_and_delay_tb/failed
add wave -noupdate /queue_and_delay_tb/test_completed
add wave -noupdate /queue_and_delay_tb/wave_in_rst
add wave -noupdate /queue_and_delay_tb/wave_in_upd
add wave -noupdate /queue_and_delay_tb/wave_ref_rst
add wave -noupdate /queue_and_delay_tb/wave_ref_upd
add wave -noupdate /queue_and_delay_tb/wave_running
add wave -noupdate /queue_and_delay_tb/wave_completed
add wave -noupdate /queue_and_delay_tb/wave_in_completed
add wave -noupdate /queue_and_delay_tb/wave_ref_completed
add wave -noupdate /queue_and_delay_tb/wave_init
add wave -noupdate /queue_and_delay_tb/wave_init_d
add wave -noupdate /queue_and_delay_tb/delay_cnt
add wave -noupdate /queue_and_delay_tb/div_cnt_in
add wave -noupdate /queue_and_delay_tb/wave_in_upd
add wave -noupdate /queue_and_delay_tb/wave_in_cnt
add wave -noupdate /queue_and_delay_tb/div_cnt_ref
add wave -noupdate /queue_and_delay_tb/wave_ref_cnt
add wave -noupdate /queue_and_delay_tb/iUUT/rstN
add wave -noupdate /queue_and_delay_tb/iUUT/clk
add wave -noupdate /queue_and_delay_tb/iUUT/init
add wave -noupdate /queue_and_delay_tb/iUUT/cnt_dir
add wave -noupdate /queue_and_delay_tb/iUUT/delay
add wave -noupdate -radix hexadecimal /queue_and_delay_tb/iUUT/ext_time
add wave -noupdate /queue_and_delay_tb/iUUT/wave_in
add wave -noupdate /queue_and_delay_tb/iUUT/wave_out
add wave -noupdate /queue_and_delay_tb/iUUT/ovf_error
add wave -noupdate /queue_and_delay_tb/iUUT/toggle_in
add wave -noupdate /queue_and_delay_tb/iUUT/toggle_out
add wave -noupdate /queue_and_delay_tb/iUUT/time_elapsed
add wave -noupdate /queue_and_delay_tb/iUUT/wave_in_d
add wave -noupdate /queue_and_delay_tb/iUUT/wave_out_i
add wave -noupdate /queue_and_delay_tb/iUUT/pending_trans
add wave -noupdate /queue_and_delay_tb/iUUT/fifo_rd_en
add wave -noupdate /queue_and_delay_tb/iUUT/fifo_empty
add wave -noupdate /queue_and_delay_tb/iUUT/fifo_full
add wave -noupdate /queue_and_delay_tb/iUUT/cnt_dir_i
add wave -noupdate /queue_and_delay_tb/iUUT/wave_out_i_d
add wave -noupdate /queue_and_delay_tb/iUUT/new_event
add wave -noupdate /queue_and_delay_tb/iUUT/wave_out_ii
add wave -noupdate /queue_and_delay_tb/iUUT/shf_enable
add wave -noupdate /queue_and_delay_tb/iUUT/delay_line
add wave -noupdate -radix hexadecimal /queue_and_delay_tb/iUUT/int_time
add wave -noupdate /queue_and_delay_tb/iUUT/local_time_d
add wave -noupdate -radix hexadecimal /queue_and_delay_tb/iUUT/event_time
add wave -noupdate /queue_and_delay_tb/iUUT/delayed_event_time
add wave -noupdate -radix hexadecimal /queue_and_delay_tb/iUUT/diff_time
add wave -noupdate /queue_and_delay_tb/iWAVE_IN_GEN/clk
add wave -noupdate /queue_and_delay_tb/iWAVE_IN_GEN/lfsr_rst
add wave -noupdate /queue_and_delay_tb/iWAVE_IN_GEN/lfsr_upd
add wave -noupdate /queue_and_delay_tb/iWAVE_IN_GEN/lfsr_reg
add wave -noupdate /queue_and_delay_tb/iWAVE_IN_GEN/lfsr_out
add wave -noupdate /queue_and_delay_tb/iWAVE_IN_GEN/new_val
add wave -noupdate /queue_and_delay_tb/iWAVE_IN_GEN/shf_reg
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {495000 ps} 0} {{Cursor 2} {635000 ps} 1}
quietly wave cursor active 1
configure wave -namecolwidth 343
configure wave -valuecolwidth 100
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {0 ps} {2007584 ps}

View file

@ -0,0 +1,6 @@
the alt_* memory components are fully configurable Altera/Intel RAMs and
FIFOs and supersede all other memory components. The others are kept here
for backwards compatibility until they can be obsoleted. No local RAMs or
FIFOs should be added to any project code. If a particular configuration
is required, but not present here, then add this and make generic so it may
be used in other projects.

View file

@ -0,0 +1,216 @@
-- megafunction wizard: %FIFO%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: dcfifo
-- ============================================================
-- File Name: alt_async_fifo.vhd
-- Megafunction Name(s):
-- dcfifo
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 18.1.0 Build 625 09/12/2018 SJ Standard Edition
-- ************************************************************
--Copyright (C) 2018 Intel Corporation. All rights reserved.
--Your use of Intel Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Intel Program License
--Subscription Agreement, the Intel Quartus Prime License Agreement,
--the Intel FPGA IP License Agreement, or other applicable license
--agreement, including, without limitation, that your use is for
--the sole purpose of programming logic devices manufactured by
--Intel and sold by Intel or its authorized distributors. Please
--refer to the applicable agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.all;
use work.common_pkg.all;
entity alt_async_fifo is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 64;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON"; -- "OFF"
SYNC_CLR : string := "OFF" -- "ON"
);
port
(
clr : in std_logic := '0';
wrclk : in std_logic ;
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrfull : out std_logic ;
wrusedw : out std_logic_vector (log2(DEPTH)-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
rdusedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end alt_async_fifo;
architecture syn of alt_async_fifo is
signal sub_wire0 : std_logic_vector (DATA_WIDTH-1 downto 0);
signal sub_wire1 : std_logic ;
signal sub_wire2 : std_logic ;
signal sub_wire3 : std_logic_vector (log2(DEPTH)-1 downto 0);
signal sub_wire4 : std_logic_vector (log2(DEPTH)-1 downto 0);
component dcfifo
generic (
intended_device_family : string;
lpm_numwords : natural;
lpm_showahead : string;
lpm_type : string;
lpm_width : natural;
lpm_widthu : natural;
overflow_checking : string;
rdsync_delaypipe : natural;
underflow_checking : string;
use_eab : string;
read_aclr_synch : string;
write_aclr_synch : string;
wrsync_delaypipe : natural
);
port (
aclr : in std_logic ;
data : in std_logic_vector (DATA_WIDTH-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
wrclk : in std_logic ;
wrreq : in std_logic ;
q : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
wrfull : out std_logic ;
wrusedw : out std_logic_vector(log2(DEPTH)-1 downto 0);
rdusedw : out std_logic_vector(log2(DEPTH)-1 downto 0)
);
end component;
begin
rddata <= sub_wire0;
rdempty <= sub_wire1;
wrfull <= sub_wire2;
wrusedw <= sub_wire3;
rdusedw <= sub_wire4;
dcfifo_component : dcfifo
generic map (
intended_device_family => DEVICE_FAMILY,
lpm_numwords => DEPTH,
lpm_showahead => SHOWAHEAD,
lpm_type => "dcfifo",
lpm_width => DATA_WIDTH,
lpm_widthu => log2(DEPTH),
overflow_checking => CHECKING,
underflow_checking => CHECKING,
read_aclr_synch => SYNC_CLR,
write_aclr_synch => SYNC_CLR,
use_eab => "ON",
rdsync_delaypipe => 4,
wrsync_delaypipe => 4
)
port map (
aclr => clr,
data => wrdata,
rdclk => rdclk,
rdreq => rdreq,
wrclk => wrclk,
wrreq => wrreq,
q => sub_wire0,
rdempty => sub_wire1,
wrfull => sub_wire2,
wrusedw => sub_wire3,
rdusedw => sub_wire4
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "-1"
-- Retrieval info: PRIVATE: AlmostFull NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "-1"
-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
-- Retrieval info: PRIVATE: Clock NUMERIC "4"
-- Retrieval info: PRIVATE: Depth NUMERIC "64"
-- Retrieval info: PRIVATE: Empty NUMERIC "1"
-- Retrieval info: PRIVATE: Full NUMERIC "1"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1"
-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: Optimize NUMERIC "0"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
-- Retrieval info: PRIVATE: Width NUMERIC "32"
-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: diff_widths NUMERIC "0"
-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
-- Retrieval info: PRIVATE: output_width NUMERIC "32"
-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
-- Retrieval info: PRIVATE: sc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: sc_sclr NUMERIC "0"
-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: wsFull NUMERIC "1"
-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "64"
-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "dcfifo"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "32"
-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "6"
-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: RDSYNC_DELAYPIPE NUMERIC "4"
-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
-- Retrieval info: CONSTANT: WRSYNC_DELAYPIPE NUMERIC "4"
-- Retrieval info: USED_PORT: wrdata 0 0 32 0 INPUT NODEFVAL "wrdata[31..0]"
-- Retrieval info: USED_PORT: rddata 0 0 32 0 OUTPUT NODEFVAL "rddata[31..0]"
-- Retrieval info: USED_PORT: rdclk 0 0 0 0 INPUT NODEFVAL "rdclk"
-- Retrieval info: USED_PORT: rdempty 0 0 0 0 OUTPUT NODEFVAL "rdempty"
-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq"
-- Retrieval info: USED_PORT: wrclk 0 0 0 0 INPUT NODEFVAL "wrclk"
-- Retrieval info: USED_PORT: wrfull 0 0 0 0 OUTPUT NODEFVAL "wrfull"
-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq"
-- Retrieval info: CONNECT: @wrdata 0 0 32 0 wrdata 0 0 32 0
-- Retrieval info: CONNECT: @rdclk 0 0 0 0 rdclk 0 0 0 0
-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
-- Retrieval info: CONNECT: @wrclk 0 0 0 0 wrclk 0 0 0 0
-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
-- Retrieval info: CONNECT: rddata 0 0 32 0 @rddata 0 0 32 0
-- Retrieval info: CONNECT: rdempty 0 0 0 0 @rdempty 0 0 0 0
-- Retrieval info: CONNECT: wrfull 0 0 0 0 @wrfull 0 0 0 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL async_fifo_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,204 @@
-- megafunction wizard: %FIFO%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: dcfifo_mixed_widths
-- ============================================================
-- File Name: alt_async_fifo_mixed_width.vhd
-- Megafunction Name(s):
-- dcfifo_mixed_widths
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 18.1.0 Build 625 09/12/2018 SJ Standard Edition
-- ************************************************************
--Copyright (C) 2018 Intel Corporation. All rights reserved.
--Your use of Intel Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Intel Program License
--Subscription Agreement, the Intel Quartus Prime License Agreement,
--the Intel FPGA IP License Agreement, or other applicable license
--agreement, including, without limitation, that your use is for
--the sole purpose of programming logic devices manufactured by
--Intel and sold by Intel or its authorized distributors. Please
--refer to the applicable agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
use work.common_pkg.all;
library altera_mf;
use altera_mf.all;
entity alt_async_fifo_mixed_width is
generic (
WDATA_WIDTH : natural range 1 to 256 := 8;
RDATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 64; -- As seen at input
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port
(
wrclk : in std_logic ;
wrreq : in std_logic ;
wrdata : in std_logic_vector (WDATA_WIDTH-1 downto 0);
wrfull : out std_logic ;
rdclk : in std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (RDATA_WIDTH-1 downto 0);
rdempty : out std_logic
);
end alt_async_fifo_mixed_width;
architecture syn of alt_async_fifo_mixed_width is
signal sub_wire0 : std_logic_vector (RDATA_WIDTH-1 downto 0);
signal sub_wire1 : std_logic ;
signal sub_wire2 : std_logic ;
component dcfifo_mixed_widths
generic (
intended_device_family : string;
lpm_numwords : natural;
lpm_showahead : string;
lpm_type : string;
lpm_width : natural;
lpm_widthu : natural;
lpm_widthu_r : natural;
lpm_width_r : natural;
overflow_checking : string;
rdsync_delaypipe : natural;
underflow_checking : string;
use_eab : string;
wrsync_delaypipe : natural
);
port (
data : in std_logic_vector (WDATA_WIDTH-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
wrclk : in std_logic ;
wrreq : in std_logic ;
q : out std_logic_vector (RDATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
wrfull : out std_logic
);
end component;
begin
rddata <= sub_wire0(RDATA_WIDTH-1 downto 0);
rdempty <= sub_wire1;
wrfull <= sub_wire2;
dcfifo_mixed_widths_component : dcfifo_mixed_widths
generic map (
intended_device_family => DEVICE_FAMILY,
lpm_numwords => DEPTH,
lpm_showahead => SHOWAHEAD,
lpm_type => "dcfifo_mixed_widths",
lpm_width => WDATA_WIDTH,
lpm_widthu => log2(DEPTH),
lpm_widthu_r => log2(DEPTH*WDATA_WIDTH/RDATA_WIDTH),
lpm_width_r => RDATA_WIDTH,
overflow_checking => CHECKING,
underflow_checking => CHECKING,
use_eab => "ON",
rdsync_delaypipe => 4,
wrsync_delaypipe => 4
)
port map (
data => wrdata,
rdclk => rdclk,
rdreq => rdreq,
wrclk => wrclk,
wrreq => wrreq,
q => sub_wire0,
rdempty => sub_wire1,
wrfull => sub_wire2
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "-1"
-- Retrieval info: PRIVATE: AlmostFull NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "-1"
-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
-- Retrieval info: PRIVATE: Clock NUMERIC "4"
-- Retrieval info: PRIVATE: Depth NUMERIC "64"
-- Retrieval info: PRIVATE: Empty NUMERIC "1"
-- Retrieval info: PRIVATE: Full NUMERIC "1"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "0"
-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: Optimize NUMERIC "0"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
-- Retrieval info: PRIVATE: Width NUMERIC "8"
-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: diff_widths NUMERIC "1"
-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
-- Retrieval info: PRIVATE: output_width NUMERIC "32"
-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
-- Retrieval info: PRIVATE: sc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: sc_sclr NUMERIC "0"
-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: wsFull NUMERIC "1"
-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "64"
-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "ON"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "dcfifo_mixed_widths"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "8"
-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "6"
-- Retrieval info: CONSTANT: LPM_WIDTHU_R NUMERIC "4"
-- Retrieval info: CONSTANT: LPM_WIDTH_R NUMERIC "32"
-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: RDSYNC_DELAYPIPE NUMERIC "4"
-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
-- Retrieval info: CONSTANT: WRSYNC_DELAYPIPE NUMERIC "4"
-- Retrieval info: USED_PORT: wrdata 0 0 8 0 INPUT NODEFVAL "wrdata[7..0]"
-- Retrieval info: USED_PORT: rddata 0 0 32 0 OUTPUT NODEFVAL "rddata[31..0]"
-- Retrieval info: USED_PORT: rdclk 0 0 0 0 INPUT NODEFVAL "rdclk"
-- Retrieval info: USED_PORT: rdempty 0 0 0 0 OUTPUT NODEFVAL "rdempty"
-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq"
-- Retrieval info: USED_PORT: wrclk 0 0 0 0 INPUT NODEFVAL "wrclk"
-- Retrieval info: USED_PORT: wrfull 0 0 0 0 OUTPUT NODEFVAL "wrfull"
-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq"
-- Retrieval info: CONNECT: @wrdata 0 0 8 0 wrdata 0 0 8 0
-- Retrieval info: CONNECT: @rdclk 0 0 0 0 rdclk 0 0 0 0
-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
-- Retrieval info: CONNECT: @wrclk 0 0 0 0 wrclk 0 0 0 0
-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
-- Retrieval info: CONNECT: rddata 0 0 32 0 @rddata 0 0 32 0
-- Retrieval info: CONNECT: rdempty 0 0 0 0 @rdempty 0 0 0 0
-- Retrieval info: CONNECT: wrfull 0 0 0 0 @wrfull 0 0 0 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo_mixed_width.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo_mixed_width.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo_mixed_width.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo_mixed_width.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL sync_fifo_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,201 @@
-- megafunction wizard: %RAM: 2-PORT%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: altsyncram
-- ============================================================
-- File Name: alt_dp_ram.vhd
-- Megafunction Name(s):
-- altsyncram
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 18.1.0 Build 625 09/12/2018 SJ Standard Edition
-- ************************************************************
--Copyright (C) 2018 Intel Corporation. All rights reserved.
--Your use of Intel Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Intel Program License
--Subscription Agreement, the Intel Quartus Prime License Agreement,
--the Intel FPGA IP License Agreement, or other applicable license
--agreement, including, without limitation, that your use is for
--the sole purpose of programming logic devices manufactured by
--Intel and sold by Intel or its authorized distributors. Please
--refer to the applicable agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.altera_mf_components.all;
use work.common_pkg.all;
entity alt_dp_ram is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
clk : in std_logic := '1';
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wraddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
wren : in std_logic := '0';
rdaddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end alt_dp_ram;
architecture syn of alt_dp_ram is
signal sub_wire0 : std_logic_vector (DATA_WIDTH-1 downto 0);
begin
rddata <= sub_wire0(DATA_WIDTH-1 downto 0);
altsyncram_component : altsyncram
generic map (
address_aclr_b => "NONE",
address_reg_b => "CLOCK0",
clock_enable_input_a => "BYPASS",
clock_enable_input_b => "BYPASS",
clock_enable_output_b => "BYPASS",
intended_device_family => DEVICE_FAMILY,
lpm_type => "altsyncram",
numwords_a => DEPTH,
numwords_b => DEPTH,
operation_mode => "DUAL_PORT",
outdata_aclr_b => "NONE",
outdata_reg_b => REGISTER_OUTPUT,
power_up_uninitialized => "FALSE",
read_during_write_mode_mixed_ports => READ_WRITE_MODE,
widthad_a => LOG2(DEPTH),
widthad_b => LOG2(DEPTH),
width_a => DATA_WIDTH,
width_b => DATA_WIDTH,
width_byteena_a => 1
)
port map (
address_a => wraddr,
address_b => rdaddr,
clock0 => clk,
data_a => wrdata,
wren_a => wren,
q_b => sub_wire0
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: ADDRESSSTALL_A NUMERIC "0"
-- Retrieval info: PRIVATE: ADDRESSSTALL_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_SIZE NUMERIC "8"
-- Retrieval info: PRIVATE: BlankMemory NUMERIC "1"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLRdata NUMERIC "0"
-- Retrieval info: PRIVATE: CLRq NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrdaddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrren NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwraddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwren NUMERIC "0"
-- Retrieval info: PRIVATE: clk NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_A NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_B NUMERIC "0"
-- Retrieval info: PRIVATE: IMPLEMENT_IN_LES NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_REG_B NUMERIC "0"
-- Retrieval info: PRIVATE: INIT_FILE_LAYOUT STRING "PORT_B"
-- Retrieval info: PRIVATE: INIT_TO_SIM_X NUMERIC "0"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: PRIVATE: JTAG_ENABLED NUMERIC "0"
-- Retrieval info: PRIVATE: JTAG_ID STRING "NONE"
-- Retrieval info: PRIVATE: MAXIMUM_DEPTH NUMERIC "0"
-- Retrieval info: PRIVATE: MEMSIZE NUMERIC "4096"
-- Retrieval info: PRIVATE: MEM_IN_BITS NUMERIC "0"
-- Retrieval info: PRIVATE: MIFfilename STRING ""
-- Retrieval info: PRIVATE: OPERATION_MODE NUMERIC "2"
-- Retrieval info: PRIVATE: OUTDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: OUTDATA_REG_B NUMERIC "1"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_MIXED_PORTS NUMERIC "1"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_A NUMERIC "3"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_B NUMERIC "3"
-- Retrieval info: PRIVATE: REGdata NUMERIC "1"
-- Retrieval info: PRIVATE: REGq NUMERIC "0"
-- Retrieval info: PRIVATE: REGrdaddress NUMERIC "1"
-- Retrieval info: PRIVATE: REGrren NUMERIC "1"
-- Retrieval info: PRIVATE: REGwraddress NUMERIC "1"
-- Retrieval info: PRIVATE: REGwren NUMERIC "1"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: USE_DIFF_CLKEN NUMERIC "0"
-- Retrieval info: PRIVATE: UseDPRAM NUMERIC "1"
-- Retrieval info: PRIVATE: VarWidth NUMERIC "0"
-- Retrieval info: PRIVATE: WIDTH_READ_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_READ_B NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_B NUMERIC "32"
-- Retrieval info: PRIVATE: WRADDR_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: WRADDR_REG_B NUMERIC "0"
-- Retrieval info: PRIVATE: WRCTRL_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: enable NUMERIC "0"
-- Retrieval info: PRIVATE: rden NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADDRESS_ACLR_B STRING "NONE"
-- Retrieval info: CONSTANT: ADDRESS_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_A STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "altsyncram"
-- Retrieval info: CONSTANT: NUMWORDS_A NUMERIC "128"
-- Retrieval info: CONSTANT: NUMWORDS_B NUMERIC "128"
-- Retrieval info: CONSTANT: OPERATION_MODE STRING "DUAL_PORT"
-- Retrieval info: CONSTANT: OUTDATA_ACLR_B STRING "NONE"
-- Retrieval info: CONSTANT: OUTDATA_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: POWER_UP_UNINITIALIZED STRING "FALSE"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_MIXED_PORTS STRING "OLD_DATA"
-- Retrieval info: CONSTANT: WIDTHAD_A NUMERIC "7"
-- Retrieval info: CONSTANT: WIDTHAD_B NUMERIC "7"
-- Retrieval info: CONSTANT: WIDTH_A NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_B NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_BYTEENA_A NUMERIC "1"
-- Retrieval info: USED_PORT: clk 0 0 0 0 INPUT VCC "clk"
-- Retrieval info: USED_PORT: wrdata 0 0 32 0 INPUT NODEFVAL "wrdata[31..0]"
-- Retrieval info: USED_PORT: rddata 0 0 32 0 OUTPUT NODEFVAL "rddata[31..0]"
-- Retrieval info: USED_PORT: rdaddr 0 0 7 0 INPUT NODEFVAL "rdaddr[6..0]"
-- Retrieval info: USED_PORT: wraddr 0 0 7 0 INPUT NODEFVAL "wraddr[6..0]"
-- Retrieval info: USED_PORT: wren 0 0 0 0 INPUT GND "wren"
-- Retrieval info: CONNECT: @address_a 0 0 7 0 wraddr 0 0 7 0
-- Retrieval info: CONNECT: @address_b 0 0 7 0 rdaddr 0 0 7 0
-- Retrieval info: CONNECT: @clock0 0 0 0 0 clk 0 0 0 0
-- Retrieval info: CONNECT: @data_a 0 0 32 0 wrdata 0 0 32 0
-- Retrieval info: CONNECT: @wren_a 0 0 0 0 wren 0 0 0 0
-- Retrieval info: CONNECT: rddata 0 0 32 0 @q_b 0 0 32 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL dp_ram_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,207 @@
-- megafunction wizard: %RAM: 2-PORT%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: altsyncram
-- ============================================================
-- File Name: alt_dp_ram_mixed_width.vhd
-- Megafunction Name(s):
-- altsyncram
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 18.1.0 Build 625 09/12/2018 SJ Standard Edition
-- ************************************************************
--Copyright (C) 2018 Intel Corporation. All rights reserved.
--Your use of Intel Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Intel Program License
--Subscription Agreement, the Intel Quartus Prime License Agreement,
--the Intel FPGA IP License Agreement, or other applicable license
--agreement, including, without limitation, that your use is for
--the sole purpose of programming logic devices manufactured by
--Intel and sold by Intel or its authorized distributors. Please
--refer to the applicable agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.altera_mf_components.all;
use work.common_pkg.all;
entity alt_dp_ram_mixed_width is
generic (
WDATA_WIDTH : natural range 1 to 256 := 32;
RDATA_WIDTH : natural range 1 to 256 := 32;
WDEPTH : natural range 2 to 131072 := 128;
RDEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
INIT_FILE : string := ""; -- e.g "ram.mif" or "ram.hex"
INIT_FILE_LAYOUT : string := "PORT_A"; -- "PORT_A", "PORT_B"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
clk : in std_logic := '1';
wrdata : in std_logic_vector (WDATA_WIDTH-1 downto 0);
wraddr : in std_logic_vector (log2(WDEPTH)-1 downto 0);
wren : in std_logic := '0';
rdaddr : in std_logic_vector (log2(RDEPTH)-1 downto 0);
rddata : out std_logic_vector (RDATA_WIDTH-1 downto 0)
);
end alt_dp_ram_mixed_width;
architecture syn of alt_dp_ram_mixed_width is
signal sub_wire0 : std_logic_vector (RDATA_WIDTH-1 downto 0);
begin
rddata <= sub_wire0;
altsyncram_component : altsyncram
generic map (
address_aclr_b => "NONE",
address_reg_b => "CLOCK0",
clock_enable_input_a => "BYPASS",
clock_enable_input_b => "BYPASS",
clock_enable_output_b => "BYPASS",
init_file => INIT_FILE,
init_file_layout => INIT_FILE_LAYOUT,
intended_device_family => DEVICE_FAMILY,
lpm_type => "altsyncram",
numwords_a => WDEPTH,
numwords_b => RDEPTH,
operation_mode => "DUAL_PORT",
outdata_aclr_b => "NONE",
outdata_reg_b => REGISTER_OUTPUT,
power_up_uninitialized => "FALSE",
read_during_write_mode_mixed_ports => READ_WRITE_MODE,
widthad_a => LOG2(WDEPTH),
widthad_b => LOG2(RDEPTH),
width_a => WDATA_WIDTH,
width_b => RDATA_WIDTH,
width_byteena_a => 1
)
port map (
address_a => wraddr,
address_b => rdaddr,
clock0 => clk,
data_a => wrdata,
wren_a => wren,
q_b => sub_wire0
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: ADDRESSSTALL_A NUMERIC "0"
-- Retrieval info: PRIVATE: ADDRESSSTALL_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_SIZE NUMERIC "8"
-- Retrieval info: PRIVATE: BlankMemory NUMERIC "1"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLRdata NUMERIC "0"
-- Retrieval info: PRIVATE: CLRq NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrdaddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrren NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwraddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwren NUMERIC "0"
-- Retrieval info: PRIVATE: clk NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_A NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_B NUMERIC "0"
-- Retrieval info: PRIVATE: IMPLEMENT_IN_LES NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_REG_B NUMERIC "0"
-- Retrieval info: PRIVATE: INIT_FILE_LAYOUT STRING "PORT_B"
-- Retrieval info: PRIVATE: INIT_TO_SIM_X NUMERIC "0"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: PRIVATE: JTAG_ENABLED NUMERIC "0"
-- Retrieval info: PRIVATE: JTAG_ID STRING "NONE"
-- Retrieval info: PRIVATE: MAXIMUM_DEPTH NUMERIC "0"
-- Retrieval info: PRIVATE: MEMSIZE NUMERIC "4096"
-- Retrieval info: PRIVATE: MEM_IN_BITS NUMERIC "0"
-- Retrieval info: PRIVATE: MIFfilename STRING ""
-- Retrieval info: PRIVATE: OPERATION_MODE NUMERIC "2"
-- Retrieval info: PRIVATE: OUTDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: OUTDATA_REG_B NUMERIC "1"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_MIXED_PORTS NUMERIC "1"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_A NUMERIC "3"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_B NUMERIC "3"
-- Retrieval info: PRIVATE: REGdata NUMERIC "1"
-- Retrieval info: PRIVATE: REGq NUMERIC "0"
-- Retrieval info: PRIVATE: REGrdaddress NUMERIC "1"
-- Retrieval info: PRIVATE: REGrren NUMERIC "1"
-- Retrieval info: PRIVATE: REGwraddress NUMERIC "1"
-- Retrieval info: PRIVATE: REGwren NUMERIC "1"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: USE_DIFF_CLKEN NUMERIC "0"
-- Retrieval info: PRIVATE: UseDPRAM NUMERIC "1"
-- Retrieval info: PRIVATE: VarWidth NUMERIC "0"
-- Retrieval info: PRIVATE: WIDTH_READ_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_READ_B NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_B NUMERIC "32"
-- Retrieval info: PRIVATE: WRADDR_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: WRADDR_REG_B NUMERIC "0"
-- Retrieval info: PRIVATE: WRCTRL_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: enable NUMERIC "0"
-- Retrieval info: PRIVATE: rden NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADDRESS_ACLR_B STRING "NONE"
-- Retrieval info: CONSTANT: ADDRESS_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_A STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "altsyncram"
-- Retrieval info: CONSTANT: NUMWORDS_A NUMERIC "128"
-- Retrieval info: CONSTANT: NUMWORDS_B NUMERIC "128"
-- Retrieval info: CONSTANT: OPERATION_MODE STRING "DUAL_PORT"
-- Retrieval info: CONSTANT: OUTDATA_ACLR_B STRING "NONE"
-- Retrieval info: CONSTANT: OUTDATA_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: POWER_UP_UNINITIALIZED STRING "FALSE"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_MIXED_PORTS STRING "OLD_DATA"
-- Retrieval info: CONSTANT: WIDTHAD_A NUMERIC "7"
-- Retrieval info: CONSTANT: WIDTHAD_B NUMERIC "7"
-- Retrieval info: CONSTANT: WIDTH_A NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_B NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_BYTEENA_A NUMERIC "1"
-- Retrieval info: USED_PORT: clk 0 0 0 0 INPUT VCC "clk"
-- Retrieval info: USED_PORT: wrdata 0 0 32 0 INPUT NODEFVAL "wrdata[31..0]"
-- Retrieval info: USED_PORT: rddata 0 0 32 0 OUTPUT NODEFVAL "rddata[31..0]"
-- Retrieval info: USED_PORT: rdaddr 0 0 7 0 INPUT NODEFVAL "rdaddr[6..0]"
-- Retrieval info: USED_PORT: wraddr 0 0 7 0 INPUT NODEFVAL "wraddr[6..0]"
-- Retrieval info: USED_PORT: wren 0 0 0 0 INPUT GND "wren"
-- Retrieval info: CONNECT: @address_a 0 0 7 0 wraddr 0 0 7 0
-- Retrieval info: CONNECT: @address_b 0 0 7 0 rdaddr 0 0 7 0
-- Retrieval info: CONNECT: @clock0 0 0 0 0 clk 0 0 0 0
-- Retrieval info: CONNECT: @data_a 0 0 32 0 wrdata 0 0 32 0
-- Retrieval info: CONNECT: @wren_a 0 0 0 0 wren 0 0 0 0
-- Retrieval info: CONNECT: rddata 0 0 32 0 @q_b 0 0 32 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram_mixed_width.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram_mixed_width.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram_mixed_width.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram_mixed_width.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL dp_ram_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,231 @@
-- megafunction wizard: %RAM: 2-PORT%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: altsyncram
-- ============================================================
-- File Name: generic_seq_ram.vhd
-- Megafunction Name(s):
-- altsyncram
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 14.1.1 Build 190 01/19/2015 SJ Web Edition
-- ************************************************************
--Copyright (C) 1991-2015 Altera Corporation. All rights reserved.
--Your use of Altera Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Altera Program License
--Subscription Agreement, the Altera Quartus II License Agreement,
--the Altera MegaCore Function License Agreement, or other
--applicable license agreement, including, without limitation,
--that your use is for the sole purpose of programming logic
--devices manufactured by Altera and sold by Altera or its
--authorized distributors. Please refer to the applicable
--agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.altera_mf_components.all;
use work.common_pkg.all;
entity alt_rw_dp_ram is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
addr_a : in std_logic_vector (log2(DEPTH)-1 downto 0);
addr_b : in std_logic_vector (log2(DEPTH)-1 downto 0);
clk : in std_logic := '1';
wrdata_a : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrdata_b : in std_logic_vector (DATA_WIDTH-1 downto 0);
wren_a : in std_logic := '0';
wren_b : in std_logic := '0';
rddata_a : out std_logic_vector (DATA_WIDTH-1 downto 0);
rddata_b : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end alt_rw_dp_ram;
architecture syn of alt_rw_dp_ram is
signal sub_wire0 : std_logic_vector (DATA_WIDTH-1 downto 0);
signal sub_wire1 : std_logic_vector (DATA_WIDTH-1 downto 0);
begin
rddata_a <= sub_wire0(DATA_WIDTH-1 downto 0);
rddata_b <= sub_wire1(DATA_WIDTH-1 downto 0);
altsyncram_component : altsyncram
generic map (
address_reg_b => "CLOCK0",
clock_enable_input_a => "BYPASS",
clock_enable_input_b => "BYPASS",
clock_enable_output_a => "BYPASS",
clock_enable_output_b => "BYPASS",
indata_reg_b => "CLOCK0",
intended_device_family => DEVICE_FAMILY,
lpm_type => "altsyncram",
numwords_a => DEPTH,
numwords_b => DEPTH,
operation_mode => "BIDIR_DUAL_PORT",
outdata_aclr_a => "NONE",
outdata_aclr_b => "NONE",
outdata_reg_a => REGISTER_OUTPUT,
outdata_reg_b => REGISTER_OUTPUT,
power_up_uninitialized => "FALSE",
read_during_write_mode_mixed_ports => READ_WRITE_MODE,
read_during_write_mode_port_a => "NEW_DATA_NO_NBE_READ",
read_during_write_mode_port_b => "NEW_DATA_NO_NBE_READ",
widthad_a => log2(DEPTH),
widthad_b => log2(DEPTH),
width_a => DATA_WIDTH,
width_b => DATA_WIDTH,
width_byteena_a => 1,
width_byteena_b => 1,
wrcontrol_wraddress_reg_b => "CLOCK0"
)
port map (
address_a => addr_a,
address_b => addr_b,
clock0 => clk,
data_a => wrdata_a,
data_b => wrdata_b,
wren_a => wren_a,
wren_b => wren_b,
q_a => sub_wire0,
q_b => sub_wire1
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: ADDRESSSTALL_A NUMERIC "0"
-- Retrieval info: PRIVATE: ADDRESSSTALL_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_SIZE NUMERIC "8"
-- Retrieval info: PRIVATE: BlankMemory NUMERIC "1"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLRdata NUMERIC "0"
-- Retrieval info: PRIVATE: CLRq NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrdaddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrren NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwraddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwren NUMERIC "0"
-- Retrieval info: PRIVATE: Clock NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_A NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_B NUMERIC "0"
-- Retrieval info: PRIVATE: IMPLEMENT_IN_LES NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_REG_B NUMERIC "1"
-- Retrieval info: PRIVATE: INIT_FILE_LAYOUT STRING "PORT_A"
-- Retrieval info: PRIVATE: INIT_TO_SIM_X NUMERIC "0"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone V"
-- Retrieval info: PRIVATE: JTAG_ENABLED NUMERIC "0"
-- Retrieval info: PRIVATE: JTAG_ID STRING "NONE"
-- Retrieval info: PRIVATE: MAXIMUM_DEPTH NUMERIC "0"
-- Retrieval info: PRIVATE: MEMSIZE NUMERIC "8192"
-- Retrieval info: PRIVATE: MEM_IN_BITS NUMERIC "0"
-- Retrieval info: PRIVATE: MIFfilename STRING ""
-- Retrieval info: PRIVATE: OPERATION_MODE NUMERIC "3"
-- Retrieval info: PRIVATE: OUTDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: OUTDATA_REG_B NUMERIC "0"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_MIXED_PORTS NUMERIC "2"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_A NUMERIC "3"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_B NUMERIC "3"
-- Retrieval info: PRIVATE: REGdata NUMERIC "1"
-- Retrieval info: PRIVATE: REGq NUMERIC "0"
-- Retrieval info: PRIVATE: REGrdaddress NUMERIC "0"
-- Retrieval info: PRIVATE: REGrren NUMERIC "0"
-- Retrieval info: PRIVATE: REGwraddress NUMERIC "1"
-- Retrieval info: PRIVATE: REGwren NUMERIC "1"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: USE_DIFF_CLKEN NUMERIC "0"
-- Retrieval info: PRIVATE: UseDPRAM NUMERIC "1"
-- Retrieval info: PRIVATE: VarWidth NUMERIC "0"
-- Retrieval info: PRIVATE: WIDTH_READ_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_READ_B NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_B NUMERIC "32"
-- Retrieval info: PRIVATE: WRADDR_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: WRADDR_REG_B NUMERIC "1"
-- Retrieval info: PRIVATE: WRCTRL_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: enable NUMERIC "0"
-- Retrieval info: PRIVATE: rden NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADDRESS_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_A STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_A STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: INDATA_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone V"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "altsyncram"
-- Retrieval info: CONSTANT: NUMWORDS_A NUMERIC "256"
-- Retrieval info: CONSTANT: NUMWORDS_B NUMERIC "256"
-- Retrieval info: CONSTANT: OPERATION_MODE STRING "BIDIR_DUAL_PORT"
-- Retrieval info: CONSTANT: OUTDATA_ACLR_A STRING "NONE"
-- Retrieval info: CONSTANT: OUTDATA_ACLR_B STRING "NONE"
-- Retrieval info: CONSTANT: OUTDATA_REG_A STRING "UNREGISTERED"
-- Retrieval info: CONSTANT: OUTDATA_REG_B STRING "UNREGISTERED"
-- Retrieval info: CONSTANT: POWER_UP_UNINITIALIZED STRING "FALSE"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_MIXED_PORTS STRING "DONT_CARE"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_PORT_A STRING "NEW_DATA_NO_NBE_READ"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_PORT_B STRING "NEW_DATA_NO_NBE_READ"
-- Retrieval info: CONSTANT: WIDTHAD_A NUMERIC "8"
-- Retrieval info: CONSTANT: WIDTHAD_B NUMERIC "8"
-- Retrieval info: CONSTANT: WIDTH_A NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_B NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_BYTEENA_A NUMERIC "1"
-- Retrieval info: CONSTANT: WIDTH_BYTEENA_B NUMERIC "1"
-- Retrieval info: CONSTANT: WRCONTROL_WRADDRESS_REG_B STRING "CLOCK0"
-- Retrieval info: USED_PORT: address_a 0 0 8 0 INPUT NODEFVAL "address_a[7..0]"
-- Retrieval info: USED_PORT: address_b 0 0 8 0 INPUT NODEFVAL "address_b[7..0]"
-- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT VCC "clock"
-- Retrieval info: USED_PORT: data_a 0 0 32 0 INPUT NODEFVAL "data_a[31..0]"
-- Retrieval info: USED_PORT: data_b 0 0 32 0 INPUT NODEFVAL "data_b[31..0]"
-- Retrieval info: USED_PORT: q_a 0 0 32 0 OUTPUT NODEFVAL "q_a[31..0]"
-- Retrieval info: USED_PORT: q_b 0 0 32 0 OUTPUT NODEFVAL "q_b[31..0]"
-- Retrieval info: USED_PORT: wren_a 0 0 0 0 INPUT GND "wren_a"
-- Retrieval info: USED_PORT: wren_b 0 0 0 0 INPUT GND "wren_b"
-- Retrieval info: CONNECT: @address_a 0 0 8 0 address_a 0 0 8 0
-- Retrieval info: CONNECT: @address_b 0 0 8 0 address_b 0 0 8 0
-- Retrieval info: CONNECT: @clock0 0 0 0 0 clock 0 0 0 0
-- Retrieval info: CONNECT: @data_a 0 0 32 0 data_a 0 0 32 0
-- Retrieval info: CONNECT: @data_b 0 0 32 0 data_b 0 0 32 0
-- Retrieval info: CONNECT: @wren_a 0 0 0 0 wren_a 0 0 0 0
-- Retrieval info: CONNECT: @wren_b 0 0 0 0 wren_b 0 0 0 0
-- Retrieval info: CONNECT: q_a 0 0 32 0 @q_a 0 0 32 0
-- Retrieval info: CONNECT: q_b 0 0 32 0 @q_b 0 0 32 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.cmp TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,234 @@
-- megafunction wizard: %FIFO%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: scfifo
-- ============================================================
-- File Name: alt_sync_fifo.vhd
-- Megafunction Name(s):
-- scfifo
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 18.1.0 Build 625 09/12/2018 SJ Standard Edition
-- ************************************************************
--Copyright (C) 2018 Intel Corporation. All rights reserved.
--Your use of Intel Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Intel Program License
--Subscription Agreement, the Intel Quartus Prime License Agreement,
--the Intel FPGA IP License Agreement, or other applicable license
--agreement, including, without limitation, that your use is for
--the sole purpose of programming logic devices manufactured by
--Intel and sold by Intel or its authorized distributors. Please
--refer to the applicable agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.all;
use work.common_pkg.all;
entity alt_sync_fifo is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 1 to 131072 := 64;
REGISTER_OUTPUT : string := "ON"; -- "OFF"
NEARLY_FULL : natural range 1 to 131072 := 62;
NEARLY_EMPTY : natural range 1 to 131072 := 2;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port
(
clk : in std_logic ;
rst_n : in std_logic := '1';
sclr : in std_logic := '0';
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
almost_full : out std_logic ;
full : out std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
almost_empty : out std_logic ;
empty : out std_logic ;
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end alt_sync_fifo;
architecture syn of alt_sync_fifo is
signal sub_wire0 : std_logic ;
signal sub_wire1 : std_logic ;
signal sub_wire2 : std_logic ;
signal sub_wire3 : std_logic ;
signal sub_wire4 : std_logic_vector (DATA_WIDTH-1 downto 0);
signal sub_wire5 : std_logic_vector (log2(DEPTH)-1 downto 0);
component scfifo
generic (
add_ram_output_register : string;
almost_empty_value : natural;
almost_full_value : natural;
intended_device_family : string;
lpm_numwords : natural;
lpm_showahead : string;
lpm_type : string;
lpm_width : natural;
lpm_widthu : natural;
overflow_checking : string;
underflow_checking : string;
use_eab : string
);
port (
aclr : in std_logic ;
clock : in std_logic ;
data : in std_logic_vector (DATA_WIDTH-1 downto 0);
rdreq : in std_logic ;
sclr : in std_logic ;
wrreq : in std_logic ;
almost_empty : out std_logic ;
almost_full : out std_logic ;
empty : out std_logic ;
full : out std_logic ;
q : out std_logic_vector (DATA_WIDTH-1 downto 0);
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
begin
almost_empty <= sub_wire0;
almost_full <= sub_wire1;
empty <= sub_wire2;
full <= sub_wire3;
rddata <= sub_wire4(DATA_WIDTH-1 downto 0);
usedw <= sub_wire5(log2(DEPTH)-1 downto 0);
scfifo_component : scfifo
generic map (
add_ram_output_register => REGISTER_OUTPUT,
almost_empty_value => NEARLY_EMPTY,
almost_full_value => NEARLY_FULL,
intended_device_family => DEVICE_FAMILY,
lpm_numwords => DEPTH,
lpm_showahead => SHOWAHEAD,
lpm_type => "scfifo",
lpm_width => DATA_WIDTH,
lpm_widthu => log2(DEPTH),
overflow_checking => CHECKING,
underflow_checking => CHECKING,
use_eab => "ON"
)
port map (
aclr => not rst_n,
clock => clk,
data => wrdata,
rdreq => rdreq,
sclr => sclr,
wrreq => wrreq,
almost_empty => sub_wire0,
almost_full => sub_wire1,
empty => sub_wire2,
full => sub_wire3,
q => sub_wire4,
usedw => sub_wire5
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "2"
-- Retrieval info: PRIVATE: AlmostFull NUMERIC "1"
-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "32"
-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
-- Retrieval info: PRIVATE: clk NUMERIC "0"
-- Retrieval info: PRIVATE: Depth NUMERIC "64"
-- Retrieval info: PRIVATE: Empty NUMERIC "1"
-- Retrieval info: PRIVATE: Full NUMERIC "1"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1"
-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: Optimize NUMERIC "1"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
-- Retrieval info: PRIVATE: Width NUMERIC "32"
-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: diff_widths NUMERIC "0"
-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
-- Retrieval info: PRIVATE: output_width NUMERIC "32"
-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
-- Retrieval info: PRIVATE: sc_aclr NUMERIC "1"
-- Retrieval info: PRIVATE: sc_sclr NUMERIC "1"
-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: wsFull NUMERIC "1"
-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADD_RAM_OUTPUT_REGISTER STRING "ON"
-- Retrieval info: CONSTANT: ALMOST_EMPTY_VALUE NUMERIC "2"
-- Retrieval info: CONSTANT: ALMOST_FULL_VALUE NUMERIC "32"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "64"
-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "scfifo"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "32"
-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "6"
-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
-- Retrieval info: USED_PORT: aclr 0 0 0 0 INPUT NODEFVAL "aclr"
-- Retrieval info: USED_PORT: almost_empty 0 0 0 0 OUTPUT NODEFVAL "almost_empty"
-- Retrieval info: USED_PORT: almost_full 0 0 0 0 OUTPUT NODEFVAL "almost_full"
-- Retrieval info: USED_PORT: clk 0 0 0 0 INPUT NODEFVAL "clk"
-- Retrieval info: USED_PORT: wrdata 0 0 32 0 INPUT NODEFVAL "wrdata[31..0]"
-- Retrieval info: USED_PORT: empty 0 0 0 0 OUTPUT NODEFVAL "empty"
-- Retrieval info: USED_PORT: full 0 0 0 0 OUTPUT NODEFVAL "full"
-- Retrieval info: USED_PORT: rddata 0 0 32 0 OUTPUT NODEFVAL "rddata[31..0]"
-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq"
-- Retrieval info: USED_PORT: sclr 0 0 0 0 INPUT NODEFVAL "sclr"
-- Retrieval info: USED_PORT: usedw 0 0 6 0 OUTPUT NODEFVAL "usedw[5..0]"
-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq"
-- Retrieval info: CONNECT: @aclr 0 0 0 0 aclr 0 0 0 0
-- Retrieval info: CONNECT: @clk 0 0 0 0 clk 0 0 0 0
-- Retrieval info: CONNECT: @wrdata 0 0 32 0 wrdata 0 0 32 0
-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
-- Retrieval info: CONNECT: @sclr 0 0 0 0 sclr 0 0 0 0
-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
-- Retrieval info: CONNECT: almost_empty 0 0 0 0 @almost_empty 0 0 0 0
-- Retrieval info: CONNECT: almost_full 0 0 0 0 @almost_full 0 0 0 0
-- Retrieval info: CONNECT: empty 0 0 0 0 @empty 0 0 0 0
-- Retrieval info: CONNECT: full 0 0 0 0 @full 0 0 0 0
-- Retrieval info: CONNECT: rddata 0 0 32 0 @rddata 0 0 32 0
-- Retrieval info: CONNECT: usedw 0 0 6 0 @usedw 0 0 6 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_sync_fifo.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_sync_fifo.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_sync_fifo.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_sync_fifo.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL try_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,198 @@
-- megafunction wizard: %FIFO%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: scfifo
-- ============================================================
-- File Name: fifo_1024x32.vhd
-- Megafunction Name(s):
-- scfifo
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 14.1.1 Build 190 01/19/2015 SJ Web Edition
-- ************************************************************
--Copyright (C) 1991-2015 Altera Corporation. All rights reserved.
--Your use of Altera Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Altera Program License
--Subscription Agreement, the Altera Quartus II License Agreement,
--the Altera MegaCore Function License Agreement, or other
--applicable license agreement, including, without limitation,
--that your use is for the sole purpose of programming logic
--devices manufactured by Altera and sold by Altera or its
--authorized distributors. Please refer to the applicable
--agreement for further details.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
LIBRARY altera_mf;
USE altera_mf.all;
ENTITY fifo_1024x32 IS
PORT
(
clock : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
rdreq : IN STD_LOGIC ;
sclr : IN STD_LOGIC ;
wrreq : IN STD_LOGIC ;
empty : OUT STD_LOGIC ;
full : OUT STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
usedw : OUT STD_LOGIC_VECTOR (9 DOWNTO 0)
);
END fifo_1024x32;
ARCHITECTURE SYN OF fifo_1024x32 IS
SIGNAL sub_wire0 : STD_LOGIC ;
SIGNAL sub_wire1 : STD_LOGIC ;
SIGNAL sub_wire2 : STD_LOGIC_VECTOR (31 DOWNTO 0);
SIGNAL sub_wire3 : STD_LOGIC_VECTOR (9 DOWNTO 0);
COMPONENT scfifo
GENERIC (
add_ram_output_register : STRING;
intended_device_family : STRING;
lpm_numwords : NATURAL;
lpm_showahead : STRING;
lpm_type : STRING;
lpm_width : NATURAL;
lpm_widthu : NATURAL;
overflow_checking : STRING;
underflow_checking : STRING;
use_eab : STRING
);
PORT (
clock : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
rdreq : IN STD_LOGIC ;
sclr : IN STD_LOGIC ;
wrreq : IN STD_LOGIC ;
empty : OUT STD_LOGIC ;
full : OUT STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
usedw : OUT STD_LOGIC_VECTOR (9 DOWNTO 0)
);
END COMPONENT;
BEGIN
empty <= sub_wire0;
full <= sub_wire1;
q <= sub_wire2(31 DOWNTO 0);
usedw <= sub_wire3(9 DOWNTO 0);
scfifo_component : scfifo
GENERIC MAP (
add_ram_output_register => "OFF",
intended_device_family => "Cyclone IV GX",
lpm_numwords => 1024,
lpm_showahead => "OFF",
lpm_type => "scfifo",
lpm_width => 32,
lpm_widthu => 10,
overflow_checking => "ON",
underflow_checking => "ON",
use_eab => "ON"
)
PORT MAP (
clock => clock,
data => data,
rdreq => rdreq,
sclr => sclr,
wrreq => wrreq,
empty => sub_wire0,
full => sub_wire1,
q => sub_wire2,
usedw => sub_wire3
);
END SYN;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "-1"
-- Retrieval info: PRIVATE: AlmostFull NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "-1"
-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
-- Retrieval info: PRIVATE: Clock NUMERIC "0"
-- Retrieval info: PRIVATE: Depth NUMERIC "1024"
-- Retrieval info: PRIVATE: Empty NUMERIC "1"
-- Retrieval info: PRIVATE: Full NUMERIC "1"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone IV GX"
-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1"
-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: Optimize NUMERIC "0"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
-- Retrieval info: PRIVATE: Width NUMERIC "32"
-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: diff_widths NUMERIC "0"
-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
-- Retrieval info: PRIVATE: output_width NUMERIC "32"
-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
-- Retrieval info: PRIVATE: sc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: sc_sclr NUMERIC "1"
-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: wsFull NUMERIC "1"
-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADD_RAM_OUTPUT_REGISTER STRING "OFF"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone IV GX"
-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "1024"
-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "scfifo"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "32"
-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "10"
-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
-- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT NODEFVAL "clock"
-- Retrieval info: USED_PORT: data 0 0 32 0 INPUT NODEFVAL "data[31..0]"
-- Retrieval info: USED_PORT: empty 0 0 0 0 OUTPUT NODEFVAL "empty"
-- Retrieval info: USED_PORT: full 0 0 0 0 OUTPUT NODEFVAL "full"
-- Retrieval info: USED_PORT: q 0 0 32 0 OUTPUT NODEFVAL "q[31..0]"
-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq"
-- Retrieval info: USED_PORT: sclr 0 0 0 0 INPUT NODEFVAL "sclr"
-- Retrieval info: USED_PORT: usedw 0 0 10 0 OUTPUT NODEFVAL "usedw[9..0]"
-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq"
-- Retrieval info: CONNECT: @clock 0 0 0 0 clock 0 0 0 0
-- Retrieval info: CONNECT: @data 0 0 32 0 data 0 0 32 0
-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
-- Retrieval info: CONNECT: @sclr 0 0 0 0 sclr 0 0 0 0
-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
-- Retrieval info: CONNECT: empty 0 0 0 0 @empty 0 0 0 0
-- Retrieval info: CONNECT: full 0 0 0 0 @full 0 0 0 0
-- Retrieval info: CONNECT: q 0 0 32 0 @q 0 0 32 0
-- Retrieval info: CONNECT: usedw 0 0 10 0 @usedw 0 0 10 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_1024x32.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_1024x32.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_1024x32.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_1024x32.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_1024x32_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,198 @@
-- megafunction wizard: %FIFO%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: scfifo
-- ============================================================
-- File Name: fifo_256x32.vhd
-- Megafunction Name(s):
-- scfifo
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 14.1.1 Build 190 01/19/2015 SJ Web Edition
-- ************************************************************
--Copyright (C) 1991-2015 Altera Corporation. All rights reserved.
--Your use of Altera Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Altera Program License
--Subscription Agreement, the Altera Quartus II License Agreement,
--the Altera MegaCore Function License Agreement, or other
--applicable license agreement, including, without limitation,
--that your use is for the sole purpose of programming logic
--devices manufactured by Altera and sold by Altera or its
--authorized distributors. Please refer to the applicable
--agreement for further details.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
LIBRARY altera_mf;
USE altera_mf.all;
ENTITY fifo_256x32 IS
PORT
(
clock : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
rdreq : IN STD_LOGIC ;
sclr : IN STD_LOGIC ;
wrreq : IN STD_LOGIC ;
empty : OUT STD_LOGIC ;
full : OUT STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
usedw : OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
END fifo_256x32;
ARCHITECTURE SYN OF fifo_256x32 IS
SIGNAL sub_wire0 : STD_LOGIC ;
SIGNAL sub_wire1 : STD_LOGIC ;
SIGNAL sub_wire2 : STD_LOGIC_VECTOR (31 DOWNTO 0);
SIGNAL sub_wire3 : STD_LOGIC_VECTOR (7 DOWNTO 0);
COMPONENT scfifo
GENERIC (
add_ram_output_register : STRING;
intended_device_family : STRING;
lpm_numwords : NATURAL;
lpm_showahead : STRING;
lpm_type : STRING;
lpm_width : NATURAL;
lpm_widthu : NATURAL;
overflow_checking : STRING;
underflow_checking : STRING;
use_eab : STRING
);
PORT (
clock : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
rdreq : IN STD_LOGIC ;
sclr : IN STD_LOGIC ;
wrreq : IN STD_LOGIC ;
empty : OUT STD_LOGIC ;
full : OUT STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
usedw : OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
END COMPONENT;
BEGIN
empty <= sub_wire0;
full <= sub_wire1;
q <= sub_wire2(31 DOWNTO 0);
usedw <= sub_wire3(7 DOWNTO 0);
scfifo_component : scfifo
GENERIC MAP (
add_ram_output_register => "OFF",
intended_device_family => "Cyclone V",
lpm_numwords => 256,
lpm_showahead => "OFF",
lpm_type => "scfifo",
lpm_width => 32,
lpm_widthu => 8,
overflow_checking => "ON",
underflow_checking => "ON",
use_eab => "ON"
)
PORT MAP (
clock => clock,
data => data,
rdreq => rdreq,
sclr => sclr,
wrreq => wrreq,
empty => sub_wire0,
full => sub_wire1,
q => sub_wire2,
usedw => sub_wire3
);
END SYN;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "-1"
-- Retrieval info: PRIVATE: AlmostFull NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "-1"
-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
-- Retrieval info: PRIVATE: Clock NUMERIC "0"
-- Retrieval info: PRIVATE: Depth NUMERIC "256"
-- Retrieval info: PRIVATE: Empty NUMERIC "1"
-- Retrieval info: PRIVATE: Full NUMERIC "1"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone V"
-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1"
-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: Optimize NUMERIC "0"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
-- Retrieval info: PRIVATE: Width NUMERIC "32"
-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: diff_widths NUMERIC "0"
-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
-- Retrieval info: PRIVATE: output_width NUMERIC "32"
-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
-- Retrieval info: PRIVATE: sc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: sc_sclr NUMERIC "1"
-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: wsFull NUMERIC "1"
-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADD_RAM_OUTPUT_REGISTER STRING "OFF"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone V"
-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "256"
-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "scfifo"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "32"
-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "8"
-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
-- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT NODEFVAL "clock"
-- Retrieval info: USED_PORT: data 0 0 32 0 INPUT NODEFVAL "data[31..0]"
-- Retrieval info: USED_PORT: empty 0 0 0 0 OUTPUT NODEFVAL "empty"
-- Retrieval info: USED_PORT: full 0 0 0 0 OUTPUT NODEFVAL "full"
-- Retrieval info: USED_PORT: q 0 0 32 0 OUTPUT NODEFVAL "q[31..0]"
-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq"
-- Retrieval info: USED_PORT: sclr 0 0 0 0 INPUT NODEFVAL "sclr"
-- Retrieval info: USED_PORT: usedw 0 0 8 0 OUTPUT NODEFVAL "usedw[7..0]"
-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq"
-- Retrieval info: CONNECT: @clock 0 0 0 0 clock 0 0 0 0
-- Retrieval info: CONNECT: @data 0 0 32 0 data 0 0 32 0
-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
-- Retrieval info: CONNECT: @sclr 0 0 0 0 sclr 0 0 0 0
-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
-- Retrieval info: CONNECT: empty 0 0 0 0 @empty 0 0 0 0
-- Retrieval info: CONNECT: full 0 0 0 0 @full 0 0 0 0
-- Retrieval info: CONNECT: q 0 0 32 0 @q 0 0 32 0
-- Retrieval info: CONNECT: usedw 0 0 8 0 @usedw 0 0 8 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_256x32.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_256x32.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_256x32.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_256x32.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL fifo_256x32_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,201 @@
-- megafunction wizard: %FIFO%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: scfifo
-- ============================================================
-- File Name: sync_fifo.vhd
-- Megafunction Name(s):
-- scfifo
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 14.1.1 Build 190 01/19/2015 SJ Web Edition
-- ************************************************************
--Copyright (C) 1991-2015 Altera Corporation. All rights reserved.
--Your use of Altera Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Altera Program License
--Subscription Agreement, the Altera Quartus II License Agreement,
--the Altera MegaCore Function License Agreement, or other
--applicable license agreement, including, without limitation,
--that your use is for the sole purpose of programming logic
--devices manufactured by Altera and sold by Altera or its
--authorized distributors. Please refer to the applicable
--agreement for further details.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
LIBRARY altera_mf;
USE altera_mf.all;
use work.common_pkg.all;
entity sync_fifo is
generic (
FIFO_WIDTH : natural range 1 to 32;
FIFO_DEPTH : natural range 1 to 8182);
port (
sclr : in std_logic;
clock : in std_logic;
data : in std_logic_vector (FIFO_WIDTH-1 downto 0);
rdreq : in std_logic;
wrreq : in std_logic;
empty : out std_logic;
full : out std_logic;
q : out std_logic_vector (FIFO_WIDTH-1 downto 0);
usedw : out std_logic_vector (log2(FIFO_DEPTH)-1 downto 0)
);
end sync_fifo;
ARCHITECTURE SYN OF sync_fifo IS
SIGNAL sub_wire0 : STD_LOGIC ;
SIGNAL sub_wire1 : STD_LOGIC ;
SIGNAL sub_wire2 : STD_LOGIC_VECTOR (FIFO_WIDTH-1 DOWNTO 0);
SIGNAL sub_wire3 : STD_LOGIC_VECTOR (log2(FIFO_DEPTH)-1 DOWNTO 0);
COMPONENT scfifo
GENERIC (
add_ram_output_register : STRING;
intended_device_family : STRING;
lpm_numwords : NATURAL;
lpm_showahead : STRING;
lpm_type : STRING;
lpm_width : NATURAL;
lpm_widthu : NATURAL;
overflow_checking : STRING;
underflow_checking : STRING;
use_eab : STRING
);
PORT (
sclr : IN STD_LOGIC ;
clock : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (FIFO_WIDTH-1 DOWNTO 0);
rdreq : IN STD_LOGIC ;
wrreq : IN STD_LOGIC ;
empty : OUT STD_LOGIC ;
full : OUT STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (FIFO_WIDTH-1 DOWNTO 0);
usedw : OUT STD_LOGIC_VECTOR (log2(FIFO_DEPTH)-1 DOWNTO 0)
);
END COMPONENT;
BEGIN
empty <= sub_wire0;
full <= sub_wire1;
q <= sub_wire2(FIFO_WIDTH-1 DOWNTO 0);
usedw <= sub_wire3(log2(FIFO_DEPTH)-1 DOWNTO 0);
scfifo_component : scfifo
GENERIC MAP (
add_ram_output_register => "OFF",
intended_device_family => "Cyclone V",
lpm_numwords => FIFO_DEPTH,
lpm_showahead => "OFF",
lpm_type => "scfifo",
lpm_width => FIFO_WIDTH,
lpm_widthu => log2(FIFO_DEPTH-1),
overflow_checking => "ON",
underflow_checking => "ON",
use_eab => "ON"
)
PORT MAP (
sclr => sclr,
clock => clock,
data => data,
rdreq => rdreq,
wrreq => wrreq,
empty => sub_wire0,
full => sub_wire1,
q => sub_wire2,
usedw => sub_wire3
);
END SYN;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "-1"
-- Retrieval info: PRIVATE: AlmostFull NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "-1"
-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
-- Retrieval info: PRIVATE: Clock NUMERIC "0"
-- Retrieval info: PRIVATE: Depth NUMERIC "256"
-- Retrieval info: PRIVATE: Empty NUMERIC "1"
-- Retrieval info: PRIVATE: Full NUMERIC "1"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone V"
-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1"
-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: Optimize NUMERIC "0"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
-- Retrieval info: PRIVATE: Width NUMERIC "32"
-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: diff_widths NUMERIC "0"
-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
-- Retrieval info: PRIVATE: output_width NUMERIC "32"
-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
-- Retrieval info: PRIVATE: sc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: sc_sclr NUMERIC "1"
-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: wsFull NUMERIC "1"
-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADD_RAM_OUTPUT_REGISTER STRING "OFF"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone V"
-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "256"
-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "scfifo"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "32"
-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "8"
-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
-- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT NODEFVAL "clock"
-- Retrieval info: USED_PORT: data 0 0 32 0 INPUT NODEFVAL "data[31..0]"
-- Retrieval info: USED_PORT: empty 0 0 0 0 OUTPUT NODEFVAL "empty"
-- Retrieval info: USED_PORT: full 0 0 0 0 OUTPUT NODEFVAL "full"
-- Retrieval info: USED_PORT: q 0 0 32 0 OUTPUT NODEFVAL "q[31..0]"
-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq"
-- Retrieval info: USED_PORT: sclr 0 0 0 0 INPUT NODEFVAL "sclr"
-- Retrieval info: USED_PORT: usedw 0 0 8 0 OUTPUT NODEFVAL "usedw[7..0]"
-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq"
-- Retrieval info: CONNECT: @clock 0 0 0 0 clock 0 0 0 0
-- Retrieval info: CONNECT: @data 0 0 32 0 data 0 0 32 0
-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
-- Retrieval info: CONNECT: @sclr 0 0 0 0 sclr 0 0 0 0
-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
-- Retrieval info: CONNECT: empty 0 0 0 0 @empty 0 0 0 0
-- Retrieval info: CONNECT: full 0 0 0 0 @full 0 0 0 0
-- Retrieval info: CONNECT: q 0 0 32 0 @q 0 0 32 0
-- Retrieval info: CONNECT: usedw 0 0 8 0 @usedw 0 0 8 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL sync_fifo.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL sync_fifo.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL sync_fifo.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL sync_fifo.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL sync_fifo_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,41 @@
-------------------------------------------------------------------------------
-- Title : common_pkg
-- Project : Generic Components
-------------------------------------------------------------------------------
-- File : common_pkg.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-04-24
-- Last update: 2018-04-24
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Common Package
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package common_pkg is
-- compute ceil(log2(num)). E.g.: log2(255) = 8, log2(256) = 8, log2(257) = 9.
function log2(num : natural) return natural;
end common_pkg;
package body common_pkg is
-- compute ceil(log2(num)). E.g.: log2(255) = 8, log2(256) = 8, log2(257) = 9.
function log2(num : natural) return natural is
variable val : natural := 0;
begin
while 2**val < num loop
val := val+1;
end loop;
return val;
end function log2;
end package body common_pkg;

View file

@ -0,0 +1,166 @@
-------------------------------------------------------------------------------
-- Title : constant_latency_if
-- Project : HMB/EMB/SMB
-------------------------------------------------------------------------------
-- File : constant_latency_if
-- Author : Christos Spirotis
-- Company : Global Inkjet Systems
-- Created : 2019-07-24
-- Last update: 2019-07-24
-- SVN ID : Git
-- Standard : VHDL'08
-------------------------------------------------------------------------------
-- Description:
-- Used to interface blocks with variable latency to a fixed waitstate
-- avalon bus
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity constant_latency_if is
generic(
READ_WAIT : integer range 0 to 7 := 4;
WRITE_WAIT : integer range 0 to 7 := 1;
ADDR_WIDTH : integer range 2 to 32 := 32
);
port(
reset_n : in std_logic;
clk : in std_logic;
avs_var_lat_req : in std_logic;
avs_var_lat_err : out std_logic;
-- Avalon MM (Slave) Interface
avs_sl_address : in std_logic_vector(ADDR_WIDTH-1 downto 0);
avs_sl_write : in std_logic;
avs_sl_writedata : in std_logic_vector(31 downto 0);
avs_sl_read : in std_logic;
avs_sl_readdata : out std_logic_vector(31 downto 0);
-- Avalon MM (Master) Interface
avs_ms_address : out std_logic_vector(ADDR_WIDTH-1 downto 0);
avs_ms_write : out std_logic;
avs_ms_writedata : out std_logic_vector(31 downto 0);
avs_ms_read : out std_logic;
avs_ms_readdata : in std_logic_vector(31 downto 0);
avs_ms_waitrequest : in std_logic
);
end entity constant_latency_if;
architecture rtl of constant_latency_if is
signal short_access : std_logic;
signal busy : std_logic;
signal cycle_cnt : integer range 0 to 7;
signal readdata : std_logic_vector(31 downto 0);
signal waitrequest_rx : std_logic;
signal access_finished : std_logic;
begin
-- Drive address to master
avs_ms_address <= avs_sl_address;
-- Drive write to master but masked
avs_ms_write <= avs_sl_write and not (access_finished);
-- Drive read to master but masked
avs_ms_read <= avs_sl_read and not (access_finished);
-- Drive writedata to master
avs_ms_writedata <= avs_sl_writedata;
-- Drive readdata to slave
avs_sl_readdata <= readdata when (short_access = '1' or waitrequest_rx = '1') else avs_ms_readdata;
-- This process handles the reads/writes
rw_handler_pr : process (clk, reset_n)
begin
if reset_n = '0' then
avs_var_lat_err <= '0';
readdata <= (others => '0');
short_access <= '0';
busy <= '0';
cycle_cnt <= 0;
waitrequest_rx <= '0';
access_finished <= '0';
elsif rising_edge(clk) then
-- Reset error pulse
avs_var_lat_err <= '0';
-- Idle
if busy = '0' then
-- Detect write with no latency required
if avs_sl_write = '1' and avs_var_lat_req = '0' then
busy <= '1';
-- Shorten the access cycle
short_access <= '1';
access_finished <= '1';
cycle_cnt <= WRITE_WAIT;
end if;
-- Detect read witn no latency required
if avs_sl_read = '1' and avs_var_lat_req = '0' then
busy <= '1';
-- Shorten the access cycle
short_access <= '1';
access_finished <= '1';
cycle_cnt <= READ_WAIT;
end if;
-- Detect write with var latency required
if avs_sl_write = '1' and avs_var_lat_req = '1' then
busy <= '1';
cycle_cnt <= WRITE_WAIT;
waitrequest_rx <= '0';
access_finished <= '0';
end if;
-- Detect read with var latency required
if avs_sl_read = '1' and avs_var_lat_req = '1' then
busy <= '1';
cycle_cnt <= READ_WAIT;
waitrequest_rx <= '0';
access_finished <= '0';
end if;
end if;
-- During transfer
if busy = '1' then
-- Store the data returned after a short cycle read
if short_access = '1' and avs_sl_read = '1' and cycle_cnt = READ_WAIT then
readdata <= avs_ms_readdata;
end if;
-- Store the data returned after a variable cycle read
if short_access = '0' and avs_sl_read = '1' and avs_ms_waitrequest = '0' then
readdata <= avs_ms_readdata;
end if;
-- Detect waitrequest assertion
if short_access = '0' and avs_ms_waitrequest = '0' then
waitrequest_rx <= '1';
access_finished <= '1';
end if;
-- Countdown the waitstates
if cycle_cnt /= 1 then
cycle_cnt <= cycle_cnt - 1;
-- Finish cycle at the end of the waitstates
else
-- Detect that waitrequest was not asserted properly within specified time
if avs_var_lat_req = '1' and waitrequest_rx = '0' and avs_ms_waitrequest = '1' then
avs_var_lat_err <= '1';
end if;
cycle_cnt <= 0;
busy <= '0';
short_access <= '0';
waitrequest_rx <= '0';
access_finished <= '0';
end if;
end if;
end if;
end process rw_handler_pr;
end architecture rtl;

View file

@ -0,0 +1,162 @@
-------------------------------------------------------------------------------
-- Title : cs_bus_ift
-------------------------------------------------------------------------------
-- File : cs_bus_ift.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Target : Altera Nios/HPS based systems
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: Split the memory space from the Avalon-MM I/F and drive the C&S
-- bus for a programmable number of FW processing blocks
-------------------------------------------------------------------------------
-- Last update: 2019-07-12
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2015-10-19 1.0 gmg Created
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity cs_bus_ift is
generic(
BLK_NUM : integer range 1 to 16 := 1;
READ_TIMEOUT : integer range 16 to 1023 := 64);
port(
rstN : in std_logic;
clk : in std_logic;
-- Avalon-MM itf
avs_address : in std_logic_vector(14 downto 0);
avs_write : in std_logic;
avs_writedata : in std_logic_vector(31 downto 0);
avs_read : in std_logic;
avs_waitrequest : out std_logic;
avs_readdata : out std_logic_vector(31 downto 0);
-- C&S bus
cs_addr : out std_logic_vector(10 downto 0);
cs_we : out std_logic_vector(BLK_NUM - 1 downto 0);
cs_wr_data : out std_logic_vector(31 downto 0);
cs_re : out std_logic_vector(BLK_NUM - 1 downto 0);
cs_rv : in std_logic_vector(BLK_NUM - 1 downto 0);
cs_rd_data : in std_logic_vector(32 * BLK_NUM - 1 downto 0));
end cs_bus_ift;
architecture RTL of cs_bus_ift is
-- limit to 16 the maximum number of user blocks
type rd_bus_t is array (0 to BLK_NUM - 1) of std_logic_vector(31 downto 0);
signal cs_rd_data_i : rd_bus_t;
signal busy : std_logic;
signal avs_read_d : std_logic;
signal avs_rd_en : std_logic;
signal avs_wr_en : std_logic;
signal avs_wr_en_d : std_logic;
signal sel_read_valid : std_logic;
signal read_valid : std_logic;
signal read_valid_d : std_logic;
signal dummy_rv : std_logic; -- Dummy Read valid: asserted when
-- trying to read from not allocated addresses
signal timeout_flag : std_logic;
signal read_timeout_cnt : std_logic_vector(9 downto 0);
signal avs_address_i : std_logic_vector(14 downto 0);
begin
BUS_REMAP : for i in 0 to BLK_NUM - 1 generate
cs_rd_data_i(i) <= cs_rd_data((i + 1) * 32 - 1 downto i * 32);
end generate BUS_REMAP;
pLatchIO : process(rstN, clk)
begin
if (rstN = '0') then
avs_address_i <= (others => '0');
cs_we <= (others => '0');
cs_wr_data <= (others => '0');
cs_re <= (others => '0');
avs_readdata <= (others => '0');
avs_waitrequest <= '1';
busy <= '0';
avs_wr_en_d <= '0';
avs_read_d <= '0';
read_valid_d <= '0';
dummy_rv <= '0';
read_timeout_cnt <= (others => '0');
elsif (clk = '1' and clk'event) then
if (avs_write = '1' or avs_read = '1') then
avs_address_i <= avs_address;
end if;
avs_wr_en_d <= avs_wr_en;
avs_read_d <= avs_read;
read_valid_d <= read_valid;
for i in 0 to BLK_NUM - 1 loop
-- limit to 16 the maximum number of user blocks
if (avs_wr_en = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high - 3))) = i) then
cs_we(i) <= '1';
else
cs_we(i) <= '0';
end if;
end loop; -- i
if (avs_wr_en = '1') then
cs_wr_data <= avs_writedata;
end if;
for i in 0 to BLK_NUM - 1 loop
if (avs_rd_en = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high - 3))) = i) then
cs_re(i) <= '1';
else
cs_re(i) <= '0';
end if;
end loop; -- i
if ((avs_rd_en = '1' and (to_integer(unsigned(avs_address(avs_address'high downto avs_address'high - 3))) >= BLK_NUM)) or timeout_flag = '1') then
dummy_rv <= '1';
else
dummy_rv <= '0';
end if;
if (sel_read_valid = '1') then
avs_readdata <= cs_rd_data_i(to_integer(unsigned(avs_address_i(avs_address'high downto avs_address'high - 3))));
elsif (dummy_rv = '1') then
avs_readdata <= X"DEAD_BEEF";
end if;
-- waitrequest can be decoupled from the read and write request signals.
-- waitrequest may be asserted during idle cycles. An Avalon-MM master may initiate
-- a transaction when waitrequest is asserted and wait for that signal to be
-- deasserted. Decoupling waitrequest from read and write requests may improve
-- system timing. Decoupling eliminates a combinational loop including the read,
-- write, and waitrequest signals.
if (avs_wr_en = '1' or read_valid = '1') then
avs_waitrequest <= '0';
else
avs_waitrequest <= '1';
end if;
if (avs_wr_en = '1' or avs_rd_en = '1') then
busy <= '1';
elsif (avs_wr_en_d = '1' or read_valid_d = '1') then
busy <= '0';
end if;
if (avs_rd_en = '1') then
read_timeout_cnt <= (others => '0');
elsif (avs_read_d = '1') then
read_timeout_cnt <= std_logic_vector(unsigned(read_timeout_cnt) + 1);
end if;
end if;
end process pLatchIO;
sel_read_valid <= cs_rv(to_integer(unsigned(avs_address_i(avs_address'high downto avs_address'high - 3))));
read_valid <= dummy_rv or sel_read_valid;
avs_rd_en <= avs_read and not busy;
avs_wr_en <= avs_write and not busy;
cs_addr <= avs_address_i(10 downto 0);
timeout_flag <= '1' when unsigned(read_timeout_cnt) = READ_TIMEOUT else '0';
end RTL;

View file

@ -0,0 +1,97 @@
-------------------------------------------------------------------------------
-- Title : cs_bus_ift_no_wait
-------------------------------------------------------------------------------
-- File : cs_bus_ift_no_wait.vhd
-- Author : Christos Spirotis
-- Company : Global Inkjet Systems
-- Target : Altera Nios/HPS based systems
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: Split the memory space from the Avalon-MM I/F and drive the C&S
-- bus for a programmable number of FW processing blocks
-------------------------------------------------------------------------------
-- Last update: 2021-05-12
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2021-05-12 1.0 cs Created
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity cs_bus_ift_no_wait is
generic(
BLK_NUM : integer range 1 to 16 := 1);
port(
rstN : in std_logic;
clk : in std_logic;
-- Avalon-MM itf
avs_address : in std_logic_vector(14 downto 0);
avs_write : in std_logic;
avs_writedata : in std_logic_vector(31 downto 0);
avs_read : in std_logic;
avs_readdata : out std_logic_vector(31 downto 0);
-- C&S bus
cs_addr : out std_logic_vector(10 downto 0);
cs_we : out std_logic_vector(BLK_NUM-1 downto 0);
cs_wr_data : out std_logic_vector(31 downto 0);
cs_re : out std_logic_vector(BLK_NUM-1 downto 0);
cs_rd_data : in std_logic_vector(32*BLK_NUM-1 downto 0));
end cs_bus_ift_no_wait;
architecture RTL of cs_bus_ift_no_wait is
-- limit to 16 the maximum number of user blocks
type rd_bus_t is array (0 to BLK_NUM-1) of std_logic_vector(31 downto 0);
signal cs_rd_data_i : rd_bus_t;
signal avs_address_i : std_logic_vector(14 downto 0);
signal cs_re_l : std_logic;
signal cs_re_i : std_logic_vector(BLK_NUM-1 downto 0);
begin
BUS_REMAP: for i in 0 to BLK_NUM-1 generate
cs_rd_data_i(i) <= cs_rd_data((i+1)*32-1 downto i*32);
end generate BUS_REMAP;
GEN_CS_WE: for i in 0 to BLK_NUM-1 generate
cs_we(i) <= '1' when (avs_write = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) = i) else '0';
end generate GEN_CS_WE;
GEN_CS_RE: for i in 0 to BLK_NUM-1 generate
cs_re_i(i) <= '1' when (avs_read = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) = i) else '0';
end generate GEN_CS_RE;
pLatchAddr : process(rstN, clk)
begin
if(rstN = '0') then
avs_address_i <= (others => '0');
cs_re_l <= '0';
elsif(clk = '1' and clk'event) then
if(avs_read = '1') then
avs_address_i <= avs_address;
end if;
if (to_integer(unsigned(cs_re_i)) /= 0) then
cs_re_l <= '1';
else
cs_re_l <= '0';
end if;
end if;
end process pLatchAddr;
cs_re <= cs_re_i;
cs_addr <= avs_address(10 downto 0);
cs_wr_data <= avs_writedata;
avs_readdata <= cs_rd_data_i(to_integer(unsigned(avs_address_i(avs_address'high downto avs_address'high-3)))) when cs_re_l = '1' else (others => '0');
end RTL;

View file

@ -0,0 +1,217 @@
-------------------------------------------------------------------------------
-- Title : digital_lpf
-------------------------------------------------------------------------------
-- File : digital_lpf.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Target : Generic (simulation), Generic (synthesis)
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: Digital Low-Pass-Filter with programmable lenght and
-- hysteresis, with clock domain synchronization
-------------------------------------------------------------------------------
-- Last update: 2018-08-20
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2010-05-10 1.0 gmg Created
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Filter Description:
-------------------------------------------------------------------------------
-- The filter includes an input synchronization stage, to the local clock, and
-- a programmable lenght delay line. At reset, or after applying a new
-- configuration the filter reset to initial state: the internal delay line and
-- the output value switches to the reset value.
-- When running, the filter counts the internal value of '0' and '1' in the
-- delay line. If the value of ones is greater than or equal than the upper
-- threshold (floor(filt_order/2)+hyst), the output switches to '1'.
-- If the value of ones is less than or equal than the lower threshold
-- (floor(filt_order/2)-hyst), the output switches to '1'.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Filter Configuration
-------------------------------------------------------------------------------
-- To support a signal with a maximum frequency f_max, being half_per_min the
-- number of clock cycles corresponding to a half period, then the following
-- inequality needs to be met:
-- floor(filt_order/2) + hyst <= floor(half_per_min)
-- For signals with asymmetric duty-cycles, half_per_min must be set to the
-- minimum of the active high/low period.
-- Examples:
-- half_per_min = 11 => LPF order=18, hyst=2, or LPF order=16, hyst=3
-- half_per_min = 10 => LPF order=16, hyst=2
-- half_per_min = 9 => LPF order=14, hyst=2
-- half_per_min = 8 => LPF order=12, hyst=2
-- half_per_min = 7 => LPF order=10, hyst=2
-- half_per_min = 6 => LPF order=10, hyst=1, LPF order=8, hyst=2
-- half_per_min = 5 => LPF order=8, hyst=1
-- half_per_min = 4 => LPF order=6, hyst=1
-- half_per_min = 3 => LPF order=4, hyst=1
-- half_per_min = 2 => LPF order=2, hyst=1
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.common_pkg.all;
entity digital_lpf is
generic(
RESET_VALUE : std_logic := '0';
MAX_ORDER : positive := 32; -- max length of the delay line
DEFAULT_ORDER : positive := 8; -- delay line length at reset (minimum = 2)
DEFAULT_HYST : positive := 2); -- hysteresis value at reset (minimum = 1)
port(
clk : in std_logic;
reset_n : in std_logic;
ld_cfg : in std_logic; -- load filt_order and hyst values,
-- reset the content of the filter
filt_order : in std_logic_vector(log2(MAX_ORDER)-1 downto 0);
hyst : in std_logic_vector(log2(MAX_ORDER)-1 downto 0);
filt_in : in std_logic;
filt_out : out std_logic;
rEdge : out std_logic;
fEdge : out std_logic);
end entity digital_lpf;
architecture behav of digital_lpf is
signal sig_ii, sig_i, sig : std_logic;
--
signal filt_order_i : std_logic_vector(log2(MAX_ORDER)-1 downto 0);
signal cnt_ones, hyst_i : std_logic_vector(log2(MAX_ORDER)-1 downto 0);
signal delay_line : std_logic_vector(MAX_ORDER-1 downto 0);
begin
-- A couple of FFs to avoid metastability issues
SynchrFFs : process(reset_n, clk)
begin
if(reset_n = '0') then
sig_ii <= reset_value;
sig_i <= reset_value;
elsif(clk = '1' and clk'event) then
sig_ii <= filt_in;
sig_i <= sig_ii;
end if;
end process SynchrFFs;
-- Configuration register
pCFG_REGs : process(reset_n, clk)
begin
if(reset_n = '0') then
filt_order_i <= std_logic_vector(to_unsigned(DEFAULT_ORDER, log2(MAX_ORDER)));
hyst_i <= std_logic_vector(to_unsigned(DEFAULT_HYST, log2(MAX_ORDER)));
elsif(clk = '1' and clk'event) then
if(ld_cfg = '1') then
filt_order_i <= filt_order;
hyst_i <= hyst;
end if;
end if;
end process pCFG_REGs;
---------------------------------------------------------------------------
-- LPF for signals equal to '0' at reset
---------------------------------------------------------------------------
-- Low-Pass Filter process
gLPF0: if reset_value = '0' generate
pLPF : process(reset_n, clk)
begin
if(reset_n = '0') then
sig <= '0';
rEdge <= '0';
fEdge <= '0';
cnt_ones <= (others => '0');
delay_line <= (others => '0');
elsif(clk = '1' and clk'event) then
rEdge <= '0';
fEdge <= '0';
-- update the filter output
if(ld_cfg = '1') then
sig <= '0';
elsif(unsigned(cnt_ones) >= unsigned(filt_order_i(log2(MAX_ORDER)-1 downto 1)) + unsigned(hyst_i)) then
sig <= '1';
if(sig = '0') then
rEdge <= '1';
end if;
elsif(unsigned(cnt_ones) <= unsigned(filt_order_i(log2(MAX_ORDER)-1 downto 1)) - unsigned(hyst_i)) then
sig <= '0';
if(sig = '1') then
fEdge <= '1';
end if;
end if;
-- update the filter memory and the count of logic ones
if(ld_cfg = '1') then
delay_line <= (others => '0');
else
delay_line <= delay_line(MAX_ORDER-2 downto 0) & sig_i;
end if;
if(ld_cfg = '1') then
cnt_ones <= (others => '0');
elsif(sig_i = '1' and delay_line(to_integer(unsigned(filt_order_i)-1)) = '0' and unsigned(cnt_ones) /= unsigned(filt_order_i)) then
cnt_ones <= std_logic_vector(unsigned(cnt_ones)+1);
elsif(sig_i = '0' and delay_line(to_integer(unsigned(filt_order_i)-1)) = '1' and unsigned(cnt_ones) /= 0) then
cnt_ones <= std_logic_vector(unsigned(cnt_ones)-1);
end if;
end if;
end process pLPF;
end generate gLPF0;
---------------------------------------------------------------------------
-- LPF for signals equal to '1' at reset
---------------------------------------------------------------------------
-- Low-Pass Filter process
gLPF1: if reset_value = '1' generate
pLPF : process(reset_n, clk)
begin
if(reset_n = '0') then
sig <= '1';
rEdge <= '0';
fEdge <= '0';
cnt_ones <= (others => '1');
delay_line <= (others => '1');
elsif(clk = '1' and clk'event) then
rEdge <= '0';
fEdge <= '0';
-- update the filter output
if(ld_cfg = '1') then
sig <= '1';
elsif(unsigned(cnt_ones) >= unsigned(filt_order_i(log2(MAX_ORDER)-1 downto 1)) + unsigned(hyst_i)) then
sig <= '1';
if(sig = '0') then
rEdge <= '1';
end if;
elsif(unsigned(cnt_ones) <= unsigned(filt_order_i(log2(MAX_ORDER)-1 downto 1)) - unsigned(hyst_i)) then
sig <= '0';
if(sig = '1') then
fEdge <= '1';
end if;
end if;
-- update the filter memory and the count of logic ones
if(ld_cfg = '1') then
delay_line <= (others => '1');
else
delay_line <= delay_line(MAX_ORDER-2 downto 0) & sig_i;
end if;
if(ld_cfg = '1') then
cnt_ones <= (others => '1');
elsif(sig_i = '1' and delay_line(to_integer(unsigned(filt_order_i)-1)) = '0' and unsigned(cnt_ones) /= unsigned(filt_order_i)) then
cnt_ones <= std_logic_vector(unsigned(cnt_ones)+1);
elsif(sig_i = '0' and delay_line(to_integer(unsigned(filt_order_i)-1)) = '1' and unsigned(cnt_ones) /= 0) then
cnt_ones <= std_logic_vector(unsigned(cnt_ones)-1);
end if;
end if;
end process pLPF;
end generate gLPF1;
filt_out <= sig;
end architecture behav;

View file

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////
// Title : dpram_sclk
// Project :
///////////////////////////////////////////////////////////////////////////////
// File : dpram_sclk.vhd
// Author : Gianmarco Girau
// Company : Global Inkjet Systems
// Created : 2019-11-21
// Last update: 2019-11-21
// SVN ID : Git
// Standard :
///////////////////////////////////////////////////////////////////////////////
// Description:
// True Dual-Port, single clock RAM, based on Intel's template
///////////////////////////////////////////////////////////////////////////////
module dpram_sclk
#(
parameter DATA_WIDTH = 32,
parameter ADDR_WIDTH = 8)
(
input [DATA_WIDTH-1:0] data_a, data_b,
input [ADDR_WIDTH-1:0] addr_a, addr_b,
input we_a, we_b, clk,
output reg [DATA_WIDTH-1:0] q_a, q_b
);
// Declare the RAM variable
reg [DATA_WIDTH-1:0] ram[2**ADDR_WIDTH-1:0];
// Port A
always @ (posedge clk)
begin
if (we_a)
begin
ram[addr_a] <= data_a;
q_a <= data_a;
end
else
begin
q_a <= ram[addr_a];
end
end
// Port B
always @ (posedge clk)
begin
if (we_b)
begin
ram[addr_b] <= data_b;
q_b <= data_b;
end
else
begin
q_b <= ram[addr_b];
end
end
endmodule

View file

@ -0,0 +1,75 @@
-------------------------------------------------------------------------------
-- Title : dpram_sclk
-- Project : Dual-Port, single clock RAM
-------------------------------------------------------------------------------
-- File : dpram_sclk.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-04-24
-- Last update: 2019-11-22
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- True Dual-Port, single clock RAM, based on Intel's template
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity dpram_sclk is
generic(
DATA_WIDTH : natural := 32;
ADDR_WIDTH : natural := 8);
port(
clk : in std_logic;
-- Port-A
addr_a : in std_logic_vector(ADDR_WIDTH-1 downto 0);
we_a : in std_logic := '1';
data_a : in std_logic_vector(DATA_WIDTH-1 downto 0);
q_a : out std_logic_vector(DATA_WIDTH-1 downto 0);
-- Port-B
addr_b : in std_logic_vector(ADDR_WIDTH-1 downto 0);
we_b : in std_logic := '1';
data_b : in std_logic_vector(DATA_WIDTH-1 downto 0);
q_b : out std_logic_vector(DATA_WIDTH-1 downto 0));
end dpram_sclk;
architecture rtl of dpram_sclk is
constant DEPTH : natural := 2**ADDR_WIDTH; -- RAM size
-- Build a 2-D array type for the RAM
subtype word_t is std_logic_vector(DATA_WIDTH-1 downto 0);
type memory_t is array(DEPTH-1 downto 0) of word_t;
-- Declare the RAM
shared variable ram : memory_t;
begin
-- Port A
pPORT_A : process(clk)
begin
if(clk = '1' and clk'event) then
if(we_a = '1') then
ram(to_integer(unsigned(addr_a))) := data_a;
end if;
q_a <= ram(to_integer(unsigned(addr_a)));
end if;
end process pPORT_A;
-- Port B
pPORT_B : process(clk)
begin
if(clk = '1' and clk'event) then
if(we_b = '1') then
ram(to_integer(unsigned(addr_b))) := data_b;
end if;
q_b <= ram(to_integer(unsigned(addr_b)));
end if;
end process pPORT_B;
end rtl;

View file

@ -0,0 +1,184 @@
-------------------------------------------------------------------------------
--! @file
--! @brief Frequency counter
--!
--! @details See
--! https://confluence.gisapps.co.uk/pages/viewpage.action?spaceKey=GMAHMB&title=HMB-FD-GMA+Design+Documentation
--!
--! @b Clock/resets:
--! @li clk : nominally 100MHz
--! @li rst_n : active low reset for clk (asynchronous assert)
--!
--! @b Interfaces:
--! @li in_sig : Input to be measured
--! @li clr_errors : Clear error status
--! @li out_of_range : Out of range status (too slow counter or too fast for filter)
--! @li edge_count_avg : Average of last four widths, in clock ticks
--!
--! @b Clock-crossing considerations:
--! @li in_sig is asynchronous, but synchronised with in_sig_sync
--!
--! @b Language build standard requirements:
--! @li VHDL 2008
--!
--! @author Simon Southwell
--! @copyright (c) 2018 Global Inkjet Systems
--! @date 2018-9-20
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_misc.all;
use work.pkg_functions.all;
entity freq_counter is
generic (
FILT_LEN_LOG2 : natural range 1 to 10 := 7
);
port(
clk : in std_logic;
rst_n : in std_logic;
in_sig : in std_logic;
clr_errors : in std_logic;
out_of_range : out std_logic;
edge_count_avg : out std_logic_vector(31 downto 0)
);
end entity freq_counter;
architecture rtl of freq_counter is
type pulse_width_t is array (0 to 3) of std_logic_vector(31 downto 0);
signal filter : std_logic_vector(FILT_LEN_LOG2-1 downto 0);
signal filter_p1 : std_logic_vector(FILT_LEN_LOG2-1 downto 0);
signal in_sig_filt : std_logic;
signal in_sig_filt_dly : std_logic;
signal in_sig_dly : std_logic;
signal width_count : std_logic_vector(31 downto 0);
signal in_sig_sync : std_logic_vector(1 downto 0);
signal last_4_widths : pulse_width_t;
signal a : std_logic_vector(31 downto 0);
signal b : std_logic_vector(31 downto 0);
signal c : std_logic_vector(31 downto 0);
signal d : std_logic_vector(31 downto 0);
signal wr_ptr : unsigned(1 downto 0);
signal a_plus_b : std_logic_vector(31 downto 0);
signal c_plus_d : std_logic_vector(31 downto 0);
begin
-- Filter coult value plus 1
filter_p1 <= std_logic_vector(unsigned(filter) + 1);
-- The last four saved values, divided by 4
a <= "00" & std_logic_vector(unsigned(last_4_widths(0)(31 downto 2)) + unsigned(last_4_widths(0)(1 downto 1)));
b <= "00" & std_logic_vector(unsigned(last_4_widths(1)(31 downto 2)) + unsigned(last_4_widths(1)(1 downto 1)));
c <= "00" & std_logic_vector(unsigned(last_4_widths(2)(31 downto 2)) + unsigned(last_4_widths(2)(1 downto 1)));
d <= "00" & std_logic_vector(unsigned(last_4_widths(3)(31 downto 2)) + unsigned(last_4_widths(3)(1 downto 1)));
process (clk, rst_n)
variable next_in_sig_filt : std_logic := '0';
begin
if rst_n = '0' then
out_of_range <= '0';
in_sig_sync <= (others => '0');
in_sig_filt <= '0';
in_sig_dly <= '0';
in_sig_filt_dly <= '0';
filter <= (others => '0');
width_count <= (others => '0');
edge_count_avg <= (others => '0');
wr_ptr <= (others => '0');
for i in 0 to 3 loop
last_4_widths(i) <= (others => '0');
end loop;
elsif clk'event and clk = '1' then
next_in_sig_filt := in_sig_filt;
-- Synchronise the input
in_sig_sync <= in_sig & in_sig_sync(in_sig_sync'length-1 downto 1);
if clr_errors = '1' then
out_of_range <= '0';
end if;
in_sig_dly <= in_sig_sync(0);
in_sig_filt_dly <= in_sig_filt;
-- If filter count has reached 0, then filtered value is 0
if unsigned(filter) = 0 then
next_in_sig_filt := '0';
end if;
-- If filter count has reached maximum, then filtered value is 1
if unsigned(filter_p1) = 0 then
next_in_sig_filt := '1';
end if;
-- If the input is 1, and not at maximum, increment the filter count
if in_sig_sync(0) = '1' and unsigned(filter_p1) /= 0 then
filter <= std_logic_vector(unsigned(filter) + 1);
end if;
-- If the input is 0, and not at 0, decrement the filter count
if in_sig_sync(0) = '0' and unsigned(filter) /= 0 then
filter <= std_logic_vector(unsigned(filter) - 1);
end if;
-- If the input signal changes...
if in_sig_sync(0) /= in_sig_dly then
-- If the filtered signal is currently low, reset the count to 0
if next_in_sig_filt = '0' then
filter <= (others => '0');
-- If the filtered signal is currently high, reset the count to maximum
else
filter <= (others => '1');
end if;
end if;
in_sig_filt <= next_in_sig_filt;
-- If filtered input is static, increment the width count
if in_sig_filt_dly = in_sig_filt then
width_count <= std_logic_vector(unsigned(width_count) + 1);
-- If the width count wraps, the the signal is either too fast, and the filter
-- is squelching it, or is too slow, and the counter isn't long enough. In
-- either case, flag an out-of-range error.
if width_count = 32x"ffffffff" then
out_of_range <= '1';
end if;
-- If the filtered signal changes, log the count in the next save register,
-- and clear the count. MOve the write piinter on to the next save register.
else
last_4_widths(to_integer(wr_ptr)) <= width_count;
width_count <= (others => '0');
wr_ptr <= wr_ptr + 1;
end if;
-- Average up the four saved pulse widths. Do this in stages to relieve timing.
a_plus_b <= std_logic_vector(unsigned(a) + unsigned(b));
c_plus_d <= std_logic_vector(unsigned(c) + unsigned(d));
edge_count_avg <= std_logic_vector(unsigned(a_plus_b) + unsigned(c_plus_d));
end if;
end process;
end rtl;

View file

@ -0,0 +1,150 @@
-------------------------------------------------------------------------------
-- Title : Markov Edges
-- Project :
-------------------------------------------------------------------------------
-- File : markov_edges.vhd
-- Author : <Damian@JERSEY>
-- Company : Global Inkjet Systems
-- Created : 2008-05-01
-- Last update: 2010-02-03
-- SVN ID : $Id: markov_edges.vhd 3267 2010-02-03 20:00:20Z damiansmith $
-- Standard : VHDL'93
-------------------------------------------------------------------------------
-- Description: Uses a Markov chain to detect rising and falling edges of a
-- signal. Generic allows configuration of length.
--
-- Counts up for '1' and down for '0' (saturating at 0 and chain_len)
-- when reaches limit, an edge has been detected and the value is held as the
-- filtered signal until the other limit is reached.
--
-- Note that this reduces the maximum encoder rate to RATE_clk / chain_len
-- assuming no noise and a 50% Mark Space ratio
--
-------------------------------------------------------------------------------
-- Copyright (c) 2008 Global Inkjet Systems
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2008-05-01 1.0 Damian Created
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.pkg_functions.all;
-------------------------------------------------------------------------------
entity markov_edges is
generic (
MAX_CHAIN_LEN : positive range 2 to 256 := 32;
DEFAULT_CHAIN_LEN : positive range 2 to 32 := 16
);
port (
clk : in std_logic;
arst_n : in std_logic := '1';
srst_n : in std_logic := '1';
ena : in std_logic := '1';
load_chain_len : in std_logic;
chain_len : in std_logic_vector(log2(MAX_CHAIN_LEN)-1 downto 0);
raw_signal : in std_logic;
filtered_signal : out std_logic;
edge_rising : out std_logic; -- strobe
edge_falling : out std_logic -- strobe
);
end entity markov_edges;
-------------------------------------------------------------------------------
architecture rtl of markov_edges is
signal filtered_signal_int : std_logic;
begin
markov : process (clk, arst_n) is
variable chain : unsigned(log2(MAX_CHAIN_LEN - 1)-1 downto 0);
variable raw_signal_d : std_logic_vector(1 downto 0);
variable chain_len_d : unsigned(chain_len'range);
begin -- process markov
if arst_n = '0' then
filtered_signal_int <= '0';
edge_falling <= '0';
edge_rising <= '0';
chain := (others => '0');
raw_signal_d := (others => '0');
chain_len_d := to_unsigned(DEFAULT_CHAIN_LEN,chain_len_d'length);
elsif rising_edge(clk) then
if srst_n = '0' then
filtered_signal_int <= '0';
edge_falling <= '0';
edge_rising <= '0';
chain := (others => '0');
raw_signal_d := (others => '0');
chain_len_d := to_unsigned(DEFAULT_CHAIN_LEN,chain_len_d'length);
elsif ena = '1' then
edge_rising <= '0';
edge_falling <= '0';
-----------------------------------------------------------------------
-- Detect Edges and Filter Output
-----------------------------------------------------------------------
if chain = chain_len_d and filtered_signal_int = '0' then
-- markov chain has reached '1'
edge_rising <= '1';
filtered_signal_int <= '1';
elsif chain = 0 and filtered_signal_int = '1' then
-- markov chain has reached '0'
edge_falling <= '1';
filtered_signal_int <= '0';
else
-- maintain filtered value
filtered_signal_int <= filtered_signal_int;
end if;
-----------------------------------------------------------------------
-- Move Markov Chain if necessary
-----------------------------------------------------------------------
if raw_signal_d(raw_signal_d'high) = '1' and chain /= chain_len_d then
chain := chain + 1;
elsif raw_signal_d(raw_signal_d'high) = '0' and chain /= 0 then
chain := chain - 1;
end if;
-----------------------------------------------------------------------
-- sr for metastability
-----------------------------------------------------------------------
raw_signal_d := raw_signal_d(raw_signal_d'high - 1 downto 0) & raw_signal;
-----------------------------------------------------------------------
-- Load new Chain Length - reset output values
-----------------------------------------------------------------------
if load_chain_len = '1' then
chain_len_d := unsigned(chain_len);
chain := (others => '0');
filtered_signal_int <= '0';
edge_falling <= '0';
edge_rising <= '0';
if unsigned(chain_len) < 1 then
chain_len_d := to_unsigned(1,chain_len_d'length);
elsif unsigned(chain_len) > MAX_CHAIN_LEN then
chain_len_d := to_unsigned(MAX_CHAIN_LEN, chain_len_d'length);
end if;
end if;
end if;
end if;
end process markov;
filtered_signal <= filtered_signal_int;
end architecture rtl;
-------------------------------------------------------------------------------

View file

@ -0,0 +1,443 @@
-------------------------------------------------------------------------------
-- Title : Package Functions
-- Project : Common
-------------------------------------------------------------------------------
-- File : pkg_functions.vhd
-- Author : <Damian@LANGERHANS>
-- Company : Global Inkjet Systems
-- Created : 2010-11-17
-- Last update: 2015-05-22
-- SVN ID : $Id$
-- Standard : VHDL'87
-------------------------------------------------------------------------------
-- Description: Various useful functions
-------------------------------------------------------------------------------
-- Copyright (c) 2010 Global Inkjet Systems
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use std.textio.all;
package PKG_FUNCTIONS is
type fifo_80b_vector is array (natural range <>) of std_logic_vector(79 downto 0);
type fifo_64b_vector is array (natural range <>) of std_logic_vector(63 downto 0);
type fifo_32b_vector is array (natural range <>) of std_logic_vector(31 downto 0);
type fifo_20b_vector is array (natural range <>) of std_logic_vector(19 downto 0);
type fifo_18b_vector is array (natural range <>) of std_logic_vector(17 downto 0);
type fifo_19b_vector is array (natural range <>) of std_logic_vector(18 downto 0);
type dc_dout_t is array (16 downto 1) of std_logic_vector(15 downto 0);
type dout_t is array (16 downto 0) of std_logic_vector(15 downto 0);
type fifo_16b_vector is array (natural range <>) of std_logic_vector(15 downto 0);
type fifo_13b_vector is array (natural range <>) of std_logic_vector(12 downto 0);
type fifo_12b_vector is array (natural range <>) of std_logic_vector(11 downto 0);
type fifo_10b_vector is array (natural range <>) of std_logic_vector(9 downto 0);
type fifo_9b_vector is array (natural range <>) of std_logic_vector(8 downto 0);
type fifo_8b_vector is array (natural range <>) of std_logic_vector(7 downto 0);
type fifo_5b_vector is array (natural range <>) of std_logic_vector(4 downto 0);
type fifo_4b_vector is array (natural range <>) of std_logic_vector(3 downto 0);
type fifo_3b_vector is array (natural range <>) of std_logic_vector(2 downto 0);
type fifo_2b_vector is array (natural range <>) of std_logic_vector(1 downto 0);
-- TYPE fifo_3b_unsigned_vector IS ARRAY ( NATURAL RANGE <>) OF unsigned(2 downto 0);
-- Get the log to base 2 of an integer
function LOG2(N : integer) return integer;
function UNSIGNEDHIGH (N : natural) return integer;
function IS_POWER_OF_2 (N : integer) return boolean;
function WORDS(N : integer; M : integer) return integer;
function OR_BUS(DATA : std_logic_vector) return std_logic;
function CLIP (N : natural; MAX : natural) return natural;
function MAX_VAL (N : unsigned) return boolean;
function MAX_VAL (N : signed) return boolean;
function MAX_VAL (N : std_logic_vector) return boolean;
function STD2UINT (
n : std_logic_vector)
return natural;
function STD2INT (
n : std_logic_vector)
return integer;
-- useful for moving tristate signals up to a top level
type tristate_port_t is record
O : std_logic; -- output
I : std_logic; -- input
EN : std_logic; -- tristate enable - active high for 'Z'
end record;
function sel(Cond : boolean; If_True, If_False : integer) return integer;
-- pragma translate_off
-- Assemble a GBUS PKT
function GBUS_PKT (
ID : std_logic_vector(7 downto 0);
WLEN : natural;
RLEN : natural;
ADDR : natural;
WDATA : std_logic_vector := x"00")
return std_logic_vector;
function FIFO_WRAP (
CHAN : integer range 0 to 8;
PAYLOAD : std_logic_vector)
return std_logic_vector;
impure function print(
mytext : string;
emph : boolean := false;
display : boolean := true)
return boolean;
type storage_type is protected
impure function add(value : integer) return boolean; -- puts an item into the storage
impure function rmv return integer; -- removes and returns the oldest item from the storage
impure function level return integer; -- number of items in storage
impure function empty return boolean; -- true if no items in storage
impure function full return boolean; -- true if no space remaining in storage
impure function rst return boolean; -- resets storage to empty condition
end protected storage_type;
-- pragma translate_on
end PKG_FUNCTIONS;
package body PKG_FUNCTIONS is
-----------------------------------------------------------------------------
-- Get the log to base 2 of an integer
function LOG2(N : integer) return integer is
begin
if N = 1 then
return 1;
elsif N <= 0 then
--pragma translate_off
report "Invalid input for LOG function" severity error;
--pragma translate_on
return 0;
else
return 1 + LOG2(N/2);
end if;
end function LOG2;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- purpose: Given a value N, this function returns the value for the HIGH end of an unsigned vector large enough to hold the value N
function UNSIGNEDHIGH (
N : natural)
return integer is
begin -- UNSIGNEDHIGH
if N <= 1 then
return 0;
else
return LOG2(N)-1;
end if;
end UNSIGNEDHIGH;
function IS_POWER_OF_2(N : integer) return boolean is
begin
if 2**(log2(N)-1) = N then
return true;
else
return false;
end if;
end function IS_POWER_OF_2;
-----------------------------------------------------------------------------
-- Return number of words of length M in N bits of data
function WORDS(N : integer; M : integer) return integer is
begin
if M = 0 then
--pragma translate_off
report "Invalid input for WORDS function" severity error;
--pragma translate_on
return 0;
elsif N = 0 then
return 0;
elsif N < M then
return 1;
else
return 1 + WORDS(N - M, M);
end if;
end function WORDS;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- Logical or of all bits in a bus
function OR_BUS(DATA : std_logic_vector) return std_logic is
variable OR_ARRAY : std_logic_vector(2*DATA'length-2 downto 0);
begin
--Produces a tree of OR gates.
OR_ARRAY(DATA'length-1 downto 0) := DATA;
for n in 0 to DATA'length-2 loop
OR_ARRAY(DATA'length+n) := OR_ARRAY(2*n) or OR_ARRAY(2*n+1);
end loop; -- XOR_COUNT
return OR_ARRAY(OR_ARRAY'high);
end function OR_BUS;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
function CLIP (N : natural; MAX : natural) return natural is
begin
if N <= MAX then
return N;
else
return MAX;
end if;
end function CLIP;
function MAX_VAL (N : unsigned) return boolean is
begin
if (not(N)) = 0 then
return true;
end if;
return false;
end function MAX_VAL;
function MAX_VAL (N : signed) return boolean is
begin -- MAX_VAL
return max_val(unsigned(N));
end MAX_VAL;
function MAX_VAL (N : std_logic_vector) return boolean is
begin -- MAX_VAL
return max_val(unsigned(N));
end MAX_VAL;
function STD2UINT (n : std_logic_vector) return natural is
begin
return to_integer(unsigned(n));
end function STD2UINT;
function STD2INT (n : std_logic_vector) return integer is
begin
return to_integer(signed(n));
end function STD2INT;
----------------------------------------------------------------
-- Functions to select one or the other based on a boolean (or
-- std_ulogic or std_logic) input.
-- Analogous to the C statement x = Cond ? a : b
----------------------------------------------------------------
-- constant k: integer := sel(BOOLEAN_GENERIC, 5, 8);
-- or ...
-- constant k: integer := sel(Cond => BOOLEAN_GENERIC, If_True => 5, If_False => 8);
function sel(Cond : boolean; If_True, If_False : integer) return integer is
begin
if (Cond = true) then
return(If_True);
else
return(If_False);
end if;
end function sel;
-----------------------------------------------------------------------------
-- pragma translate_off
-----------------------------------------------------------------------------
function GBUS_PKT (
ID : std_logic_vector(7 downto 0);
WLEN : natural;
RLEN : natural;
ADDR : natural;
WDATA : std_logic_vector := x"00")
return std_logic_vector is
function ONE_IF_GT (
N : natural;
MAX : natural) return natural is
begin
if N > MAX then
return 1;
else
return 0;
end if;
end function ONE_IF_GT;
-- Byte 0 Entity ID (ignore locally) \
-- Byte 1(7) read#/write | stripped out and passed
-- Byte 1(6) single word reply | as individual control lines
-- Byte 1(5) no further data | to the entity of this block
-- Byte 1(4:0) Command Address /
-- Byte 2,3 Write Length (/words) (unless no further data)
-- Byte 4,5 Reply Length (/words) (unless write, or single word reply)
-- Next Bytes - Write Length words of data unless no further data
constant return_len : natural := 16*(1 + ONE_IF_GT(WLEN, 0) + ONE_IF_GT(RLEN, 1) + WLEN);
variable return_vec : std_logic_vector(return_len - 1 downto 0);
begin
if WLEN > 0 then
if RLEN > 1 then
-- long data, long reply
return_vec := ID&'0'&'0'&'0'&std_logic_vector(to_unsigned(ADDR, 5))&
std_logic_vector(to_unsigned(WLEN, 16)) &
std_logic_vector(to_unsigned(RLEN, 16)) &
WDATA;
elsif RLEN = 1 then
-- long data, short reply
return_vec := ID&'0'&'1'&'0'&std_logic_vector(to_unsigned(ADDR, 5))&
std_logic_vector(to_unsigned(WLEN, 16)) &
WDATA;
else
-- long data, no reply
return_vec := ID&'1'&'0'&'0'&std_logic_vector(to_unsigned(ADDR, 5))&
std_logic_vector(to_unsigned(WLEN, 16)) &
WDATA;
end if;
else
if RLEN > 1 then
-- no data, long reply
return_vec := ID&'0'&'0'&'1'&std_logic_vector(to_unsigned(ADDR, 5))&
std_logic_vector(to_unsigned(RLEN, 16));
elsif RLEN = 1 then
-- no data, short reply
return_vec := ID&'0'&'1'&'1'&std_logic_vector(to_unsigned(ADDR, 5));
else
-- no data, no reply
return_vec := ID&'1'&'0'&'1'&std_logic_vector(to_unsigned(ADDR, 5));
end if;
end if;
return return_vec;
end function GBUS_PKT;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
function FIFO_WRAP (
chan : integer range 0 to 8;
payload : std_logic_vector)
return std_logic_vector is
variable return_vec : std_logic_vector(WORDS(payload'length, 16)*16 + 31 downto 0);
begin
return_vec := (others => '0');
return_vec(return_vec'high downto return_vec'high - 31 - payload'length) := x"11" & std_logic_vector(to_unsigned(WORDS(payload'length, 16), 16)) & payload;
return return_vec;
end function FIFO_WRAP;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
impure function print(
mytext : string;
emph : boolean := false;
display : boolean := true)
return boolean is
variable my_input_line : line;
variable my_output_line : line;
begin
if display then
-- allows user to specify verbosity
if emph then
write(my_output_line, string'(" ******************************************************* "));
writeline(output, my_output_line);
end if;
write(my_output_line, NOW);
write(my_output_line, string'(" : "));
write(my_output_line, mytext);
writeline(output, my_output_line);
if emph then
write(my_output_line, string'(" ******************************************************* "));
writeline(output, my_output_line);
end if;
deallocate(my_input_line);
end if;
return true;
end function print;
-----------------------------------------------------------------------------
type storage_type is protected body
type int_array_type is array (1 to 1000) of integer;
variable int_array : int_array_type := (others => -3);
variable fill_level : integer := 0;
impure function level return integer is
begin
return fill_level;
end function level;
impure function empty return boolean is
begin
if fill_level = 0 then
return true;
else
return false;
end if;
end function empty;
impure function full return boolean is
begin
if fill_level = int_array'high then
return true;
else
return false;
end if;
end function full;
impure function add(value : integer) return boolean is
begin
if not full then
int_array := value & int_array(1 to int_array'high - 1);
fill_level := fill_level + 1;
return true;
else
report "Error - too much buffering" severity error;
return false;
end if;
end function add;
impure function rmv return integer is
variable tmp : integer;
begin
if not empty then
tmp := int_array(fill_level);
int_array(fill_level) := -3;
fill_level := fill_level - 1;
return tmp;
else
report "Error - No buffering" severity error;
return -2;
end if;
end function rmv;
impure function rst return boolean is
begin
int_array := (others => -3);
fill_level := 0;
return true;
end function rst;
end protected body storage_type;
-- pragma translate_on
end PKG_FUNCTIONS;

View file

@ -0,0 +1,94 @@
-------------------------------------------------------------------------------
--! @file
--! @brief PWM with specifiable perio (in clk ticks), and control granularity of 1/256
--!
--! @details See
--! https://confluence.gisapps.co.uk/pages/viewpage.action?spaceKey=GMAHMB&title=HMB-FD-GMA+Design+Documentation
--!
--! @b Clock/resets:
--! @li clk : nominally 100MHz
--! @li rst_n : active low reset for clk (asynchronous assert)
--!
--! @b Interfaces:
--! @li mod_val : modulation value input between 0 an 255 giving fraction (of 256) signal is high
--! @li ticks_per_period : PWM period input as count of clk ticks
--! @li pwm_out : PWM output signal
--!
--! @b Clock-crossing considerations:
--! @li Module is a single clock domain synchronous block
--!
--! @b Language build standard requirements:
--! @li VHDL 2008
--!
--! @author Simon Southwell
--! @copyright (c) 2018 Global Inkjet Systems
--! @date 2018-9-20
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_misc.all;
use work.pkg_functions.all;
entity pwm is
port(
clk : in std_logic;
rst_n : in std_logic;
mod_val : in std_logic_vector( 7 downto 0);
ticks_per_period : in std_logic_vector(31 downto 0);
pwm_out : out std_logic
);
end entity pwm;
architecture rtl of pwm is
signal phase_count : std_logic_vector(31 downto 0);
signal period_div256 : std_logic_vector(31 downto 0);
signal phase : std_logic_vector(7 downto 0);
begin
-- The specified period of the PWM signal, divided by 256, with rounding
period_div256 <= 8x"0" & std_logic_vector(unsigned(ticks_per_period(31 downto 8)) + unsigned(ticks_per_period(7 downto 7)));
process (clk, rst_n)
begin
if rst_n = '0' then
phase_count <= (others => '0');
phase <= (others => '0');
pwm_out <= '0';
elsif clk'event and clk = '1' then
-- If the phase count reaches 1/256th of period, reset to 0 and increment the phase number
if unsigned(mod_val) /= 0 then
if unsigned(phase_count) = (unsigned(period_div256) - 1) then
phase_count <= (others => '0');
phase <= std_logic_vector(unsigned(phase) + 1);
else
phase_count <= std_logic_vector(unsigned(phase_count) + 1);
end if;
end if;
-- If the phase number is less than the specified modulation value, set
-- the output high, else set low. Note that, in order to have both a
-- full on and full off, without 257 settings, when mod_val = 256 o/p
-- forced on (would otherwise be low for last phase).
if unsigned(phase) < unsigned(mod_val) or mod_val = 8x"ff" then
pwm_out <= '1';
else
pwm_out <= '0';
end if;
end if;
end process;
end rtl;

View file

@ -0,0 +1,267 @@
-------------------------------------------------------------------------------
-- Title : queue_and_delay
-- Project : project independent
-------------------------------------------------------------------------------
-- File : queue_and_delay.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2016-05-28
-- Last update: 2019-11-18
-- SVN ID : Git
-- Standard : VHDL'93
-------------------------------------------------------------------------------
-- Description:
-- Generic component implementing a queue and delay functionality: Apply a
-- static programmable delay to the input signal. Since the block is FIFO based
-- (2048 words), the user must make sure that the number of transitions on the
-- input signal happening within the programmed delay is lower than the size of the FIFO.
-- E.g.: if the user program a delay of 2 ms, the input signal must have less
-- than 1024 pulses in 2 ms => max pulse rate = 512kHz. The block rises the
-- error bit when this condition is violated.
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.common_pkg.all;
entity queue_and_delay is
generic(
DELAY_WIDTH : integer range 8 to 32 := 32;
USE_EXT_TIME : boolean := false;
QUEUE_SIZE : natural range 16 to 8192 := 1024);
port (
rstN : in std_logic;
clk : in std_logic;
init : in std_logic;
cnt_dir : in std_logic; -- specify the direction of the cnt (0 => up, 1
-- => down), when use_ext_time is set to true
delay : in std_logic_vector(DELAY_WIDTH-1 downto 0);
ext_time : in std_logic_vector(31 downto 0);
wave_in : in std_logic;
wave_out : out std_logic;
no_edge_detect : in std_logic := '0';
ovf_error : out std_logic);
end queue_and_delay;
architecture RTL of queue_and_delay is
component sync_fifo
generic (
FIFO_WIDTH : natural range 1 to 32;
FIFO_DEPTH : natural range 1 to 8192);
port (
clock : in std_logic;
data : in std_logic_vector (FIFO_WIDTH-1 downto 0);
rdreq : in std_logic;
sclr : in std_logic;
wrreq : in std_logic;
empty : out std_logic;
full : out std_logic;
q : out std_logic_vector (FIFO_WIDTH-1 downto 0);
usedw : out std_logic_vector (log2(FIFO_DEPTH)-1 downto 0));
end component;
signal toggle_in, toggle_out,time_elapsed : std_logic;
signal wave_in_d, wave_out_i, pending_trans : std_logic;
signal fifo_rd_en, fifo_empty, fifo_full : std_logic;
signal cnt_dir_i, wave_out_i_d, new_event : std_logic;
signal wave_out_ii, shf_enable, ext_msb : std_logic;
signal delay_line : std_logic_vector( 7 downto 0);
signal int_time, local_time_d, event_time : std_logic_vector(31 downto 0);
signal diff_time, time_entry : std_logic_vector(31 downto 0);
begin -- RTL
-----------------------------------------------------------------------------
-- Detect transitions in the input signal and memorize those events in a
-- FIFO, together with a timetag. This process can be seen as a representation
-- of the input signal in a compressed format.
-----------------------------------------------------------------------------
toggle_in <= '1' when wave_in /= wave_in_d else '0';
pInputEdgeDetect : process(clk)
begin
if(clk = '1' and clk'event) then
wave_in_d <= wave_in;
end if;
end process pInputEdgeDetect;
iENTRY_QUEUE: sync_fifo
generic map(
FIFO_WIDTH => 32,
FIFO_DEPTH => QUEUE_SIZE)
port map (
clock => clk,
data => time_entry,
rdreq => fifo_rd_en,
sclr => init,
wrreq => toggle_in,
empty => fifo_empty,
full => fifo_full,
q => event_time,
usedw => open);
-- Check Overflow error:
pCHECK_OVF : process(rstN, clk)
begin
if(rstN = '0') then
ovf_error <= '0';
elsif(clk = '1' and clk'event) then
if(init = '1') then
ovf_error <= '0';
elsif(toggle_in = '1' and fifo_full = '1') then
ovf_error <= '1';
end if;
end if;
end process pCHECK_OVF;
-- Time reference: either use the external one or generate it locally
gTIME_REF0: if USE_EXT_TIME = true generate
int_time <= ext_time;
shf_enable <= '1' when int_time /= local_time_d else '0';
pTimeElapsed : process(clk)
begin
if(clk = '1' and clk'event) then
if(cnt_dir_i = '0') then
time_entry <= std_logic_vector(signed(int_time) + signed(delay));
else
time_entry <= std_logic_vector(signed(int_time) - signed(delay) + 1);
end if;
local_time_d <= int_time;
cnt_dir_i <= cnt_dir;
if(cnt_dir_i = '0') then
time_elapsed <= not diff_time(diff_time'left);
else
time_elapsed <= diff_time(diff_time'left);
end if;
new_event <= fifo_rd_en;
end if;
end process pTimeElapsed;
diff_time <= std_logic_vector(signed(ext_time)-signed(event_time));
end generate gTIME_REF0;
gTIME_REF1: if USE_EXT_TIME = false generate
pGEN_LOC_REF : process(rstN, clk)
begin
if(rstN = '0') then
int_time <= (others => '0');
elsif(clk = '1' and clk'event) then
if(init = '1') then
int_time <= (others => '0');
else
int_time <= std_logic_vector(unsigned(int_time)+1);
end if;
end if;
end process pGEN_LOC_REF;
new_event <= fifo_rd_en;
pTimeElapsed : process(clk)
begin
if(clk = '1' and clk'event) then
time_entry <= std_logic_vector(signed(int_time) + signed(delay));
end if;
end process pTimeElapsed;
diff_time <= std_logic_vector(unsigned(int_time)-unsigned(event_time));
time_elapsed <= '1' when diff_time(diff_time'left) = '0' else '0';
shf_enable <= '1';
end generate gTIME_REF1;
-----------------------------------------------------------------------------
-- Delay the input signal
-----------------------------------------------------------------------------
-- Read the signal transitions recorded in the FIFO, apply the static delay
pDELAY_WAVE_GEN : process(clk)
begin
if(clk = '1' and clk'event) then
if(init = '1' or (time_elapsed = '1' and new_event = '0')) then
pending_trans <= '0';
elsif(new_event = '1') then
pending_trans <= '1';
end if;
if(pending_trans = '0' and fifo_empty = '0' and fifo_rd_en = '0' and new_event = '0') then
fifo_rd_en <= '1';
else
fifo_rd_en <= '0';
end if;
end if;
end process pDELAY_WAVE_GEN;
pGEN_OUT : process(rstN, clk)
begin
if(rstN = '0') then
wave_out_i <= '0';
elsif(clk = '1' and clk'event) then
if(init = '1') then
wave_out_i <= wave_in_d;
elsif(toggle_out = '1') then
wave_out_i <= not wave_out_i;
end if;
end if;
end process pGEN_OUT;
-- Because of the intrinsic latency with the FIFO, a shift register is used
-- to achieve small delays (< 8).
pDELAY_THROUGH_SHF : process(clk)
begin
if(clk = '1' and clk'event) then
if(shf_enable = '1') then
delay_line <= delay_line(6 downto 0) & wave_in;
end if;
end if;
end process pDELAY_THROUGH_SHF;
toggle_out <= time_elapsed and pending_trans;
-- When using the external counter, the input signal might have multiple rising and
-- falling events whitout a change a value in the counter. When this happens,
-- the pulse width is not properly replicated in the output of the delay
-- block. To make the behaviour more predictable, when using the external
-- counter, a positive edge detector is inserted at the output.
gOUT_GEN0: if use_ext_time = false generate
wave_out_ii <= wave_out_i when unsigned(delay) >= 8 else delay_line(to_integer(unsigned(delay(2 downto 0))));
pOUT_GEN0: process(clk)
begin
if(clk = '1' and clk'event) then
wave_out <= wave_out_ii;
end if;
end process pOUT_GEN0;
end generate gOUT_GEN0;
gOUT_GEN1: if use_ext_time = true generate
pOUT_GEN1: process(clk)
begin
if(clk = '1' and clk'event) then
wave_out_i_d <= wave_out_i;
if(no_edge_detect = '0') then
wave_out <= wave_out_i and not wave_out_i_d;
else
wave_out <= wave_out_i;
end if;
end if;
end process pOUT_GEN1;
end generate gOUT_GEN1;
end RTL;

View file

@ -0,0 +1,95 @@
-------------------------------------------------------------------------------
-- Title : simple_delay
-- Project : project independent
-------------------------------------------------------------------------------
-- File : simple_delay.vhd
-- Author : Dave Steele
-- Company : Global Inkjet Systems
-- Created : 2023-05-22
-- Last update: 2023-05-22
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Implements a simple variable delay. Delay must be complete before new one is started
-- else get error status. en can be used to adjust tick size without increasing logic
-- Generic queue_and_delay cannot cope with shorter delay afer longer ones
-- Fifo is first in first out
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity simple_delay is
generic(
DELAY_WIDTH : integer range 8 to 32 := 16;
CLK_DIVISOR : integer range 1 to 32 := 10
);
port (
rst_n : in std_logic;
clk : in std_logic;
d_in_plse : in std_logic;
delay : in std_logic_vector(DELAY_WIDTH-1 downto 0);
d_out_plse : out std_logic;
busy : out std_logic;
err : out std_logic
);
end simple_delay;
architecture RTL of simple_delay is
signal count : std_logic_vector(DELAY_WIDTH-1 downto 0);
signal divisor : integer range 0 to CLK_DIVISOR;
signal div_en : std_logic;
begin -- RTL
TIME_PROC : process(clk,rst_n)
begin
if rst_n = '0' then
err <= '0';
busy <= '0';
d_out_plse <= '0';
count <= (others => '0');
divisor <= 0;
div_en <= '0';
elsif(clk = '1' and clk'event) then
d_out_plse <= '0';
if d_in_plse = '1' then
count <= delay;
busy <= '1';
if busy = '1' then
err <= '0';
end if;
elsif unsigned(count) = 1 and div_en = '1' then
count <= std_logic_vector(unsigned(count)-1);
d_out_plse <= '1';
busy <= '0';
elsif unsigned(count) /= 0 and div_en = '1' then
count <= std_logic_vector(unsigned(count)-1);
end if;
div_en <= '0';
if CLK_DIVISOR = 1 then
div_en <= '1';
end if;
if d_in_plse = '1' then
divisor <= 0;
elsif divisor = CLK_DIVISOR-1 then
divisor <= 0;
div_en <= '1';
else
divisor <= divisor + 1;
end if;
end if;
end process;
end RTL;

View file

@ -0,0 +1,279 @@
//----------------------------------------------------------------------------
// Module Description
//
// This is a simple I2C slave, with device address fixed at instantiation.
// Data format is 2-Byte Address, 1-Byte data on writes. For reads a 2-byte
// address write is sent, followed by a 1-byte read.
//
// When SDA is low, output a zero, when high, I/O cell must go to tristate, otherwise reads will not work.
//
// Input clock must be at least 12x higher than I2C SCL frequency, i.e. >1.2MHz for 100kHz, >4.8MHz for 400kHz.
//----------------------------------------------------------------------------
// Revision Date Author Notes
//
// 1.0 14-8-2015 GJL First Written
//
//----------------------------------------------------------------------------
`resetall
`timescale 1ns/1ps
module simple_i2c_slave
(
input wire clk,
input wire scl_in,
output wire scl_out,
input wire sda_in,
output wire sda_out,
output wire i2c_busy_out,
output wire [15:0] add_out,
output wire [7:0] wr_data_out,
output wire wr_en_out,
output wire rd_en_out,
input wire [7:0] rd_data_in,
input wire rd_dv_in
);
//----------------------------------------------------------------------------
// Internal Declarations
//----------------------------------------------------------------------------
// Parameters
parameter DEVICE_ADDRESS = 7'h70; // 7 bit Device Address
//localparam DEVICE_ADDRESS = 7'h70; // 7 bit Device Address
// Timing
parameter LAST_BYTE = 2'd3;
// I2C State Machine States
localparam IDLE = 3'd0;
localparam RX_BYTE = 3'd1;
localparam SLV_ACK = 3'd2;
localparam ACK_HOLD = 3'd3;
localparam TX_BYTE = 3'd4;
// Internal Signals
reg [2:0] scl_sr = 3'b111;
reg [2:0] sda_sr = 3'b111;
wire scl_re;
wire scl_fe;
wire scl_hi;
wire sda_re;
wire sda_fe;
wire start;
wire stop;
reg [2:0] bit_cnt = 3'd0;
reg [1:0] byte_cnt = 2'd0;
reg sda = 1'b1;
reg scl = 1'b1;
reg read_pending = 1'b0;
reg rnw = 1'b0;
reg [2:0] next_state = RX_BYTE;
reg [2:0] state = IDLE;
reg [15:0] add = 16'd0;
reg [7:0] wr_data = 8'd0;
reg wr_en = 1'b0;
reg i2c_busy = 1'b0;
//----------------------------------------------------------------------------
// Output assignments
//----------------------------------------------------------------------------
assign scl_out = scl;
assign sda_out = sda;
assign i2c_busy_out = i2c_busy;
assign add_out = add;
assign wr_data_out = wr_data;
assign wr_en_out = wr_en;
assign rd_en_out = read_pending;
//----------------------------------------------------------------------------
// Input detection
//----------------------------------------------------------------------------
always @(posedge clk)
begin
scl_sr <= {scl_sr[1:0], scl_in};
sda_sr <= {sda_sr[1:0], sda_in};
end
assign scl_re = (scl_sr[2:1] == 2'b01);
assign scl_fe = (scl_sr[2:1] == 2'b10);
assign scl_hi = (scl_sr[2:1] == 2'b11);
assign sda_re = (sda_sr[2:1] == 2'b01);
assign sda_fe = (sda_sr[2:1] == 2'b10);
assign start = sda_fe & scl_hi;
assign stop = sda_re & scl_hi;
//----------------------------------------------------------------------------
// I2C state machine
//----------------------------------------------------------------------------
reg [7:0] rd_byte = 8'd0;
reg [7:0] rd_data = 8'd0;
//----------------------------------------------------------------------------
// I2C Slave State Machine
//----------------------------------------------------------------------------
always @(posedge clk)
begin
case (state)
IDLE:
begin
bit_cnt <= 3'd0;
byte_cnt <= 2'd0;
sda <= 1'b1;
scl <= 1'b1;
wr_en <= 1'b0;
read_pending <= 1'b0;
i2c_busy <= 1'b0;
if (start)
begin
state <= RX_BYTE;
end
end
RX_BYTE :
if (stop)
begin
state <= IDLE;
end
else if (scl_re)
begin
rd_byte <= {rd_byte[6:0], sda_in}; // Read in next bit
bit_cnt <= bit_cnt + 3'd1; // Increment bit counter
if (&bit_cnt)
begin
state <= SLV_ACK; // If last bit, go to Slave Acknowledge state
end
end
SLV_ACK:
if (stop)
begin
state <= IDLE;
end
else if (scl_fe)
begin
byte_cnt <= byte_cnt + 2'd1; // Increment the byte count
if ((byte_cnt == 2'd0) & (rd_byte[7:1] == DEVICE_ADDRESS))
i2c_busy <= 1'b1; // Assert so I/O control passes this through
if ((byte_cnt == 2'd0) & (rd_byte[7:1] != DEVICE_ADDRESS))
state <= IDLE; // If not for us, ignore
else
state <= ACK_HOLD; // Otherwise respond
if (rd_byte[0] & (byte_cnt == 2'd0))
next_state <= TX_BYTE;
else if (byte_cnt == LAST_BYTE)
next_state <= IDLE;
else
next_state <= RX_BYTE;
if (byte_cnt == 2'd0)
rnw <= rd_byte[0];
if (~rnw)
begin
if (byte_cnt == 2'd1)
begin
if (LAST_BYTE != 2'd2)
add[15:8] <= rd_byte;
else
add[15:0] <= {rd_byte, 8'h00};
end
if (byte_cnt == 2'd2 && LAST_BYTE != 2'd2)
add[7:0] <= rd_byte;
if (byte_cnt == LAST_BYTE)
wr_data <= rd_byte;
end
wr_en <= ((~rnw) & (byte_cnt == LAST_BYTE)); // Assert write strobe if last byte of a write command
read_pending <= rd_byte[0] & (byte_cnt == 2'd0);
if (byte_cnt == 8'd0)
sda <= (rd_byte[7:1] != DEVICE_ADDRESS); // If receiving byte address, verify before asserting ACK
else
sda <= 1'b0; // Send ACK once line is clear
end
ACK_HOLD:
if (stop)
begin
state <= IDLE;
wr_en <= 1'b0; // Clear write enable
end
else
begin
wr_en <= 1'b0; // Clear write enable
if (rd_dv_in)
begin
read_pending <= 1'b0;
rd_data <= rd_data_in;
end
if (scl_fe)
begin
sda <= 1'b1; // On next falling edge, deassert SDA
scl <= ~read_pending; // If we're waiting for a read, keep SCL low
state <= next_state;
end
end
TX_BYTE:
if (stop)
begin
state <= IDLE;
end
else
begin
if (rd_dv_in)
begin
read_pending <= 1'b0;
rd_data <= rd_data_in;
end
scl <= ~read_pending; // Keep SCL low until read is complete
sda <= rd_data[7];
if (scl_fe)
begin
rd_data <= {rd_data[6:0], 1'b0}; // Read in next bit
bit_cnt <= bit_cnt + 3'd1; // Increment bit counter
if (&bit_cnt)
state <= IDLE; // If last bit sent, go to idle condition
end
end
default :
begin // If we end up here, go to IDLE
bit_cnt <= 3'd0;
byte_cnt <= 2'd0;
sda <= 1'b1;
scl <= 1'b1;
read_pending <= 1'b0;
state <= IDLE;
end
endcase
end
endmodule

View file

@ -0,0 +1,71 @@
-------------------------------------------------------------------------------
-- Title : stretch pulse
-- Project : EMB-1
-------------------------------------------------------------------------------
-- File : stretch_pulse.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2016-05-27
-- Last update: 2018-05-18
-- SVN ID : Git
-- Standard : VHDL'93
-------------------------------------------------------------------------------
-- Description:
-- Stretch pulse to a programmable width
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.common_pkg.all;
entity stretch_pulse is
generic(
pulse_polarity : natural := 0; -- 0 => strecth on rising edge, 1 => strecth on falling edge
ext_pulse_width : natural := 100);
port(
rstN : in std_logic;
clk : in std_logic;
pulse_in : in std_logic;
pulse_out : out std_logic);
end stretch_pulse;
architecture RTL of stretch_pulse is
signal pulse, pulse_d : std_logic;
signal not_zero_cnt_flag : std_logic;
signal pulse_cnt : std_logic_vector(log2(ext_pulse_width)-1 downto 0);
begin -- RTL
gDetect_Pos_Pulse: if pulse_polarity = 0 generate
pulse <= pulse_in and not pulse_d;
end generate gDetect_Pos_Pulse;
gDetect_Neg_Pulse: if pulse_polarity = 1 generate
pulse <= not pulse_in and pulse_d;
end generate gDetect_Neg_Pulse;
pStretchPulse : process(rstN, clk)
begin
if(rstN = '0') then
pulse_d <= '0';
pulse_out <= '0';
pulse_cnt <= (others => '0');
elsif(clk = '1' and clk'event) then
pulse_d <= pulse_in;
pulse_out <= not_zero_cnt_flag;
if(pulse = '1') then
pulse_cnt <= std_logic_vector(to_unsigned(ext_pulse_width, log2(ext_pulse_width)));
elsif(not_zero_cnt_flag = '1') then
pulse_cnt <= std_logic_vector(unsigned(pulse_cnt)-1);
end if;
end if;
end process pStretchPulse;
not_zero_cnt_flag <= '1' when unsigned(pulse_cnt) /= 0 else '0';
end RTL;

View file

@ -0,0 +1,88 @@
-------------------------------------------------------------------------------
-- Title : sync_pulse
-------------------------------------------------------------------------------
-- File : sync_pulse.vhd
-- Author : Simon Southwell
-- Company : GIS
-- Target : Generic (simulation), Generic (synthesis)
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: synchronise single cycle pulse between two async clk domains
-------------------------------------------------------------------------------
-- Last update: 2021-01-19
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2021-01-19 1.0 SDS Created
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
entity sync_pulse is
generic(
SYNC_STAGES : positive := 2
);
port
(
clk_in : in std_logic;
rst_n : in std_logic;
pulse_in : in std_logic;
clk_out : in std_logic;
pulse_out : out std_logic
);
end sync_pulse;
architecture rtl of sync_pulse is
signal pulse_in_hold : std_logic;
signal pulse_in_sync : std_logic_vector(SYNC_STAGES-1 downto 0);
signal pulse_out_sync : std_logic_vector(SYNC_STAGES-1 downto 0);
signal pulse_out_hold : std_logic;
signal pulse_out_hold_dly : std_logic := '0';
begin
--Synchronised pulse hold
pulse_out_hold <= pulse_in_sync(0);
-- Pulse output on rising edge of output pulse held
pulse_out <= pulse_out_hold and not pulse_out_hold_dly;
P_SYNC_IN : process (clk_in, rst_n)
begin
if rst_n = '0' then
pulse_in_hold <= '0';
pulse_out_sync <= (others => '0');
elsif clk_in'event and clk_in = '1' then
-- Hold input pulse until cleared by return path
pulse_in_hold <= (pulse_in_hold or pulse_in) and not pulse_out_sync(0);
-- Synchronise output held pulse
pulse_out_sync <= pulse_out_hold & pulse_out_sync(pulse_in_sync'left downto 1);
end if;
end process;
P_SYNC_OUT : process (clk_out)
begin
if clk_out'event and clk_out = '1' then
-- Synchronise held input pulse
pulse_in_sync <= pulse_in_hold & pulse_in_sync(pulse_in_sync'left downto 1);
-- Generate delayed version of held pulse for rising edge detection.
pulse_out_hold_dly <= pulse_out_hold;
end if;
end process;
end;

View file

@ -0,0 +1,87 @@
-------------------------------------------------------------------------------
-- Title : sync_pulse
-------------------------------------------------------------------------------
-- File : sync_pulse.vhd
-- Author : Simon Southwell
-- Company : GIS
-- Target : Generic (simulation), Generic (synthesis)
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: samples vector in clock domain b and presents in clock domain a
-- with busy status
-------------------------------------------------------------------------------
-- Last update: 2020-12-14
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2020-12-14 1.0 SDS Created
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
entity sync_pulse_vec is
generic(
SYNC_STAGES : positive := 2;
VEC_WIDTH : positive := 32
);
port
(
clk_a : in std_logic;
rst_n_a : in std_logic;
pulse_a : in std_logic;
busy_a : out std_logic;
vec_a : out std_logic_vector(VEC_WIDTH-1 downto 0);
clk_b : in std_logic;
rst_n_b : in std_logic;
vec_b : in std_logic_vector(VEC_WIDTH-1 downto 0)
);
end sync_pulse_vec;
architecture rtl of sync_pulse_vec is
signal pulse_b : std_logic;
signal pulse_b_rtn : std_logic;
signal vec_smpl : std_logic_vector(VEC_WIDTH-1 downto 0);
begin
P_CLK_A : process(clk_a, rst_n_a)
begin
if rst_n_a = '0' then
busy_a <= '0';
elsif clk_a'event and clk_a = '1' then
if pulse_a = '1' then
busy_a <= '1';
end if;
if pulse_b_rtn = '1' then
vec_a <= vec_smpl;
busy_a <= '0';
end if;
end if;
end process;
P_CLK_B : process(clk_b)
begin
if clk_b'event and clk_b = '1' then
if pulse_b = '1' then
vec_smpl <= vec_b;
end if;
end if;
end process;
sync_pulse_0 : entity work.sync_pulse
generic map (SYNC_STAGES => SYNC_STAGES)
port map(clk_in => clk_a, rst_n=> rst_n_a, pulse_in => pulse_a and not busy_a, clk_out => clk_b, pulse_out => pulse_b);
sync_pulse_1 : entity work.sync_pulse
generic map (SYNC_STAGES => SYNC_STAGES)
port map(clk_in => clk_b, rst_n=> rst_n_b, pulse_in => pulse_b, clk_out => clk_a, pulse_out => pulse_b_rtn);
end rtl;

View file

@ -0,0 +1,87 @@
-------------------------------------------------------------------------------
-- Title : sync_pulse_vec_push
-------------------------------------------------------------------------------
-- File : sync_pulse_vec_push.vhd
-- Author : Damian Smith
-- Company : GIS
-- Target : Generic (simulation), Generic (synthesis)
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: samples vector in clock domain a and presents in clock domain b
-- with busy for a and pulse in b
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
entity sync_pulse_vec_push is
generic(
SYNC_STAGES : positive := 2;
VEC_WIDTH : positive := 32
);
port
(
clk_a : in std_logic;
rst_n_a : in std_logic;
pulse_a : in std_logic;
busy_a : out std_logic;
vec_a : in std_logic_vector(VEC_WIDTH - 1 downto 0);
clk_b : in std_logic;
rst_n_b : in std_logic;
pulse_b : out std_logic;
vec_b : out std_logic_vector(VEC_WIDTH - 1 downto 0)
);
end sync_pulse_vec_push;
architecture rtl of sync_pulse_vec_push is
signal pulse_b_int : std_logic;
signal pulse_b_rtn : std_logic;
signal vec_smpl : std_logic_vector(VEC_WIDTH - 1 downto 0);
begin
P_CLK_A : process(clk_a, rst_n_a)
begin
if rst_n_a = '0' then
busy_a <= '0';
elsif clk_a'event and clk_a = '1' then
if pulse_a = '1' then
busy_a <= '1';
vec_smpl <= vec_a;
end if;
if pulse_b_rtn = '1' then
busy_a <= '0';
end if;
end if;
end process;
P_CLK_B : process(clk_b, rst_n_b)
begin
if rst_n_b = '0' then
vec_b <= (others => '0');
pulse_b <= '0';
elsif clk_b'event and clk_b = '1' then
pulse_b <= '0';
if pulse_b_int = '1' then
vec_b <= vec_smpl;
pulse_b <= pulse_b_int;
end if;
end if;
end process;
sync_pulse_0 : entity work.sync_pulse
generic map(SYNC_STAGES => SYNC_STAGES)
port map(clk_in => clk_a, rst_n => rst_n_a, pulse_in => pulse_a and not busy_a, clk_out => clk_b, pulse_out => pulse_b_int);
sync_pulse_1 : entity work.sync_pulse
generic map(SYNC_STAGES => SYNC_STAGES)
port map(clk_in => clk_b, rst_n => rst_n_b, pulse_in => pulse_b_int, clk_out => clk_a, pulse_out => pulse_b_rtn);
end rtl;

View file

@ -0,0 +1,51 @@
-------------------------------------------------------------------------------
-- Title : sync_reset
-------------------------------------------------------------------------------
-- File : sync_reset.vhd
-- Author : Gianmarco Girau <ggianmarco.girau@gmail.com>
-- Company : On my own
-- Target : Generic (simulation), Generic (synthesis)
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: Generate a active-low reset with async assertion and sync
-- de-assertion.
-------------------------------------------------------------------------------
-- Last update: 2015-08-16
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2010-08-06 1.0 gmg Created
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
entity sync_reset is
port(
async_rstN : in std_logic;
clk : in std_logic;
sync_rstN : out std_logic);
end sync_reset;
architecture RTL of sync_reset is
signal sync_rstN_i : std_logic;
begin
pSYNC : process(async_rstN, clk)
begin
if(async_rstN = '0') then
sync_rstN_i <= '0';
sync_rstN <= '0';
elsif(clk = '1' and clk'event) then
sync_rstN_i <= '1';
sync_rstN <= sync_rstN_i;
end if;
end process pSYNC;
end RTL;

View file

@ -0,0 +1,62 @@
-------------------------------------------------------------------------------
-- Title : sync_wire
-------------------------------------------------------------------------------
-- File : sync_wire.vhd
-- Author : Gianmarco Girau <ggianmarco.girau@gmail.com>
-- Company : On my own
-- Target : Generic (simulation), Generic (synthesis)
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: synchronize a std_logic signal to a clock domain
-------------------------------------------------------------------------------
-- Last update: 2015-08-17
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2010-10-25 1.0 gmg Created
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
entity sync_wire is
generic(
rst_val : std_logic := '0';
sync_stages : positive := 2);
port(
rstN : in std_logic;
clk : in std_logic;
async_in : in std_logic;
sync_out : out std_logic);
end sync_wire;
architecture RTL of sync_wire is
signal sync_sig : std_logic_vector(sync_stages-1 downto 0);
begin
pSYNC : process(rstN, clk)
begin
if(rstN = '0') then
for n in 0 to sync_stages-1 loop
sync_sig(n) <= rst_val;
end loop; -- n
elsif(clk = '1' and clk'event) then
for n in 0 to sync_stages-1 loop
if(n = 0) then
sync_sig(0) <= async_in;
else
sync_sig(n) <= sync_sig(n-1);
end if;
end loop; -- n
end if;
end process pSYNC;
sync_out <= sync_sig(sync_stages-1);
end RTL;

View file

@ -0,0 +1,67 @@
-------------------------------------------------------------------------------
-- Title : sync_wire_rEdge
-------------------------------------------------------------------------------
-- File : sync_wire_rEdge.vhd
-- Author : Gianmarco Girau <ggianmarco.girau@gmail.com>
-- Company : On my own
-- Target : Generic (simulation), Generic (synthesis)
-- Dependency : none
-------------------------------------------------------------------------------
-- Description: synchronize a std_logic signal to a clock domain with rising edge
-------------------------------------------------------------------------------
-- Last update: 2015-08-17
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2010-12-03 1.0 gmg Created
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
entity sync_wire_rEdge is
generic(
rst_val : std_logic := '0';
sync_stages : positive := 2);
port(
rstN : in std_logic;
clk : in std_logic;
async_in : in std_logic;
sync_out : out std_logic);
end sync_wire_rEdge;
architecture RTL of sync_wire_rEdge is
signal sync_out_i, sync_out_d : std_logic;
signal sync_sig : std_logic_vector(sync_stages-1 downto 0);
begin
pSYNC : process(rstN, clk)
begin
if(rstN = '0') then
sync_out_d <= rst_val;
for n in 0 to sync_stages-1 loop
sync_sig(n) <= rst_val;
end loop; -- n
elsif(clk = '1' and clk'event) then
sync_out_d <= sync_out_i;
for n in 0 to sync_stages-1 loop
if(n = 0) then
sync_sig(0) <= async_in;
else
sync_sig(n) <= sync_sig(n-1);
end if;
end loop; -- n
end if;
end process pSYNC;
sync_out_i <= sync_sig(sync_stages-1);
-- rising edge detect
sync_out <= sync_out_i and not sync_out_d;
end RTL;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,158 @@
--
-- File Name: MessagePkg.vhd
-- Design Unit Name: MessagePkg
-- Revision: STANDARD VERSION, revision 2014.01
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis SynthWorks
--
--
-- Package Defines
-- Data structure for multi-line name/message to be associated with a data structure.
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Latest standard version available at:
-- http://www.SynthWorks.com/downloads
--
-- Revision History:
-- Date Version Description
-- 06/2010: 0.1 Initial revision
-- 07/2014: 2014.07 Moved specialization required by CoveragePkg to CoveragePkg
--
--
-- Copyright (c) 2010 - 2014 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.numeric_std.all ;
use ieee.math_real.all ;
use std.textio.all ;
package MessagePkg is
type MessagePType is protected
procedure Set (MessageIn : String) ;
impure function Get (ItemNumber : integer := 1) return string ;
impure function GetCount return integer ;
impure function IsSet return boolean ;
procedure Clear ; -- clear message
procedure Deallocate ; -- clear message
end protected MessagePType ;
end package MessagePkg ;
package body MessagePkg is
-- Local Data Structure Types
type LineArrayType is array (natural range <>) of line ;
type LineArrayPtrType is access LineArrayType ;
type MessagePType is protected body
variable MessageCount : integer := 0 ;
constant INITIAL_ITEM_COUNT : integer := 25 ;
variable MaxMessageCount : integer := INITIAL_ITEM_COUNT ;
variable MessagePtr : LineArrayPtrType := new LineArrayType(1 to INITIAL_ITEM_COUNT) ;
------------------------------------------------------------
procedure Set (MessageIn : String) is
------------------------------------------------------------
variable NamePtr : line ;
variable OldMaxMessageCount : integer ;
variable OldMessagePtr : LineArrayPtrType ;
begin
MessageCount := MessageCount + 1 ;
if MessageCount > MaxMessageCount then
OldMaxMessageCount := MaxMessageCount ;
MaxMessageCount := OldMaxMessageCount * 2 ;
OldMessagePtr := MessagePtr ;
MessagePtr := new LineArrayType(1 to MaxMessageCount) ;
for i in 1 to OldMaxMessageCount loop
MessagePtr(i) := OldMessagePtr(i) ;
end loop ;
Deallocate( OldMessagePtr ) ;
end if ;
MessagePtr(MessageCount) := new string'(MessageIn) ;
end procedure Set ;
------------------------------------------------------------
impure function Get (ItemNumber : integer := 1) return string is
------------------------------------------------------------
begin
if MessageCount > 0 then
if ItemNumber >= 1 and ItemNumber <= MessageCount then
return MessagePtr(ItemNumber).all ;
else
report LF & "%% MessagePkg:MessagePType.GetMessage input value out of range" severity failure ;
return "" ; -- error if this happens
end if ;
else
report LF & "%% MessagePkg:MessagePType.GetMessage message is not set" severity failure ;
return "" ; -- error if this happens
-- return NamePtr.all ;
end if ;
end function Get ;
------------------------------------------------------------
impure function GetCount return integer is
------------------------------------------------------------
begin
return MessageCount ;
end function GetCount ;
------------------------------------------------------------
impure function IsSet return boolean is
------------------------------------------------------------
begin
return MessageCount > 0 ;
end function IsSet ;
------------------------------------------------------------
procedure Deallocate is -- clear message
------------------------------------------------------------
variable CurPtr : LineArrayPtrType ;
begin
for i in 1 to MessageCount loop
deallocate( MessagePtr(i) ) ;
end loop ;
MessageCount := 0 ;
-- Do NOT Do this: deallocate( MessagePtr ) ;
end procedure Deallocate ;
------------------------------------------------------------
procedure Clear is -- clear
------------------------------------------------------------
begin
Deallocate ;
end procedure Clear ;
end protected body MessagePType ;
end package body MessagePkg ;

View file

@ -0,0 +1,109 @@
--
-- File Name: NamePkg.vhd
-- Design Unit Name: NamePkg
-- Revision: STANDARD VERSION, revision 2014.07
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis SynthWorks
--
--
-- Package Defines
-- Data structure for name.
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Latest standard version available at:
-- http://www.SynthWorks.com/downloads
--
-- Revision History:
-- Date Version Description
-- 06/2010: 0.1 Initial revision
-- 07/2014: 2014.07 Moved specialization required by CoveragePkg to CoveragePkg
-- Separated name handling from message handling to simplify naming
--
--
-- Copyright (c) 2010 - 2014 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
use std.textio.all ;
package NamePkg is
type NamePType is protected
procedure Set (NameIn : String) ;
impure function Get return string ;
impure function IsSet return boolean ;
procedure Clear ; -- clear name
procedure Deallocate ; -- effectively alias to clear name
end protected NamePType ;
end package NamePkg ;
package body NamePkg is
type NamePType is protected body
variable NamePtr : line := new string'("") ;
------------------------------------------------------------
procedure Set (NameIn : String) is
------------------------------------------------------------
begin
deallocate(NamePtr) ;
NamePtr := new string'(NameIn) ;
end procedure Set ;
------------------------------------------------------------
impure function Get return string is
------------------------------------------------------------
begin
return NamePtr.all ;
end function Get ;
------------------------------------------------------------
impure function IsSet return boolean is
------------------------------------------------------------
begin
return NamePtr.all /= "" ;
end function IsSet ;
------------------------------------------------------------
procedure Clear is -- clear name
------------------------------------------------------------
begin
deallocate(NamePtr) ;
NamePtr := new string'("") ;
end procedure Clear ;
------------------------------------------------------------
procedure Deallocate is -- clear name
------------------------------------------------------------
begin
Clear ;
end procedure Deallocate ;
end protected body NamePType ;
end package body NamePkg ;

View file

@ -0,0 +1,226 @@
--
-- File Name: RandomBasePkg.vhd
-- Design Unit Name: RandomBasePkg
-- Revision: STANDARD VERSION, revision 2013.05
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis jim@synthworks.com
--
--
-- Description:
-- Defines Base randomization, seed definition, seed generation,
-- and seed IO functionality for RandomPkg.vhd
-- Defines:
-- Procedure Uniform - baseline randomization
-- Type RandomSeedType - the seed as a single object
-- function GenRandSeed from integer_vector, integer, or string
-- IO function to_string, & procedures write, read
--
-- In revision 2.0 these types and functions are included by package reference.
-- Long term these will be passed as generics to RandomGenericPkg
--
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Revision History:
-- Date Version Description
-- 01/2008: 0.1 Initial revision
-- Numerous revisions for VHDL Testbenches and Verification
-- 02/2009: 1.0 First Public Released Version
-- 02/25/2009 1.1 Replaced reference to std_2008 with a reference
-- to ieee_proposed.standard_additions.all ;
-- 03/01/2011 2.0 STANDARD VERSION
-- Fixed abstraction by moving RandomParmType to RandomPkg.vhd
-- 4/2013 2013.04 No Changes
-- 5/2013 2013.05 No Changes
--
--
-- Copyright (c) 2008 - 2013 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
library ieee ;
use ieee.math_real.all ;
use std.textio.all ;
-- comment out following 2 lines with VHDL-2008. Leave in for VHDL-2002
-- library ieee_proposed ; -- remove with VHDL-2008
-- use ieee_proposed.standard_additions.all ; -- remove with VHDL-2008
package RandomBasePkg is
-- RandomSeedType and Uniform can be replaced by any procedure that
-- produces a uniform distribution with 0 <= Value < 1 or 0 < Value < 1
-- and maintains the same call interface
type RandomSeedType is array (1 to 2) of integer ;
procedure Uniform (Result : out real ; Seed : inout RandomSeedType) ;
-- Translate from integer_vector, integer, or string to RandomSeedType
-- Required by RandomPkg.InitSeed
-- GenRandSeed makes sure all values are in a valid range
function GenRandSeed(IV : integer_vector) return RandomSeedType ;
function GenRandSeed(I : integer) return RandomSeedType ;
function GenRandSeed(S : string) return RandomSeedType ;
-- IO for RandomSeedType. If use subtype, then create aliases here
-- in a similar fashion VHDL-2008 std_logic_textio.
-- Not required by RandomPkg
function to_string(A : RandomSeedType) return string ;
procedure write(variable L: inout line ; A : RandomSeedType ) ;
procedure read (variable L: inout line ; A : out RandomSeedType ; good : out boolean ) ;
procedure read (variable L: inout line ; A : out RandomSeedType ) ;
end RandomBasePkg ;
-----------------------------------------------------------------
-----------------------------------------------------------------
package body RandomBasePkg is
-----------------------------------------------------------------
-- Uniform
-- Generate a random number with a Uniform distribution
-- Required by RandomPkg. All randomization is derived from here.
-- Value produced must be either:
-- 0 <= Value < 1 or 0 < Value < 1
--
-- Current version uses ieee.math_real.Uniform
-- This abstraction allows higher precision version
-- of a uniform distribution to be used provided
--
procedure Uniform (
Result : out real ;
Seed : inout RandomSeedType
) is
begin
ieee.math_real.Uniform (Seed(Seed'left), Seed(Seed'right), Result) ;
end procedure Uniform ;
-----------------------------------------------------------------
-- GenRandSeed
-- Convert integer_vector to RandomSeedType
-- Uniform requires two seed values of the form:
-- 1 <= SEED1 <= 2147483562; 1 <= SEED2 <= 2147483398
--
-- if 2 seed values are passed to GenRandSeed and they are
-- in the above range, then they must remain unmodified.
--
function GenRandSeed(IV : integer_vector) return RandomSeedType is
alias iIV : integer_vector(1 to IV'length) is IV ;
variable Seed1 : integer ;
variable Seed2 : integer ;
constant SEED1_MAX : integer := 2147483562 ;
constant SEED2_MAX : integer := 2147483398 ;
begin
if iIV'Length <= 0 then -- no seed
report "%%FATAL: GenRandSeed received NULL integer_vector" severity failure ;
return (3, 17) ; -- if continue seed = (3, 17)
elsif iIV'Length = 1 then -- one seed value
-- inefficient handling, but condition is unlikely
return GenRandSeed(iIV(1)) ; -- generate a seed
else -- only use the left two values
-- 1 <= SEED1 <= 2147483562
-- mod returns 0 to MAX-1, the -1 adjusts legal values, +1 adjusts them back
Seed1 := ((iIV(1)-1) mod SEED1_MAX) + 1 ;
-- 1 <= SEED2 <= 2147483398
Seed2 := ((iIV(2)-1) mod SEED2_MAX) + 1 ;
return (Seed1, Seed2) ;
end if ;
end function GenRandSeed ;
-----------------------------------------------------------------
-- GenRandSeed
-- transform a single integer into the internal seed
--
function GenRandSeed(I : integer) return RandomSeedType is
variable result : integer_vector(1 to 2) ;
begin
result(1) := I ;
result(2) := I/3 + 1 ;
return GenRandSeed(result) ; -- make value ranges legal
end function GenRandSeed ;
-----------------------------------------------------------------
-- GenRandSeed
-- transform a string value into the internal seed
-- usage: RV.GenRandSeed(RV'instance_path));
--
function GenRandSeed(S : string) return RandomSeedType is
constant LEN : integer := S'length ;
constant HALF_LEN : integer := LEN/2 ;
alias revS : string(LEN downto 1) is S ;
variable result : integer_vector(1 to 2) ;
variable temp : integer := 0 ;
begin
for i in 1 to HALF_LEN loop
temp := (temp + character'pos(revS(i))) mod (integer'right - 2**8) ;
end loop ;
result(1) := temp ;
for i in HALF_LEN + 1 to LEN loop
temp := (temp + character'pos(revS(i))) mod (integer'right - 2**8) ;
end loop ;
result(2) := temp ;
return GenRandSeed(result) ; -- make value ranges legal
end function GenRandSeed ;
-----------------------------------------------------------------
function to_string(A : RandomSeedType) return string is
begin
return to_string(A(A'left)) & " " & to_string(A(A'right)) ;
end function to_string ;
-----------------------------------------------------------------
procedure write(variable L: inout line ; A : RandomSeedType ) is
begin
write(L, to_string(A)) ;
end procedure ;
-----------------------------------------------------------------
procedure read(variable L: inout line ; A : out RandomSeedType ; good : out boolean ) is
variable iGood : boolean ;
begin
for i in A'range loop
read(L, A(i), iGood) ;
exit when not iGood ;
end loop ;
good := iGood ;
end procedure read ;
-----------------------------------------------------------------
procedure read(variable L: inout line ; A : out RandomSeedType ) is
variable good : boolean ;
begin
read(L, A, good) ;
assert good report "read[line, RandomSeedType] failed" severity error ;
end procedure read ;
end RandomBasePkg ;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,409 @@
--
-- File Name: SortListPkg_int.vhd
-- Design Unit Name: SortListPkg_int
-- Revision: STANDARD VERSION, revision 2014.01
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis jim@synthworks.com
--
-- Description:
-- Sorting utility for array of scalars
-- Uses protected type so as to shrink and expand the data structure
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Revision History:
-- Date Version Description
-- 06/2008: 0.1 Initial revision
-- Numerous revisions for VHDL Testbenches and Verification
-- 02/2009: 1.0 First Public Released Version
-- 02/25/2009 1.1 Replaced reference to std_2008 with a reference to
-- ieee_proposed.standard_additions.all ;
-- 06/16/2010 1.2 Added EraseList parameter to to_array
-- 3/2011 2.0 added inside as non protected type
-- 6/2011 2.1 added sort as non protected type
-- 4/2013 2013.04 No Changes
-- 5/2013 2013.05 No changes of substance.
-- Deleted extra variable declaration in procedure remove
-- 1/2014 2014.01 Added RevSort. Added AllowDuplicate paramter to Add procedure
--
--
--
-- Copyright (c) 2008 - 2014 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
use std.textio.all ;
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.numeric_std.all ;
use ieee.std_logic_textio.all ;
-- comment out following 2 lines with VHDL-2008. Leave in for VHDL-2002
-- library ieee_proposed ; -- remove with VHDL-2008
-- use ieee_proposed.standard_additions.all ; -- remove with VHDL-2008
package SortListPkg_int is
-- with VHDL-2008, convert package to generic package
-- convert subtypes ElementType and ArrayofElementType to generics
-- package SortListGenericPkg is
subtype ElementType is integer ;
subtype ArrayofElementType is integer_vector ;
function inside (constant E : ElementType; constant A : in ArrayofElementType) return boolean ;
impure function sort (constant A : in ArrayofElementType) return ArrayofElementType ;
impure function revsort (constant A : in ArrayofElementType) return ArrayofElementType ;
type SortListPType is protected
procedure add ( constant A : in ElementType ; constant AllowDuplicate : Boolean := FALSE ) ;
procedure add ( constant A : in ArrayofElementType ) ;
procedure add ( constant A : in ArrayofElementType ; Min, Max : integer ) ;
procedure add ( variable A : inout SortListPType ) ;
-- Count items in list
impure function count return integer ;
impure function find_index ( constant A : ElementType) return integer ;
impure function inside (constant A : ElementType) return boolean ;
procedure insert ( constant A : in ElementType; constant index : in integer := 1 ) ;
impure function get ( constant index : in integer := 1 ) return ElementType ;
procedure erase ;
impure function Empty return boolean ;
procedure print ;
procedure remove ( constant A : in ElementType ) ;
procedure remove ( constant A : in ArrayofElementType ) ;
procedure remove ( variable A : inout SortListPType ) ;
impure function to_array (constant EraseList : boolean := FALSE) return ArrayofElementType ;
impure function to_rev_array (constant EraseList : boolean := FALSE) return ArrayofElementType ;
end protected SortListPType ;
end SortListPkg_int ;
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
package body SortListPkg_int is
function inside (constant E : ElementType; constant A : in ArrayofElementType) return boolean is
begin
for i in A'range loop
if E = A(i) then
return TRUE ;
end if ;
end loop ;
return FALSE ;
end function inside ;
type SortListPType is protected body
type ListType ;
type ListPointerType is access ListType ;
type ListType is record
A : ElementType ;
-- item_num : integer ;
NextPtr : ListPointerType ;
-- PrevPtr : ListPointerType ;
end record ;
variable HeadPointer : ListPointerType := NULL ;
-- variable TailPointer : ListPointerType := NULL ;
procedure add ( constant A : in ElementType ; constant AllowDuplicate : Boolean := FALSE ) is
variable CurPtr, tempPtr : ListPointerType ;
begin
if HeadPointer = NULL then
HeadPointer := new ListType'(A, NULL) ;
elsif A = HeadPointer.A then -- ignore duplicates
if AllowDuplicate then
tempPtr := HeadPointer ;
HeadPointer := new ListType'(A, tempPtr) ;
end if ;
elsif A < HeadPointer.A then
tempPtr := HeadPointer ;
HeadPointer := new ListType'(A, tempPtr) ;
else
CurPtr := HeadPointer ;
AddLoop : loop
exit AddLoop when CurPtr.NextPtr = NULL ;
exit AddLoop when A < CurPtr.NextPtr.A ;
if A = CurPtr.NextPtr.A then
if AllowDuplicate then
exit AddLoop ; -- insert
else
return ; -- return without insert
end if;
end if ;
CurPtr := CurPtr.NextPtr ;
end loop AddLoop ;
tempPtr := CurPtr.NextPtr ;
CurPtr.NextPtr := new ListType'(A, tempPtr) ;
end if ;
end procedure add ;
procedure add ( constant A : in ArrayofElementType ) is
begin
for i in A'range loop
add(A(i)) ;
end loop ;
end procedure add ;
procedure add ( constant A : in ArrayofElementType ; Min, Max : integer ) is
begin
for i in A'range loop
if A(i) >= Min and A(i) <= Max then
add(A(i)) ;
end if ;
end loop ;
end procedure add ;
procedure add ( variable A : inout SortListPType ) is
begin
for i in 1 to A.Count loop
add(A.Get(i)) ;
end loop ;
end procedure add ;
-- Count items in list
impure function count return integer is
variable result : positive := 1 ;
variable CurPtr : ListPointerType ;
begin
if HeadPointer = NULL then
return 0 ;
else
CurPtr := HeadPointer ;
loop
exit when CurPtr.NextPtr = NULL ;
result := result + 1 ;
CurPtr := CurPtr.NextPtr ;
end loop ;
return result ;
end if ;
end function count ;
impure function find_index (constant A : ElementType) return integer is
variable result : positive := 2 ;
variable CurPtr : ListPointerType ;
begin
if HeadPointer = NULL then
return 0 ;
elsif A <= HeadPointer.A then
return 1 ;
else
CurPtr := HeadPointer ;
loop
exit when CurPtr.NextPtr = NULL ;
exit when A <= CurPtr.NextPtr.A ;
result := result + 1 ;
CurPtr := CurPtr.NextPtr ;
end loop ;
return result ;
end if ;
end function find_index ;
impure function inside (constant A : ElementType) return boolean is
variable CurPtr : ListPointerType ;
begin
if HeadPointer = NULL then
return FALSE ;
end if ;
if A = HeadPointer.A then
return TRUE ;
else
CurPtr := HeadPointer ;
loop
exit when CurPtr.NextPtr = NULL ;
exit when A < CurPtr.NextPtr.A ;
if A = CurPtr.NextPtr.A then
return TRUE ; -- exit
end if;
CurPtr := CurPtr.NextPtr ;
end loop ;
end if ;
return FALSE ;
end function inside ;
procedure insert( constant A : in ElementType; constant index : in integer := 1 ) is
variable CurPtr, tempPtr : ListPointerType ;
begin
if index <= 1 then
tempPtr := HeadPointer ;
HeadPointer := new ListType'(A, tempPtr) ;
else
CurPtr := HeadPointer ;
for i in 3 to index loop
exit when CurPtr.NextPtr = NULL ; -- end of list
CurPtr := CurPtr.NextPtr ;
end loop ;
tempPtr := CurPtr.NextPtr ;
CurPtr.NextPtr := new ListType'(A, tempPtr) ;
end if;
end procedure insert ;
impure function get ( constant index : in integer := 1 ) return ElementType is
variable CurPtr : ListPointerType ;
begin
if index > Count then
report "%%FAILURE: SortListPType index out of range" severity failure ;
return ElementType'left ;
elsif HeadPointer = NULL then
return ElementType'left ;
elsif index <= 1 then
return HeadPointer.A ;
else
CurPtr := HeadPointer ;
for i in 2 to index loop
CurPtr := CurPtr.NextPtr ;
end loop ;
return CurPtr.A ;
end if;
end function get ;
procedure erase (variable CurPtr : inout ListPointerType ) is
begin
if CurPtr.NextPtr /= NULL then
erase (CurPtr.NextPtr) ;
end if ;
deallocate (CurPtr) ;
end procedure erase ;
procedure erase is
begin
if HeadPointer /= NULL then
erase(HeadPointer) ;
-- deallocate (HeadPointer) ;
HeadPointer := NULL ;
end if;
end procedure erase ;
impure function Empty return boolean is
begin
return HeadPointer = NULL ;
end Empty ;
procedure print is
variable buf : line ;
variable CurPtr : ListPointerType ;
begin
if HeadPointer = NULL then
write (buf, string'("( )")) ;
else
CurPtr := HeadPointer ;
write (buf, string'("(")) ;
loop
write (buf, CurPtr.A) ;
exit when CurPtr.NextPtr = NULL ;
write (buf, string'(", ")) ;
CurPtr := CurPtr.NextPtr ;
end loop ;
write (buf, string'(")")) ;
end if ;
writeline(OUTPUT, buf) ;
end procedure print ;
procedure remove ( constant A : in ElementType ) is
variable CurPtr, tempPtr : ListPointerType ;
begin
if HeadPointer = NULL then
return ;
elsif A = HeadPointer.A then
tempPtr := HeadPointer ;
HeadPointer := HeadPointer.NextPtr ;
deallocate (tempPtr) ;
else
CurPtr := HeadPointer ;
loop
exit when CurPtr.NextPtr = NULL ;
if A = CurPtr.NextPtr.A then
tempPtr := CurPtr.NextPtr ;
CurPtr.NextPtr := CurPtr.NextPtr.NextPtr ;
deallocate (tempPtr) ;
exit ;
end if ;
exit when A < CurPtr.NextPtr.A ;
CurPtr := CurPtr.NextPtr ;
end loop ;
end if ;
end procedure remove ;
procedure remove ( constant A : in ArrayofElementType ) is
begin
for i in A'range loop
remove(A(i)) ;
end loop ;
end procedure remove ;
procedure remove ( variable A : inout SortListPType ) is
begin
for i in 1 to A.Count loop
remove(A.Get(i)) ;
end loop ;
end procedure remove ;
impure function to_array (constant EraseList : boolean := FALSE) return ArrayofElementType is
variable result : ArrayofElementType(1 to Count) ;
begin
for i in 1 to Count loop
result(i) := Get(i) ;
end loop ;
if EraseList then
erase ;
end if ;
return result ;
end function to_array ;
impure function to_rev_array (constant EraseList : boolean := FALSE) return ArrayofElementType is
variable result : ArrayofElementType(Count downto 1) ;
begin
for i in 1 to Count loop
result(i) := Get(i) ;
end loop ;
if EraseList then
erase ;
end if ;
return result ;
end function to_rev_array ;
end protected body SortListPType ;
impure function sort (constant A : in ArrayofElementType) return ArrayofElementType is
variable Result : SortListPType ;
begin
for i in A'range loop
Result.Add(A(i), TRUE) ;
end loop ;
return Result.to_array(EraseList => TRUE) ;
end function sort ;
impure function revsort (constant A : in ArrayofElementType) return ArrayofElementType is
variable Result : SortListPType ;
begin
for i in A'range loop
Result.Add(A(i), TRUE) ;
end loop ;
return Result.to_rev_array(EraseList => TRUE) ;
end function revsort ;
end SortListPkg_int ;

View file

@ -0,0 +1,14 @@
Compile the files into your osvvm library in the following order...
SortListPkg_int.vhd
RandomBasePkg.vhd
RandomPkg.vhd
MessagePkg.vhd
NamePkg.vhd
CoveragePkg.vhd
In your code, add the lines
library osvvm;
use osvvm.RandomPkg.all;
use osvvm.CoveragePkg.all;
useful guide at Doulos: https://www.doulos.com/knowhow/vhdl_designers_guide/OSVVM/

View file

@ -0,0 +1,702 @@
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use std.textio.all;
library OSVVM ;
use OSVVM.RandomBasePkg.all ;
use OSVVM.RandomPkg.all ;
library work;
use work.common_test_pkg.all;
package AVALON_VERIFY_PKG is
shared variable RV : RandomPType;
-----------------------------------------------------------------------------
-- Bus duty cycle control
-----------------------------------------------------------------------------
signal int_mmBusPunctureAllowed : boolean := false;
signal int_mmBusPunctureMax : integer := 3;
signal int_stmBusPunctureAllowed : boolean := false;
signal int_stmBusPunctureMin : integer := 3;
signal int_stmBusPunctureMax : integer := 3;
-----------------------------------------------------------------------------
-- Clock and reset section
-----------------------------------------------------------------------------
signal clk_clk : std_logic := '0';
signal reset_reset_n : std_logic := '0';
shared variable mm_read_latency : prot_int_t;
shared variable mm_use_waitrequest : prot_flag_t;
-----------------------------------------------------------------------------
-- Avalon MM section
-----------------------------------------------------------------------------
type data_128b_vec_t is array (0 to 1023) of std_logic_vector(127 downto 0);
type data_96b_vec_t is array (0 to 1023) of std_logic_vector( 95 downto 0);
type data_64b_vec_t is array (0 to 1023) of std_logic_vector( 63 downto 0);
type data_32b_vec_t is array (0 to 1023) of std_logic_vector( 31 downto 0);
type data_16b_vec_t is array (0 to 1023) of std_logic_vector( 15 downto 0);
type data_8b_vec_t is array (0 to 1023) of std_logic_vector( 7 downto 0);
signal base_addr : std_logic_vector(31 downto 0) := (others => '0');
type mm_m_rec_t is
record
mm_burstcount : std_logic_vector(31 downto 0) ;
mm_burst : std_logic ;
mm_writedata : std_logic_vector(31 downto 0) ;
mm_address : std_logic_vector(31 downto 0) ;
mm_write : std_logic ;
mm_read : std_logic ;
mm_byteenable : std_logic_vector(3 downto 0) ;
mm_debugaccess : std_logic ;
end record;
type mm_s_rec_t is
record
mm_waitrequest : std_logic;
mm_readdata : std_logic_vector(31 downto 0);
mm_readdatavalid : std_logic;
use_readvalid : boolean;
end record;
type mm_128b_m_rec_t is
record
mm_burstcount : std_logic_vector( 31 downto 0);
mm_burst : std_logic ;
mm_writedata : std_logic_vector(127 downto 0);
mm_address : std_logic_vector( 31 downto 0);
mm_write : std_logic ;
mm_read : std_logic ;
mm_byteenable : std_logic_vector( 15 downto 0);
mm_debugaccess : std_logic ;
end record;
type mm_128b_s_rec_t is
record
mm_waitrequest : std_logic;
mm_readdata : std_logic_vector(127 downto 0);
mm_readdatavalid : std_logic;
end record;
procedure mm_m_init( signal mm_m_rec : out mm_m_rec_t; read_latency : natural := 0; use_waitrequest : boolean := false);
procedure mm_s_init( signal mm_s_rec : out mm_s_rec_t );
procedure mm_128b_m_init( signal mm_m_rec : out mm_128b_m_rec_t );
procedure mm_128b_s_init( signal mm_s_rec : out mm_128b_s_rec_t );
procedure mm_128b_burst( addr : in std_logic_vector(31 downto 0);
size : in integer;
data : in data_128b_vec_t;
signal mm_s_rec : in mm_128b_s_rec_t;
signal mm_m_rec : out mm_128b_m_rec_t);
procedure mm_32b_burst( addr : in std_logic_vector(31 downto 0);
size : in integer;
data : in data_32b_vec_t;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_32b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(31 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_16b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(15 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_8b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector( 7 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_32b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(31 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_16b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(15 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_8b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector( 7 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
-----------------------------------------------------------------------------
-- Avalon Stream section
-----------------------------------------------------------------------------
type stm_m_rec_t is
record
stm_channel : std_logic_vector( 7 downto 0);
stm_data : std_logic_vector(31 downto 0);
stm_valid : std_logic;
stm_sop : std_logic;
stm_eop : std_logic;
end record;
type stm_s_rec_t is
record
stm_ready : std_logic;
stm_error : std_logic_vector( 7 downto 0);
end record;
procedure stm_m_init( signal stm_m_rec : out stm_m_rec_t );
procedure stm_s_init( signal stm_s_rec : out stm_s_rec_t );
procedure stm_puncture;
procedure stm_32b_write( len : in integer;
channel : in integer;
data_vec : in data_32b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t);
procedure stm_16b_write( len : in integer;
channel : in integer;
data_vec : in data_16b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t);
procedure stm_8b_write( len : in integer;
channel : in integer;
data_vec : in data_8b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t);
procedure stm_8b_read( signal stm_m_rec : in stm_m_rec_t;
signal stm_s_rec : out stm_s_rec_t;
data_vec : out data_8b_vec_t;
channel : out integer;
len : out integer);
-----------------------------------------------------------------------------
-- LVDS section
-----------------------------------------------------------------------------
type lvds_m_rec_t is
record
lvds_1_rx_data : std_logic_vector(9 downto 0);
lvds_1_rx_nlock : std_logic;
lvds_1_rx_clk : std_logic;
lvds_2_rx_data : std_logic_vector(9 downto 0);
lvds_2_rx_nlock : std_logic;
lvds_2_rx_clk : std_logic;
end record;
type lvds_s_rec_t is
record
lvds_refclk : std_logic;
lvds_1_rx_npwrdn : std_logic;
lvds_1_rx_en : std_logic;
lvds_2_rx_npwrdn : std_logic;
lvds_2_rx_en : std_logic;
end record;
procedure lvds_m_init( signal lvds_m_rec : out lvds_m_rec_t );
procedure lvds_s_init( signal lvds_s_rec : out lvds_s_rec_t );
procedure lvds_write( len : in integer;
data_vec : in data_8b_vec_t;
signal lvds_s_rec : in lvds_s_rec_t;
signal lvds_m_rec : out lvds_m_rec_t);
end AVALON_VERIFY_PKG;
package body AVALON_VERIFY_PKG is
-----------------------------------------------------------------------------
-- Avalon MM section
-----------------------------------------------------------------------------
procedure mm_128b_m_init( signal mm_m_rec : out mm_128b_m_rec_t ) is
begin
mm_m_rec.mm_address <= (others => '0');
mm_m_rec.mm_byteenable <= (others => '0');
mm_m_rec.mm_writedata <= (others => '0');
mm_m_rec.mm_write <= '0';
mm_m_rec.mm_read <= '0';
mm_m_rec.mm_byteenable <= (others => '0');
mm_m_rec.mm_debugaccess <= '0';
mm_m_rec.mm_burstcount <= (others => '0');
end mm_128b_m_init;
procedure mm_128b_s_init( signal mm_s_rec : out mm_128b_s_rec_t ) is
begin
mm_s_rec.mm_waitrequest <= '0';
mm_s_rec.mm_readdata <= (others => '0');
mm_s_rec.mm_readdatavalid <= '0';
end mm_128b_s_init;
procedure mm_m_init( signal mm_m_rec : out mm_m_rec_t; read_latency : natural := 0; use_waitrequest : boolean := false) is
begin
mm_m_rec.mm_address <= (others => '0');
mm_m_rec.mm_byteenable <= (others => '0');
mm_m_rec.mm_writedata <= (others => '0');
mm_m_rec.mm_write <= '0';
mm_m_rec.mm_read <= '0';
mm_m_rec.mm_byteenable <= (others => '0');
mm_m_rec.mm_debugaccess <= '0';
mm_m_rec.mm_burstcount <= (others => '0');
mm_read_latency.set(read_latency);
if(use_waitrequest = true) then
mm_use_waitrequest.set;
else
mm_use_waitrequest.reset;
end if;
end mm_m_init;
procedure mm_s_init( signal mm_s_rec : out mm_s_rec_t ) is
begin
mm_s_rec.mm_waitrequest <= '0';
mm_s_rec.mm_readdata <= (others => '0');
mm_s_rec.mm_readdatavalid <= '0';
end mm_s_init;
procedure mm_128b_burst( addr : in std_logic_vector(31 downto 0);
size : in integer;
data : in data_128b_vec_t;
signal mm_s_rec : in mm_128b_s_rec_t;
signal mm_m_rec : out mm_128b_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
for i in 0 to size-1 loop
if i = 0 then
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= x"1111";
mm_m_rec.mm_writedata <= data(i);
mm_m_rec.mm_write <= '1';
mm_m_rec.mm_burst <= '1';
mm_m_rec.mm_burstcount <= std_logic_vector(to_unsigned(size,32));
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= x"0000";
mm_m_rec.mm_write <= '0';
mm_m_rec.mm_burst <= '0';
else
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= x"1111";
mm_m_rec.mm_writedata <= data(i);
mm_m_rec.mm_write <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= x"0000";
mm_m_rec.mm_write <= '0';
end if;
end loop; -- i
wait until rising_edge(clk_clk);
end mm_128b_burst;
procedure mm_32b_burst( addr : in std_logic_vector(31 downto 0);
size : in integer;
data : in data_32b_vec_t;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
for i in 0 to size-1 loop
if i = 0 then
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= "1111";
mm_m_rec.mm_writedata <= data(i);
mm_m_rec.mm_write <= '1';
mm_m_rec.mm_burst <= '1';
mm_m_rec.mm_burstcount <= std_logic_vector(to_unsigned(size,32));
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
mm_m_rec.mm_burst <= '0';
else
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= "1111";
mm_m_rec.mm_writedata <= data(i);
mm_m_rec.mm_write <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
end if;
end loop; -- i
wait until rising_edge(clk_clk);
end mm_32b_burst;
procedure mm_32b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(31 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= "1111";
mm_m_rec.mm_writedata <= data;
mm_m_rec.mm_write <= '1';
wait until falling_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
end mm_32b_write;
procedure mm_16b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(15 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable my_addr : std_logic_vector(31 downto 0) := (others=>'0');
begin
my_addr := addr;
if addr(1) = '1' then
my_addr := std_logic_vector(unsigned(my_addr)+2);
end if;
wait until rising_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_writedata <= data & data;
if addr(1) = '0' then
mm_m_rec.mm_byteenable <= "0011";
else
mm_m_rec.mm_byteenable <= "1100";
end if;
mm_m_rec.mm_write <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
wait until rising_edge(clk_clk);
end mm_16b_write;
procedure mm_8b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector( 7 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_writedata <= data & data & data & data;
if addr(1 downto 0) = "00" then
mm_m_rec.mm_byteenable <= "0001";
elsif addr(1 downto 0) = "01" then
mm_m_rec.mm_byteenable <= "0010";
elsif addr(1 downto 0) = "10" then
mm_m_rec.mm_byteenable <= "0100";
else
mm_m_rec.mm_byteenable <= "1000";
end if;
mm_m_rec.mm_write <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
wait until rising_edge(clk_clk);
end mm_8b_write;
procedure mm_32b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(31 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_read <= '1';
wait until falling_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
wait until rising_edge(clk_clk);
mm_m_rec.mm_read <= '0';
if(mm_use_waitrequest.is_set = false) then
for n in 1 to mm_read_latency.get loop
wait until rising_edge(clk_clk);
end loop; -- n
end if;
if(mm_s_rec.use_readvalid = true) then
if(mm_s_rec.mm_readdatavalid = '0') then
wait until mm_s_rec.mm_readdatavalid = '1';
end if;
end if;
wait until falling_edge(clk_clk);
data := mm_s_rec.mm_readdata;
end mm_32b_read;
procedure mm_16b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(15 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_read <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_read <= '0';
wait until rising_edge(mm_s_rec.mm_readdatavalid);
data := mm_s_rec.mm_readdata(15 downto 0);
end mm_16b_read;
procedure mm_8b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector( 7 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_read <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_read <= '0';
wait until rising_edge(mm_s_rec.mm_readdatavalid);
data := mm_s_rec.mm_readdata( 7 downto 0);
end mm_8b_read;
-----------------------------------------------------------------------------
-- Avalon Stream section
-----------------------------------------------------------------------------
procedure stm_m_init( signal stm_m_rec : out stm_m_rec_t ) is
begin
stm_m_rec.stm_channel <= (others => '0');
stm_m_rec.stm_data <= (others => '0');
stm_m_rec.stm_valid <= '0';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
end stm_m_init;
procedure stm_s_init( signal stm_s_rec : out stm_s_rec_t ) is
begin
stm_s_rec.stm_ready <= '0';
stm_s_rec.stm_error <= (others => '0');
end stm_s_init;
procedure stm_puncture is
variable loop_max : integer;
begin
loop_max := RV.RandInt(int_stmBusPunctureMin,int_stmBusPunctureMax);
if loop_max > 0 then
for i in 1 to loop_max loop
wait until rising_edge(clk_clk);
end loop; -- i
end if;
end stm_puncture;
procedure stm_32b_write( len : in integer;
channel : in integer;
data_vec : in data_32b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t) is
variable loop_max : integer;
begin
wait until rising_edge(clk_clk);
if stm_s_rec.stm_ready = '0' then
wait until rising_edge(stm_s_rec.stm_ready);
end if;
wait until rising_edge(clk_clk);
for i in 1 to len loop
stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8));
stm_m_rec.stm_data <= data_vec(i-1);
stm_m_rec.stm_valid <= '1';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
if i = 1 then
stm_m_rec.stm_sop <= '1';
end if;
if i = len then
stm_m_rec.stm_eop <= '1';
end if;
wait until rising_edge(clk_clk);
stm_m_rec.stm_valid <= '0';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_puncture;
end loop; -- i
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_m_rec.stm_valid <= '0';
end stm_32b_write;
procedure stm_16b_write( len : in integer;
channel : in integer;
data_vec : in data_16b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t) is
variable loop_max : integer;
begin
wait until rising_edge(clk_clk);
if stm_s_rec.stm_ready = '0' then
wait until rising_edge(stm_s_rec.stm_ready);
end if;
wait until rising_edge(clk_clk);
for i in 1 to len loop
stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8));
stm_m_rec.stm_data <= x"0000" & data_vec(i-1);
stm_m_rec.stm_valid <= '1';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
if i = 1 then
stm_m_rec.stm_sop <= '1';
end if;
if i = len then
stm_m_rec.stm_eop <= '1';
end if;
wait until rising_edge(clk_clk);
stm_m_rec.stm_valid <= '0';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_puncture;
end loop; -- i
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_m_rec.stm_valid <= '0';
end stm_16b_write;
procedure stm_8b_write( len : in integer;
channel : in integer;
data_vec : in data_8b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t) is
variable loop_max : integer;
begin
wait until rising_edge(clk_clk);
if stm_s_rec.stm_ready = '0' then
wait until rising_edge(stm_s_rec.stm_ready);
end if;
wait until rising_edge(clk_clk);
for i in 1 to len loop
stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8));
stm_m_rec.stm_data <= x"000000" & data_vec(i-1);
stm_m_rec.stm_valid <= '1';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
if i = 1 then
stm_m_rec.stm_sop <= '1';
end if;
if i = len then
stm_m_rec.stm_eop <= '1';
end if;
wait until rising_edge(clk_clk);
stm_m_rec.stm_valid <= '0';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_puncture;
end loop; -- i
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_m_rec.stm_valid <= '0';
end stm_8b_write;
procedure stm_8b_read( signal stm_m_rec : in stm_m_rec_t;
signal stm_s_rec : out stm_s_rec_t;
data_vec : out data_8b_vec_t;
channel : out integer;
len : out integer) is
variable tmp_len : integer := 0;
begin
wait until rising_edge(clk_clk);
if stm_m_rec.stm_sop = '0' then
wait until rising_edge(stm_m_rec.stm_sop);
end if;
channel := to_integer(unsigned(stm_m_rec.stm_data));
while stm_m_rec.stm_eop = '0' loop
tmp_len := tmp_len + 1;
wait until rising_edge(clk_clk);
if stm_m_rec.stm_valid = '1' then
data_vec(tmp_len-1) := stm_m_rec.stm_data(7 downto 0);
end if;
end loop;
len := tmp_len;
end stm_8b_read;
-----------------------------------------------------------------------------
-- LVDS section
-----------------------------------------------------------------------------
procedure lvds_m_init( signal lvds_m_rec : out lvds_m_rec_t ) is
begin
lvds_m_rec.lvds_1_rx_data <= (others => '0');
lvds_m_rec.lvds_1_rx_nlock <= '0';
lvds_m_rec.lvds_1_rx_clk <= '0';
lvds_m_rec.lvds_2_rx_data <= (others => '0');
lvds_m_rec.lvds_2_rx_nlock <= '0';
lvds_m_rec.lvds_2_rx_clk <= '0';
end lvds_m_init;
procedure lvds_s_init( signal lvds_s_rec : out lvds_s_rec_t ) is
begin
lvds_s_rec.lvds_refclk <= '0';
lvds_s_rec.lvds_1_rx_npwrdn <= '0';
lvds_s_rec.lvds_1_rx_en <= '0';
lvds_s_rec.lvds_2_rx_npwrdn <= '0';
lvds_s_rec.lvds_2_rx_en <= '0';
end lvds_s_init;
procedure lvds_write( len : in integer;
data_vec : in data_8b_vec_t;
signal lvds_s_rec : in lvds_s_rec_t;
signal lvds_m_rec : out lvds_m_rec_t) is
variable tog : std_logic := '1';
variable lvds_crc : std_logic_vector(7 downto 0) := x"00";
variable lvds_tmp : std_logic_vector(7 downto 0) := x"00";
constant STX : std_logic_vector(7 downto 0) := x"02";
constant ETX : std_logic_vector(7 downto 0) := x"03";
begin
wait until rising_edge(lvds_s_rec.lvds_refclk);
lvds_m_rec.lvds_1_rx_data <= '1' & '0' & STX;
wait until rising_edge(lvds_s_rec.lvds_refclk);
lvds_m_rec.lvds_1_rx_data <= '0' & '0' & std_logic_vector(to_unsigned(len / 256,8));
wait until rising_edge(lvds_s_rec.lvds_refclk);
lvds_m_rec.lvds_1_rx_data <= '1' & '0' & std_logic_vector(to_unsigned(len mod 256,8));
wait until rising_edge(lvds_s_rec.lvds_refclk);
for i in 0 to len-1 loop
tog := not tog;
lvds_crc := lvds_crc xor data_vec(i);
lvds_m_rec.lvds_1_rx_data <= tog & '0' & data_vec(i);
wait until rising_edge(lvds_s_rec.lvds_refclk);
end loop; -- i
tog := not tog;
lvds_m_rec.lvds_1_rx_data <= tog & '0' & lvds_crc;
wait until rising_edge(lvds_s_rec.lvds_refclk);
tog := not tog;
lvds_m_rec.lvds_1_rx_data <= tog & '0' & ETX;
wait until rising_edge(lvds_s_rec.lvds_refclk);
if tog = '1' then
lvds_m_rec.lvds_1_rx_data <= (others => '0');
wait until rising_edge(lvds_s_rec.lvds_refclk);
end if;
end lvds_write;
end AVALON_VERIFY_PKG;

View file

@ -0,0 +1,703 @@
-- avalon_verify_pkg_2 vs avalon_verify_pkg:
-- in avalon_verify_pkg_2 the read_latency and the usage of the wait_request
-- can be individually selected to for every avalon master/slave couple.
-- Note: the full package needs to be revised
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use std.textio.all;
library OSVVM ;
use OSVVM.RandomBasePkg.all ;
use OSVVM.RandomPkg.all ;
package avalon_verify_pkg_2 is
shared variable RV : RandomPType;
-----------------------------------------------------------------------------
-- Bus duty cycle control
-----------------------------------------------------------------------------
signal int_mmBusPunctureAllowed : boolean := false;
signal int_mmBusPunctureMax : integer := 3;
signal int_stmBusPunctureAllowed : boolean := false;
signal int_stmBusPunctureMin : integer := 3;
signal int_stmBusPunctureMax : integer := 3;
-----------------------------------------------------------------------------
-- Clock and reset section
-----------------------------------------------------------------------------
signal clk_clk : std_logic := '0';
signal reset_reset_n : std_logic := '0';
-----------------------------------------------------------------------------
-- Avalon MM section
-----------------------------------------------------------------------------
type data_128b_vec_t is array (0 to 1023) of std_logic_vector(127 downto 0);
type data_96b_vec_t is array (0 to 1023) of std_logic_vector( 95 downto 0);
type data_64b_vec_t is array (0 to 1023) of std_logic_vector( 63 downto 0);
type data_32b_vec_t is array (0 to 1023) of std_logic_vector( 31 downto 0);
type data_16b_vec_t is array (0 to 1023) of std_logic_vector( 15 downto 0);
type data_8b_vec_t is array (0 to 1023) of std_logic_vector( 7 downto 0);
signal base_addr : std_logic_vector(31 downto 0) := (others => '0');
type mm_m_rec_t is
record
mm_burstcount : std_logic_vector(31 downto 0) ;
mm_burst : std_logic ;
mm_writedata : std_logic_vector(31 downto 0) ;
mm_address : std_logic_vector(31 downto 0) ;
mm_write : std_logic ;
mm_read : std_logic ;
mm_byteenable : std_logic_vector(3 downto 0) ;
mm_debugaccess : std_logic ;
use_waitrequest : boolean;
use_readvalid : boolean;
read_latency : natural;
end record;
type mm_s_rec_t is
record
mm_waitrequest : std_logic;
mm_readdata : std_logic_vector(31 downto 0);
mm_readdatavalid : std_logic;
end record;
type mm_128b_m_rec_t is
record
mm_burstcount : std_logic_vector( 31 downto 0);
mm_burst : std_logic ;
mm_writedata : std_logic_vector(127 downto 0);
mm_address : std_logic_vector( 31 downto 0);
mm_write : std_logic ;
mm_read : std_logic ;
mm_byteenable : std_logic_vector( 15 downto 0);
mm_debugaccess : std_logic ;
use_waitrequest : boolean;
use_readvalid : boolean;
read_latency : natural;
end record;
type mm_128b_s_rec_t is
record
mm_waitrequest : std_logic;
mm_readdata : std_logic_vector(127 downto 0);
mm_readdatavalid : std_logic;
end record;
procedure mm_m_init( signal mm_m_rec : out mm_m_rec_t; read_latency : natural := 0; use_readvalid : boolean := false; use_waitrequest : boolean := false);
procedure mm_s_init( signal mm_s_rec : out mm_s_rec_t);
procedure mm_128b_m_init( signal mm_m_rec : out mm_128b_m_rec_t );
procedure mm_128b_s_init( signal mm_s_rec : out mm_128b_s_rec_t );
procedure mm_128b_burst( addr : in std_logic_vector(31 downto 0);
size : in integer;
data : in data_128b_vec_t;
signal mm_s_rec : in mm_128b_s_rec_t;
signal mm_m_rec : out mm_128b_m_rec_t);
procedure mm_32b_burst( addr : in std_logic_vector(31 downto 0);
size : in integer;
data : in data_32b_vec_t;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_32b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(31 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_16b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(15 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_8b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector( 7 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_32b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(31 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_16b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(15 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
procedure mm_8b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector( 7 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t);
-----------------------------------------------------------------------------
-- Avalon Stream section
-----------------------------------------------------------------------------
type stm_m_rec_t is
record
stm_channel : std_logic_vector( 7 downto 0);
stm_data : std_logic_vector(31 downto 0);
stm_valid : std_logic;
stm_sop : std_logic;
stm_eop : std_logic;
end record;
type stm_s_rec_t is
record
stm_ready : std_logic;
stm_error : std_logic_vector( 7 downto 0);
end record;
procedure stm_m_init( signal stm_m_rec : out stm_m_rec_t );
procedure stm_s_init( signal stm_s_rec : out stm_s_rec_t );
procedure stm_puncture;
procedure stm_32b_write( len : in integer;
channel : in integer;
data_vec : in data_32b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t);
procedure stm_16b_write( len : in integer;
channel : in integer;
data_vec : in data_16b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t);
procedure stm_8b_write( len : in integer;
channel : in integer;
data_vec : in data_8b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t);
procedure stm_8b_read( signal stm_m_rec : in stm_m_rec_t;
signal stm_s_rec : out stm_s_rec_t;
data_vec : out data_8b_vec_t;
channel : out integer;
len : out integer);
-----------------------------------------------------------------------------
-- LVDS section
-----------------------------------------------------------------------------
type lvds_m_rec_t is
record
lvds_1_rx_data : std_logic_vector(9 downto 0);
lvds_1_rx_nlock : std_logic;
lvds_1_rx_clk : std_logic;
lvds_2_rx_data : std_logic_vector(9 downto 0);
lvds_2_rx_nlock : std_logic;
lvds_2_rx_clk : std_logic;
end record;
type lvds_s_rec_t is
record
lvds_refclk : std_logic;
lvds_1_rx_npwrdn : std_logic;
lvds_1_rx_en : std_logic;
lvds_2_rx_npwrdn : std_logic;
lvds_2_rx_en : std_logic;
end record;
procedure lvds_m_init( signal lvds_m_rec : out lvds_m_rec_t );
procedure lvds_s_init( signal lvds_s_rec : out lvds_s_rec_t );
procedure lvds_write( len : in integer;
data_vec : in data_8b_vec_t;
signal lvds_s_rec : in lvds_s_rec_t;
signal lvds_m_rec : out lvds_m_rec_t);
end avalon_verify_pkg_2;
package body avalon_verify_pkg_2 is
-----------------------------------------------------------------------------
-- Avalon MM section
-----------------------------------------------------------------------------
procedure mm_128b_m_init( signal mm_m_rec : out mm_128b_m_rec_t ) is
begin
mm_m_rec.mm_address <= (others => '0');
mm_m_rec.mm_byteenable <= (others => '0');
mm_m_rec.mm_writedata <= (others => '0');
mm_m_rec.mm_write <= '0';
mm_m_rec.mm_read <= '0';
mm_m_rec.mm_byteenable <= (others => '0');
mm_m_rec.mm_debugaccess <= '0';
mm_m_rec.mm_burstcount <= (others => '0');
end mm_128b_m_init;
procedure mm_128b_s_init( signal mm_s_rec : out mm_128b_s_rec_t ) is
begin
--mm_s_rec.mm_waitrequest <= '0';
--mm_s_rec.mm_readdata <= (others => '0');
--mm_s_rec.mm_readdatavalid <= '0';
end mm_128b_s_init;
procedure mm_m_init( signal mm_m_rec : out mm_m_rec_t; read_latency : natural := 0; use_readvalid : boolean := false; use_waitrequest : boolean := false) is
begin
mm_m_rec.mm_address <= (others => '0');
mm_m_rec.mm_byteenable <= (others => '0');
mm_m_rec.mm_writedata <= (others => '0');
mm_m_rec.mm_write <= '0';
mm_m_rec.mm_read <= '0';
mm_m_rec.mm_byteenable <= (others => '0');
mm_m_rec.mm_debugaccess <= '0';
mm_m_rec.mm_burstcount <= (others => '0');
mm_m_rec.use_waitrequest <= use_waitrequest;
mm_m_rec.use_readvalid <= use_readvalid;
mm_m_rec.read_latency <= read_latency;
end mm_m_init;
procedure mm_s_init( signal mm_s_rec : out mm_s_rec_t) is
begin
mm_s_rec.mm_waitrequest <= '0';
mm_s_rec.mm_readdata <= (others => '0');
mm_s_rec.mm_readdatavalid <= '0';
end mm_s_init;
procedure mm_128b_burst( addr : in std_logic_vector(31 downto 0);
size : in integer;
data : in data_128b_vec_t;
signal mm_s_rec : in mm_128b_s_rec_t;
signal mm_m_rec : out mm_128b_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
for i in 0 to size-1 loop
if i = 0 then
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= x"1111";
mm_m_rec.mm_writedata <= data(i);
mm_m_rec.mm_write <= '1';
mm_m_rec.mm_burst <= '1';
mm_m_rec.mm_burstcount <= std_logic_vector(to_unsigned(size,32));
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= x"0000";
mm_m_rec.mm_write <= '0';
mm_m_rec.mm_burst <= '0';
else
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= x"1111";
mm_m_rec.mm_writedata <= data(i);
mm_m_rec.mm_write <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= x"0000";
mm_m_rec.mm_write <= '0';
end if;
end loop; -- i
wait until rising_edge(clk_clk);
end mm_128b_burst;
procedure mm_32b_burst( addr : in std_logic_vector(31 downto 0);
size : in integer;
data : in data_32b_vec_t;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
for i in 0 to size-1 loop
if i = 0 then
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= "1111";
mm_m_rec.mm_writedata <= data(i);
mm_m_rec.mm_write <= '1';
mm_m_rec.mm_burst <= '1';
mm_m_rec.mm_burstcount <= std_logic_vector(to_unsigned(size,32));
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
mm_m_rec.mm_burst <= '0';
else
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= "1111";
mm_m_rec.mm_writedata <= data(i);
mm_m_rec.mm_write <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
end if;
end loop; -- i
wait until rising_edge(clk_clk);
end mm_32b_burst;
procedure mm_32b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(31 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= "1111";
mm_m_rec.mm_writedata <= data;
mm_m_rec.mm_write <= '1';
wait until falling_edge(clk_clk);
if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
end mm_32b_write;
procedure mm_16b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(15 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable my_addr : std_logic_vector(31 downto 0) := (others=>'0');
begin
my_addr := addr;
if addr(1) = '1' then
my_addr := std_logic_vector(unsigned(my_addr)+2);
end if;
wait until rising_edge(clk_clk);
if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_writedata <= data & data;
if addr(1) = '0' then
mm_m_rec.mm_byteenable <= "0011";
else
mm_m_rec.mm_byteenable <= "1100";
end if;
mm_m_rec.mm_write <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
wait until rising_edge(clk_clk);
end mm_16b_write;
procedure mm_8b_write( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector( 7 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_writedata <= data & data & data & data;
if addr(1 downto 0) = "00" then
mm_m_rec.mm_byteenable <= "0001";
elsif addr(1 downto 0) = "01" then
mm_m_rec.mm_byteenable <= "0010";
elsif addr(1 downto 0) = "10" then
mm_m_rec.mm_byteenable <= "0100";
else
mm_m_rec.mm_byteenable <= "1000";
end if;
mm_m_rec.mm_write <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
wait until rising_edge(clk_clk);
end mm_8b_write;
procedure mm_32b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(31 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_read <= '1';
wait until falling_edge(clk_clk);
if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
wait until rising_edge(clk_clk);
mm_m_rec.mm_read <= '0';
if(mm_m_rec.use_waitrequest = false) then
for n in 1 to mm_m_rec.read_latency loop
wait until rising_edge(clk_clk);
end loop; -- n
end if;
if(mm_m_rec.use_readvalid = true) then
if(mm_s_rec.mm_readdatavalid = '0') then
wait until mm_s_rec.mm_readdatavalid = '1';
end if;
end if;
wait until falling_edge(clk_clk);
data := mm_s_rec.mm_readdata;
end mm_32b_read;
procedure mm_16b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(15 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_read <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_read <= '0';
wait until rising_edge(mm_s_rec.mm_readdatavalid);
data := mm_s_rec.mm_readdata(15 downto 0);
end mm_16b_read;
procedure mm_8b_read( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector( 7 downto 0);
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_read <= '1';
wait until rising_edge(clk_clk);
mm_m_rec.mm_read <= '0';
wait until rising_edge(mm_s_rec.mm_readdatavalid);
data := mm_s_rec.mm_readdata( 7 downto 0);
end mm_8b_read;
-----------------------------------------------------------------------------
-- Avalon Stream section
-----------------------------------------------------------------------------
procedure stm_m_init( signal stm_m_rec : out stm_m_rec_t ) is
begin
stm_m_rec.stm_channel <= (others => '0');
stm_m_rec.stm_data <= (others => '0');
stm_m_rec.stm_valid <= '0';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
end stm_m_init;
procedure stm_s_init( signal stm_s_rec : out stm_s_rec_t ) is
begin
stm_s_rec.stm_ready <= '0';
stm_s_rec.stm_error <= (others => '0');
end stm_s_init;
procedure stm_puncture is
variable loop_max : integer;
begin
loop_max := RV.RandInt(int_stmBusPunctureMin,int_stmBusPunctureMax);
if loop_max > 0 then
for i in 1 to loop_max loop
wait until rising_edge(clk_clk);
end loop; -- i
end if;
end stm_puncture;
procedure stm_32b_write( len : in integer;
channel : in integer;
data_vec : in data_32b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t) is
variable loop_max : integer;
begin
wait until rising_edge(clk_clk);
if stm_s_rec.stm_ready = '0' then
wait until rising_edge(stm_s_rec.stm_ready);
end if;
wait until rising_edge(clk_clk);
for i in 1 to len loop
stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8));
stm_m_rec.stm_data <= data_vec(i-1);
stm_m_rec.stm_valid <= '1';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
if i = 1 then
stm_m_rec.stm_sop <= '1';
end if;
if i = len then
stm_m_rec.stm_eop <= '1';
end if;
wait until rising_edge(clk_clk);
stm_m_rec.stm_valid <= '0';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_puncture;
end loop; -- i
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_m_rec.stm_valid <= '0';
end stm_32b_write;
procedure stm_16b_write( len : in integer;
channel : in integer;
data_vec : in data_16b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t) is
variable loop_max : integer;
begin
wait until rising_edge(clk_clk);
if stm_s_rec.stm_ready = '0' then
wait until rising_edge(stm_s_rec.stm_ready);
end if;
wait until rising_edge(clk_clk);
for i in 1 to len loop
stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8));
stm_m_rec.stm_data <= x"0000" & data_vec(i-1);
stm_m_rec.stm_valid <= '1';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
if i = 1 then
stm_m_rec.stm_sop <= '1';
end if;
if i = len then
stm_m_rec.stm_eop <= '1';
end if;
wait until rising_edge(clk_clk);
stm_m_rec.stm_valid <= '0';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_puncture;
end loop; -- i
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_m_rec.stm_valid <= '0';
end stm_16b_write;
procedure stm_8b_write( len : in integer;
channel : in integer;
data_vec : in data_8b_vec_t;
signal stm_s_rec : in stm_s_rec_t;
signal stm_m_rec : out stm_m_rec_t) is
variable loop_max : integer;
begin
wait until rising_edge(clk_clk);
if stm_s_rec.stm_ready = '0' then
wait until rising_edge(stm_s_rec.stm_ready);
end if;
wait until rising_edge(clk_clk);
for i in 1 to len loop
stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8));
stm_m_rec.stm_data <= x"000000" & data_vec(i-1);
stm_m_rec.stm_valid <= '1';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
if i = 1 then
stm_m_rec.stm_sop <= '1';
end if;
if i = len then
stm_m_rec.stm_eop <= '1';
end if;
wait until rising_edge(clk_clk);
stm_m_rec.stm_valid <= '0';
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_puncture;
end loop; -- i
stm_m_rec.stm_sop <= '0';
stm_m_rec.stm_eop <= '0';
stm_m_rec.stm_valid <= '0';
end stm_8b_write;
procedure stm_8b_read( signal stm_m_rec : in stm_m_rec_t;
signal stm_s_rec : out stm_s_rec_t;
data_vec : out data_8b_vec_t;
channel : out integer;
len : out integer) is
variable tmp_len : integer := 0;
begin
wait until rising_edge(clk_clk);
if stm_m_rec.stm_sop = '0' then
wait until rising_edge(stm_m_rec.stm_sop);
end if;
channel := to_integer(unsigned(stm_m_rec.stm_data));
while stm_m_rec.stm_eop = '0' loop
tmp_len := tmp_len + 1;
wait until rising_edge(clk_clk);
if stm_m_rec.stm_valid = '1' then
data_vec(tmp_len-1) := stm_m_rec.stm_data(7 downto 0);
end if;
end loop;
len := tmp_len;
end stm_8b_read;
-----------------------------------------------------------------------------
-- LVDS section
-----------------------------------------------------------------------------
procedure lvds_m_init( signal lvds_m_rec : out lvds_m_rec_t ) is
begin
lvds_m_rec.lvds_1_rx_data <= (others => '0');
lvds_m_rec.lvds_1_rx_nlock <= '0';
lvds_m_rec.lvds_1_rx_clk <= '0';
lvds_m_rec.lvds_2_rx_data <= (others => '0');
lvds_m_rec.lvds_2_rx_nlock <= '0';
lvds_m_rec.lvds_2_rx_clk <= '0';
end lvds_m_init;
procedure lvds_s_init( signal lvds_s_rec : out lvds_s_rec_t ) is
begin
lvds_s_rec.lvds_refclk <= '0';
lvds_s_rec.lvds_1_rx_npwrdn <= '0';
lvds_s_rec.lvds_1_rx_en <= '0';
lvds_s_rec.lvds_2_rx_npwrdn <= '0';
lvds_s_rec.lvds_2_rx_en <= '0';
end lvds_s_init;
procedure lvds_write( len : in integer;
data_vec : in data_8b_vec_t;
signal lvds_s_rec : in lvds_s_rec_t;
signal lvds_m_rec : out lvds_m_rec_t) is
variable tog : std_logic := '1';
variable lvds_crc : std_logic_vector(7 downto 0) := x"00";
variable lvds_tmp : std_logic_vector(7 downto 0) := x"00";
constant STX : std_logic_vector(7 downto 0) := x"02";
constant ETX : std_logic_vector(7 downto 0) := x"03";
begin
wait until rising_edge(lvds_s_rec.lvds_refclk);
lvds_m_rec.lvds_1_rx_data <= '1' & '0' & STX;
wait until rising_edge(lvds_s_rec.lvds_refclk);
lvds_m_rec.lvds_1_rx_data <= '0' & '0' & std_logic_vector(to_unsigned(len / 256,8));
wait until rising_edge(lvds_s_rec.lvds_refclk);
lvds_m_rec.lvds_1_rx_data <= '1' & '0' & std_logic_vector(to_unsigned(len mod 256,8));
wait until rising_edge(lvds_s_rec.lvds_refclk);
for i in 0 to len-1 loop
tog := not tog;
lvds_crc := lvds_crc xor data_vec(i);
lvds_m_rec.lvds_1_rx_data <= tog & '0' & data_vec(i);
wait until rising_edge(lvds_s_rec.lvds_refclk);
end loop; -- i
tog := not tog;
lvds_m_rec.lvds_1_rx_data <= tog & '0' & lvds_crc;
wait until rising_edge(lvds_s_rec.lvds_refclk);
tog := not tog;
lvds_m_rec.lvds_1_rx_data <= tog & '0' & ETX;
wait until rising_edge(lvds_s_rec.lvds_refclk);
if tog = '1' then
lvds_m_rec.lvds_1_rx_data <= (others => '0');
wait until rising_edge(lvds_s_rec.lvds_refclk);
end if;
end lvds_write;
end avalon_verify_pkg_2;

View file

@ -0,0 +1,273 @@
-------------------------------------------------------------------------------
-- Title : common_test_pkg
-- Project : project independent
-------------------------------------------------------------------------------
-- File : common_test_pkg.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2017-05-10
-- Last update: 2017-07-06
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Support package for testbenches
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
-------------------------------------------------------------------------------
-- Common Test Package
-------------------------------------------------------------------------------
package common_test_pkg is
-----------------------------------------------------------------------------
-- Protected Flag Type
-----------------------------------------------------------------------------
type prot_flag_t is protected
procedure set;
procedure reset;
impure function is_set return boolean;
impure function is_reset return boolean;
end protected prot_flag_t;
-----------------------------------------------------------------------------
-- Protected Integer Type
-----------------------------------------------------------------------------
type prot_int_t is protected
procedure set(val : in integer);
procedure reset;
procedure inc(val : in integer);
procedure dec(val : in integer);
impure function get return integer;
end protected prot_int_t;
-----------------------------------------------------------------------------
-- Linked List of Integers
-----------------------------------------------------------------------------
type int_linked_list_t is protected
-- return the length of the list
impure function len return integer;
-- clear the list
procedure clear;
-- Add an item to the end of the list
procedure append(val : in integer);
-- read the value of element at position idx in the list. Return -2^31
-- (2147483648) in case element idx does not exist
impure function get_value(idx : natural) return integer;
-- Insert an item at a given position. The first argument is the index
-- of the element before which to insert, so a.insert(0, x) inserts at
-- the front of the list, and a.insert(len(a), x)
procedure insert(idx : in natural; val : in integer);
-- Remove from the list the element a position idx and returns the value of
-- that element.
-- list.pop(0) => remove the first element added to the list (FIFO behaviour)
-- list.pop(list.len-1) => get the last element added to the list (LIFO behaviour)
impure function pop(idx : integer) return integer;
-- find the first occurrence of an item in the list. Return the
-- position of the item in the list if present, -1 if not present
impure function find(val : integer) return integer;
-- similar to find, but return the last occurrence of the item in the list
impure function rfind(val : integer) return integer;
end protected int_linked_list_t;
end package common_test_pkg;
-------------------------------------------------------------------------------
-- Common Test Package (Body)
-------------------------------------------------------------------------------
package body common_test_pkg is
-----------------------------------------------------------------------------
-- Protected Flag Type
-----------------------------------------------------------------------------
type prot_flag_t is protected body
variable flag : boolean := false;
procedure set is
begin flag := True; end procedure set;
procedure reset is
begin flag := False; end procedure reset;
impure function is_set return boolean is
begin return flag; end function is_set;
impure function is_reset return boolean is
begin return not flag; end function is_reset;
end protected body prot_flag_t;
-----------------------------------------------------------------------------
-- Protected Integer Type
-----------------------------------------------------------------------------
type prot_int_t is protected body
variable value : integer := 0;
procedure set(val : in integer) is
begin value := val; end procedure set;
procedure reset is
begin value := 0; end procedure reset;
procedure inc(val : in integer) is
begin value := value + val; end procedure inc;
procedure dec(val : in integer) is
begin value := value - val; end procedure dec;
impure function get return integer is
begin return value; end function get;
end protected body prot_int_t;
-----------------------------------------------------------------------------
-- Linked List of Integers
-----------------------------------------------------------------------------
type int_linked_list_t is protected body
-- define the cell element type
type value_cell;
type value_ptr is access value_cell;
type value_cell is record
value : integer;
next_cell : value_ptr;
end record value_cell;
-- list variable
variable list : value_ptr;
variable length : integer := 0;
-- return the length of the list
impure function len return integer is
begin return length; end function len;
-- clear the list
procedure clear is
begin list := NULL; length := 0; end procedure clear;
-- Add an item to the end of the list
procedure append(val : in integer) is
begin list := new value_cell'(val, list); length := length+1; end procedure append;
-- read the value of element at position idx in the list. Return -2^31
-- (2147483648) in case element idx does not exist
impure function get_value(idx : natural) return integer is
variable value : integer := -2147483648;
variable cell_ptr : value_ptr := list;
begin
if(idx < length) then
for i in 1 to length-idx-1 loop
cell_ptr := cell_ptr.next_cell;
end loop; -- i
if cell_ptr /= NULL then
value := cell_ptr.value;
end if;
end if;
return value;
end function get_value;
-- Insert an item at a given position. The first argument is the index
-- of the element before which to insert, so a.insert(0, x) inserts at
-- the front of the list, and a.insert(len(a), x)
procedure insert(idx : in natural; val : in integer) is
variable cell_ptr : value_ptr := list;
begin
if(idx = length) then
list := new value_cell'(val, list);
length := length+1;
elsif(idx < length) then
for i in 1 to length-idx-1 loop
cell_ptr := cell_ptr.next_cell;
end loop; -- i
cell_ptr.next_cell := new value_cell'(val, cell_ptr.next_cell);
length := length+1;
end if;
end procedure insert;
-- Remove from the list the element a position idx and returns the value of
-- that element.
-- list.pop(0) => remove the first element added to the list (FIFO behaviour)
-- list.pop(list.len-1) => get the last element added to the list (LIFO behaviour)
impure function pop(idx : integer) return integer is
variable val : integer := -2147483648;
variable cell_ptr : value_ptr := list;
variable to_delete : value_ptr := NULL;
variable cell_previous : value_ptr;
begin
if(idx = length-1) then
val := list.value;
to_delete := list;
list := list.next_cell;
length := length-1;
elsif(idx >= 0 and idx < length-1) then
for n in 1 to length-idx-1 loop
cell_previous := cell_ptr;
cell_ptr := cell_ptr.next_cell;
end loop; -- n
val := cell_ptr.value;
to_delete := cell_ptr;
cell_previous.next_cell := cell_ptr.next_cell;
length := length-1;
end if;
deallocate(to_delete);
return val;
end function pop;
-- find the first occurrence of an item in the list. Return the
-- position of the item in the list if present, -1 if not present
impure function find(val : integer) return integer is
variable idx : integer := -1;
variable cell_ptr : value_ptr := list;
begin
for n in length-1 downto 0 loop
if(cell_ptr.value = val) then
idx := n;
end if;
cell_ptr := cell_ptr.next_cell;
end loop; -- n
return idx;
end function find;
-- similar to find, but return the last occurrence of the item in the list
impure function rfind(val : integer) return integer is
variable idx : integer := -1;
variable curr_val : integer := -1;
variable cell_ptr : value_ptr := list;
begin
for n in length-1 downto 0 loop
curr_val := cell_ptr.value;
cell_ptr := cell_ptr.next_cell;
if(curr_val = val) then
idx := n;
exit;
end if;
end loop;
return idx;
end function rfind;
end protected body int_linked_list_t;
end package body common_test_pkg;

View file

@ -0,0 +1,523 @@
-------------------------------------------------------------------------------
-- Title : cs_bus_itf_tb
-- Project : Generic
-------------------------------------------------------------------------------
-- File : cs_bus_itf_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2019-07-10
-- Last update: 2019-07-17
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Verifies Time-of-Flight Compensation
-------------------------------------------------------------------------------
library std;
use std.textio.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.log_pkg.all;
use work.avalon_verify_pkg.all;
entity cs_bus_itf_tb is
-- ..
end entity cs_bus_itf_tb;
architecture behav of cs_bus_itf_tb is
constant CLK_PERIOD : time := 10 ns;
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
constant BLK_NUM : natural := 8;
-----------------------------------------------------------------------------
-- Signal declarations
-----------------------------------------------------------------------------
signal reset_n : std_logic;
signal clk : std_logic := '0';
signal avs_address : std_logic_vector(14 downto 0);
signal avs_write : std_logic;
signal avs_writedata : std_logic_vector(31 downto 0);
signal avs_read : std_logic;
signal avs_waitrequest : std_logic;
signal avs_readdata : std_logic_vector(31 downto 0);
signal cs_addr : std_logic_vector(10 downto 0);
signal cs_we : std_logic_vector(BLK_NUM-1 downto 0);
signal cs_wr_data : std_logic_vector(31 downto 0);
signal cs_re : std_logic_vector(BLK_NUM-1 downto 0);
signal cs_rv : std_logic_vector(BLK_NUM-1 downto 0);
signal cs_rd_data : std_logic_vector(32*BLK_NUM-1 downto 0);
--
signal avs_m : mm_m_rec_t;
signal avs_s : mm_s_rec_t;
--
signal end_of_stimuli : boolean;
signal test_completed : boolean;
signal setup : boolean;
signal running : boolean;
signal passed : boolean;
signal failed : boolean;
shared variable error_flag : boolean;
signal blk_0_re, blk_0_we, blk_0_rv, blk_0_re_d : std_logic;
signal blk_1_re, blk_1_we, blk_1_rv, blk_1_re_d : std_logic;
signal blk_0_wr_data, blk_0_rd_data : std_logic_vector(31 downto 0);
signal blk_1_wr_data, blk_1_rd_data : std_logic_vector(31 downto 0);
-----------------------------------------------------------------------------
-- TB Functions / Procedures
-----------------------------------------------------------------------------
procedure wait_latency(
signal clk : in std_logic;
cycles : in natural) is
begin
for i in 1 to cycles loop
wait until clk = '1' and clk'event;
end loop; -- i
end procedure wait_latency;
procedure mm_32b_write_f( addr : in std_logic_vector(31 downto 0);
data : in std_logic_vector(31 downto 0);
skip_wait_re : in boolean := false;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_byteenable <= "1111";
mm_m_rec.mm_writedata <= data;
mm_m_rec.mm_write <= '1';
wait until falling_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
if(skip_wait_re = false) then
wait until rising_edge(clk_clk);
else
wait until falling_edge(clk_clk);
end if;
mm_m_rec.mm_byteenable <= "0000";
mm_m_rec.mm_write <= '0';
end mm_32b_write_f;
procedure mm_32b_read_f( addr : in std_logic_vector(31 downto 0);
data : out std_logic_vector(31 downto 0);
skip_wait_re : in boolean := false;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
begin
wait until rising_edge(clk_clk);
mm_m_rec.mm_address <= addr or base_addr;
mm_m_rec.mm_read <= '1';
wait until falling_edge(clk_clk);
if(mm_use_waitrequest.is_set = true and mm_s_rec.mm_waitrequest = '1') then
wait until falling_edge(mm_s_rec.mm_waitrequest);
end if;
if(skip_wait_re = false) then
wait until rising_edge(clk_clk);
else
wait until falling_edge(clk_clk);
end if;
mm_m_rec.mm_read <= '0';
if(mm_use_waitrequest.is_set = false) then
for n in 1 to mm_read_latency.get loop
wait until rising_edge(clk_clk);
end loop; -- n
end if;
if(mm_s_rec.use_readvalid = true) then
if(mm_s_rec.mm_readdatavalid = '0') then
wait until mm_s_rec.mm_readdatavalid = '1';
end if;
end if;
--wait until falling_edge(clk_clk);
data := mm_s_rec.mm_readdata;
end mm_32b_read_f;
-----------------------------------------------------------------------------
-- End declarative part
-----------------------------------------------------------------------------
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- UUT
-----------------------------------------------------------------------------
iUUT: entity work.cs_bus_ift
generic map (
BLK_NUM => BLK_NUM,
READ_TIMEOUT => 32)
port map (
rstN => reset_n,
clk => clk,
avs_address => avs_address,
avs_write => avs_write,
avs_writedata => avs_writedata,
avs_read => avs_read,
avs_waitrequest => avs_waitrequest,
avs_readdata => avs_readdata,
cs_addr => cs_addr,
cs_we => cs_we,
cs_wr_data => cs_wr_data,
cs_re => cs_re,
cs_rv => cs_rv,
cs_rd_data => cs_rd_data);
-- Instantiate only 2 dummy blocks, leave the rest unconnected
blk_0_we <= cs_we(0);
blk_1_we <= cs_we(1);
blk_0_re <= cs_re(0);
blk_1_re <= cs_re(1);
cs_rv <= (0 => blk_0_rv, 1 => blk_1_rv, others => '0');
cs_rd_data(31 downto 0) <= blk_0_rd_data;
cs_rd_data(63 downto 32) <= blk_1_rd_data;
cs_rd_data(32*BLK_NUM-1 downto 64) <= (others => '1');
-----------------------------------------------------------------------------
-- CS-BUS dummy pripherals
-----------------------------------------------------------------------------
pDUMMY_0 : process(clk)
variable rd_val_v : std_logic_vector(3 downto 0) := (others => '0');
begin
if(clk = '1' and clk'event) then
if(blk_0_we = '1') then
blk_0_wr_data <= cs_wr_data;
end if;
blk_0_re_d <= blk_0_re;
if(blk_0_re = '1' and blk_0_re_d = '0') then
rd_val_v := (0 => '1', others => '0');
else
rd_val_v := '0' & rd_val_v(rd_val_v'left downto 1);
end if;
if(rd_val_v(0) = '1') then
blk_0_rv <= '1';
blk_0_rd_data <= X"AAAA0000";
else
blk_0_rv <= '0';
blk_0_rd_data <= X"0000BAD0";
end if;
end if;
end process pDUMMY_0;
pDUMMY_1 : process(clk)
variable rd_val_v : std_logic_vector(3 downto 0) := (others => '0');
begin
if(clk = '1' and clk'event) then
if(blk_1_we = '1') then
blk_1_wr_data <= cs_wr_data;
end if;
blk_1_re_d <= blk_1_re;
if(blk_1_re = '1' and blk_1_re_d = '0') then
rd_val_v := (3 => '1', others => '0');
else
rd_val_v := '0' & rd_val_v(rd_val_v'left downto 1);
end if;
if(rd_val_v(0) = '1') then
blk_1_rv <= '1';
blk_1_rd_data <= X"BBBB0000";
else
blk_1_rv <= '0';
blk_1_rd_data <= X"0000BAD1";
end if;
end if;
end process pDUMMY_1;
-----------------------------------------------------------------------------
-- Avalon interface
-----------------------------------------------------------------------------
clk_clk <= clk;
reset_reset_n <= reset_n;
avs_s.mm_readdata <= avs_readdata;
avs_s.mm_readdatavalid <= '0';
avs_s.mm_waitrequest <= avs_waitrequest;
avs_s.use_readvalid <= false;
avs_address <= avs_m.mm_address(avs_address'range);
avs_write <= avs_m.mm_write;
avs_writedata <= avs_m.mm_writedata;
avs_read <= avs_m.mm_read;
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pTB_CTRL : process
procedure wr_data(
blk : natural;
reg : natural;
data : in std_logic_vector(31 downto 0);
signal avs_s : in mm_s_rec_t;
signal avs_m : out mm_m_rec_t;
skip_wait_re : boolean := false) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
begin
addr := 17x"0" & std_logic_vector(to_unsigned(blk,4)) & std_logic_vector(to_unsigned(reg,11));
mm_32b_write_f(addr, data, skip_wait_re, avs_s, avs_m);
end procedure wr_data;
procedure rd_data(
blk : natural;
reg : natural;
data : out std_logic_vector(31 downto 0);
signal avs_s : in mm_s_rec_t;
signal avs_m : out mm_m_rec_t;
skip_wait_re : boolean := false) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
begin
addr := 17x"0" & std_logic_vector(to_unsigned(blk,4)) & std_logic_vector(to_unsigned(reg,11));
mm_32b_read_f(addr, data, skip_wait_re, avs_s, avs_m);
end procedure rd_data;
variable data : std_logic_vector(31 downto 0);
begin
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
--set_log_verbosity(VHIGH);
-- initilialize the Avalon master-bus
mm_m_init(avs_m, use_waitrequest => true);
log_header("verifying CS_BUS_ITF:", VLOW);
setup <= false;
running <= false;
passed <= false;
failed <= false;
error_flag := false;
-- Reset
reset_n <= '0';
wait for 100 ns;
wait until clk = '1' and clk'event;
reset_n <= '1';
wait for 200 ns;
running <= true;
---------------------------------------------------------------------------
-- Write & Read : pause between operations
---------------------------------------------------------------------------
wait_latency(clk, 20);
wr_data(0, 4, X"A0A0B1B1", avs_s, avs_m);
wait_latency(clk, 5);
if(blk_0_wr_data /= X"A0A0B1B1") then
log("ERROR : Expecting written data A0A0B1B1 on block 0", VLOW);
error_flag := true;
end if;
wait_latency(clk, 20);
wr_data(1, 8, X"C0C0D1D1", avs_s, avs_m);
wait_latency(clk, 5);
if(blk_1_wr_data /= X"C0C0D1D1") then
log("ERROR : Expecting written data C0C0D1D1 on block 1", VLOW);
error_flag := true;
end if;
wait_latency(clk, 20);
wr_data(2, 0, X"EE00FF11", avs_s, avs_m);
wait_latency(clk, 20);
wr_data(7, 0, X"EE00FF11", avs_s, avs_m);
for blk_num in 0 to 7 loop
rd_data(blk_num, 16, data, avs_s, avs_m);
log("Read Data 0x" & to_hstring(data) & " from block " & to_string(blk_num), VLOW);
wait_latency(clk, 50);
end loop; -- blk_num
-- repeat the same test, but without pause between read/write accesses
---------------------------------------------------------------------------
-- Write & Read : no pause between operations
---------------------------------------------------------------------------
log_header("Repeating the test without pauses between accesses:", VLOW);
wait_latency(clk, 20);
/*
wr_data(0, 4, X"A2A2B1B1", avs_s, avs_m, true);
wr_data(1, 8, X"C2C2D1D1", avs_s, avs_m, true);
wr_data(2, 0, X"EE00FF11", avs_s, avs_m, true);
wr_data(7, 0, X"EE00FF11", avs_s, avs_m, true);
for blk_num in 0 to 7 loop
rd_data(blk_num, 16, data, avs_s, avs_m, true);
log("Read Data 0x" & to_hstring(data) & " from block " & to_string(blk_num), VLOW);
end loop; -- blk_num
*/
-- manually drive the master signals
wait until clk = '1' and clk'event;
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(0,4)) & std_logic_vector(to_unsigned(4,11));
avs_m.mm_writedata <= X"A2A2B1B1";
avs_m.mm_write <= '1';
wait until clk = '0' and clk'event;
while avs_s.mm_waitrequest = '1' loop
wait until clk = '0' and clk'event;
end loop;
wait until clk = '1' and clk'event;
-- transfer is concluded, but don't de-assert the write enable, just move
-- to the next data
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(1,4)) & std_logic_vector(to_unsigned(8,11));
avs_m.mm_writedata <= X"C2C2D1D1";
avs_m.mm_write <= '1';
wait until clk = '0' and clk'event;
-- Check first the data written before:
if(blk_0_wr_data /= X"A2A2B1B1") then
log("ERROR : Expecting written data A2A2B1B1 on block 0", VLOW);
error_flag := true;
end if;
while avs_s.mm_waitrequest = '1' loop
wait until clk = '0' and clk'event;
end loop;
wait until clk = '1' and clk'event;
-- transfer is concluded, but don't de-assert the write enable, just move
-- to the next data
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(2,4)) & std_logic_vector(to_unsigned(0,11));
avs_m.mm_writedata <= X"EE00FF11";
avs_m.mm_write <= '1';
wait until clk = '0' and clk'event;
-- Check first the data written before:
if(blk_1_wr_data /= X"C2C2D1D1") then
log("ERROR : Expecting written data C2C2D1D1 on block 1", VLOW);
error_flag := true;
end if;
while avs_s.mm_waitrequest = '1' loop
wait until clk = '0' and clk'event;
end loop;
wait until clk = '1' and clk'event;
-- transfer is concluded, but don't de-assert the write enable, just move
-- to the next data
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(7,4)) & std_logic_vector(to_unsigned(0,11));
avs_m.mm_writedata <= X"FF11EE00";
avs_m.mm_write <= '1';
wait until clk = '0' and clk'event;
while avs_s.mm_waitrequest = '1' loop
wait until clk = '0' and clk'event;
end loop;
wait until clk = '1' and clk'event;
-- disable write and start immediately reading
avs_m.mm_write <= '0';
for n in 0 to 7 loop
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(n,4)) & std_logic_vector(to_unsigned(16,11));
avs_m.mm_read <= '1';
wait until clk = '0' and clk'event;
while avs_s.mm_waitrequest = '1' loop
wait until clk = '0' and clk'event;
end loop;
log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(n), VLOW);
wait until clk = '1' and clk'event;
end loop; -- n
avs_m.mm_read <= '0';
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
-- now do a loop with read-write-read without interruption
for n in 0 to 7 loop
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(n,4)) & std_logic_vector(to_unsigned(16,11));
avs_m.mm_read <= '1';
wait until clk = '0' and clk'event;
while avs_s.mm_waitrequest = '1' loop
wait until clk = '0' and clk'event;
end loop;
log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(n), VLOW);
wait until clk = '1' and clk'event;
avs_m.mm_read <= '0';
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(0,4)) & std_logic_vector(to_unsigned(4,11));
avs_m.mm_writedata <= X"A2A2B1B1";
avs_m.mm_write <= '1';
wait until clk = '0' and clk'event;
while avs_s.mm_waitrequest = '1' loop
wait until clk = '0' and clk'event;
end loop;
wait until clk = '1' and clk'event;
avs_m.mm_write <= '0';
avs_m.mm_address <= 17x"0" & std_logic_vector(to_unsigned(7,4)) & std_logic_vector(to_unsigned(8,11));
avs_m.mm_read <= '1';
wait until clk = '0' and clk'event;
while avs_s.mm_waitrequest = '1' loop
wait until clk = '0' and clk'event;
end loop;
log("Read Data 0x" & to_hstring(avs_s.mm_readdata) & " from block " & to_string(7), VLOW);
wait until clk = '1' and clk'event;
end loop; -- n
avs_m.mm_read <= '0';
wait_latency(clk, 50);
running <= false;
wait for 5 us;
end_of_stimuli <= true;
if(error_flag = false) then
passed <= true after 100 ns;
else
failed <= true;
end if;
wait;
end process pTB_CTRL;
--failed <= error_flag after 100 ns;
pREPORT_RESULT : process
begin
wait until failed = true or passed = true;
wait for 1 us;
log_separator_line(VLOW);
if(failed = true) then
log("FAILURE: test completed with errors.", VLOW);
elsif(passed = true) then
log("SUCCESS: test successfully completed.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
end process pREPORT_RESULT;
end architecture behav;

View file

@ -0,0 +1,63 @@
-------------------------------------------------------------------------------
-- Title : lfsr_6
-- Project : generic-ip
-------------------------------------------------------------------------------
-- File : lfsr_6.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2019-10-08
-- Last update: 2019-10-08
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- 6-bit, max length LFSR with removed absorbing state
-- Taps are 5,6
-- For different LFSR lengths please consult:
-- Xilinx XAPP052, 7th July 1996, "Efficient Shift Registers, LFSR Counters,
-- and Long Pseudo-Random Sequence Generators", by Peter Alfke.
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity lfsr_6 is
generic(
SEED : std_logic_vector(5 downto 0) := (others => '1'));
port(
clk : in std_logic;
lfsr_rst : in std_logic;
lfsr_upd : in std_logic;
lfsr_reg : out std_logic_vector(5 downto 0);
lfsr_out : out std_logic);
end lfsr_6;
architecture RTL of lfsr_6 is
signal new_val : std_logic;
signal shf_reg : std_logic_vector(5 downto 0);
begin
pLFSR : process(clk)
begin
if(clk = '1' and clk'event) then
if(lfsr_rst = '1') then
shf_reg <= SEED;
elsif(lfsr_upd = '1') then
shf_reg <= shf_reg(shf_reg'left-1 downto 0) & new_val;
end if;
end if;
end process pLFSR;
new_val <= shf_reg(5) xor shf_reg(4);
lfsr_reg <= shf_reg;
lfsr_out <= shf_reg(shf_reg'left);
end RTL;

View file

@ -0,0 +1,205 @@
-------------------------------------------------------------------------------
-- Title : common_test_pkg
-- Project : project independent
-------------------------------------------------------------------------------
-- File : common_test_pkg.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2017-05-10
-- Last update: 2017-09-25
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Support package for testbenches
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use std.textio.all;
use work.common_test_pkg.all;
-------------------------------------------------------------------------------
-- Log Package
-------------------------------------------------------------------------------
package log_pkg is
-- verbosity level
shared variable verb_level : prot_int_t;
-- verbosity levels
type verb_level_t is (V_NONE, V_LOW, V_MEDIUM, V_HIGH, V_FULL, V_DEBUG);
constant VNONE : verb_level_t := V_NONE;
constant VLOW : verb_level_t := V_LOW;
constant VMEDIUM : verb_level_t := V_MEDIUM;
constant VHIGH : verb_level_t := V_HIGH;
constant VFULL : verb_level_t := V_FULL;
constant VDEBUG : verb_level_t := V_DEBUG;
-- Defines whether to save log data to the transcript panel only or also to a
-- text file
-- in the simulator transcript.
shared variable log_to_file_en : prot_flag_t;
file log_file : text;
procedure set_log_verbosity(
level : in verb_level_t);
procedure log_to_file(
enable : in boolean;
file_name : in string);
procedure log_file_close;
procedure log_separator_line(
vlevel : in verb_level_t);
procedure log_header(
mytext : in string;
vlevel : in verb_level_t);
procedure log(
mytext : in string;
vlevel : in verb_level_t;
timetag : in boolean := true;
emph : in boolean := false);
end package log_pkg;
-------------------------------------------------------------------------------
-- Log Package (Body)
-------------------------------------------------------------------------------
package body log_pkg is
procedure set_log_verbosity(
level : in verb_level_t) is
begin
verb_level.set(verb_level_t'pos(level));
end procedure set_log_verbosity;
-- log_init : open the specified log file
procedure log_to_file(
enable : in boolean;
file_name : in string) is
variable status : file_open_status;
begin
if(enable = false) then
log_to_file_en.reset;
else
log_to_file_en.set;
file_open(status, log_file, file_name, write_mode);
if(status /= open_ok) then
--log_to_file_en.reset;
assert false report "Failed to open log file " & file_name & "." severity error;
end if;
end if;
end procedure log_to_file;
-- log_close: close the log file
procedure log_file_close is
begin
if(log_to_file_en.is_set) then
log_to_file_en.reset;
file_close(log_file);
end if;
end procedure log_file_close;
procedure log_separator_line(
vlevel : in verb_level_t) is
variable out_line : line;
begin
if(verb_level_t'pos(vlevel) <= verb_level.get) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(output, out_line);
if(log_to_file_en.is_set) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(log_file, out_line);
flush(log_file);
end if;
end if;
end procedure log_separator_line;
procedure log_header(
mytext : in string;
vlevel : in verb_level_t) is
variable out_line : line;
begin
if(verb_level_t'pos(vlevel) <= verb_level.get) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(output, out_line);
if(log_to_file_en.is_set) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(log_file, out_line);
flush(log_file);
end if;
write(out_line, mytext);
writeline(output, out_line);
if(log_to_file_en.is_set) then
write(out_line, mytext);
writeline(log_file, out_line);
flush(log_file);
end if;
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(output, out_line);
if(log_to_file_en.is_set) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(log_file, out_line);
flush(log_file);
end if;
end if;
end procedure log_header;
procedure log(
mytext : in string;
vlevel : in verb_level_t;
timetag : in boolean := true;
emph : in boolean := false) is
variable out_line : line;
begin
if(verb_level_t'pos(vlevel) <= verb_level.get) then
if(emph = true) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(output, out_line);
if(log_to_file_en.is_set) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(log_file, out_line);
flush(log_file);
end if;
end if;
if(timetag) then
write(out_line, now, UNIT => ns);
write(out_line, string'(" : ") & mytext);
else
write(out_line, mytext);
end if;
writeline(output, out_line);
if(log_to_file_en.is_set) then
if(timetag) then
write(out_line, now, UNIT => ns);
write(out_line, string'(" : ") & mytext);
else
write(out_line, mytext);
end if;
writeline(log_file, out_line);
flush(log_file);
end if;
if(emph = true) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(output, out_line);
if(log_to_file_en.is_set) then
write(out_line, string'("//////////////////////////////////////////////////////////////////"));
writeline(log_file, out_line);
flush(log_file);
end if;
end if;
end if;
end procedure log;
end package body log_pkg;

View file

@ -0,0 +1,428 @@
-------------------------------------------------------------------------------
-- Title : Testbench for queue_and_delay
-- Project : project independent
-------------------------------------------------------------------------------
-- File : .vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2016-11-01
-- Last update: 2019-11-18
-- SVN ID : Git
-- Standard : VHDL'93
-------------------------------------------------------------------------------
-- Description:
-- Simple Testbench for the queue and delay: Only corner cases of the delay
-- mechanism are checked: wrapping around of the counter, usage of the external
-- reference for the counter, up and down counting.
-- Check also latency issues when using the external counter: what happens if
-- the external counter is not updated every clock cycles.
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.log_pkg.all;
library OSVVM;
use OSVVM.RandomBasePkg.all;
use OSVVM.RandomPkg.all;
entity queue_and_delay_tb is
generic(
USE_EXT_TIME : boolean := true);
-- ...
end queue_and_delay_tb;
architecture behav of queue_and_delay_tb is
-----------------------------------------------------------------------------
-- Constant, types and signals
-----------------------------------------------------------------------------
constant clk_period : time := 10.0 ns; -- clock period
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
constant WAVE_UPD_PERIOD : natural := 4;
constant EXT_TIME_PERIOD : natural := 3;
constant DELAY_ERROR : natural := 1;
-- Number of delay values to be tested. For each value the testbench
-- initializes the timing reference with a wide set of values
constant DELAY_TEST_NUM : natural := 10;
signal reset_n : std_logic;
signal clk : std_logic := '0';
signal init : std_logic;
signal cnt_dir : std_logic;
signal delay : std_logic_vector(31 downto 0);
signal ext_time : std_logic_vector(31 downto 0);
signal wave_in : std_logic;
signal wave_out : std_logic;
signal no_edge_detect : std_logic;
signal ovf_error : std_logic;
--
signal passed : boolean;
signal failed : boolean;
signal test_completed : boolean := false;
--
signal wave_in_rst : std_logic;
signal wave_in_upd : std_logic;
signal wave_ref : std_logic;
signal wave_ref_rst : std_logic;
signal wave_ref_upd : std_logic;
signal wave_running : std_logic;
signal wave_completed : std_logic;
signal wave_in_completed : std_logic;
signal wave_ref_completed : std_logic;
signal wave_init : std_logic;
signal wave_init_d : std_logic;
signal delay_cnt : natural;
signal div_cnt_in : natural;
signal wave_in_cnt : natural;
signal div_cnt_ref : natural;
signal wave_ref_cnt : natural;
signal set_ext_time : std_logic;
signal ext_time_init : std_logic_vector(31 downto 0);
signal ext_time_upd_cnt : natural;
shared variable error_flag : boolean;
begin -- behav
-- clock generation
clk <= not clk after 0.5*clk_period;
-----------------------------------------------------------------------------
-- UUT
-----------------------------------------------------------------------------
iUUT : entity work.queue_and_delay
generic map (
use_ext_time => USE_EXT_TIME,
queue_size => 128)
port map (
rstN => reset_n,
clk => clk,
init => init,
cnt_dir => cnt_dir,
delay => delay,
ext_time => ext_time,
wave_in => wave_in,
wave_out => wave_out,
no_edge_detect => no_edge_detect,
ovf_error => ovf_error);
-----------------------------------------------------------------------------
-- Stimuli generator and output checker
-----------------------------------------------------------------------------
-- Generate the ext_time reference
pEXT_TIME_GEN : process(clk)
begin
if(clk = '1' and clk'event) then
/*
if(set_ext_time = '1' or ext_time_upd_cnt = EXT_TIME_PERIOD-1) then
ext_time_upd_cnt <= 0;
else
ext_time_upd_cnt <= ext_time_upd_cnt + 1;
end if;
*/
ext_time_upd_cnt <= 0;
if(set_ext_time = '1') then
ext_time <= ext_time_init;
else
if(cnt_dir = '0' and ext_time_upd_cnt = 0) then
if(ext_time_upd_cnt = 0) then
ext_time <= std_logic_vector(unsigned(ext_time)+1);
end if;
else
if(ext_time_upd_cnt = 0) then
ext_time <= std_logic_vector(unsigned(ext_time)-1);
end if;
end if;
end if;
end if;
end process pEXT_TIME_GEN;
-- Use a first lfsr to generate the a random input waveform, to be delayed,
-- and a second lfsr, to be compared against the output of the Q&D block.
-- The second lfsr starts the generation after the programmed delay
iWAVE_IN_GEN: entity work.lfsr_6
port map (
clk => clk,
lfsr_rst => wave_in_rst,
lfsr_upd => wave_in_upd,
lfsr_reg => open,
lfsr_out => wave_in);
iWAVE_REF_GEN: entity work.lfsr_6
port map (
clk => clk,
lfsr_rst => wave_ref_rst,
lfsr_upd => wave_ref_upd,
lfsr_reg => open,
lfsr_out => wave_ref);
-- The logic down below drive the two LFSRs, and make sure the second one,
-- used as a reference, is delayed of the same amount used in the Q&D block.
-- The full LFSR pattern is automatically generated each time wave_init is asserted
pRUN_WAVES : process(reset_n, clk)
begin
if(reset_n = '0') then
wave_in_rst <= '0';
wave_in_upd <= '0';
wave_ref_rst <= '0';
wave_ref_upd <= '0';
wave_running <= '0';
elsif(clk = '1' and clk'event) then
wave_in_upd <= '0';
wave_ref_upd <= '0';
wave_init_d <= wave_init;
if(wave_init = '1') then
wave_in_rst <= '1';
wave_ref_rst <= '1';
else
wave_in_rst <= '0';
wave_ref_rst <= '0';
end if;
if(wave_init = '1' or wave_completed = '1') then
wave_running <= '0';
elsif(wave_init_d = '1') then
wave_running <= '1';
end if;
if(wave_init_d = '1' or div_cnt_in = WAVE_UPD_PERIOD-1) then
div_cnt_in <= 0;
if(wave_running = '1' and wave_in_cnt <= 63) then
wave_in_upd <= '1';
end if;
else
div_cnt_in <= div_cnt_in + 1;
end if;
if(wave_init = '1') then
wave_in_cnt <= 0;
elsif(wave_in_upd = '1') then
wave_in_cnt <= wave_in_cnt + 1;
end if;
if(wave_init_d = '1') then
if(USE_EXT_TIME = false) then
delay_cnt <= to_integer(unsigned(delay)) + DELAY_ERROR;
else
delay_cnt <= to_integer(unsigned(delay)) + DELAY_ERROR+1;
end if;
elsif(delay_cnt /= 0) then
delay_cnt <= delay_cnt - 1;
end if;
if(wave_init_d = '1' or div_cnt_ref = WAVE_UPD_PERIOD-1) then
div_cnt_ref <= 0;
if(wave_running = '1' and delay_cnt = 0 and wave_ref_cnt <= 63) then
wave_ref_upd <= '1';
end if;
elsif(delay_cnt = 0) then
div_cnt_ref <= div_cnt_ref + 1;
end if;
if(wave_init = '1') then
wave_ref_cnt <= 0;
elsif(wave_ref_upd = '1') then
wave_ref_cnt <= wave_ref_cnt + 1;
end if;
end if;
end process pRUN_WAVES;
wave_in_completed <= '1' when wave_in_cnt = 63 else '0';
wave_ref_completed <= '1' when wave_ref_cnt = 63 else '0';
wave_completed <= wave_ref_completed;
pERROR_CHECK : process(clk)
begin
if(clk = '1' and clk'event) then
if(wave_running = '1' and delay_cnt = 0 and wave_completed = '0') then
if(wave_out /= wave_ref) then
log("ERROR : Detected difference between wave_out and wave_ref", VLOW);
error_flag := true;
end if;
end if;
end if;
end process pERROR_CHECK;
-----------------------------------------------------------------------------
-- Test the block via configuration & control through the C&S bus
-----------------------------------------------------------------------------
pTB_CTRL : process
variable rv : RandomPType;
variable loop_iteration : natural;
alias internal_time is <<signal iUUT.int_time : std_logic_vector >>;
begin
passed <= false;
--
error_flag := false;
--Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
log_separator_line(VMEDIUM);
log("Queue&Delay Test - USE_EXT_TIME set to " & to_string(USE_EXT_TIME) & ".", VLOW);
log_separator_line(VMEDIUM);
init <= '0';
cnt_dir <= '0';
no_edge_detect <= '0';
delay <= (others => '0');
set_ext_time <= '0';
ext_time_init <= (others => '0');
--
wave_init <= '0';
-- Apply reset
reset_n <= '0';
wait for 20*clk_period;
--
wait for 10*clk_period;
wait until clk = '1' and clk'event;
reset_n <= '1';
-- Drive the Q&D block with the waveform generated by the LFSR.
-- Repeat many times, forcing each time a different initial value
-- in the Q&D internal time counter
log("Test with internal time reference:", VLOW);
log_separator_line(VMEDIUM);
for delay_idx in 1 to DELAY_TEST_NUM loop
delay <= std_logic_vector(to_unsigned(rv.RandInt(5, 100), 32));
log("Delay value set to " & to_string(to_integer(unsigned(delay))) & ":", VMEDIUM);
loop_iteration := 1;
if(USE_EXT_TIME = false) then
for int_time_msb_idx in 0 to 7 loop
for int_time_lsb_idx in 0 to 127 loop
internal_time <= force (std_logic_vector(to_unsigned(int_time_msb_idx, 3)) & 22x"3FFFFF" & std_logic_vector(to_unsigned(int_time_lsb_idx, 7)));
wait until clk = '1' and clk'event;
log("Iteration #" & to_string(loop_iteration) & ": starting with internal-time " & to_hstring(internal_time), VMEDIUM);
wait until clk = '1' and clk'event;
internal_time <= release;
wait for 10*clk_period;
wave_init <= '1';
--delay <= std_logic_vector(to_unsigned(20, 32));
wait until clk = '1' and clk'event;
wave_init <= '0';
wait until wave_completed = '1';
wait for 10*clk_period;
loop_iteration := loop_iteration + 1;
end loop; -- int_time_lsb_idx
end loop; -- int_time_msb_idx
end if; -- USE_EXT_TIME = false
if(USE_EXT_TIME = true) then
log_separator_line(VMEDIUM);
log("Test with external time reference - Positive count direction:", VLOW);
log_separator_line(VMEDIUM);
no_edge_detect <= '1';
for ext_time_msb_idx in 0 to 7 loop
for ext_time_lsb_idx in 0 to 127 loop
ext_time_init <= std_logic_vector(to_unsigned(ext_time_msb_idx, 3)) & 22x"3FFFFF" & std_logic_vector(to_unsigned(ext_time_lsb_idx, 7));
set_ext_time <= '1';
wait until clk = '1' and clk'event;
set_ext_time <= '0';
log("Iteration #" & to_string(loop_iteration) & ": starting with external-time " & to_hstring(ext_time_init), VMEDIUM);
wait until clk = '1' and clk'event;
wait for 10*clk_period;
wave_init <= '1';
--delay <= std_logic_vector(to_unsigned(20, 32));
wait until clk = '1' and clk'event;
wave_init <= '0';
wait until wave_completed = '1';
wait for 10*clk_period;
loop_iteration := loop_iteration + 1;
end loop; -- ext_time_lsb_idx
end loop; -- ext_time_msb_idx
log_separator_line(VMEDIUM);
log("Test with external time reference - Negative count direction:", VLOW);
log_separator_line(VMEDIUM);
cnt_dir <= '1';
for ext_time_msb_idx in 0 to 7 loop
for ext_time_lsb_idx in 0 to 127 loop
ext_time_init <= std_logic_vector(to_unsigned(ext_time_msb_idx, 3)) & 22x"0" & std_logic_vector(to_unsigned(ext_time_lsb_idx, 7));
set_ext_time <= '1';
wait until clk = '1' and clk'event;
set_ext_time <= '0';
log("Iteration #" & to_string(loop_iteration) & ": starting with external-time " & to_hstring(ext_time_init), VMEDIUM);
wait until clk = '1' and clk'event;
wait for 10*clk_period;
wave_init <= '1';
--delay <= std_logic_vector(to_unsigned(20, 32));
wait until clk = '1' and clk'event;
wave_init <= '0';
wait until wave_completed = '1';
wait for 10*clk_period;
loop_iteration := loop_iteration + 1;
end loop; -- ext_time_lsb_idx
end loop; -- ext_time_msb_idx
end if; -- USE_EXT_TIME = true
end loop; -- delay_idx
--
wait for 10*clk_period;
if(error_flag = false) then
passed <= true;
end if;
---------------------------------------------------------------------------
-- End of Testing
---------------------------------------------------------------------------
wait;
end process pTB_CTRL;
pERROR_MONITOR : process
begin
wait for 10*clk_period;
if(error_flag = true) then
failed <= true;
wait;
end if;
end process pERROR_MONITOR;
pREPORT_RESULT : process
begin
wait until failed = true or passed = true;
wait for 1 us;
log_separator_line(VLOW);
if(failed = true) then
log("FAILURE: test completed with errors.", VLOW);
elsif(passed = true) then
log("SUCCESS: test successfully completed.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
end process pREPORT_RESULT;
end behav;

View file

@ -0,0 +1,621 @@
-- -------------------------------------------------------------------
-- Design:
--
-- Package for VHDL text output
--
-- Note:
-- -----
-- This package uses the VHDL 95 standard.
-- If VHDL 95 is not supported by your simulator
-- you need to comment out the file access functions.
--
-- The package provides a means to output text and
-- manipulate strings.
--
-- The basic usage is like this: >> print(s); <<
-- (where s is any string)
-- To print something which is not a string it has to be converted
-- into a string first. For this purpose the package contains
-- conversion functions called >> str(...) <<.
-- For example a std_logic_vector slv would be printed like this:
-- >> print(str(slv)); <<. To print several items on one line the
-- items have to concatenated as strings with the "&" operator eg:
-- >> print("The value of slv is "& str(slv)); <<
-- The string functions can also be used in assert statements as shown
-- in the example below:
-- >> assert DIN = "0101" <<
-- >> report "DIN = "& str(DIN)& " expected 0101 " <<
-- >> severity Error; <<
--
--
--
-- -------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use std.textio.all;
package txt_util is
-- prints a message to the screen
procedure print(text: string);
-- prints the message when active
-- useful for debug switches
procedure print(active: boolean; text: string);
-- converts std_logic into a character
function chr(sl: std_logic) return character;
-- converts std_logic into a string (1 to 1)
function str(sl: std_logic) return string;
-- converts std_logic_vector into a string (binary base)
function str(slv: std_logic_vector) return string;
-- converts boolean into a string
function str(b: boolean) return string;
-- converts an integer into a single character
-- (can also be used for hex conversion and other bases)
function chr(int: integer) return character;
-- converts integer into string using specified base
function str(int: integer; base: integer) return string;
-- converts integer to string, using base 10
function str(int: integer) return string;
-- convert std_logic_vector into a string in hex format
function hstr(slv: std_logic_vector) return string;
-- functions to manipulate strings
-----------------------------------
-- convert a character to upper case
function to_upper(c: character) return character;
-- convert a character to lower case
function to_lower(c: character) return character;
-- convert a string to upper case
function to_upper(s: string) return string;
-- convert a string to lower case
function to_lower(s: string) return string;
-- functions to convert strings into other formats
--------------------------------------------------
-- converts a character into std_logic
function to_std_logic(c: character) return std_logic;
-- converts a string into std_logic_vector
function to_std_logic_vector(s: string) return std_logic_vector;
-- file I/O
-----------
-- read variable length string from input file
procedure str_read(file in_file: TEXT;
res_string: out string);
-- print string to a file and start new line
procedure print(file out_file: TEXT;
new_string: in string);
-- print character to a file and start new line
procedure print(file out_file: TEXT;
char: in character);
end txt_util;
package body txt_util is
-- prints text to the screen
procedure print(text: string) is
variable msg_line: line;
begin
write(msg_line, text);
writeline(output, msg_line);
end print;
-- prints text to the screen when active
procedure print(active: boolean; text: string) is
begin
if active then
print(text);
end if;
end print;
-- converts std_logic into a character
function chr(sl: std_logic) return character is
variable c: character;
begin
case sl is
when 'U' => c:= 'U';
when 'X' => c:= 'X';
when '0' => c:= '0';
when '1' => c:= '1';
when 'Z' => c:= 'Z';
when 'W' => c:= 'W';
when 'L' => c:= 'L';
when 'H' => c:= 'H';
when '-' => c:= '-';
end case;
return c;
end chr;
-- converts std_logic into a string (1 to 1)
function str(sl: std_logic) return string is
variable s: string(1 to 1);
begin
s(1) := chr(sl);
return s;
end str;
-- converts std_logic_vector into a string (binary base)
-- (this also takes care of the fact that the range of
-- a string is natural while a std_logic_vector may
-- have an integer range)
function str(slv: std_logic_vector) return string is
variable result : string (1 to slv'length);
variable r : integer;
begin
r := 1;
for i in slv'range loop
result(r) := chr(slv(i));
r := r + 1;
end loop;
return result;
end str;
function str(b: boolean) return string is
begin
if b then
return "true";
else
return "false";
end if;
end str;
-- converts an integer into a character
-- for 0 to 9 the obvious mapping is used, higher
-- values are mapped to the characters A-Z
-- (this is usefull for systems with base > 10)
-- (adapted from Steve Vogwell's posting in comp.lang.vhdl)
function chr(int: integer) return character is
variable c: character;
begin
case int is
when 0 => c := '0';
when 1 => c := '1';
when 2 => c := '2';
when 3 => c := '3';
when 4 => c := '4';
when 5 => c := '5';
when 6 => c := '6';
when 7 => c := '7';
when 8 => c := '8';
when 9 => c := '9';
when 10 => c := 'A';
when 11 => c := 'B';
when 12 => c := 'C';
when 13 => c := 'D';
when 14 => c := 'E';
when 15 => c := 'F';
when 16 => c := 'G';
when 17 => c := 'H';
when 18 => c := 'I';
when 19 => c := 'J';
when 20 => c := 'K';
when 21 => c := 'L';
when 22 => c := 'M';
when 23 => c := 'N';
when 24 => c := 'O';
when 25 => c := 'P';
when 26 => c := 'Q';
when 27 => c := 'R';
when 28 => c := 'S';
when 29 => c := 'T';
when 30 => c := 'U';
when 31 => c := 'V';
when 32 => c := 'W';
when 33 => c := 'X';
when 34 => c := 'Y';
when 35 => c := 'Z';
when others => c := '?';
end case;
return c;
end chr;
-- convert integer to string using specified base
-- (adapted from Steve Vogwell's posting in comp.lang.vhdl)
function str(int: integer; base: integer) return string is
variable temp: string(1 to 10);
variable num: integer;
variable abs_int: integer;
variable len: integer := 1;
variable power: integer := 1;
begin
-- bug fix for negative numbers
abs_int := abs(int);
num := abs_int;
while num >= base loop -- Determine how many
len := len + 1; -- characters required
num := num / base; -- to represent the
end loop ; -- number.
for i in len downto 1 loop -- Convert the number to
temp(i) := chr(abs_int/power mod base); -- a string starting
power := power * base; -- with the right hand
end loop ; -- side.
-- return result and add sign if required
if int < 0 then
return '-'& temp(1 to len);
else
return temp(1 to len);
end if;
end str;
-- convert integer to string, using base 10
function str(int: integer) return string is
begin
return str(int, 10) ;
end str;
-- converts a std_logic_vector into a hex string.
function hstr(slv: std_logic_vector) return string is
variable hexlen: integer;
variable longslv : std_logic_vector(67 downto 0) := (others => '0');
variable hex : string(1 to 16);
variable fourbit : std_logic_vector(3 downto 0);
begin
hexlen := (slv'left+1)/4;
if (slv'left+1) mod 4 /= 0 then
hexlen := hexlen + 1;
end if;
longslv(slv'left downto 0) := slv;
for i in (hexlen -1) downto 0 loop
fourbit := longslv(((i*4)+3) downto (i*4));
case fourbit is
when "0000" => hex(hexlen -I) := '0';
when "0001" => hex(hexlen -I) := '1';
when "0010" => hex(hexlen -I) := '2';
when "0011" => hex(hexlen -I) := '3';
when "0100" => hex(hexlen -I) := '4';
when "0101" => hex(hexlen -I) := '5';
when "0110" => hex(hexlen -I) := '6';
when "0111" => hex(hexlen -I) := '7';
when "1000" => hex(hexlen -I) := '8';
when "1001" => hex(hexlen -I) := '9';
when "1010" => hex(hexlen -I) := 'A';
when "1011" => hex(hexlen -I) := 'B';
when "1100" => hex(hexlen -I) := 'C';
when "1101" => hex(hexlen -I) := 'D';
when "1110" => hex(hexlen -I) := 'E';
when "1111" => hex(hexlen -I) := 'F';
when "ZZZZ" => hex(hexlen -I) := 'z';
when "UUUU" => hex(hexlen -I) := 'u';
when "XXXX" => hex(hexlen -I) := 'x';
when others => hex(hexlen -I) := '?';
end case;
end loop;
return hex(1 to hexlen);
end hstr;
-- functions to manipulate strings
-----------------------------------
-- convert a character to upper case
function to_upper(c: character) return character is
variable u: character;
begin
case c is
when 'a' => u := 'A';
when 'b' => u := 'B';
when 'c' => u := 'C';
when 'd' => u := 'D';
when 'e' => u := 'E';
when 'f' => u := 'F';
when 'g' => u := 'G';
when 'h' => u := 'H';
when 'i' => u := 'I';
when 'j' => u := 'J';
when 'k' => u := 'K';
when 'l' => u := 'L';
when 'm' => u := 'M';
when 'n' => u := 'N';
when 'o' => u := 'O';
when 'p' => u := 'P';
when 'q' => u := 'Q';
when 'r' => u := 'R';
when 's' => u := 'S';
when 't' => u := 'T';
when 'u' => u := 'U';
when 'v' => u := 'V';
when 'w' => u := 'W';
when 'x' => u := 'X';
when 'y' => u := 'Y';
when 'z' => u := 'Z';
when others => u := c;
end case;
return u;
end to_upper;
-- convert a character to lower case
function to_lower(c: character) return character is
variable l: character;
begin
case c is
when 'A' => l := 'a';
when 'B' => l := 'b';
when 'C' => l := 'c';
when 'D' => l := 'd';
when 'E' => l := 'e';
when 'F' => l := 'f';
when 'G' => l := 'g';
when 'H' => l := 'h';
when 'I' => l := 'i';
when 'J' => l := 'j';
when 'K' => l := 'k';
when 'L' => l := 'l';
when 'M' => l := 'm';
when 'N' => l := 'n';
when 'O' => l := 'o';
when 'P' => l := 'p';
when 'Q' => l := 'q';
when 'R' => l := 'r';
when 'S' => l := 's';
when 'T' => l := 't';
when 'U' => l := 'u';
when 'V' => l := 'v';
when 'W' => l := 'w';
when 'X' => l := 'x';
when 'Y' => l := 'y';
when 'Z' => l := 'z';
when others => l := c;
end case;
return l;
end to_lower;
-- convert a string to upper case
function to_upper(s: string) return string is
variable uppercase: string (s'range);
begin
for i in s'range loop
uppercase(i):= to_upper(s(i));
end loop;
return uppercase;
end to_upper;
-- convert a string to lower case
function to_lower(s: string) return string is
variable lowercase: string (s'range);
begin
for i in s'range loop
lowercase(i):= to_lower(s(i));
end loop;
return lowercase;
end to_lower;
-- functions to convert strings into other types
-- converts a character into a std_logic
function to_std_logic(c: character) return std_logic is
variable sl: std_logic;
begin
case c is
when 'U' =>
sl := 'U';
when 'X' =>
sl := 'X';
when '0' =>
sl := '0';
when '1' =>
sl := '1';
when 'Z' =>
sl := 'Z';
when 'W' =>
sl := 'W';
when 'L' =>
sl := 'L';
when 'H' =>
sl := 'H';
when '-' =>
sl := '-';
when others =>
sl := 'X';
end case;
return sl;
end to_std_logic;
-- converts a string into std_logic_vector
function to_std_logic_vector(s: string) return std_logic_vector is
variable slv: std_logic_vector(s'high-s'low downto 0);
variable k: integer;
begin
k := s'high-s'low;
for i in s'range loop
slv(k) := to_std_logic(s(i));
k := k - 1;
end loop;
return slv;
end to_std_logic_vector;
----------------
-- file I/O --
----------------
-- read variable length string from input file
procedure str_read(file in_file: TEXT;
res_string: out string) is
variable l: line;
variable c: character;
variable is_string: boolean;
begin
readline(in_file, l);
-- clear the contents of the result string
for i in res_string'range loop
res_string(i) := ' ';
end loop;
-- read all characters of the line, up to the length
-- of the results string
for i in res_string'range loop
read(l, c, is_string);
res_string(i) := c;
if not is_string then -- found end of line
exit;
end if;
end loop;
end str_read;
-- print string to a file
procedure print(file out_file: TEXT;
new_string: in string) is
variable l: line;
begin
write(l, new_string);
writeline(out_file, l);
end print;
-- print character to a file and start new line
procedure print(file out_file: TEXT;
char: in character) is
variable l: line;
begin
write(l, char);
writeline(out_file, l);
end print;
-- appends contents of a string to a file until line feed occurs
-- (LF is considered to be the end of the string)
procedure str_write(file out_file: TEXT;
new_string: in string) is
begin
for i in new_string'range loop
print(out_file, new_string(i));
if new_string(i) = LF then -- end of string
exit;
end if;
end loop;
end str_write;
end txt_util;

View file

@ -0,0 +1,189 @@
-------------------------------------------------------------------------------
-- Title : uart_rx
-- Project : EMB-1
-------------------------------------------------------------------------------
-- File : uart_rx.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2016-10-24
-- Last update: 2018-09-12
-- SVN ID : Git
-- Standard : VHDL'08
-------------------------------------------------------------------------------
-- Description:
-- Simple UART receiver, used to receive data over the POF, 1 start, 1 stop
-- bit, no parity
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity uart_rx is
generic(
data_width : natural range 1 to 31);
port(
reset_n : in std_logic;
clk : in std_logic;
bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit
init : in std_logic;
data_out : out std_logic_vector(data_width-1 downto 0);
data_out_valid : out std_logic;
rx_error : out std_logic;
rx_data : in std_logic);
end entity uart_rx;
architecture rtl of uart_rx is
component sync_wire
generic (
rst_val : std_logic;
sync_stages : positive);
port (
rstN : in std_logic;
clk : in std_logic;
async_in : in std_logic;
sync_out : out std_logic);
end component;
type fsm_state_t is (s_init, s_idle, s_get_start_bit, s_get_data, s_get_stop_bit);
signal fsm_state_curr, fsm_state_next : fsm_state_t;
--
signal rx_data_i, shf_data, rst_bit_cnt, inc_bit_cnt : std_logic;
signal rst_clk_cnt, end_of_bit, end_of_rx, data_valid : std_logic;
signal stop_bit, rx_error_i : std_logic;
--
signal data : std_logic_vector(data_width-1 downto 0);
signal clk_cnt : std_logic_vector(3 downto 0);
signal bit_cnt : std_logic_vector(5 downto 0);
begin
-----------------------------------------------------------------------------
-- Input Synchronization
-----------------------------------------------------------------------------
iSYNC_IN : sync_wire
generic map (
rst_val => '1',
sync_stages => 3)
port map (
rstN => reset_n,
clk => clk,
async_in => rx_data,
sync_out => rx_data_i);
-----------------------------------------------------------------------------
-- UART registers and sequential logic
-----------------------------------------------------------------------------
pREGs : process(clk)
begin
if(clk ='1' and clk'event) then
if(rst_bit_cnt = '1') then
bit_cnt <= (others => '0');
elsif(inc_bit_cnt = '1') then
bit_cnt <= std_logic_vector(unsigned(bit_cnt)+1);
end if;
if(rst_clk_cnt = '1' or end_of_bit = '1') then
clk_cnt <= (others => '0');
else
clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1);
end if;
if(rst_clk_cnt = '1') then
data <= (others => '0');
elsif(shf_data = '1') then
data <= rx_data_i & data(data'high downto 1);
end if;
data_out_valid <= data_valid;
if(init = '1') then
data_out <= (others => '0');
elsif(data_valid = '1') then
data_out <= data;
end if;
rx_error <= rx_error_i;
end if;
end process pREGs;
end_of_bit <= '1' when unsigned(clk_cnt) = (unsigned(bit_div)-1) else '0';
end_of_rx <= '1' when unsigned(bit_cnt) = data_width else '0';
--shf_data <= '1' when unsigned(clk_cnt) = 1 and stop_bit = '0' else '0';
shf_data <= '1' when unsigned(clk_cnt) = (unsigned(bit_div(bit_div'high downto 1))-1) and stop_bit = '0' else '0';
-----------------------------------------------------------------------------
-- FSM
-----------------------------------------------------------------------------
-- FSM state register
pFSM_SR : process(clk)
begin
if(clk = '1' and clk'event) then
if(init = '1') then
fsm_state_curr <= s_init;
else
fsm_state_curr <= fsm_state_next;
end if;
end if;
end process pFSM_SR;
-- FSM Combinational Logic
pFSM_CL : process(fsm_state_curr, rx_data_i, end_of_bit, end_of_rx)
begin
--default assignments
rst_clk_cnt <= '0';
rst_bit_cnt <= '0';
inc_bit_cnt <= '0';
data_valid <= '0';
stop_bit <= '0';
rx_error_i <= '0';
--
fsm_state_next <= fsm_state_curr;
case fsm_state_curr is
when s_init =>
if(rx_data_i = '1') then
fsm_state_next <= s_idle;
end if;
when s_idle =>
if(rx_data_i = '0') then
rst_clk_cnt <= '1';
rst_bit_cnt <= '1';
fsm_state_next <= s_get_start_bit;
end if;
when s_get_start_bit =>
if(end_of_bit = '1') then
inc_bit_cnt <= '1';
fsm_state_next <= s_get_data;
end if;
when s_get_data =>
if(end_of_bit = '1') then
inc_bit_cnt <= '1';
if(end_of_rx = '1') then
fsm_state_next <= s_get_stop_bit;
end if;
end if;
when s_get_stop_bit =>
stop_bit <= '1';
if(end_of_bit = '1') then
if(rx_data_i = '1') then
data_valid <= '1';
fsm_state_next <= s_idle;
else
rx_error_i <= '1';
fsm_state_next <= s_init;
end if;
end if;
when others => null;
end case;
end process pFSM_CL;
end architecture rtl;

View file

@ -0,0 +1,164 @@
-------------------------------------------------------------------------------
-- Title : uart_tx
-- Project : EMB-1
-------------------------------------------------------------------------------
-- File : uart_tx.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2016-10-24
-- Last update: 2017-10-19
-- SVN ID : Git
-- Standard : VHDL'08
-------------------------------------------------------------------------------
-- Description:
-- Simple UART trasmitter, used to trasmit data over the POF, 1 start, 1 stop
-- bit, no parity
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity uart_tx is
generic(
data_width : natural range 1 to 31);
port(
reset_n : in std_logic;
clk : in std_logic;
bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit
init : in std_logic;
ready : out std_logic;
data_in : in std_logic_vector(data_width-1 downto 0);
data_valid : in std_logic;
tx_data : out std_logic);
end entity uart_tx;
architecture rtl of uart_tx is
type fsm_state_t is (idle, send_start_bit, send_data, send_stop_bit);
signal fsm_state_curr, fsm_state_next : fsm_state_t;
--
signal ld_data, shf_data, rst_bit_cnt, inc_bit_cnt : std_logic;
signal rst_clk_cnt, end_of_bit, end_of_tx : std_logic;
signal rst_tx_data, set_tx_data, ld_tx_data : std_logic;
signal ready_i : std_logic;
--
signal data : std_logic_vector(data_width-1 downto 0);
signal clk_cnt : std_logic_vector(3 downto 0);
signal bit_cnt : std_logic_vector(5 downto 0);
begin
-----------------------------------------------------------------------------
-- UART registers and sequential logic
-----------------------------------------------------------------------------
pREGs : process(clk)
begin
if(clk ='1' and clk'event) then
if(ld_data = '1') then
data <= data_in;
elsif(shf_data = '1') then
data <= '0' & data(data'high downto 1);
end if;
if(rst_bit_cnt = '1') then
bit_cnt <= (others => '0');
elsif(inc_bit_cnt = '1') then
bit_cnt <= std_logic_vector(unsigned(bit_cnt)+1);
end if;
if(rst_clk_cnt = '1' or end_of_bit = '1') then
clk_cnt <= (others => '0');
else
clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1);
end if;
if(rst_tx_data = '1') then
tx_data <= '0';
elsif(set_tx_data = '1') then
tx_data <= '1';
elsif(ld_tx_data = '1') then
tx_data <= data(0);
end if;
end if;
end process pREGs;
end_of_bit <= '1' when unsigned(clk_cnt) = (unsigned(bit_div)-1) else '0';
end_of_tx <= '1' when unsigned(bit_cnt) = data_width else '0';
--shf_data <= inc_bit_cnt;
shf_data <= ld_tx_data;
inc_bit_cnt <= ld_tx_data;
-----------------------------------------------------------------------------
-- FSM
-----------------------------------------------------------------------------
-- FSM state register
pFSM_SR : process(reset_n, clk)
begin
if(reset_n = '0') then
fsm_state_curr <= idle;
elsif(clk = '1' and clk'event) then
fsm_state_curr <= fsm_state_next;
end if;
end process pFSM_SR;
-- FSM Combinational Logic
pFSM_CL : process(fsm_state_curr, init, data_valid, end_of_bit, end_of_tx)
begin
--default assignments
ready_i <= '0';
rst_clk_cnt <= '0';
rst_tx_data <= '0';
set_tx_data <= '0';
ld_tx_data <= '0';
rst_bit_cnt <= '0';
ld_data <= '0';
--
fsm_state_next <= fsm_state_curr;
if(init = '1') then
set_tx_data <= '1';
fsm_state_next <= idle;
else
case fsm_state_curr is
when idle =>
ready_i <= '1';
ld_data <= '1';
rst_clk_cnt <= '1';
rst_bit_cnt <= '1';
set_tx_data <= '1';
if(data_valid = '1') then
rst_tx_data <= '1';
fsm_state_next <= send_start_bit;
end if;
when send_start_bit =>
if(end_of_bit = '1') then
ld_tx_data <= '1';
fsm_state_next <= send_data;
end if;
when send_data =>
if(end_of_bit = '1') then
ld_tx_data <= '1';
if(end_of_tx = '1') then
set_tx_data <= '1';
fsm_state_next <= send_stop_bit;
end if;
end if;
when send_stop_bit =>
if(end_of_bit = '1') then
fsm_state_next <= idle;
end if;
when others => null;
end case;
end if;
end process pFSM_CL;
ready <= ready_i;
end architecture rtl;

View file

@ -0,0 +1,9 @@
# Compile the code into the appropriate libraries
foreach lib [list work tb_pkg] {
file delete -force -- $lib
vlib $lib
}
vlog -quiet glbl.v -work work
vcom -quiet -2008 -f files.tcl -work work
vlog -quiet ../src/efinix/efx_fifo.v -work work

View file

@ -0,0 +1,18 @@
../../0/src/common_pkg.vhd
../../0/src/sync_pulse.vhd
../../1/src/vendor_pkg_1.vhd
../src/altera/alt_async_fifo_1.vhd
../src/inferred/inferred_async_fifo_1.vhd
../src/shim/async_fifo_1.vhd
tb_async_fifo.vhd
../src/altera/alt_sync_fifo_1.vhd
../src/inferred/inferred_sync_fifo_1.vhd
../src/shim/sync_fifo_1.vhd
tb_sync_fifo.vhd
../src/inferred/inferred_dpram_1.vhd
../src/altera/alt_dp_ram_1.vhd
../src/shim/dp_ram_1.vhd
tb_dp_ram.vhd
../src/altera/alt_rw_dp_ram_1.vhd
../src/shim/rw_dp_ram_1.vhd
tb_rw_dp_ram.vhd

View file

@ -0,0 +1,84 @@
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/verunilibs/data/glbl.v,v 1.14 2010/10/28 20:44:00 fphillip Exp $
`ifndef GLBL
`define GLBL
`timescale 1 ps / 1 ps
module glbl ();
parameter ROC_WIDTH = 100000;
parameter TOC_WIDTH = 0;
parameter GRES_WIDTH = 10000;
parameter GRES_START = 10000;
//-------- STARTUP Globals --------------
wire GSR;
wire GTS;
wire GWE;
wire PRLD;
wire GRESTORE;
tri1 p_up_tmp;
tri (weak1, strong0) PLL_LOCKG = p_up_tmp;
wire PROGB_GLBL;
wire CCLKO_GLBL;
wire FCSBO_GLBL;
wire [3:0] DO_GLBL;
wire [3:0] DI_GLBL;
reg GSR_int;
reg GTS_int;
reg PRLD_int;
reg GRESTORE_int;
//-------- JTAG Globals --------------
wire JTAG_TDO_GLBL;
wire JTAG_TCK_GLBL;
wire JTAG_TDI_GLBL;
wire JTAG_TMS_GLBL;
wire JTAG_TRST_GLBL;
reg JTAG_CAPTURE_GLBL;
reg JTAG_RESET_GLBL;
reg JTAG_SHIFT_GLBL;
reg JTAG_UPDATE_GLBL;
reg JTAG_RUNTEST_GLBL;
reg JTAG_SEL1_GLBL = 0;
reg JTAG_SEL2_GLBL = 0 ;
reg JTAG_SEL3_GLBL = 0;
reg JTAG_SEL4_GLBL = 0;
reg JTAG_USER_TDO1_GLBL = 1'bz;
reg JTAG_USER_TDO2_GLBL = 1'bz;
reg JTAG_USER_TDO3_GLBL = 1'bz;
reg JTAG_USER_TDO4_GLBL = 1'bz;
assign (strong1, weak0) GSR = GSR_int;
assign (strong1, weak0) GTS = GTS_int;
assign (weak1, weak0) PRLD = PRLD_int;
assign (strong1, weak0) GRESTORE = GRESTORE_int;
initial begin
GSR_int = 1'b1;
PRLD_int = 1'b1;
#(ROC_WIDTH)
GSR_int = 1'b0;
PRLD_int = 1'b0;
end
initial begin
GTS_int = 1'b1;
#(TOC_WIDTH)
GTS_int = 1'b0;
end
initial begin
GRESTORE_int = 1'b0;
#(GRES_START);
GRESTORE_int = 1'b1;
#(GRES_WIDTH);
GRESTORE_int = 1'b0;
end
endmodule
`endif

View file

@ -0,0 +1,9 @@
To sim
1/. open cmd. Type modelsim
2/. In modelsim transcript : type do compile.do
3/. In modelsim transcript : type vsim work.tb_xxxx glbl
4/. In modelsim transcript : type run 10us.
5/. Test pass prints :"# ** Error: Test complete (Not an Error - just stops testbench)"
Test fails prints :"# ** Failure:"

View file

@ -0,0 +1,309 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
-- Self checking test bench to ensure Xilinx xil_lvds_serdes_tx_2 is functionally equivalent to alt_lvds_serdes_tx_2
library modelsim_lib;
use modelsim_lib.util.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.common_pkg.all;
use STD.textio.all;
--pragma translate_off
--{{{
entity tb_async_fifo is end;
--}}}
--{{{
architecture sim of tb_async_fifo is
constant ALT_DEVICE_FAMILY : string := "Cyclone V";
constant XIL_DEVICE_FAMILY : string := "Ultrascale+";
constant EFX_DEVICE_FAMILY : string := "Efinix T20";
constant DATA_WIDTH : natural range 1 to 256 := 32;
constant DEPTH : natural range 2 to 131072 := 64;
constant SHOWAHEAD : string := "ON"; -- "OFF"
--{{{ signals
signal wrclk : std_logic := '0';
signal rdclk : std_logic := '0';
signal clr : std_logic;
signal wrreq : std_logic;
signal wrdata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal alt_wrusedw : std_logic_vector (log2(DEPTH)-1 downto 0);
signal alt_wrfull : std_logic;
signal xil_wrusedw : std_logic_vector (log2(DEPTH)-1 downto 0);
signal xil_wrfull : std_logic;
signal efx_wrusedw : std_logic_vector (log2(DEPTH)-1 downto 0);
signal efx_wrfull : std_logic;
signal alt_rdempty : std_logic;
signal alt_rdreq : std_logic;
signal alt_rddata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal alt_rdusedw : std_logic_vector (log2(DEPTH)-1 downto 0);
signal xil_rdempty : std_logic;
signal xil_rdreq : std_logic;
signal xil_rddata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal xil_rdusedw : std_logic_vector (log2(DEPTH)-1 downto 0);
signal efx_rdempty : std_logic;
signal efx_rdreq : std_logic;
signal efx_rddata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal efx_rdusedw : std_logic_vector (log2(DEPTH)-1 downto 0);
--}}}
--{{{
component async_fifo_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 64;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON"; -- "OFF"
SYNC_CLR : string := "OFF" -- "ON"
);
port
(
clr : in std_logic := '0';
wrclk : in std_logic ;
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrfull : out std_logic ;
wrusedw : out std_logic_vector (log2(DEPTH)-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
rdusedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
--}}}
--constant mem_depth : integer := 256;
--type mem is array (mem_depth-1 downto 0) of std_logic_vector (NUM_CHANS*SER_FACTOR - 1 DOWNTO 0);
--shared variable test_array : mem;
begin
--{{{
c_alt_async_fifo : async_fifo_1 -- altera version
generic map (
DEVICE_FAMILY => ALT_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
SHOWAHEAD => SHOWAHEAD
)
port map (
clr => clr,
wrclk => wrclk,
wrreq => wrreq,
wrdata => wrdata,
wrfull => alt_wrfull,
wrusedw => alt_wrusedw,
rdclk => rdclk,
rdreq => alt_rdreq,
rddata => alt_rddata,
rdempty => alt_rdempty,
rdusedw => alt_rdusedw
);
--}}}
--{{{
c_xil_async_fifo : async_fifo_1 -- xilinx version
generic map (
DEVICE_FAMILY => XIL_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
SHOWAHEAD => SHOWAHEAD
)
port map (
clr => clr,
wrclk => wrclk,
wrreq => wrreq,
wrdata => wrdata,
wrfull => xil_wrfull,
wrusedw => xil_wrusedw,
rdclk => rdclk,
rdreq => xil_rdreq,
rddata => xil_rddata,
rdempty => xil_rdempty,
rdusedw => xil_rdusedw
);
--}}}
--{{{
c_efx_async_fifo : async_fifo_1 -- efinix version
generic map (
DEVICE_FAMILY => EFX_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
SHOWAHEAD => SHOWAHEAD
)
port map (
clr => clr,
wrclk => wrclk,
wrreq => wrreq,
wrdata => wrdata,
wrfull => efx_wrfull,
wrusedw => efx_wrusedw,
rdclk => rdclk,
rdreq => efx_rdreq,
rddata => efx_rddata,
rdempty => efx_rdempty,
rdusedw => efx_rdusedw
);
--}}}
--{{{
p_wrclk : process
begin
wrclk <= not wrclk;
wait for 5 ns;
--wait for 13 ns;
end process;
--}}}
--{{{
p_rdclk : process
begin
rdclk <= not rdclk;
wait for 10 ns;
end process;
--}}}
--{{{
p_tb : process
begin
clr <= '1';
alt_rdreq <= '0';
xil_rdreq <= '0';
efx_rdreq <= '0';
wrreq <= '0';
wait for 0.1 us;
wait until wrclk'event and wrclk = '1';
clr <= '0' after 0.1 ns;
-- ************ xilinx native fifo takes 28 clocks to recover after reset
for i in 0 to 29 loop
wait until wrclk'event and wrclk = '1';
end loop;
wrreq <= '1' after 0.1 ns;
wait until wrclk'event and wrclk = '1';
wrreq <= '1' after 0.1 ns;
wait until wrclk'event and wrclk = '1';
for i in 0 to 9 loop
wait until wrclk'event and wrclk = '1';
end loop;
wait until rdclk'event and rdclk = '1';
alt_rdreq <= '1' after 0.1 ns;
xil_rdreq <= '1' after 0.1 ns;
efx_rdreq <= '1' after 0.1 ns;
wait until rdclk'event and rdclk = '1';
alt_rdreq <= '0' after 0.1 ns;
xil_rdreq <= '0' after 0.1 ns;
efx_rdreq <= '0' after 0.1 ns;
for i in 0 to 55 loop
wait until wrclk'event and wrclk = '1';
end loop;
wrreq <= '1' after 0.1 ns;
wait until wrclk'event and wrclk = '1';
wait until wrclk'event and wrclk = '1';
wait until wrclk'event and wrclk = '1';
alt_rdreq <= '1' after 0.1 ns;
xil_rdreq <= '1' after 0.1 ns;
efx_rdreq <= '1' after 0.1 ns;
for i in 0 to 55 loop
wait until wrclk'event and wrclk = '1';
end loop;
assert false
report "Test complete (Not an Error - just stops testbench)"
severity error;
wait;
end process;
--}}}
--{{{
p_writedata : process (wrclk, clr)
begin
if clr = '1' then
wrdata <= (others => '0');
elsif rising_edge(wrclk) then
wrdata <= x"12345600" after 0.1 ns;
if wrreq = '1' then
wrdata <= std_logic_vector(unsigned(wrdata)+1) after 0.1 ns;
end if;
end if;
end process;
--}}}
--{{{
--p_tx_in : process
--variable addr : integer;
--begin
--wait until rising_edge(clk);
--if tx_in_enable = '0' then
--addr := 0;
--elsif addr < mem_depth then
--test_array(addr) := tx_in;
--addr := addr + 1;
--end if;
--end process;
--}}}
--{{{
--p_check_alt : process
--variable addr : integer := 0;
--variable mem_data : std_logic_vector (NUM_CHANS*SER_FACTOR - 1 DOWNTO 0);
--variable run : boolean := false;
--begin
--wait until rising_edge(xil_clk);
--if unsigned(xil_data) /= 0 then
--run := true;
--end if;
--if run and addr < mem_depth then
--mem_data := test_array(addr);
--addr := addr + 1;
--assert (mem_data(6 downto 0) = xil_data(6 downto 0))
--report "************Altera Check data Error***************"
--severity error;
--end if;
--end process;
--}}}
--{{{
--p_check_xil : process
--variable addr : integer := 0;
--variable mem_data : std_logic_vector (NUM_CHANS*SER_FACTOR - 1 DOWNTO 0);
--variable run : boolean := false;
--begin
--wait until rising_edge(xil_clk);
--if unsigned(xil_data) /= 0 then
--run := true;
--end if;
--if run and addr < mem_depth then
--mem_data := test_array(addr);
--addr := addr + 1;
--assert (mem_data(6 downto 0) = xil_data(6 downto 0))
--report "************Xilinx Check data Error***************"
--severity error;
--end if;
--end process;
--}}}
end sim;
--}}}
--pragma translate_on

View file

@ -0,0 +1,177 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
-- Self checking test bench to ensure Xilinx xil_lvds_serdes_tx_2 is functionally equivalent to alt_lvds_serdes_tx_2
library modelsim_lib;
use modelsim_lib.util.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.common_pkg.all;
use STD.textio.all;
--pragma translate_off
--{{{
entity tb_dp_ram is end;
--}}}
--{{{
architecture sim of tb_dp_ram is
constant ALT_DEVICE_FAMILY : string := "Cyclone V";
constant XIL_DEVICE_FAMILY : string := "Ultrascale+";
constant DATA_WIDTH : natural range 1 to 256 := 32;
constant DEPTH : natural range 2 to 131072 := 64;
constant REGISTER_OUTPUT : string := "UNREGISTERED";
--constant REGISTER_OUTPUT : string := "CLOCK0";
--constant READ_WRITE_MODE : string := "OLD_DATA";
constant READ_WRITE_MODE : string := "DONT_CARE";
--{{{ signals
signal clk : std_logic := '0';
signal wren : std_logic;
signal wrdata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal wraddr : std_logic_vector (log2(DEPTH)-1 downto 0);
signal rdaddr : std_logic_vector (log2(DEPTH)-1 downto 0);
signal alt_rddata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal xil_rddata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal docheck : boolean := false;
--}}}
--{{{
component dp_ram_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
clk : in std_logic := '1';
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wraddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
wren : in std_logic := '0';
rdaddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end component;
--}}}
begin
--{{{
c_alt_dp_ram : dp_ram_1 -- altera version
generic map (
DEVICE_FAMILY => ALT_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT,
READ_WRITE_MODE => READ_WRITE_MODE
)
port map (
clk => clk,
wren => wren,
wraddr => wraddr,
wrdata => wrdata,
rdaddr => rdaddr,
rddata => alt_rddata
);
--}}}
--{{{
c_xil_dp_ram : dp_ram_1 -- xilinx version
generic map (
DEVICE_FAMILY => XIL_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT
)
port map (
clk => clk,
wren => wren,
wraddr => wraddr,
wrdata => wrdata,
rdaddr => rdaddr,
rddata => xil_rddata
);
--}}}
--{{{
p_clk : process
begin
clk <= not clk;
wait for 13 ns;
end process;
--}}}
--{{{
p_tb : process
begin
docheck <= false;
wren <= '0';
wraddr <= (others => '0');
rdaddr <= (others => '0');
wrdata <= (others => '0');
rdaddr <= (others => '0');
wait for 0.1 us;
wait until clk'event and clk = '1';
wait until clk'event and clk = '1';
wait until clk'event and clk = '1';
wren <= '1' after 0.1 ns;
wrdata <= x"12345678" after 0.1 ns;
wait until clk'event and clk = '1';
wren <= '0' after 0.1 ns;
wrdata <= (others => '0') after 0.1 ns;
docheck <= true after 0.1 ns;
wait until clk'event and clk = '1';
for i in 0 to 9 loop
wren <= '1' after 0.1 ns;
wraddr <= std_logic_vector(unsigned(wraddr)+1) after 0.1 ns;
wrdata <= std_logic_vector(unsigned(wrdata)+1) after 0.1 ns;
wait until clk'event and clk = '1';
wren <= '0' after 0.1 ns;
wait until clk'event and clk = '1';
end loop;
wait until clk'event and clk = '1';
rdaddr <= std_logic_vector(unsigned(rdaddr)+1) after 0.1 ns;
wait until clk'event and clk = '1';
rdaddr <= std_logic_vector(unsigned(rdaddr)+1) after 0.1 ns;
wait until clk'event and clk = '1';
wait until clk'event and clk = '1';
assert false
report "Test complete (Not an Error - just stops testbench)"
severity error;
wait;
end process;
--}}}
--{{{
p_check : process
begin
wait until rising_edge(clk);
if docheck and unsigned(alt_rddata) /= 0 then
assert (alt_rddata = xil_rddata)
report "************Check data Error - Altera and Xilinx different***************"
severity error;
end if;
end process;
--}}}
end sim;
--}}}
--pragma translate_on

View file

@ -0,0 +1,191 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
-- Self checking test bench to ensure Xilinx xil_lvds_serdes_tx_2 is functionally equivalent to alt_lvds_serdes_tx_2
library modelsim_lib;
use modelsim_lib.util.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.common_pkg.all;
use STD.textio.all;
--pragma translate_off
--{{{
entity tb_rw_dp_ram is end;
--}}}
--{{{
architecture sim of tb_rw_dp_ram is
constant ALT_DEVICE_FAMILY : string := "Cyclone V";
constant XIL_DEVICE_FAMILY : string := "Ultrascale+";
constant DATA_WIDTH : natural range 1 to 256 := 32;
constant DEPTH : natural range 2 to 131072 := 64;
constant REGISTER_OUTPUT : string := "UNREGISTERED";
--constant REGISTER_OUTPUT : string := "CLOCK0";
--constant READ_WRITE_MODE : string := "OLD_DATA";
constant READ_WRITE_MODE : string := "DONT_CARE";
--{{{ signals
signal clk : std_logic := '0';
signal wren_a : std_logic;
signal wren_b : std_logic;
signal wrdata_a : std_logic_vector (DATA_WIDTH-1 downto 0);
signal wrdata_b : std_logic_vector (DATA_WIDTH-1 downto 0);
signal addr_a : std_logic_vector (log2(DEPTH)-1 downto 0);
signal addr_b : std_logic_vector (log2(DEPTH)-1 downto 0);
signal alt_rddata_a : std_logic_vector (DATA_WIDTH-1 downto 0);
signal alt_rddata_b : std_logic_vector (DATA_WIDTH-1 downto 0);
signal xil_rddata_a : std_logic_vector (DATA_WIDTH-1 downto 0);
signal xil_rddata_b : std_logic_vector (DATA_WIDTH-1 downto 0);
signal docheck : boolean := false;
--}}}
--{{{
component rw_dp_ram_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
addr_a : in std_logic_vector (log2(DEPTH)-1 downto 0);
addr_b : in std_logic_vector (log2(DEPTH)-1 downto 0);
clk : in std_logic := '1';
wrdata_a : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrdata_b : in std_logic_vector (DATA_WIDTH-1 downto 0);
wren_a : in std_logic := '0';
wren_b : in std_logic := '0';
rddata_a : out std_logic_vector (DATA_WIDTH-1 downto 0);
rddata_b : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end component;
--}}}
begin
--{{{
c_alt_rw_dp_ram : rw_dp_ram_1 -- altera version
generic map (
DEVICE_FAMILY => ALT_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT,
READ_WRITE_MODE => READ_WRITE_MODE
)
port map (
clk => clk,
wren_a => wren_a,
wren_b => wren_b,
addr_a => addr_a,
addr_b => addr_b,
wrdata_a => wrdata_a,
wrdata_b => wrdata_b,
rddata_a => alt_rddata_a,
rddata_b => alt_rddata_b
);
--}}}
--{{{
c_xil_rw_dp_ram : rw_dp_ram_1 -- xilinx version
generic map (
DEVICE_FAMILY => XIL_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT
)
port map (
clk => clk,
wren_a => wren_a,
wren_b => wren_b,
addr_a => addr_a,
addr_b => addr_b,
wrdata_a => wrdata_a,
wrdata_b => wrdata_b,
rddata_a => xil_rddata_a,
rddata_b => xil_rddata_b
);
--}}}
--{{{
p_clk : process
begin
clk <= not clk;
wait for 13 ns;
end process;
--}}}
--{{{
p_tb : process
begin
docheck <= false;
wren_a <= '0';
wren_b <= '0';
addr_a <= (others => '0');
addr_b <= (others => '0');
wrdata_a <= (others => '0');
addr_b <= (others => '0');
wait for 0.1 us;
wait until clk'event and clk = '1';
wait until clk'event and clk = '1';
wait until clk'event and clk = '1';
wren_a <= '1' after 0.1 ns;
wrdata_a <= x"12345678" after 0.1 ns;
wait until clk'event and clk = '1';
wren_a <= '0' after 0.1 ns;
wrdata_a <= (others => '0') after 0.1 ns;
docheck <= true after 0.1 ns;
wait until clk'event and clk = '1';
for i in 0 to 9 loop
wren_a <= '1' after 0.1 ns;
addr_a <= std_logic_vector(unsigned(addr_a)+1) after 0.1 ns;
wrdata_a <= std_logic_vector(unsigned(wrdata_a)+1) after 0.1 ns;
wait until clk'event and clk = '1';
wren_a <= '0' after 0.1 ns;
wait until clk'event and clk = '1';
end loop;
wait until clk'event and clk = '1';
addr_b <= std_logic_vector(unsigned(addr_b)+1) after 0.1 ns;
wait until clk'event and clk = '1';
addr_b <= std_logic_vector(unsigned(addr_b)+1) after 0.1 ns;
wait until clk'event and clk = '1';
wait until clk'event and clk = '1';
assert false
report "Test complete (Not an Error - just stops testbench)"
severity error;
wait;
end process;
--}}}
--{{{
p_check : process
begin
wait until rising_edge(clk);
if docheck and unsigned(alt_rddata_b) /= 0 then
assert (alt_rddata_b = xil_rddata_b)
report "************Check data Error - Altera and Xilinx B port different***************"
severity error;
assert (alt_rddata_a = xil_rddata_a)
report "************Check data Error - Altera and Xilinx A port different***************"
severity error;
end if;
end process;
--}}}
end sim;
--}}}
--pragma translate_on

View file

@ -0,0 +1,336 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
-- Self checking test bench to ensure Xilinx xil_sync_fifo is functionally equivalent to alt_sync_fifo
library modelsim_lib;
use modelsim_lib.util.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.common_pkg.all;
use STD.textio.all;
--pragma translate_off
--{{{
entity tb_sync_fifo is end;
--}}}
--{{{
architecture sim of tb_sync_fifo is
constant ALT_DEVICE_FAMILY : string := "Cyclone V";
constant XIL_DEVICE_FAMILY : string := "Ultrascale+";
constant EFX_DEVICE_FAMILY : string := "Efinix T20";
constant DATA_WIDTH : natural range 1 to 256 := 32;
constant DEPTH : natural range 2 to 131072 := 64;
constant SHOWAHEAD : string := "ON"; -- "OFF"
--constant SHOWAHEAD : string := "OFF"; -- "OFF"
constant CHECKING : string := "ON"; -- "OFF"
constant REGISTER_OUTPUT : string := "ON"; -- "OFF"
constant NEARLY_FULL : natural range 1 to 131072 := 62;
constant NEARLY_EMPTY : natural range 1 to 131072 := 2;
--{{{ signals
signal clk : std_logic := '0';
signal sclr : std_logic;
signal wrreq : std_logic;
signal wrdata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal alt_usedw : std_logic_vector (log2(DEPTH)-1 downto 0);
signal alt_almost_full : std_logic;
signal alt_full : std_logic;
signal xil_usedw : std_logic_vector (log2(DEPTH)-1 downto 0);
signal xil_almost_full : std_logic;
signal xil_full : std_logic;
signal efx_usedw : std_logic_vector (log2(DEPTH)-1 downto 0);
signal efx_almost_full : std_logic;
signal efx_full : std_logic;
signal alt_empty : std_logic;
signal alt_almost_empty : std_logic;
signal alt_rdreq : std_logic;
signal alt_rddata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal xil_empty : std_logic;
signal xil_almost_empty : std_logic;
signal xil_rdreq : std_logic;
signal xil_rddata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal efx_empty : std_logic;
signal efx_almost_empty : std_logic;
signal efx_rdreq : std_logic;
signal efx_rddata : std_logic_vector (DATA_WIDTH-1 downto 0);
signal docheck : boolean;
--}}}
--{{{
component sync_fifo_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 1 to 131072 := 64;
REGISTER_OUTPUT : string := "ON"; -- "OFF"
NEARLY_FULL : natural range 1 to 131072 := 62;
NEARLY_EMPTY : natural range 1 to 131072 := 2;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port
(
clk : in std_logic ;
rst_n : in std_logic := '1';
sclr : in std_logic := '0';
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
almost_full : out std_logic ;
full : out std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
almost_empty : out std_logic ;
empty : out std_logic ;
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
--}}}
--constant mem_depth : integer := 256;
--type mem is array (mem_depth-1 downto 0) of std_logic_vector (NUM_CHANS*SER_FACTOR - 1 DOWNTO 0);
--shared variable test_array : mem;
begin
--{{{
c_alt_sync_fifo : sync_fifo_1 -- altera version
generic map (
DEVICE_FAMILY => ALT_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT,
NEARLY_FULL => NEARLY_FULL,
NEARLY_EMPTY => NEARLY_EMPTY,
SHOWAHEAD => SHOWAHEAD,
CHECKING => CHECKING
)
port map (
sclr => sclr,
clk => clk,
wrreq => wrreq,
wrdata => wrdata,
almost_full => alt_almost_full,
full => alt_full,
rdreq => alt_rdreq,
rddata => alt_rddata,
almost_empty => alt_almost_empty,
empty => alt_empty,
usedw => alt_usedw
);
--}}}
--{{{
c_xil_sync_fifo : sync_fifo_1 -- xilinx version
generic map (
DEVICE_FAMILY => XIL_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT,
NEARLY_FULL => NEARLY_FULL,
NEARLY_EMPTY => NEARLY_EMPTY,
SHOWAHEAD => SHOWAHEAD,
CHECKING => CHECKING
)
port map (
sclr => sclr,
clk => clk,
wrreq => wrreq,
wrdata => wrdata,
almost_full => xil_almost_full,
full => xil_full,
rdreq => xil_rdreq,
rddata => xil_rddata,
almost_empty => xil_almost_empty,
empty => xil_empty,
usedw => xil_usedw
);
--}}}
--{{{
c_efx_sync_fifo : sync_fifo_1 -- xilinx version
generic map (
DEVICE_FAMILY => EFX_DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT,
NEARLY_FULL => NEARLY_FULL,
NEARLY_EMPTY => NEARLY_EMPTY,
SHOWAHEAD => SHOWAHEAD,
CHECKING => CHECKING
)
port map (
sclr => sclr,
clk => clk,
wrreq => wrreq,
wrdata => wrdata,
almost_full => efx_almost_full,
full => efx_full,
rdreq => efx_rdreq,
rddata => efx_rddata,
almost_empty => efx_almost_empty,
empty => efx_empty,
usedw => efx_usedw
);
--}}}
--{{{
p_clk : process
begin
clk <= not clk;
wait for 13 ns;
end process;
--}}}
--{{{
p_tb : process
begin
sclr <= '1';
alt_rdreq <= '0';
xil_rdreq <= '0';
efx_rdreq <= '0';
wrreq <= '0';
wrdata <= (others => '0');
docheck <= false;
wait for 0.1 us;
wait until clk'event and clk = '1';
sclr <= '0' after 0.1 ns;
-- ************ xilinx takes 28 clocks to recover after reset
for i in 0 to 29 loop
wait until clk'event and clk = '1';
end loop;
docheck <= true;
wrreq <= '1' after 0.1 ns;
wrdata <= x"12345678" after 0.1 ns;
wait until clk'event and clk = '1';
wrreq <= '0' after 0.1 ns;
wrdata <= (others => '0') after 0.1 ns;
wait until clk'event and clk = '1';
for i in 0 to 9 loop
wrdata <= std_logic_vector(unsigned(wrdata) + 1) after 0.1 ns;
wrreq <= '1' after 0.1 ns;
wait until clk'event and clk = '1';
wrreq <= '0' after 0.1 ns;
wait until clk'event and clk = '1';
end loop;
wait until clk'event and clk = '1';
alt_rdreq <= '1' after 0.1 ns;
xil_rdreq <= '1' after 0.1 ns;
efx_rdreq <= '1' after 0.1 ns;
wait until clk'event and clk = '1';
alt_rdreq <= '0' after 0.1 ns;
xil_rdreq <= '0' after 0.1 ns;
efx_rdreq <= '0' after 0.1 ns;
for i in 0 to 60 loop
if alt_full = '0' then
wrreq <= '1' after 0.1 ns;
wrdata <= std_logic_vector(unsigned(wrdata) + 1) after 0.1 ns;
end if;
wait until clk'event and clk = '1';
wrreq <= '0' after 0.1 ns;
wait until clk'event and clk = '1';
end loop;
for i in 0 to 66 loop
if alt_empty = '0' then
alt_rdreq <= '1' after 0.1 ns;
xil_rdreq <= '1' after 0.1 ns;
efx_rdreq <= '1' after 0.1 ns;
end if;
wait until clk'event and clk = '1';
alt_rdreq <= '0' after 0.1 ns;
xil_rdreq <= '0' after 0.1 ns;
efx_rdreq <= '0' after 0.1 ns;
wait until clk'event and clk = '1';
end loop;
assert false
report "Test complete (Not an Error - just stops testbench)"
severity error;
wait;
end process;
--}}}
--{{{
p_check : process
begin
wait until rising_edge(clk);
if docheck then
assert (alt_rddata = xil_rddata)
report "************Check data Error - Altera and Xilinx different***************"
severity warning;
assert (alt_full = xil_full)
report "************Check flag full Error - Altera and Xilinx different***************"
severity warning;
assert (alt_almost_full = xil_almost_full)
report "************Check flag almost_full Error - Altera and Xilinx different***************"
severity warning;
assert (alt_almost_empty = xil_almost_empty)
report "************Check flag almost_empty Error - Altera and Xilinx different***************"
severity warning;
assert (alt_empty = xil_empty)
report "************Check flag empty Error - Altera and Xilinx different***************"
severity warning;
assert (alt_usedw = xil_usedw)
report "************Check usedw count Error - Altera and Xilinx different***************"
severity warning;
assert (alt_rddata = efx_rddata or efx_empty = '1') -- efx output is undefined vs altera 0
report "************Check data Error - Altera and Efinix different***************"
severity warning;
assert (alt_full = efx_full)
report "************Check flag full Error - Altera and Efinix different***************"
severity warning;
assert (alt_almost_full = efx_almost_full)
report "************Check flag almost_full Error - Altera and Efinix different***************"
severity warning;
assert (alt_almost_empty = efx_almost_empty)
report "************Check flag almost_empty Error - Altera and Efinix different***************"
severity warning;
assert (alt_empty = efx_empty)
report "************Check flag empty Error - Altera and Efinix different***************"
severity warning;
assert (alt_usedw = efx_usedw)
report "************Check usedw count Error - Altera and Efinix different***************"
severity warning;
end if;
end process;
--}}}
end sim;
--}}}
--pragma translate_on

View file

@ -0,0 +1,86 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /tb_async_fifo/wrclk
add wave -noupdate /tb_async_fifo/rdclk
add wave -noupdate /tb_async_fifo/clr
add wave -noupdate /tb_async_fifo/wrreq
add wave -noupdate /tb_async_fifo/wrdata
add wave -noupdate -radix unsigned /tb_async_fifo/alt_wrusedw
add wave -noupdate /tb_async_fifo/alt_wrfull
add wave -noupdate /tb_async_fifo/alt_rdempty
add wave -noupdate /tb_async_fifo/alt_rdreq
add wave -noupdate -radix unsigned /tb_async_fifo/alt_rdusedw
add wave -noupdate /tb_async_fifo/alt_rddata
add wave -noupdate -divider {New Divider}
add wave -noupdate -radix unsigned /tb_async_fifo/xil_wrusedw
add wave -noupdate /tb_async_fifo/xil_wrfull
add wave -noupdate /tb_async_fifo/xil_rdempty
add wave -noupdate /tb_async_fifo/xil_rdreq
add wave -noupdate /tb_async_fifo/xil_rddata
add wave -noupdate -radix unsigned /tb_async_fifo/xil_rdusedw
add wave -noupdate -divider {New Divider}
add wave -noupdate -radix unsigned /tb_async_fifo/efx_wrusedw
add wave -noupdate /tb_async_fifo/efx_wrfull
add wave -noupdate /tb_async_fifo/efx_rdempty
add wave -noupdate /tb_async_fifo/efx_rdreq
add wave -noupdate /tb_async_fifo/efx_rddata
add wave -noupdate -radix unsigned /tb_async_fifo/efx_rdusedw
TreeUpdate [SetDefaultTree]
quietly WaveActivateNextPane
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/clr
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrclk
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrreq
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrdata
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wr_addr
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wr_rst_d
add wave -noupdate -radix unsigned /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrcount
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrfull
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrreq_int
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrreq_sync
add wave -noupdate -expand /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrreq_wr_clk
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/g(0)/wr_sync/pulse_in
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/g(0)/wr_sync/pulse_in_hold
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/g(0)/wr_sync/pulse_in_sync
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/g(0)/wr_sync/pulse_out
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/g(0)/wr_sync/pulse_out_hold
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/g(0)/wr_sync/pulse_out_hold_dly
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/g(0)/wr_sync/pulse_out_sync
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrusedw
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/CHECKING
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/DATA_WIDTH
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/DEPTH
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/SHOWAHEAD
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/SYNC_CLR
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/numSyncs
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/ram
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdclk
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdempty
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdreq
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rddata
add wave -noupdate -radix unsigned /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdusedw
add wave -noupdate -radix unsigned /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdcount
add wave -noupdate -expand /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/wrreq_rd_clk
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rd_addr
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rd_rst_d
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdreq_int
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdreq_rd_clk
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdreq_sync
add wave -noupdate /tb_async_fifo/c_xil_async_fifo/GEN_VENDOR/inferred_async_fifo_inst/rdreq_wr_clk
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {1492677 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 154
configure wave -valuecolwidth 76
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {0 ps} {3447224 ps}

View file

@ -0,0 +1,48 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/DATA_WIDTH
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/DEPTH
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/DEVICE_FAMILY
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/READ_WRITE_MODE
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/REGISTER_OUTPUT
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/clk
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/wrdata
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/wraddr
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/wren
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/rdaddr
add wave -noupdate /tb_dp_ram/c_alt_dp_ram/rddata
add wave -noupdate -divider {New Divider}
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/rddata
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/clk
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/wraddr
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/wren
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/wrdata
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/rdaddr
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(9)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(8)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(7)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(6)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(5)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(4)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(3)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(2)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(1)
add wave -noupdate /tb_dp_ram/c_xil_dp_ram/GEN_USCALE_P/dp_ram_inst/pPORT_A_rd/ram(0)
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {533818 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 178
configure wave -valuecolwidth 87
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {0 ps} {2337455 ps}

View file

@ -0,0 +1,73 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /tb_rw_dp_ram/ALT_DEVICE_FAMILY
add wave -noupdate /tb_rw_dp_ram/DATA_WIDTH
add wave -noupdate /tb_rw_dp_ram/DEPTH
add wave -noupdate /tb_rw_dp_ram/READ_WRITE_MODE
add wave -noupdate /tb_rw_dp_ram/REGISTER_OUTPUT
add wave -noupdate /tb_rw_dp_ram/XIL_DEVICE_FAMILY
add wave -noupdate /tb_rw_dp_ram/clk
add wave -noupdate /tb_rw_dp_ram/docheck
add wave -noupdate /tb_rw_dp_ram/addr_a
add wave -noupdate /tb_rw_dp_ram/wren_a
add wave -noupdate /tb_rw_dp_ram/wrdata_a
add wave -noupdate /tb_rw_dp_ram/alt_rddata_a
add wave -noupdate /tb_rw_dp_ram/xil_rddata_a
add wave -noupdate /tb_rw_dp_ram/addr_b
add wave -noupdate /tb_rw_dp_ram/wren_b
add wave -noupdate /tb_rw_dp_ram/wrdata_b
add wave -noupdate /tb_rw_dp_ram/alt_rddata_b
add wave -noupdate /tb_rw_dp_ram/xil_rddata_b
TreeUpdate [SetDefaultTree]
quietly WaveActivateNextPane
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/clk
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/addr_a
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/we_a
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/data_a
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/q_a
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/addr_b
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/we_b
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/data_b
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/q_b
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/addr_a_reg
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/addr_a_sel
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/data_a_reg
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/data_a_sel
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/we_a_reg
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/we_a_sel
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/ram(7)
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/ram(6)
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/ram(5)
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/ram(4)
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/ram(3)
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/ram(2)
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/ram(1)
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/ram(0)
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/read_a
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/read_a_reg
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/addr_b_reg
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/addr_b_sel
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/data_b_reg
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/data_b_sel
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/we_b_reg
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/we_b_sel
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/read_b
add wave -noupdate /tb_rw_dp_ram/c_xil_rw_dp_ram/GEN_USCALE_P/rw_dp_ram_inst/read_b_reg
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {321450 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 170
configure wave -valuecolwidth 98
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {0 ps} {2333056 ps}

View file

@ -0,0 +1,48 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /tb_sync_fifo/clk
add wave -noupdate /tb_sync_fifo/sclr
add wave -noupdate /tb_sync_fifo/wrreq
add wave -noupdate /tb_sync_fifo/wrdata
add wave -noupdate -radix unsigned -radixshowbase 0 /tb_sync_fifo/alt_usedw
add wave -noupdate /tb_sync_fifo/alt_full
add wave -noupdate /tb_sync_fifo/alt_almost_full
add wave -noupdate /tb_sync_fifo/alt_almost_empty
add wave -noupdate /tb_sync_fifo/alt_empty
add wave -noupdate /tb_sync_fifo/alt_rdreq
add wave -noupdate /tb_sync_fifo/alt_rddata
add wave -noupdate -divider {New Divider}
add wave -noupdate -radix unsigned -radixshowbase 0 /tb_sync_fifo/xil_usedw
add wave -noupdate /tb_sync_fifo/xil_full
add wave -noupdate /tb_sync_fifo/xil_almost_full
add wave -noupdate /tb_sync_fifo/xil_almost_empty
add wave -noupdate /tb_sync_fifo/xil_empty
add wave -noupdate /tb_sync_fifo/xil_rdreq
add wave -noupdate /tb_sync_fifo/xil_rddata
add wave -noupdate -divider {New Divider}
add wave -noupdate -radix unsigned /tb_sync_fifo/efx_usedw
add wave -noupdate /tb_sync_fifo/efx_almost_full
add wave -noupdate /tb_sync_fifo/efx_full
add wave -noupdate /tb_sync_fifo/efx_almost_empty
add wave -noupdate /tb_sync_fifo/efx_empty
add wave -noupdate /tb_sync_fifo/efx_rdreq
add wave -noupdate /tb_sync_fifo/efx_rddata
TreeUpdate [SetDefaultTree]
quietly WaveActivateNextPane
WaveRestoreCursors {{Cursor 1} {976402 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 182
configure wave -valuecolwidth 113
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {0 ps} {6233952 ps}

View file

@ -0,0 +1,6 @@
the alt_* memory components are fully configurable Altera/Intel RAMs and
FIFOs and supersede all other memory components. The others are kept here
for backwards compatibility until they can be obsoleted. No local RAMs or
FIFOs should be added to any project code. If a particular configuration
is required, but not present here, then add this and make generic so it may
be used in other projects.

View file

@ -0,0 +1,216 @@
-- megafunction wizard: %FIFO%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: dcfifo
-- ============================================================
-- File Name: alt_async_fifo.vhd
-- Megafunction Name(s):
-- dcfifo
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 18.1.0 Build 625 09/12/2018 SJ Standard Edition
-- ************************************************************
--Copyright (C) 2018 Intel Corporation. All rights reserved.
--Your use of Intel Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Intel Program License
--Subscription Agreement, the Intel Quartus Prime License Agreement,
--the Intel FPGA IP License Agreement, or other applicable license
--agreement, including, without limitation, that your use is for
--the sole purpose of programming logic devices manufactured by
--Intel and sold by Intel or its authorized distributors. Please
--refer to the applicable agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.all;
use work.common_pkg.all;
entity alt_async_fifo_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 64;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON"; -- "OFF"
SYNC_CLR : string := "OFF" -- "ON"
);
port
(
clr : in std_logic := '0';
wrclk : in std_logic ;
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrfull : out std_logic ;
wrusedw : out std_logic_vector (log2(DEPTH)-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
rdusedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end alt_async_fifo_1;
architecture syn of alt_async_fifo_1 is
signal sub_wire0 : std_logic_vector (DATA_WIDTH-1 downto 0);
signal sub_wire1 : std_logic ;
signal sub_wire2 : std_logic ;
signal sub_wire3 : std_logic_vector (log2(DEPTH)-1 downto 0);
signal sub_wire4 : std_logic_vector (log2(DEPTH)-1 downto 0);
component dcfifo
generic (
intended_device_family : string;
lpm_numwords : natural;
lpm_showahead : string;
lpm_type : string;
lpm_width : natural;
lpm_widthu : natural;
overflow_checking : string;
rdsync_delaypipe : natural;
underflow_checking : string;
use_eab : string;
read_aclr_synch : string;
write_aclr_synch : string;
wrsync_delaypipe : natural
);
port (
aclr : in std_logic ;
data : in std_logic_vector (DATA_WIDTH-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
wrclk : in std_logic ;
wrreq : in std_logic ;
q : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
wrfull : out std_logic ;
wrusedw : out std_logic_vector(log2(DEPTH)-1 downto 0);
rdusedw : out std_logic_vector(log2(DEPTH)-1 downto 0)
);
end component;
begin
rddata <= sub_wire0;
rdempty <= sub_wire1;
wrfull <= sub_wire2;
wrusedw <= sub_wire3;
rdusedw <= sub_wire4;
dcfifo_component : dcfifo
generic map (
intended_device_family => DEVICE_FAMILY,
lpm_numwords => DEPTH,
lpm_showahead => SHOWAHEAD,
lpm_type => "dcfifo",
lpm_width => DATA_WIDTH,
lpm_widthu => log2(DEPTH),
overflow_checking => CHECKING,
underflow_checking => CHECKING,
read_aclr_synch => SYNC_CLR,
write_aclr_synch => SYNC_CLR,
use_eab => "ON",
rdsync_delaypipe => 4,
wrsync_delaypipe => 4
)
port map (
aclr => clr,
data => wrdata,
rdclk => rdclk,
rdreq => rdreq,
wrclk => wrclk,
wrreq => wrreq,
q => sub_wire0,
rdempty => sub_wire1,
wrfull => sub_wire2,
wrusedw => sub_wire3,
rdusedw => sub_wire4
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "-1"
-- Retrieval info: PRIVATE: AlmostFull NUMERIC "0"
-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "-1"
-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
-- Retrieval info: PRIVATE: Clock NUMERIC "4"
-- Retrieval info: PRIVATE: Depth NUMERIC "64"
-- Retrieval info: PRIVATE: Empty NUMERIC "1"
-- Retrieval info: PRIVATE: Full NUMERIC "1"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1"
-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: Optimize NUMERIC "0"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
-- Retrieval info: PRIVATE: Width NUMERIC "32"
-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: diff_widths NUMERIC "0"
-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
-- Retrieval info: PRIVATE: output_width NUMERIC "32"
-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
-- Retrieval info: PRIVATE: sc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: sc_sclr NUMERIC "0"
-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: wsFull NUMERIC "1"
-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "64"
-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "dcfifo"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "32"
-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "6"
-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: RDSYNC_DELAYPIPE NUMERIC "4"
-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
-- Retrieval info: CONSTANT: WRSYNC_DELAYPIPE NUMERIC "4"
-- Retrieval info: USED_PORT: wrdata 0 0 32 0 INPUT NODEFVAL "wrdata[31..0]"
-- Retrieval info: USED_PORT: rddata 0 0 32 0 OUTPUT NODEFVAL "rddata[31..0]"
-- Retrieval info: USED_PORT: rdclk 0 0 0 0 INPUT NODEFVAL "rdclk"
-- Retrieval info: USED_PORT: rdempty 0 0 0 0 OUTPUT NODEFVAL "rdempty"
-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq"
-- Retrieval info: USED_PORT: wrclk 0 0 0 0 INPUT NODEFVAL "wrclk"
-- Retrieval info: USED_PORT: wrfull 0 0 0 0 OUTPUT NODEFVAL "wrfull"
-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq"
-- Retrieval info: CONNECT: @wrdata 0 0 32 0 wrdata 0 0 32 0
-- Retrieval info: CONNECT: @rdclk 0 0 0 0 rdclk 0 0 0 0
-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
-- Retrieval info: CONNECT: @wrclk 0 0 0 0 wrclk 0 0 0 0
-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
-- Retrieval info: CONNECT: rddata 0 0 32 0 @rddata 0 0 32 0
-- Retrieval info: CONNECT: rdempty 0 0 0 0 @rdempty 0 0 0 0
-- Retrieval info: CONNECT: wrfull 0 0 0 0 @wrfull 0 0 0 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_async_fifo.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL async_fifo_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,201 @@
-- megafunction wizard: %RAM: 2-PORT%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: altsyncram
-- ============================================================
-- File Name: alt_dp_ram.vhd
-- Megafunction Name(s):
-- altsyncram
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 18.1.0 Build 625 09/12/2018 SJ Standard Edition
-- ************************************************************
--Copyright (C) 2018 Intel Corporation. All rights reserved.
--Your use of Intel Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Intel Program License
--Subscription Agreement, the Intel Quartus Prime License Agreement,
--the Intel FPGA IP License Agreement, or other applicable license
--agreement, including, without limitation, that your use is for
--the sole purpose of programming logic devices manufactured by
--Intel and sold by Intel or its authorized distributors. Please
--refer to the applicable agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.altera_mf_components.all;
use work.common_pkg.all;
entity alt_dp_ram_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
clk : in std_logic := '1';
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wraddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
wren : in std_logic := '0';
rdaddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end alt_dp_ram_1;
architecture syn of alt_dp_ram_1 is
signal sub_wire0 : std_logic_vector (DATA_WIDTH-1 downto 0);
begin
rddata <= sub_wire0(DATA_WIDTH-1 downto 0);
altsyncram_component : altsyncram
generic map (
address_aclr_b => "NONE",
address_reg_b => "CLOCK0",
clock_enable_input_a => "BYPASS",
clock_enable_input_b => "BYPASS",
clock_enable_output_b => "BYPASS",
intended_device_family => DEVICE_FAMILY,
lpm_type => "altsyncram",
numwords_a => DEPTH,
numwords_b => DEPTH,
operation_mode => "DUAL_PORT",
outdata_aclr_b => "NONE",
outdata_reg_b => REGISTER_OUTPUT,
power_up_uninitialized => "FALSE",
read_during_write_mode_mixed_ports => READ_WRITE_MODE,
widthad_a => LOG2(DEPTH),
widthad_b => LOG2(DEPTH),
width_a => DATA_WIDTH,
width_b => DATA_WIDTH,
width_byteena_a => 1
)
port map (
address_a => wraddr,
address_b => rdaddr,
clock0 => clk,
data_a => wrdata,
wren_a => wren,
q_b => sub_wire0
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: ADDRESSSTALL_A NUMERIC "0"
-- Retrieval info: PRIVATE: ADDRESSSTALL_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_SIZE NUMERIC "8"
-- Retrieval info: PRIVATE: BlankMemory NUMERIC "1"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLRdata NUMERIC "0"
-- Retrieval info: PRIVATE: CLRq NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrdaddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrren NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwraddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwren NUMERIC "0"
-- Retrieval info: PRIVATE: clk NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_A NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_B NUMERIC "0"
-- Retrieval info: PRIVATE: IMPLEMENT_IN_LES NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_REG_B NUMERIC "0"
-- Retrieval info: PRIVATE: INIT_FILE_LAYOUT STRING "PORT_B"
-- Retrieval info: PRIVATE: INIT_TO_SIM_X NUMERIC "0"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: PRIVATE: JTAG_ENABLED NUMERIC "0"
-- Retrieval info: PRIVATE: JTAG_ID STRING "NONE"
-- Retrieval info: PRIVATE: MAXIMUM_DEPTH NUMERIC "0"
-- Retrieval info: PRIVATE: MEMSIZE NUMERIC "4096"
-- Retrieval info: PRIVATE: MEM_IN_BITS NUMERIC "0"
-- Retrieval info: PRIVATE: MIFfilename STRING ""
-- Retrieval info: PRIVATE: OPERATION_MODE NUMERIC "2"
-- Retrieval info: PRIVATE: OUTDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: OUTDATA_REG_B NUMERIC "1"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_MIXED_PORTS NUMERIC "1"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_A NUMERIC "3"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_B NUMERIC "3"
-- Retrieval info: PRIVATE: REGdata NUMERIC "1"
-- Retrieval info: PRIVATE: REGq NUMERIC "0"
-- Retrieval info: PRIVATE: REGrdaddress NUMERIC "1"
-- Retrieval info: PRIVATE: REGrren NUMERIC "1"
-- Retrieval info: PRIVATE: REGwraddress NUMERIC "1"
-- Retrieval info: PRIVATE: REGwren NUMERIC "1"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: USE_DIFF_CLKEN NUMERIC "0"
-- Retrieval info: PRIVATE: UseDPRAM NUMERIC "1"
-- Retrieval info: PRIVATE: VarWidth NUMERIC "0"
-- Retrieval info: PRIVATE: WIDTH_READ_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_READ_B NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_B NUMERIC "32"
-- Retrieval info: PRIVATE: WRADDR_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: WRADDR_REG_B NUMERIC "0"
-- Retrieval info: PRIVATE: WRCTRL_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: enable NUMERIC "0"
-- Retrieval info: PRIVATE: rden NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADDRESS_ACLR_B STRING "NONE"
-- Retrieval info: CONSTANT: ADDRESS_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_A STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "altsyncram"
-- Retrieval info: CONSTANT: NUMWORDS_A NUMERIC "128"
-- Retrieval info: CONSTANT: NUMWORDS_B NUMERIC "128"
-- Retrieval info: CONSTANT: OPERATION_MODE STRING "DUAL_PORT"
-- Retrieval info: CONSTANT: OUTDATA_ACLR_B STRING "NONE"
-- Retrieval info: CONSTANT: OUTDATA_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: POWER_UP_UNINITIALIZED STRING "FALSE"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_MIXED_PORTS STRING "OLD_DATA"
-- Retrieval info: CONSTANT: WIDTHAD_A NUMERIC "7"
-- Retrieval info: CONSTANT: WIDTHAD_B NUMERIC "7"
-- Retrieval info: CONSTANT: WIDTH_A NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_B NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_BYTEENA_A NUMERIC "1"
-- Retrieval info: USED_PORT: clk 0 0 0 0 INPUT VCC "clk"
-- Retrieval info: USED_PORT: wrdata 0 0 32 0 INPUT NODEFVAL "wrdata[31..0]"
-- Retrieval info: USED_PORT: rddata 0 0 32 0 OUTPUT NODEFVAL "rddata[31..0]"
-- Retrieval info: USED_PORT: rdaddr 0 0 7 0 INPUT NODEFVAL "rdaddr[6..0]"
-- Retrieval info: USED_PORT: wraddr 0 0 7 0 INPUT NODEFVAL "wraddr[6..0]"
-- Retrieval info: USED_PORT: wren 0 0 0 0 INPUT GND "wren"
-- Retrieval info: CONNECT: @address_a 0 0 7 0 wraddr 0 0 7 0
-- Retrieval info: CONNECT: @address_b 0 0 7 0 rdaddr 0 0 7 0
-- Retrieval info: CONNECT: @clock0 0 0 0 0 clk 0 0 0 0
-- Retrieval info: CONNECT: @data_a 0 0 32 0 wrdata 0 0 32 0
-- Retrieval info: CONNECT: @wren_a 0 0 0 0 wren 0 0 0 0
-- Retrieval info: CONNECT: rddata 0 0 32 0 @q_b 0 0 32 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_dp_ram.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL dp_ram_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,231 @@
-- megafunction wizard: %RAM: 2-PORT%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: altsyncram
-- ============================================================
-- File Name: generic_seq_ram.vhd
-- Megafunction Name(s):
-- altsyncram
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 14.1.1 Build 190 01/19/2015 SJ Web Edition
-- ************************************************************
--Copyright (C) 1991-2015 Altera Corporation. All rights reserved.
--Your use of Altera Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Altera Program License
--Subscription Agreement, the Altera Quartus II License Agreement,
--the Altera MegaCore Function License Agreement, or other
--applicable license agreement, including, without limitation,
--that your use is for the sole purpose of programming logic
--devices manufactured by Altera and sold by Altera or its
--authorized distributors. Please refer to the applicable
--agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.altera_mf_components.all;
use work.common_pkg.all;
entity alt_rw_dp_ram_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
addr_a : in std_logic_vector (log2(DEPTH)-1 downto 0);
addr_b : in std_logic_vector (log2(DEPTH)-1 downto 0);
clk : in std_logic := '1';
wrdata_a : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrdata_b : in std_logic_vector (DATA_WIDTH-1 downto 0);
wren_a : in std_logic := '0';
wren_b : in std_logic := '0';
rddata_a : out std_logic_vector (DATA_WIDTH-1 downto 0);
rddata_b : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end alt_rw_dp_ram_1;
architecture syn of alt_rw_dp_ram_1 is
signal sub_wire0 : std_logic_vector (DATA_WIDTH-1 downto 0);
signal sub_wire1 : std_logic_vector (DATA_WIDTH-1 downto 0);
begin
rddata_a <= sub_wire0(DATA_WIDTH-1 downto 0);
rddata_b <= sub_wire1(DATA_WIDTH-1 downto 0);
altsyncram_component : altsyncram
generic map (
address_reg_b => "CLOCK0",
clock_enable_input_a => "BYPASS",
clock_enable_input_b => "BYPASS",
clock_enable_output_a => "BYPASS",
clock_enable_output_b => "BYPASS",
indata_reg_b => "CLOCK0",
intended_device_family => DEVICE_FAMILY,
lpm_type => "altsyncram",
numwords_a => DEPTH,
numwords_b => DEPTH,
operation_mode => "BIDIR_DUAL_PORT",
outdata_aclr_a => "NONE",
outdata_aclr_b => "NONE",
outdata_reg_a => REGISTER_OUTPUT,
outdata_reg_b => REGISTER_OUTPUT,
power_up_uninitialized => "FALSE",
read_during_write_mode_mixed_ports => "DONT_CARE",
read_during_write_mode_port_a => "NEW_DATA_NO_NBE_READ",
read_during_write_mode_port_b => "NEW_DATA_NO_NBE_READ",
widthad_a => log2(DEPTH),
widthad_b => log2(DEPTH),
width_a => DATA_WIDTH,
width_b => DATA_WIDTH,
width_byteena_a => 1,
width_byteena_b => 1,
wrcontrol_wraddress_reg_b => "CLOCK0"
)
port map (
address_a => addr_a,
address_b => addr_b,
clock0 => clk,
data_a => wrdata_a,
data_b => wrdata_b,
wren_a => wren_a,
wren_b => wren_b,
q_a => sub_wire0,
q_b => sub_wire1
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: ADDRESSSTALL_A NUMERIC "0"
-- Retrieval info: PRIVATE: ADDRESSSTALL_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTEENA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_A NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_ENABLE_B NUMERIC "0"
-- Retrieval info: PRIVATE: BYTE_SIZE NUMERIC "8"
-- Retrieval info: PRIVATE: BlankMemory NUMERIC "1"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_A NUMERIC "0"
-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_B NUMERIC "0"
-- Retrieval info: PRIVATE: CLRdata NUMERIC "0"
-- Retrieval info: PRIVATE: CLRq NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrdaddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRrren NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwraddress NUMERIC "0"
-- Retrieval info: PRIVATE: CLRwren NUMERIC "0"
-- Retrieval info: PRIVATE: Clock NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_A NUMERIC "0"
-- Retrieval info: PRIVATE: Clock_B NUMERIC "0"
-- Retrieval info: PRIVATE: IMPLEMENT_IN_LES NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: INDATA_REG_B NUMERIC "1"
-- Retrieval info: PRIVATE: INIT_FILE_LAYOUT STRING "PORT_A"
-- Retrieval info: PRIVATE: INIT_TO_SIM_X NUMERIC "0"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone V"
-- Retrieval info: PRIVATE: JTAG_ENABLED NUMERIC "0"
-- Retrieval info: PRIVATE: JTAG_ID STRING "NONE"
-- Retrieval info: PRIVATE: MAXIMUM_DEPTH NUMERIC "0"
-- Retrieval info: PRIVATE: MEMSIZE NUMERIC "8192"
-- Retrieval info: PRIVATE: MEM_IN_BITS NUMERIC "0"
-- Retrieval info: PRIVATE: MIFfilename STRING ""
-- Retrieval info: PRIVATE: OPERATION_MODE NUMERIC "3"
-- Retrieval info: PRIVATE: OUTDATA_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: OUTDATA_REG_B NUMERIC "0"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_MIXED_PORTS NUMERIC "2"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_A NUMERIC "3"
-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_B NUMERIC "3"
-- Retrieval info: PRIVATE: REGdata NUMERIC "1"
-- Retrieval info: PRIVATE: REGq NUMERIC "0"
-- Retrieval info: PRIVATE: REGrdaddress NUMERIC "0"
-- Retrieval info: PRIVATE: REGrren NUMERIC "0"
-- Retrieval info: PRIVATE: REGwraddress NUMERIC "1"
-- Retrieval info: PRIVATE: REGwren NUMERIC "1"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: USE_DIFF_CLKEN NUMERIC "0"
-- Retrieval info: PRIVATE: UseDPRAM NUMERIC "1"
-- Retrieval info: PRIVATE: VarWidth NUMERIC "0"
-- Retrieval info: PRIVATE: WIDTH_READ_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_READ_B NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_A NUMERIC "32"
-- Retrieval info: PRIVATE: WIDTH_WRITE_B NUMERIC "32"
-- Retrieval info: PRIVATE: WRADDR_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: WRADDR_REG_B NUMERIC "1"
-- Retrieval info: PRIVATE: WRCTRL_ACLR_B NUMERIC "0"
-- Retrieval info: PRIVATE: enable NUMERIC "0"
-- Retrieval info: PRIVATE: rden NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADDRESS_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_A STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_A STRING "BYPASS"
-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_B STRING "BYPASS"
-- Retrieval info: CONSTANT: INDATA_REG_B STRING "CLOCK0"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone V"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "altsyncram"
-- Retrieval info: CONSTANT: NUMWORDS_A NUMERIC "256"
-- Retrieval info: CONSTANT: NUMWORDS_B NUMERIC "256"
-- Retrieval info: CONSTANT: OPERATION_MODE STRING "BIDIR_DUAL_PORT"
-- Retrieval info: CONSTANT: OUTDATA_ACLR_A STRING "NONE"
-- Retrieval info: CONSTANT: OUTDATA_ACLR_B STRING "NONE"
-- Retrieval info: CONSTANT: OUTDATA_REG_A STRING "UNREGISTERED"
-- Retrieval info: CONSTANT: OUTDATA_REG_B STRING "UNREGISTERED"
-- Retrieval info: CONSTANT: POWER_UP_UNINITIALIZED STRING "FALSE"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_MIXED_PORTS STRING "DONT_CARE"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_PORT_A STRING "NEW_DATA_NO_NBE_READ"
-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_PORT_B STRING "NEW_DATA_NO_NBE_READ"
-- Retrieval info: CONSTANT: WIDTHAD_A NUMERIC "8"
-- Retrieval info: CONSTANT: WIDTHAD_B NUMERIC "8"
-- Retrieval info: CONSTANT: WIDTH_A NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_B NUMERIC "32"
-- Retrieval info: CONSTANT: WIDTH_BYTEENA_A NUMERIC "1"
-- Retrieval info: CONSTANT: WIDTH_BYTEENA_B NUMERIC "1"
-- Retrieval info: CONSTANT: WRCONTROL_WRADDRESS_REG_B STRING "CLOCK0"
-- Retrieval info: USED_PORT: address_a 0 0 8 0 INPUT NODEFVAL "address_a[7..0]"
-- Retrieval info: USED_PORT: address_b 0 0 8 0 INPUT NODEFVAL "address_b[7..0]"
-- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT VCC "clock"
-- Retrieval info: USED_PORT: data_a 0 0 32 0 INPUT NODEFVAL "data_a[31..0]"
-- Retrieval info: USED_PORT: data_b 0 0 32 0 INPUT NODEFVAL "data_b[31..0]"
-- Retrieval info: USED_PORT: q_a 0 0 32 0 OUTPUT NODEFVAL "q_a[31..0]"
-- Retrieval info: USED_PORT: q_b 0 0 32 0 OUTPUT NODEFVAL "q_b[31..0]"
-- Retrieval info: USED_PORT: wren_a 0 0 0 0 INPUT GND "wren_a"
-- Retrieval info: USED_PORT: wren_b 0 0 0 0 INPUT GND "wren_b"
-- Retrieval info: CONNECT: @address_a 0 0 8 0 address_a 0 0 8 0
-- Retrieval info: CONNECT: @address_b 0 0 8 0 address_b 0 0 8 0
-- Retrieval info: CONNECT: @clock0 0 0 0 0 clock 0 0 0 0
-- Retrieval info: CONNECT: @data_a 0 0 32 0 data_a 0 0 32 0
-- Retrieval info: CONNECT: @data_b 0 0 32 0 data_b 0 0 32 0
-- Retrieval info: CONNECT: @wren_a 0 0 0 0 wren_a 0 0 0 0
-- Retrieval info: CONNECT: @wren_b 0 0 0 0 wren_b 0 0 0 0
-- Retrieval info: CONNECT: q_a 0 0 32 0 @q_a 0 0 32 0
-- Retrieval info: CONNECT: q_b 0 0 32 0 @q_b 0 0 32 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.cmp TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

View file

@ -0,0 +1,234 @@
-- megafunction wizard: %FIFO%
-- GENERATION: STANDARD
-- VERSION: WM1.0
-- MODULE: scfifo
-- ============================================================
-- File Name: alt_sync_fifo.vhd
-- Megafunction Name(s):
-- scfifo
--
-- Simulation Library Files(s):
-- altera_mf
-- ============================================================
-- ************************************************************
-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
--
-- 18.1.0 Build 625 09/12/2018 SJ Standard Edition
-- ************************************************************
--Copyright (C) 2018 Intel Corporation. All rights reserved.
--Your use of Intel Corporation's design tools, logic functions
--and other software and tools, and its AMPP partner logic
--functions, and any output files from any of the foregoing
--(including device programming or simulation files), and any
--associated documentation or information are expressly subject
--to the terms and conditions of the Intel Program License
--Subscription Agreement, the Intel Quartus Prime License Agreement,
--the Intel FPGA IP License Agreement, or other applicable license
--agreement, including, without limitation, that your use is for
--the sole purpose of programming logic devices manufactured by
--Intel and sold by Intel or its authorized distributors. Please
--refer to the applicable agreement for further details.
library ieee;
use ieee.std_logic_1164.all;
library altera_mf;
use altera_mf.all;
use work.common_pkg.all;
entity alt_sync_fifo_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 1 to 131072 := 64;
REGISTER_OUTPUT : string := "ON"; -- "OFF"
NEARLY_FULL : natural range 1 to 131072 := 62;
NEARLY_EMPTY : natural range 1 to 131072 := 2;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port
(
clk : in std_logic ;
rst_n : in std_logic := '1';
sclr : in std_logic := '0';
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
almost_full : out std_logic ;
full : out std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
almost_empty : out std_logic ;
empty : out std_logic ;
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end alt_sync_fifo_1;
architecture syn of alt_sync_fifo_1 is
signal sub_wire0 : std_logic ;
signal sub_wire1 : std_logic ;
signal sub_wire2 : std_logic ;
signal sub_wire3 : std_logic ;
signal sub_wire4 : std_logic_vector (DATA_WIDTH-1 downto 0);
signal sub_wire5 : std_logic_vector (log2(DEPTH)-1 downto 0);
component scfifo
generic (
add_ram_output_register : string;
almost_empty_value : natural;
almost_full_value : natural;
intended_device_family : string;
lpm_numwords : natural;
lpm_showahead : string;
lpm_type : string;
lpm_width : natural;
lpm_widthu : natural;
overflow_checking : string;
underflow_checking : string;
use_eab : string
);
port (
aclr : in std_logic ;
clock : in std_logic ;
data : in std_logic_vector (DATA_WIDTH-1 downto 0);
rdreq : in std_logic ;
sclr : in std_logic ;
wrreq : in std_logic ;
almost_empty : out std_logic ;
almost_full : out std_logic ;
empty : out std_logic ;
full : out std_logic ;
q : out std_logic_vector (DATA_WIDTH-1 downto 0);
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
begin
almost_empty <= sub_wire0;
almost_full <= sub_wire1;
empty <= sub_wire2;
full <= sub_wire3;
rddata <= sub_wire4(DATA_WIDTH-1 downto 0);
usedw <= sub_wire5(log2(DEPTH)-1 downto 0);
scfifo_component : scfifo
generic map (
add_ram_output_register => REGISTER_OUTPUT,
almost_empty_value => NEARLY_EMPTY,
almost_full_value => NEARLY_FULL,
intended_device_family => DEVICE_FAMILY,
lpm_numwords => DEPTH,
lpm_showahead => SHOWAHEAD,
lpm_type => "scfifo",
lpm_width => DATA_WIDTH,
lpm_widthu => log2(DEPTH),
overflow_checking => CHECKING,
underflow_checking => CHECKING,
use_eab => "ON"
)
port map (
aclr => not rst_n,
clock => clk,
data => wrdata,
rdreq => rdreq,
sclr => sclr,
wrreq => wrreq,
almost_empty => sub_wire0,
almost_full => sub_wire1,
empty => sub_wire2,
full => sub_wire3,
q => sub_wire4,
usedw => sub_wire5
);
end syn;
-- ============================================================
-- CNX file retrieval info
-- ============================================================
-- Retrieval info: PRIVATE: AlmostEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: AlmostEmptyThr NUMERIC "2"
-- Retrieval info: PRIVATE: AlmostFull NUMERIC "1"
-- Retrieval info: PRIVATE: AlmostFullThr NUMERIC "32"
-- Retrieval info: PRIVATE: CLOCKS_ARE_SYNCHRONIZED NUMERIC "0"
-- Retrieval info: PRIVATE: clk NUMERIC "0"
-- Retrieval info: PRIVATE: Depth NUMERIC "64"
-- Retrieval info: PRIVATE: Empty NUMERIC "1"
-- Retrieval info: PRIVATE: Full NUMERIC "1"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: PRIVATE: LE_BasedFIFO NUMERIC "0"
-- Retrieval info: PRIVATE: LegacyRREQ NUMERIC "1"
-- Retrieval info: PRIVATE: MAX_DEPTH_BY_9 NUMERIC "0"
-- Retrieval info: PRIVATE: OVERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: Optimize NUMERIC "1"
-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: UNDERFLOW_CHECKING NUMERIC "0"
-- Retrieval info: PRIVATE: UsedW NUMERIC "1"
-- Retrieval info: PRIVATE: Width NUMERIC "32"
-- Retrieval info: PRIVATE: dc_aclr NUMERIC "0"
-- Retrieval info: PRIVATE: diff_widths NUMERIC "0"
-- Retrieval info: PRIVATE: msb_usedw NUMERIC "0"
-- Retrieval info: PRIVATE: output_width NUMERIC "32"
-- Retrieval info: PRIVATE: rsEmpty NUMERIC "1"
-- Retrieval info: PRIVATE: rsFull NUMERIC "0"
-- Retrieval info: PRIVATE: rsUsedW NUMERIC "0"
-- Retrieval info: PRIVATE: sc_aclr NUMERIC "1"
-- Retrieval info: PRIVATE: sc_sclr NUMERIC "1"
-- Retrieval info: PRIVATE: wsEmpty NUMERIC "0"
-- Retrieval info: PRIVATE: wsFull NUMERIC "1"
-- Retrieval info: PRIVATE: wsUsedW NUMERIC "0"
-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all
-- Retrieval info: CONSTANT: ADD_RAM_OUTPUT_REGISTER STRING "ON"
-- Retrieval info: CONSTANT: ALMOST_EMPTY_VALUE NUMERIC "2"
-- Retrieval info: CONSTANT: ALMOST_FULL_VALUE NUMERIC "32"
-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone 10 LP"
-- Retrieval info: CONSTANT: LPM_NUMWORDS NUMERIC "64"
-- Retrieval info: CONSTANT: LPM_SHOWAHEAD STRING "OFF"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "scfifo"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "32"
-- Retrieval info: CONSTANT: LPM_WIDTHU NUMERIC "6"
-- Retrieval info: CONSTANT: OVERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: UNDERFLOW_CHECKING STRING "ON"
-- Retrieval info: CONSTANT: USE_EAB STRING "ON"
-- Retrieval info: USED_PORT: aclr 0 0 0 0 INPUT NODEFVAL "aclr"
-- Retrieval info: USED_PORT: almost_empty 0 0 0 0 OUTPUT NODEFVAL "almost_empty"
-- Retrieval info: USED_PORT: almost_full 0 0 0 0 OUTPUT NODEFVAL "almost_full"
-- Retrieval info: USED_PORT: clk 0 0 0 0 INPUT NODEFVAL "clk"
-- Retrieval info: USED_PORT: wrdata 0 0 32 0 INPUT NODEFVAL "wrdata[31..0]"
-- Retrieval info: USED_PORT: empty 0 0 0 0 OUTPUT NODEFVAL "empty"
-- Retrieval info: USED_PORT: full 0 0 0 0 OUTPUT NODEFVAL "full"
-- Retrieval info: USED_PORT: rddata 0 0 32 0 OUTPUT NODEFVAL "rddata[31..0]"
-- Retrieval info: USED_PORT: rdreq 0 0 0 0 INPUT NODEFVAL "rdreq"
-- Retrieval info: USED_PORT: sclr 0 0 0 0 INPUT NODEFVAL "sclr"
-- Retrieval info: USED_PORT: usedw 0 0 6 0 OUTPUT NODEFVAL "usedw[5..0]"
-- Retrieval info: USED_PORT: wrreq 0 0 0 0 INPUT NODEFVAL "wrreq"
-- Retrieval info: CONNECT: @aclr 0 0 0 0 aclr 0 0 0 0
-- Retrieval info: CONNECT: @clk 0 0 0 0 clk 0 0 0 0
-- Retrieval info: CONNECT: @wrdata 0 0 32 0 wrdata 0 0 32 0
-- Retrieval info: CONNECT: @rdreq 0 0 0 0 rdreq 0 0 0 0
-- Retrieval info: CONNECT: @sclr 0 0 0 0 sclr 0 0 0 0
-- Retrieval info: CONNECT: @wrreq 0 0 0 0 wrreq 0 0 0 0
-- Retrieval info: CONNECT: almost_empty 0 0 0 0 @almost_empty 0 0 0 0
-- Retrieval info: CONNECT: almost_full 0 0 0 0 @almost_full 0 0 0 0
-- Retrieval info: CONNECT: empty 0 0 0 0 @empty 0 0 0 0
-- Retrieval info: CONNECT: full 0 0 0 0 @full 0 0 0 0
-- Retrieval info: CONNECT: rddata 0 0 32 0 @rddata 0 0 32 0
-- Retrieval info: CONNECT: usedw 0 0 6 0 @usedw 0 0 6 0
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_sync_fifo.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_sync_fifo.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_sync_fifo.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL alt_sync_fifo.bsf FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL try_inst.vhd FALSE
-- Retrieval info: LIB_FILE: altera_mf

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,196 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
-- Inferred RAM Async FIFO, modified from Damians in Firmware/Common
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
use work.common_pkg.all;
entity inferred_async_fifo_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 64;
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON"; -- "OFF"
SYNC_CLR : string := "OFF" -- "ON"
);
port
(
clr : in std_logic := '0';
wrclk : in std_logic ;
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrfull : out std_logic ;
wrusedw : out std_logic_vector (log2(DEPTH)-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
rdusedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end inferred_async_fifo_1;
architecture rtl OF inferred_async_fifo_1 is
constant numSyncs : integer := 14; -- need 14 for approx 2:1 write clock faster than read clock
type memory_t is array (DEPTH-1 downto 0) of std_logic_vector (DATA_WIDTH-1 downto 0) ;
signal ram : memory_t := (others => (others => '0')); -- make simulation same as Altera
attribute syn_ramstyle: string;
attribute syn_ramstyle of ram : signal is "block_ram";
-----------------------------------------------------------------------------
-- Internal signal declarations
-----------------------------------------------------------------------------
signal wrreq_int : std_logic;
signal rdreq_int : std_logic;
signal rd_addr, wr_addr : unsigned(log2(DEPTH-1)-1 downto 0);
signal wrcount : integer range 0 to DEPTH;
signal rdcount : integer range 0 to DEPTH;
signal wrreq_sync : integer range 0 to numSyncs-1;
signal rdreq_sync : integer range 0 to numSyncs-1;
signal wrreq_wr_clk : std_logic_vector(numSyncs-1 downto 0);
signal wrreq_rd_clk : std_logic_vector(numSyncs-1 downto 0);
signal rdreq_rd_clk : std_logic_vector(numSyncs-1 downto 0);
signal rdreq_wr_clk : std_logic_vector(numSyncs-1 downto 0);
signal wr_rst_d, rd_rst_d : std_logic_vector(1 downto 0) := (others => '1');
function count_bits(bits : std_logic_vector) return integer is
variable count : integer range 0 to numSyncs-1;
begin
count := 0;
for i in bits'range loop
if bits(i) = '1' then
count := count + 1;
end if;
end loop;
return count;
end function count_bits;
begin
wrreq_int <= wrreq when wrfull = '0' else '0';
rdreq_int <= rdreq when rdempty = '0' else '0';
wrfull <= '1' when (wrcount = DEPTH) else '0';
rdempty <= '1' when (rdcount = 0) else '0';
wrusedw <= std_logic_vector(to_unsigned(wrcount, wrusedw'high+1));
rdusedw <= std_logic_vector(to_unsigned(rdcount, rdusedw'high+1));
-- cross domain
wr_rst_d <= wr_rst_d(0) & clr when rising_edge(wrclk);
rd_rst_d <= rd_rst_d(0) & clr when rising_edge(rdclk);
-- pragma translate_off
assert not(wrfull = '1' and rising_edge(wrreq_int))
report "Tried to Write while full" severity warning;
assert not (rdempty = '1' and rising_edge(rdreq_int))
report "Tried to Read while empty" severity warning;
-- pragma translate_on
-----------------------------------------------------------------------------
-- WRITING:
-- Increments the Write Pointer
-- No protection against overflow
-----------------------------------------------------------------------------
g : for i in 0 to numSyncs-1 generate
wr_sync : entity work.sync_pulse
port map (clk_in => wrclk, rst_n => not wr_rst_d(1), pulse_in => wrreq_wr_clk(i),
clk_out => rdclk, pulse_out => wrreq_rd_clk(i));
wrreq_wr_clk(i) <= wrreq_int when wrreq_sync = i else '0';
rd_sync : entity work.sync_pulse
port map (clk_in => rdclk, rst_n => not rd_rst_d(1), pulse_in => rdreq_rd_clk(i),
clk_out => wrclk, pulse_out => rdreq_wr_clk(i));
rdreq_rd_clk(i) <= rdreq_int when rdreq_sync = i else '0';
end generate;
writing : process (wrclk, wr_rst_d(1))
begin -- process writing
if wr_rst_d(1) = '1' then
wr_addr <= (others => '0');
wrcount <= 0;
wrreq_sync <= 0;
elsif rising_edge(wrclk) then
if wrreq_int = '1' then
-- increment pointer
wr_addr <= wr_addr + 1;
if wrreq_sync = numSyncs-1 then
wrreq_sync <= 0;
else
wrreq_sync <= wrreq_sync + 1;
end if;
end if;
if wrreq_int = '1' then
wrcount <= wrcount - count_bits(rdreq_wr_clk) + 1;
else
wrcount <= wrcount - count_bits(rdreq_wr_clk) + 0;
end if;
end if;
end process writing;
-----------------------------------------------------------------------------
-- READING:
-- Increments Read Pointer
-----------------------------------------------------------------------------
reading : process (rdclk, rd_rst_d(1))
begin -- process reading
if rd_rst_d(1) = '1' then
rd_addr <= (others => '0');
rdcount <= 0;
rdreq_sync <= 0;
elsif rising_edge(rdclk) then
if rdreq_int = '1' then
rd_addr <= rd_addr + 1;
if rdreq_sync = numSyncs-1 then
rdreq_sync <= 0;
else
rdreq_sync <= rdreq_sync + 1;
end if;
end if;
if rdreq_int = '1' then
rdcount <= rdcount + count_bits(wrreq_rd_clk) - 1;
else
rdcount <= rdcount + count_bits(wrreq_rd_clk) + 0;
end if;
end if;
end process reading;
--dout_valid <= dout_valid_int;
ram_wr : process (wrclk) is
begin
if rising_edge(wrclk) then
if wrreq_int = '1' then
ram(to_integer(wr_addr)) <= wrdata;
end if;
end if;
end process ram_wr;
--ram_rd : process (rdclk) is
--begin
--if rising_edge(rdclk) then
rddata <= ram(to_integer(rd_addr));
--end if;
--end process ram_rd;
end rtl;

View file

@ -0,0 +1,138 @@
-------------------------------------------------------------------------------
-- Title : dpram_sclk
-- Project : Dual-Port, single clock RAM
-------------------------------------------------------------------------------
-- File : inferred_dpram.vhd
-- Author : DCS
-- Company : Global Inkjet Systems
-- Created : 2022-07-20
-- Last update:
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- True Dual-Port, single clock RAM
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.common_pkg.all;
entity inferred_dpram_1 is
generic(
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_ADDRA : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_ADDRB : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_OUTPUTA : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_OUTPUTB : string := "UNREGISTERED"; -- "CLOCK0"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Ultrascale+"
);
port(
clk : in std_logic;
-- Port-A
addr_a : in std_logic_vector(log2(DEPTH)-1 downto 0);
we_a : in std_logic := '0';
data_a : in std_logic_vector(DATA_WIDTH-1 downto 0) := (others => '0');
q_a : out std_logic_vector(DATA_WIDTH-1 downto 0);
-- Port-B
addr_b : in std_logic_vector(log2(DEPTH)-1 downto 0);
we_b : in std_logic := '0';
data_b : in std_logic_vector(DATA_WIDTH-1 downto 0) := (others => '0');
q_b : out std_logic_vector(DATA_WIDTH-1 downto 0));
end inferred_dpram_1;
architecture rtl of inferred_dpram_1 is
-- Build a 2-D array type for the RAM
subtype word_t is std_logic_vector(DATA_WIDTH-1 downto 0);
type memory_t is array(DEPTH-1 downto 0) of word_t;
-- Declare the RAM
shared variable ram : memory_t := (others => (others => '0')); -- Must Init to zero or avs_seq_reads don't work.
signal addr_a_reg : std_logic_vector(log2(DEPTH)-1 downto 0);
signal addr_a_sel : std_logic_vector(log2(DEPTH)-1 downto 0);
signal data_a_reg : std_logic_vector(DATA_WIDTH-1 downto 0);
signal data_a_sel : std_logic_vector(DATA_WIDTH-1 downto 0);
signal we_a_reg : std_logic;
signal we_a_sel : std_logic;
signal read_a : std_logic_vector(DATA_WIDTH-1 downto 0);
signal read_a_reg : std_logic_vector(DATA_WIDTH-1 downto 0);
signal addr_b_reg : std_logic_vector(log2(DEPTH)-1 downto 0);
signal addr_b_sel : std_logic_vector(log2(DEPTH)-1 downto 0);
signal data_b_reg : std_logic_vector(DATA_WIDTH-1 downto 0);
signal data_b_sel : std_logic_vector(DATA_WIDTH-1 downto 0);
signal we_b_reg : std_logic;
signal we_b_sel : std_logic;
signal read_b : std_logic_vector(DATA_WIDTH-1 downto 0);
signal read_b_reg : std_logic_vector(DATA_WIDTH-1 downto 0);
begin
-- Port A
pPORT_A_wr : process(clk)
begin
if(clk = '1' and clk'event) then
if(we_a_sel = '1') then
ram(to_integer(unsigned(addr_a_sel))) := data_a_sel;
end if;
addr_a_reg <= addr_a;
data_a_reg <= data_a;
we_a_reg <= we_a;
end if;
end process;
addr_a_sel <= addr_a_reg when ((REGISTER_ADDRA = "CLOCK0") or (REGISTER_ADDRA = "CLOCK1")) else addr_a;
data_a_sel <= data_a_reg when ((REGISTER_ADDRA = "CLOCK0") or (REGISTER_ADDRA = "CLOCK1")) else data_a;
we_a_sel <= we_a_reg when ((REGISTER_ADDRA = "CLOCK0") or (REGISTER_ADDRA = "CLOCK1")) else we_a;
q_a <= read_a_reg when ((REGISTER_OUTPUTA = "CLOCK0") or (REGISTER_OUTPUTA = "CLOCK1")) else read_a;
pPORT_A_rd : process(clk)
begin
if(clk = '1' and clk'event) then
if (we_a_sel = '1') and READ_WRITE_MODE = "OLD_DATA" then
-- hold old data
else
read_a <= ram(to_integer(unsigned(addr_a_sel)));
end if;
read_a_reg <= read_a;
end if;
end process;
-- Port B
pPORT_B_wr : process(clk)
begin
if(clk = '1' and clk'event) then
if(we_b_sel = '1') then
ram(to_integer(unsigned(addr_b_sel))) := data_b_sel;
end if;
addr_b_reg <= addr_b;
data_b_reg <= data_b;
we_b_reg <= we_b;
end if;
end process;
addr_b_sel <= addr_b_reg when ((REGISTER_ADDRB = "CLOCK0") or (REGISTER_ADDRB = "CLOCK1")) else addr_b;
data_b_sel <= data_b_reg when ((REGISTER_ADDRB = "CLOCK0") or (REGISTER_ADDRB = "CLOCK1")) else data_b;
we_b_sel <= we_b_reg when ((REGISTER_ADDRB = "CLOCK0") or (REGISTER_ADDRB = "CLOCK1")) else we_b;
q_b <= read_b_reg when ((REGISTER_OUTPUTB = "CLOCK0") or (REGISTER_OUTPUTB = "CLOCK1")) else read_b;
pPORT_B_rd : process(clk)
begin
if(clk = '1' and clk'event) then
if (we_b_sel = '1') and READ_WRITE_MODE = "OLD_DATA" then
-- hold old data
else
read_b <= ram(to_integer(unsigned(addr_b_sel)));
end if;
read_b_reg <= read_b;
end if;
end process;
end rtl;

View file

@ -0,0 +1,203 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
-- Inferred RAM Sync FIFO
library ieee;
use ieee.std_logic_1164.all;
USE ieee.numeric_std.ALL;
use work.common_pkg.all;
-- ****** REGISTER_OUTPUT : string := "ON"; -- "OFF"
-- never used in all current instances. Doesn't seem to make any difference to Altera sim dcs
-- Note usedw goes to 0 when fifo is full. This is the same as Altera
entity inferred_sync_fifo_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 1 to 131072 := 64;
REGISTER_OUTPUT : string := "ON"; -- "OFF"
NEARLY_FULL : natural range 1 to 131072 := 62;
NEARLY_EMPTY : natural range 1 to 131072 := 2;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port
(
clk : in std_logic ;
rst_n : in std_logic := '1';
sclr : in std_logic := '0';
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
almost_full : out std_logic ;
full : out std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
almost_empty : out std_logic ;
empty : out std_logic ;
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end inferred_sync_fifo_1;
architecture rtl OF inferred_sync_fifo_1 is
type memory_t is array (DEPTH-1 downto 0) of std_logic_vector (DATA_WIDTH-1 downto 0) ;
signal ram : memory_t := (others => (others => '0')); -- make simulation same as Altera
signal wr_addr : integer range 0 to DEPTH-1;
signal rd_addr : integer range 0 to DEPTH-1;
signal rd_addr_reg : integer range 0 to DEPTH-1;
signal count : integer range 0 to DEPTH;
signal empty_int : std_logic;
signal empty_d : std_logic;
begin
usedw <= std_logic_vector(to_unsigned(count, usedw'high+1));
PROC_WRITE : process(rst_n, clk)
begin
if rst_n = '0' then
elsif(clk'event and clk = '1') then
if(wrreq = '1') and full = '0' and sclr = '0' then
ram(wr_addr) <= wrdata;
end if;
end if;
end process;
PROC_READ : process(rst_n, clk)
begin
if rst_n = '0' then
rddata <= (others => '0');
elsif(clk'event and clk = '1') then
if sclr = '1' then
rddata <= (others => '0');
elsif SHOWAHEAD = "ON" then
rddata <= ram(rd_addr);
elsif rdreq = '1' then
rddata <= ram(rd_addr_reg);
end if;
end if;
end process;
PROC_WR_ADDR : process(rst_n, clk)
begin
if rst_n = '0' then
wr_addr <= 0;
elsif(clk'event and clk = '1') then
if sclr = '1' then
wr_addr <= 0;
elsif wrreq = '1' then -- write
if full = '0' then
if wr_addr = DEPTH-1 then
wr_addr <= 0;
else
wr_addr <= wr_addr + 1;
end if;
end if;
end if;
end if;
end process;
PROC_RD_ADDR : process(all)
begin
if rst_n = '0' then
rd_addr <= 0;
elsif sclr = '1' then
rd_addr <= 0;
elsif rdreq = '1' then -- read
if empty = '0' then
if rd_addr_reg = DEPTH-1 then
rd_addr <= 0;
else
rd_addr <= rd_addr_reg + 1;
end if;
else
rd_addr <= rd_addr_reg;
end if;
else
rd_addr <= rd_addr_reg;
end if;
end process;
PROC_ADDR_REG : process(rst_n, clk)
begin
if rst_n = '0' then
rd_addr_reg <= 0;
elsif(clk'event and clk = '1') then
rd_addr_reg <= rd_addr;
end if;
end process;
PROC_FLAGS : process(rst_n, clk)
begin
if rst_n = '0' then
count <= 0;
full <= '0';
empty_int <= '1';
empty_d <= '1';
almost_full <= '0';
almost_empty <= '1';
elsif(clk'event and clk = '1') then
empty_d <= empty_int;
if sclr = '1' then
count <= 0;
full <= '0';
empty_int <= '1';
almost_full <= '0';
almost_empty <= '1';
elsif wrreq = '1' and rdreq = '0' then -- Count goes up by 1
if full = '0' then
count <= count + 1;
if count = DEPTH-1 then
full <= '1';
end if;
if (NEARLY_FULL-1) = count then
almost_full <= '1';
end if;
end if;
if (NEARLY_EMPTY-1) = count then
almost_empty <= '0';
end if;
empty_int <= '0';
elsif wrreq = '0' and rdreq = '1' then
if empty_int = '0' then
count <= count - 1;
if count = 1 then
empty_int <= '1';
end if;
end if;
if NEARLY_EMPTY = count then
almost_empty <= '1';
end if;
if NEARLY_FULL = count then
almost_full <= '0';
end if;
full <= '0';
end if;
end if;
end process;
ASSERT_PROC : process(clk)
begin
assert DEPTH > 1
report "**** Config error Fifo Depth must be grester than 1!"
severity error;
end process;
empty <= empty_int or empty_d when SHOWAHEAD = "ON" else empty_int; -- delay going not empty to match Altera when SHOWAHEAD
end rtl;

View file

@ -0,0 +1,443 @@
-------------------------------------------------------------------------------
-- Title : Package Functions
-- Project : Common
-------------------------------------------------------------------------------
-- File : pkg_functions.vhd
-- Author : <Damian@LANGERHANS>
-- Company : Global Inkjet Systems
-- Created : 2010-11-17
-- Last update: 2015-05-22
-- SVN ID : $Id$
-- Standard : VHDL'87
-------------------------------------------------------------------------------
-- Description: Various useful functions
-------------------------------------------------------------------------------
-- Copyright (c) 2010 Global Inkjet Systems
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use std.textio.all;
package PKG_FUNCTIONS is
type fifo_80b_vector is array (natural range <>) of std_logic_vector(79 downto 0);
type fifo_64b_vector is array (natural range <>) of std_logic_vector(63 downto 0);
type fifo_32b_vector is array (natural range <>) of std_logic_vector(31 downto 0);
type fifo_20b_vector is array (natural range <>) of std_logic_vector(19 downto 0);
type fifo_18b_vector is array (natural range <>) of std_logic_vector(17 downto 0);
type fifo_19b_vector is array (natural range <>) of std_logic_vector(18 downto 0);
type dc_dout_t is array (16 downto 1) of std_logic_vector(15 downto 0);
type dout_t is array (16 downto 0) of std_logic_vector(15 downto 0);
type fifo_16b_vector is array (natural range <>) of std_logic_vector(15 downto 0);
type fifo_13b_vector is array (natural range <>) of std_logic_vector(12 downto 0);
type fifo_12b_vector is array (natural range <>) of std_logic_vector(11 downto 0);
type fifo_10b_vector is array (natural range <>) of std_logic_vector(9 downto 0);
type fifo_9b_vector is array (natural range <>) of std_logic_vector(8 downto 0);
type fifo_8b_vector is array (natural range <>) of std_logic_vector(7 downto 0);
type fifo_5b_vector is array (natural range <>) of std_logic_vector(4 downto 0);
type fifo_4b_vector is array (natural range <>) of std_logic_vector(3 downto 0);
type fifo_3b_vector is array (natural range <>) of std_logic_vector(2 downto 0);
type fifo_2b_vector is array (natural range <>) of std_logic_vector(1 downto 0);
-- TYPE fifo_3b_unsigned_vector IS ARRAY ( NATURAL RANGE <>) OF unsigned(2 downto 0);
-- Get the log to base 2 of an integer. Return result plus 1
function LOG2_PLUS_ONE(N : integer) return integer;
function UNSIGNEDHIGH (N : natural) return integer;
function IS_POWER_OF_2 (N : integer) return boolean;
function WORDS(N : integer; M : integer) return integer;
function OR_BUS(DATA : std_logic_vector) return std_logic;
function CLIP (N : natural; MAX : natural) return natural;
function MAX_VAL (N : unsigned) return boolean;
function MAX_VAL (N : signed) return boolean;
function MAX_VAL (N : std_logic_vector) return boolean;
function STD2UINT (
n : std_logic_vector)
return natural;
function STD2INT (
n : std_logic_vector)
return integer;
-- useful for moving tristate signals up to a top level
type tristate_port_t is record
O : std_logic; -- output
I : std_logic; -- input
EN : std_logic; -- tristate enable - active high for 'Z'
end record;
function sel(Cond : boolean; If_True, If_False : integer) return integer;
-- pragma translate_off
-- Assemble a GBUS PKT
function GBUS_PKT (
ID : std_logic_vector(7 downto 0);
WLEN : natural;
RLEN : natural;
ADDR : natural;
WDATA : std_logic_vector := x"00")
return std_logic_vector;
function FIFO_WRAP (
CHAN : integer range 0 to 8;
PAYLOAD : std_logic_vector)
return std_logic_vector;
impure function print(
mytext : string;
emph : boolean := false;
display : boolean := true)
return boolean;
type storage_type is protected
impure function add(value : integer) return boolean; -- puts an item into the storage
impure function rmv return integer; -- removes and returns the oldest item from the storage
impure function level return integer; -- number of items in storage
impure function empty return boolean; -- true if no items in storage
impure function full return boolean; -- true if no space remaining in storage
impure function rst return boolean; -- resets storage to empty condition
end protected storage_type;
-- pragma translate_on
end PKG_FUNCTIONS;
package body PKG_FUNCTIONS is
-----------------------------------------------------------------------------
-- Get the log to base 2 of an integer. Return result plus 1
function LOG2_PLUS_ONE(N : integer) return integer is
begin
if N = 1 then
return 1;
elsif N <= 0 then
--pragma translate_off
report "Invalid input for LOG function" severity error;
--pragma translate_on
return 0;
else
return 1 + LOG2_PLUS_ONE(N/2);
end if;
end function LOG2_PLUS_ONE;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- purpose: Given a value N, this function returns the value for the HIGH end of an unsigned vector large enough to hold the value N
function UNSIGNEDHIGH (
N : natural)
return integer is
begin -- UNSIGNEDHIGH
if N <= 1 then
return 0;
else
return LOG2_PLUS_ONE(N)-1;
end if;
end UNSIGNEDHIGH;
function IS_POWER_OF_2(N : integer) return boolean is
begin
if 2**(LOG2_PLUS_ONE(N)-1) = N then
return true;
else
return false;
end if;
end function IS_POWER_OF_2;
-----------------------------------------------------------------------------
-- Return number of words of length M in N bits of data
function WORDS(N : integer; M : integer) return integer is
begin
if M = 0 then
--pragma translate_off
report "Invalid input for WORDS function" severity error;
--pragma translate_on
return 0;
elsif N = 0 then
return 0;
elsif N < M then
return 1;
else
return 1 + WORDS(N - M, M);
end if;
end function WORDS;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- Logical or of all bits in a bus
function OR_BUS(DATA : std_logic_vector) return std_logic is
variable OR_ARRAY : std_logic_vector(2*DATA'length-2 downto 0);
begin
--Produces a tree of OR gates.
OR_ARRAY(DATA'length-1 downto 0) := DATA;
for n in 0 to DATA'length-2 loop
OR_ARRAY(DATA'length+n) := OR_ARRAY(2*n) or OR_ARRAY(2*n+1);
end loop; -- XOR_COUNT
return OR_ARRAY(OR_ARRAY'high);
end function OR_BUS;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
function CLIP (N : natural; MAX : natural) return natural is
begin
if N <= MAX then
return N;
else
return MAX;
end if;
end function CLIP;
function MAX_VAL (N : unsigned) return boolean is
begin
if (not(N)) = 0 then
return true;
end if;
return false;
end function MAX_VAL;
function MAX_VAL (N : signed) return boolean is
begin -- MAX_VAL
return max_val(unsigned(N));
end MAX_VAL;
function MAX_VAL (N : std_logic_vector) return boolean is
begin -- MAX_VAL
return max_val(unsigned(N));
end MAX_VAL;
function STD2UINT (n : std_logic_vector) return natural is
begin
return to_integer(unsigned(n));
end function STD2UINT;
function STD2INT (n : std_logic_vector) return integer is
begin
return to_integer(signed(n));
end function STD2INT;
----------------------------------------------------------------
-- Functions to select one or the other based on a boolean (or
-- std_ulogic or std_logic) input.
-- Analogous to the C statement x = Cond ? a : b
----------------------------------------------------------------
-- constant k: integer := sel(BOOLEAN_GENERIC, 5, 8);
-- or ...
-- constant k: integer := sel(Cond => BOOLEAN_GENERIC, If_True => 5, If_False => 8);
function sel(Cond : boolean; If_True, If_False : integer) return integer is
begin
if (Cond = true) then
return(If_True);
else
return(If_False);
end if;
end function sel;
-----------------------------------------------------------------------------
-- pragma translate_off
-----------------------------------------------------------------------------
function GBUS_PKT (
ID : std_logic_vector(7 downto 0);
WLEN : natural;
RLEN : natural;
ADDR : natural;
WDATA : std_logic_vector := x"00")
return std_logic_vector is
function ONE_IF_GT (
N : natural;
MAX : natural) return natural is
begin
if N > MAX then
return 1;
else
return 0;
end if;
end function ONE_IF_GT;
-- Byte 0 Entity ID (ignore locally) \
-- Byte 1(7) read#/write | stripped out and passed
-- Byte 1(6) single word reply | as individual control lines
-- Byte 1(5) no further data | to the entity of this block
-- Byte 1(4:0) Command Address /
-- Byte 2,3 Write Length (/words) (unless no further data)
-- Byte 4,5 Reply Length (/words) (unless write, or single word reply)
-- Next Bytes - Write Length words of data unless no further data
constant return_len : natural := 16*(1 + ONE_IF_GT(WLEN, 0) + ONE_IF_GT(RLEN, 1) + WLEN);
variable return_vec : std_logic_vector(return_len - 1 downto 0);
begin
if WLEN > 0 then
if RLEN > 1 then
-- long data, long reply
return_vec := ID&'0'&'0'&'0'&std_logic_vector(to_unsigned(ADDR, 5))&
std_logic_vector(to_unsigned(WLEN, 16)) &
std_logic_vector(to_unsigned(RLEN, 16)) &
WDATA;
elsif RLEN = 1 then
-- long data, short reply
return_vec := ID&'0'&'1'&'0'&std_logic_vector(to_unsigned(ADDR, 5))&
std_logic_vector(to_unsigned(WLEN, 16)) &
WDATA;
else
-- long data, no reply
return_vec := ID&'1'&'0'&'0'&std_logic_vector(to_unsigned(ADDR, 5))&
std_logic_vector(to_unsigned(WLEN, 16)) &
WDATA;
end if;
else
if RLEN > 1 then
-- no data, long reply
return_vec := ID&'0'&'0'&'1'&std_logic_vector(to_unsigned(ADDR, 5))&
std_logic_vector(to_unsigned(RLEN, 16));
elsif RLEN = 1 then
-- no data, short reply
return_vec := ID&'0'&'1'&'1'&std_logic_vector(to_unsigned(ADDR, 5));
else
-- no data, no reply
return_vec := ID&'1'&'0'&'1'&std_logic_vector(to_unsigned(ADDR, 5));
end if;
end if;
return return_vec;
end function GBUS_PKT;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
function FIFO_WRAP (
chan : integer range 0 to 8;
payload : std_logic_vector)
return std_logic_vector is
variable return_vec : std_logic_vector(WORDS(payload'length, 16)*16 + 31 downto 0);
begin
return_vec := (others => '0');
return_vec(return_vec'high downto return_vec'high - 31 - payload'length) := x"11" & std_logic_vector(to_unsigned(WORDS(payload'length, 16), 16)) & payload;
return return_vec;
end function FIFO_WRAP;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
impure function print(
mytext : string;
emph : boolean := false;
display : boolean := true)
return boolean is
variable my_input_line : line;
variable my_output_line : line;
begin
if display then
-- allows user to specify verbosity
if emph then
write(my_output_line, string'(" ******************************************************* "));
writeline(output, my_output_line);
end if;
write(my_output_line, NOW);
write(my_output_line, string'(" : "));
write(my_output_line, mytext);
writeline(output, my_output_line);
if emph then
write(my_output_line, string'(" ******************************************************* "));
writeline(output, my_output_line);
end if;
deallocate(my_input_line);
end if;
return true;
end function print;
-----------------------------------------------------------------------------
type storage_type is protected body
type int_array_type is array (1 to 1000) of integer;
variable int_array : int_array_type := (others => -3);
variable fill_level : integer := 0;
impure function level return integer is
begin
return fill_level;
end function level;
impure function empty return boolean is
begin
if fill_level = 0 then
return true;
else
return false;
end if;
end function empty;
impure function full return boolean is
begin
if fill_level = int_array'high then
return true;
else
return false;
end if;
end function full;
impure function add(value : integer) return boolean is
begin
if not full then
int_array := value & int_array(1 to int_array'high - 1);
fill_level := fill_level + 1;
return true;
else
report "Error - too much buffering" severity error;
return false;
end if;
end function add;
impure function rmv return integer is
variable tmp : integer;
begin
if not empty then
tmp := int_array(fill_level);
int_array(fill_level) := -3;
fill_level := fill_level - 1;
return tmp;
else
report "Error - No buffering" severity error;
return -2;
end if;
end function rmv;
impure function rst return boolean is
begin
int_array := (others => -3);
fill_level := 0;
return true;
end function rst;
end protected body storage_type;
-- pragma translate_on
end PKG_FUNCTIONS;

View file

@ -0,0 +1,288 @@
-------------------------------------------------------------------------------
-- Title : queue_and_delay_1
-- Project : project independent
-------------------------------------------------------------------------------
-- File : queue_and_delay_1.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2016-05-28
-- Last update: 2019-11-18
-- SVN ID : Git
-- Standard : VHDL'93
-------------------------------------------------------------------------------
-- Description:
-- Generic component implementing a queue and delay functionality: Apply a
-- static programmable delay to the input signal. Since the block is FIFO based
-- (2048 words), the user must make sure that the number of transitions on the
-- input signal happening within the programmed delay is lower than the size of the FIFO.
-- E.g.: if the user program a delay of 2 ms, the input signal must have less
-- than 1024 pulses in 2 ms => max pulse rate = 512kHz. The block rises the
-- error bit when this condition is violated.
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.common_pkg.all;
entity queue_and_delay_1 is
generic(
DELAY_WIDTH : integer range 8 to 32 := 32;
USE_EXT_TIME : boolean := false;
QUEUE_SIZE : natural range 16 to 8192 := 1024;
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port (
rstN : in std_logic;
clk : in std_logic;
init : in std_logic;
cnt_dir : in std_logic; -- specify the direction of the cnt (0 => up, 1
-- => down), when use_ext_time is set to true
delay : in std_logic_vector(DELAY_WIDTH-1 downto 0);
ext_time : in std_logic_vector(31 downto 0);
wave_in : in std_logic;
wave_out : out std_logic;
no_edge_detect : in std_logic := '0';
ovf_error : out std_logic);
end queue_and_delay_1;
architecture RTL of queue_and_delay_1 is
component sync_fifo_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 1 to 131072 := 64;
REGISTER_OUTPUT : string := "ON"; -- "OFF"
NEARLY_FULL : natural range 1 to 131072 := 62;
NEARLY_EMPTY : natural range 1 to 131072 := 2;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port (
clk : in std_logic ;
rst_n : in std_logic := '1';
sclr : in std_logic := '0';
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
almost_full : out std_logic ;
full : out std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
almost_empty : out std_logic ;
empty : out std_logic ;
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
signal toggle_in, toggle_out,time_elapsed : std_logic;
signal wave_in_d, wave_out_i, pending_trans : std_logic;
signal fifo_rd_en, fifo_empty, fifo_full : std_logic;
signal cnt_dir_i, wave_out_i_d, new_event : std_logic;
signal wave_out_ii, shf_enable, ext_msb : std_logic;
signal delay_line : std_logic_vector( 7 downto 0);
signal int_time, local_time_d, event_time : std_logic_vector(31 downto 0);
signal diff_time, time_entry : std_logic_vector(31 downto 0);
begin -- RTL
-----------------------------------------------------------------------------
-- Detect transitions in the input signal and memorize those events in a
-- FIFO, together with a timetag. This process can be seen as a representation
-- of the input signal in a compressed format.
-----------------------------------------------------------------------------
toggle_in <= '1' when wave_in /= wave_in_d else '0';
pInputEdgeDetect : process(clk)
begin
if(clk = '1' and clk'event) then
wave_in_d <= wave_in;
end if;
end process pInputEdgeDetect;
iENTRY_QUEUE: sync_fifo_1
generic map(
DATA_WIDTH => 32,
DEPTH => QUEUE_SIZE,
REGISTER_OUTPUT => "OFF",
DEVICE_FAMILY => DEVICE_FAMILY,
SHOWAHEAD => "OFF"
)
port map (
clk => clk,
wrdata => time_entry,
rdreq => fifo_rd_en,
sclr => init,
wrreq => toggle_in,
empty => fifo_empty,
full => fifo_full,
rddata => event_time,
usedw => open
);
-- Check Overflow error:
pCHECK_OVF : process(rstN, clk)
begin
if(rstN = '0') then
ovf_error <= '0';
elsif(clk = '1' and clk'event) then
if(init = '1') then
ovf_error <= '0';
elsif(toggle_in = '1' and fifo_full = '1') then
ovf_error <= '1';
end if;
end if;
end process pCHECK_OVF;
-- Time reference: either use the external one or generate it locally
gTIME_REF0: if USE_EXT_TIME = true generate
int_time <= ext_time;
shf_enable <= '1' when int_time /= local_time_d else '0';
pTimeElapsed : process(clk)
begin
if(clk = '1' and clk'event) then
if(cnt_dir_i = '0') then
time_entry <= std_logic_vector(signed(int_time) + signed(delay));
else
time_entry <= std_logic_vector(signed(int_time) - signed(delay) + 1);
end if;
local_time_d <= int_time;
cnt_dir_i <= cnt_dir;
if(cnt_dir_i = '0') then
time_elapsed <= not diff_time(diff_time'left);
else
time_elapsed <= diff_time(diff_time'left);
end if;
new_event <= fifo_rd_en;
end if;
end process pTimeElapsed;
diff_time <= std_logic_vector(signed(ext_time)-signed(event_time));
end generate gTIME_REF0;
gTIME_REF1: if USE_EXT_TIME = false generate
pGEN_LOC_REF : process(rstN, clk)
begin
if(rstN = '0') then
int_time <= (others => '0');
elsif(clk = '1' and clk'event) then
if(init = '1') then
int_time <= (others => '0');
else
int_time <= std_logic_vector(unsigned(int_time)+1);
end if;
end if;
end process pGEN_LOC_REF;
new_event <= fifo_rd_en;
pTimeElapsed : process(clk)
begin
if(clk = '1' and clk'event) then
time_entry <= std_logic_vector(signed(int_time) + signed(delay));
end if;
end process pTimeElapsed;
diff_time <= std_logic_vector(unsigned(int_time)-unsigned(event_time));
time_elapsed <= '1' when diff_time(diff_time'left) = '0' else '0';
shf_enable <= '1';
end generate gTIME_REF1;
-----------------------------------------------------------------------------
-- Delay the input signal
-----------------------------------------------------------------------------
-- Read the signal transitions recorded in the FIFO, apply the static delay
pDELAY_WAVE_GEN : process(clk)
begin
if(clk = '1' and clk'event) then
if(init = '1' or (time_elapsed = '1' and new_event = '0')) then
pending_trans <= '0';
elsif(new_event = '1') then
pending_trans <= '1';
end if;
if(pending_trans = '0' and fifo_empty = '0' and fifo_rd_en = '0' and new_event = '0') then
fifo_rd_en <= '1';
else
fifo_rd_en <= '0';
end if;
end if;
end process pDELAY_WAVE_GEN;
pGEN_OUT : process(rstN, clk)
begin
if(rstN = '0') then
wave_out_i <= '0';
elsif(clk = '1' and clk'event) then
if(init = '1') then
wave_out_i <= wave_in_d;
elsif(toggle_out = '1') then
wave_out_i <= not wave_out_i;
end if;
end if;
end process pGEN_OUT;
-- Because of the intrinsic latency with the FIFO, a shift register is used
-- to achieve small delays (< 8).
pDELAY_THROUGH_SHF : process(clk)
begin
if(clk = '1' and clk'event) then
if(shf_enable = '1') then
delay_line <= delay_line(6 downto 0) & wave_in;
end if;
end if;
end process pDELAY_THROUGH_SHF;
toggle_out <= time_elapsed and pending_trans;
-- When using the external counter, the input signal might have multiple rising and
-- falling events whitout a change a value in the counter. When this happens,
-- the pulse width is not properly replicated in the output of the delay
-- block. To make the behaviour more predictable, when using the external
-- counter, a positive edge detector is inserted at the output.
gOUT_GEN0: if use_ext_time = false generate
wave_out_ii <= wave_out_i when unsigned(delay) >= 8 else delay_line(to_integer(unsigned(delay(2 downto 0))));
pOUT_GEN0: process(clk)
begin
if(clk = '1' and clk'event) then
wave_out <= wave_out_ii;
end if;
end process pOUT_GEN0;
end generate gOUT_GEN0;
gOUT_GEN1: if use_ext_time = true generate
pOUT_GEN1: process(clk)
begin
if(clk = '1' and clk'event) then
wave_out_i_d <= wave_out_i;
if(no_edge_detect = '0') then
wave_out <= wave_out_i and not wave_out_i_d;
else
wave_out <= wave_out_i;
end if;
end if;
end process pOUT_GEN1;
end generate gOUT_GEN1;
end RTL;

View file

@ -0,0 +1,222 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use work.common_pkg.all;
use work.vendor_pkg_1.all;
entity async_fifo_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 64;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON"; -- "OFF"
SYNC_CLR : string := "OFF" -- "ON"
);
port
(
clr : in std_logic := '0';
wrclk : in std_logic ;
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrfull : out std_logic ;
wrusedw : out std_logic_vector (log2(DEPTH)-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
rdusedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end async_fifo_1;
architecture struct of async_fifo_1 is
--{{{
component alt_async_fifo_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 64;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON"; -- "OFF"
SYNC_CLR : string := "OFF" -- "ON"
);
port
(
clr : in std_logic := '0';
wrclk : in std_logic ;
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrfull : out std_logic ;
wrusedw : out std_logic_vector (log2(DEPTH)-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
rdusedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
--}}}
--{{{
component efx_fifo_1 is
generic (
FAMILY : string := "TRION";
SYNC_CLK : integer := 0;
BYPASS_RESET_SYNC : integer := 0;
SYNC_STAGE : integer := 2;
MODE : string := "FWFT"; -- STANDARD
DEPTH : integer := 512;
DATA_WIDTH : integer := 16;
PIPELINE_REG : integer := 0;
OPTIONAL_FLAGS : integer := 0;
OUTPUT_REG : integer := 1;
PROGRAMMABLE_FULL : string := "NONE";
PROG_FULL_ASSERT : integer := 128;
PROG_FULL_NEGATE : integer := 128;
PROGRAMMABLE_EMPTY : string := "NONE";
PROG_EMPTY_ASSERT : integer := 0;
PROG_EMPTY_NEGATE : integer := 2;
ASYM_WIDTH_RATIO : integer := 4 -- 1:1
);
port (
full_o : out std_logic;
empty_o : out std_logic;
rdata : out std_logic_vector(DATA_WIDTH-1 downto 0);
wr_clk_i : in std_logic;
rd_clk_i : in std_logic;
wr_en_i : in std_logic;
rd_en_i : in std_logic;
wdata : in std_logic_vector(DATA_WIDTH-1 downto 0);
wr_datacount_o : out std_logic_vector(log2(DEPTH) downto 0);
rst_busy : out std_logic;
rd_datacount_o : out std_logic_vector(log2(DEPTH) downto 0);
clk_i : in std_logic := '0';
a_wr_rst_i : in std_logic := '0';
a_rd_rst_i : in std_logic := '0';
a_rst_i : in std_logic
);
end component;
--}}}
--{{{
component inferred_async_fifo_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 64;
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON"; -- "OFF"
SYNC_CLR : string := "OFF" -- "ON"
);
port
(
clr : in std_logic := '0';
wrclk : in std_logic ;
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrfull : out std_logic ;
wrusedw : out std_logic_vector (log2(DEPTH)-1 downto 0);
rdclk : in std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
rdempty : out std_logic ;
rdusedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
--}}}
signal wr_datacount_o : std_logic_vector(log2(DEPTH) downto 0);
signal rd_datacount_o : std_logic_vector(log2(DEPTH) downto 0);
begin
GEN_VENDOR : if IS_ALTERA(DEVICE_FAMILY) generate
alt_async_fifo_inst : alt_async_fifo_1
generic map(
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
DEVICE_FAMILY => DEVICE_FAMILY,
SHOWAHEAD => SHOWAHEAD,
CHECKING => CHECKING,
SYNC_CLR => SYNC_CLR
)
port map(
clr => clr,
wrclk => wrclk,
wrreq => wrreq,
wrdata => wrdata,
wrfull => wrfull,
wrusedw => wrusedw,
rdclk => rdclk,
rdreq => rdreq,
rddata => rddata,
rdempty => rdempty,
rdusedw => rdusedw);
elsif IS_EFINIX(DEVICE_FAMILY) generate
efx_async_fifo_inst : efx_fifo_1
generic map (
SYNC_CLK => 0,
MODE => EFX_MODE(SHOWAHEAD),
OUTPUT_REG => 0,
DEPTH => DEPTH,
DATA_WIDTH => DATA_WIDTH
)
port map (
full_o => wrfull,
empty_o => rdempty,
rdata => rddata,
wr_clk_i => wrclk,
rd_clk_i => rdclk,
wr_en_i => wrreq,
rd_en_i => rdreq,
wdata => wrdata,
wr_datacount_o => wr_datacount_o,
rd_datacount_o => rd_datacount_o,
rst_busy => open,
a_rst_i => clr
);
wrusedw <= wr_datacount_o(wrusedw'range);
rdusedw <= rd_datacount_o(rdusedw'range) when rdempty = '0' else (others => '0'); -- rdused is quicker than empty
else generate
inferred_async_fifo_inst : inferred_async_fifo_1
generic map(
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
SHOWAHEAD => SHOWAHEAD,
CHECKING => CHECKING,
SYNC_CLR => SYNC_CLR
)
port map(
clr => clr,
wrclk => wrclk,
wrreq => wrreq,
wrdata => wrdata,
wrfull => wrfull,
wrusedw => wrusedw,
rdclk => rdclk,
rdreq => rdreq,
rddata => rddata,
rdempty => rdempty,
rdusedw => rdusedw);
end generate;
end struct;

View file

@ -0,0 +1,125 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use work.common_pkg.all;
use work.vendor_pkg_1.all;
entity dp_ram_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
clk : in std_logic := '1';
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wraddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
wren : in std_logic := '0';
rdaddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end dp_ram_1;
architecture struct of dp_ram_1 is
--{{{
component alt_dp_ram_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
clk : in std_logic := '1';
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
wraddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
wren : in std_logic := '0';
rdaddr : in std_logic_vector (log2(DEPTH)-1 downto 0);
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end component;
--}}}
--{{{
component inferred_dpram_1
generic(
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_ADDRA : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_ADDRB : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_OUTPUTA : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_OUTPUTB : string := "UNREGISTERED"; -- "CLOCK0"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Ultrascale+"
);
port(
clk : in std_logic;
-- Port-A
addr_a : in std_logic_vector(log2(DEPTH)-1 downto 0);
we_a : in std_logic := '0';
data_a : in std_logic_vector(DATA_WIDTH-1 downto 0) := (others => '0');
q_a : out std_logic_vector(DATA_WIDTH-1 downto 0);
-- Port-B
addr_b : in std_logic_vector(log2(DEPTH)-1 downto 0);
we_b : in std_logic := '0';
data_b : in std_logic_vector(DATA_WIDTH-1 downto 0) := (others => '0');
q_b : out std_logic_vector(DATA_WIDTH-1 downto 0)
);
end component;
--}}}
begin
GEN_VENDOR : if IS_ALTERA(DEVICE_FAMILY) generate
dp_ram_inst : alt_dp_ram_1
generic map(
DEVICE_FAMILY => DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
READ_WRITE_MODE => READ_WRITE_MODE,
REGISTER_OUTPUT => REGISTER_OUTPUT
)
port map(
clk => clk,
wren => wren,
wraddr => wraddr,
wrdata => wrdata,
rdaddr => rdaddr,
rddata => rddata
);
else generate
dp_ram_inst : inferred_dpram_1
generic map(
DEVICE_FAMILY => DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
READ_WRITE_MODE => READ_WRITE_MODE,
REGISTER_OUTPUTB => REGISTER_OUTPUT
)
port map(
clk => clk,
we_a => wren,
addr_a => wraddr,
data_a => wrdata,
addr_b => rdaddr,
q_b => rddata
);
end generate;
end struct;

View file

@ -0,0 +1,137 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use work.common_pkg.all;
use work.vendor_pkg_1.all;
entity rw_dp_ram_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
addr_a : in std_logic_vector (log2(DEPTH)-1 downto 0);
addr_b : in std_logic_vector (log2(DEPTH)-1 downto 0);
clk : in std_logic := '1';
wrdata_a : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrdata_b : in std_logic_vector (DATA_WIDTH-1 downto 0);
wren_a : in std_logic := '0';
wren_b : in std_logic := '0';
rddata_a : out std_logic_vector (DATA_WIDTH-1 downto 0);
rddata_b : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end rw_dp_ram_1;
architecture struct of rw_dp_ram_1 is
--{{{
component alt_rw_dp_ram_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_OUTPUT : string := "CLOCK0"; -- "UNREGISTERED"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP"
);
port
(
addr_a : in std_logic_vector (log2(DEPTH)-1 downto 0);
addr_b : in std_logic_vector (log2(DEPTH)-1 downto 0);
clk : in std_logic := '1';
wrdata_a : in std_logic_vector (DATA_WIDTH-1 downto 0);
wrdata_b : in std_logic_vector (DATA_WIDTH-1 downto 0);
wren_a : in std_logic := '0';
wren_b : in std_logic := '0';
rddata_a : out std_logic_vector (DATA_WIDTH-1 downto 0);
rddata_b : out std_logic_vector (DATA_WIDTH-1 downto 0)
);
end component;
--}}}
--{{{
component inferred_dpram_1
generic(
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 2 to 131072 := 128;
REGISTER_ADDRA : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_ADDRB : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_OUTPUTA : string := "UNREGISTERED"; -- "CLOCK0"
REGISTER_OUTPUTB : string := "UNREGISTERED"; -- "CLOCK0"
READ_WRITE_MODE : string := "OLD_DATA"; -- "DONT_CARE"
DEVICE_FAMILY : string := "Ultrascale+"
);
port(
clk : in std_logic;
-- Port-A
addr_a : in std_logic_vector(log2(DEPTH)-1 downto 0);
we_a : in std_logic := '0';
data_a : in std_logic_vector(DATA_WIDTH-1 downto 0) := (others => '0');
q_a : out std_logic_vector(DATA_WIDTH-1 downto 0);
-- Port-B
addr_b : in std_logic_vector(log2(DEPTH)-1 downto 0);
we_b : in std_logic := '0';
data_b : in std_logic_vector(DATA_WIDTH-1 downto 0) := (others => '0');
q_b : out std_logic_vector(DATA_WIDTH-1 downto 0));
end component;
--}}}
begin
GEN_VENDOR : if IS_ALTERA(DEVICE_FAMILY) generate
alt_rw_dp_ram_inst : alt_rw_dp_ram_1
generic map(
DEVICE_FAMILY => DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
READ_WRITE_MODE => READ_WRITE_MODE,
REGISTER_OUTPUT => REGISTER_OUTPUT
)
port map(
clk => clk,
addr_a => addr_a,
addr_b => addr_b,
wrdata_a => wrdata_a,
wrdata_b => wrdata_b,
wren_a => wren_a,
wren_b => wren_b,
rddata_a => rddata_a,
rddata_b => rddata_b
);
else generate
inferred_rw_dp_ram_inst : inferred_dpram_1
generic map(
DEVICE_FAMILY => DEVICE_FAMILY,
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
READ_WRITE_MODE => READ_WRITE_MODE,
REGISTER_OUTPUTA => REGISTER_OUTPUT
)
port map(
clk => clk,
addr_a => addr_a,
we_a => wren_a,
data_a => wrdata_a,
q_a => rddata_a,
addr_b => addr_b,
we_b => wren_b,
data_b => wrdata_b,
q_b => rddata_b
);
end generate;
end struct;

View file

@ -0,0 +1,254 @@
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use work.common_pkg.all;
use work.vendor_pkg_1.all;
entity sync_fifo_1 is
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 1 to 131072 := 64;
REGISTER_OUTPUT : string := "ON"; -- "OFF"
NEARLY_FULL : natural range 1 to 131072 := 62;
NEARLY_EMPTY : natural range 1 to 131072 := 2;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port
(
clk : in std_logic ;
rst_n : in std_logic := '1';
sclr : in std_logic := '0';
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
almost_full : out std_logic ;
full : out std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
almost_empty : out std_logic ;
empty : out std_logic ;
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end sync_fifo_1;
architecture struct of sync_fifo_1 is
--{{{
component alt_sync_fifo_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 1 to 131072 := 64;
REGISTER_OUTPUT : string := "ON"; -- "OFF"
NEARLY_FULL : natural range 1 to 131072 := 62;
NEARLY_EMPTY : natural range 1 to 131072 := 2;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port
(
clk : in std_logic ;
rst_n : in std_logic := '1';
sclr : in std_logic := '0';
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
almost_full : out std_logic ;
full : out std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
almost_empty : out std_logic ;
empty : out std_logic ;
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
--}}}
--{{{
component efx_fifo_1
generic (
FAMILY : string := "TRION";
SYNC_CLK : integer := 1;
BYPASS_RESET_SYNC : integer := 0;
SYNC_STAGE : integer := 2;
MODE : string := "FWFT"; -- STANDARD
DEPTH : integer := 512;
DATA_WIDTH : integer := 16;
PIPELINE_REG : integer := 0;
OPTIONAL_FLAGS : integer := 0;
OUTPUT_REG : integer := 0;
PROGRAMMABLE_FULL : string := "STATIC_SINGLE";
PROG_FULL_ASSERT : integer := 128;
PROG_FULL_NEGATE : integer := 128;
PROGRAMMABLE_EMPTY : string := "STATIC_SINGLE";
PROG_EMPTY_ASSERT : integer := 0;
PROG_EMPTY_NEGATE : integer := 2;
ASYM_WIDTH_RATIO : integer := 4 -- 1:1
);
port (
full_o : out std_logic;
prog_full_o : out std_logic;
empty_o : out std_logic;
prog_empty_o : out std_logic;
rdata : out std_logic_vector(DATA_WIDTH-1 downto 0);
clk_i : in std_logic;
wr_en_i : in std_logic;
rd_en_i : in std_logic;
wdata : in std_logic_vector(DATA_WIDTH-1 downto 0);
datacount_o : out std_logic_vector(log2(DEPTH) downto 0);
rst_busy : out std_logic;
wr_clk_i : in std_logic := '0';
rd_clk_i : in std_logic := '0';
a_wr_rst_i : in std_logic := '0';
a_rd_rst_i : in std_logic := '0';
a_rst_i : in std_logic
);
end component;
--}}}
--{{{
component inferred_sync_fifo_1
generic (
DATA_WIDTH : natural range 1 to 256 := 32;
DEPTH : natural range 1 to 131072 := 64;
REGISTER_OUTPUT : string := "ON"; -- "OFF"
NEARLY_FULL : natural range 1 to 131072 := 62;
NEARLY_EMPTY : natural range 1 to 131072 := 2;
DEVICE_FAMILY : string := "Cyclone V" ; -- "Cyclone 10 LP"
SHOWAHEAD : string := "ON"; -- "OFF"
CHECKING : string := "ON" -- "OFF"
);
port
(
clk : in std_logic ;
rst_n : in std_logic := '1';
sclr : in std_logic := '0';
wrreq : in std_logic ;
wrdata : in std_logic_vector (DATA_WIDTH-1 downto 0);
almost_full : out std_logic ;
full : out std_logic ;
rdreq : in std_logic ;
rddata : out std_logic_vector (DATA_WIDTH-1 downto 0);
almost_empty : out std_logic ;
empty : out std_logic ;
usedw : out std_logic_vector (log2(DEPTH)-1 downto 0)
);
end component;
--}}}
function calc_nearly_full_legal(nearly_full : integer; depth : integer) return integer is
begin
if nearly_full >= depth then
return depth-1;
end if;
return nearly_full;
end function calc_nearly_full_legal;
CONSTANT NEARLY_FULL_LEGAL : integer := calc_nearly_full_legal(NEARLY_FULL, DEPTH);
signal datacount_o : std_logic_vector(log2(DEPTH) downto 0);
begin
GEN_VENDOR : if IS_ALTERA(DEVICE_FAMILY) generate
alt_sync_fifo_inst : alt_sync_fifo_1
generic map(
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT,
NEARLY_FULL => NEARLY_FULL_LEGAL,
NEARLY_EMPTY => NEARLY_EMPTY,
DEVICE_FAMILY => DEVICE_FAMILY,
SHOWAHEAD => SHOWAHEAD,
CHECKING => CHECKING
)
port map(
clk => clk,
rst_n => rst_n,
sclr => sclr,
wrreq => wrreq,
wrdata => wrdata,
almost_full => almost_full,
full => full,
rdreq => rdreq,
rddata => rddata,
almost_empty => almost_empty,
empty => empty,
usedw => usedw);
elsif IS_EFINIX(DEVICE_FAMILY) generate
efx_sync_fifo_inst : efx_fifo_1
generic map (
SYNC_CLK => 1,
MODE => EFX_MODE(SHOWAHEAD),
OUTPUT_REG => 0,
DEPTH => DEPTH,
DATA_WIDTH => DATA_WIDTH,
PROG_FULL_ASSERT => NEARLY_FULL_LEGAL,
PROG_FULL_NEGATE => NEARLY_FULL_LEGAL,
PROG_EMPTY_ASSERT => NEARLY_EMPTY-1, -- Make same as Altera
PROG_EMPTY_NEGATE => NEARLY_EMPTY-1
)
port map (
full_o => full,
empty_o => empty,
rdata => rddata,
clk_i => clk,
wr_en_i => wrreq,
rd_en_i => rdreq,
wdata => wrdata,
prog_full_o => almost_full,
prog_empty_o => almost_empty,
datacount_o => datacount_o,
rst_busy => open,
a_rst_i => sclr or not rst_n
);
usedw <= datacount_o(usedw'range);
else generate
inferred_sync_fifo_inst : inferred_sync_fifo_1
generic map(
DATA_WIDTH => DATA_WIDTH,
DEPTH => DEPTH,
REGISTER_OUTPUT => REGISTER_OUTPUT,
NEARLY_FULL => NEARLY_FULL_LEGAL,
NEARLY_EMPTY => NEARLY_EMPTY,
DEVICE_FAMILY => DEVICE_FAMILY,
SHOWAHEAD => SHOWAHEAD,
CHECKING => CHECKING
)
port map(
clk => clk,
rst_n => rst_n,
sclr => sclr,
wrreq => wrreq,
wrdata => wrdata,
almost_full => almost_full,
full => full,
rdreq => rdreq,
rddata => rddata,
almost_empty => almost_empty,
empty => empty,
usedw => usedw);
end generate;
end struct;

View file

@ -0,0 +1,72 @@
-------------------------------------------------------------------------------
-- Title : Vendor Package
-- Project : Common
-------------------------------------------------------------------------------
-- File : vendor_pkg.vhd
-- Author : DCS
-- Company : Global Inkjet Systems
-- Created : 2022-09-21
-- Last update: 2022-09-21
-- SVN ID : GIT
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description: Vendor identity functions
-------------------------------------------------------------------------------
-- Copyright (c) 2022 Global Inkjet Systems
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
package vendor_pkg_1 is
function IS_ALTERA (DEVICE_FAMILY : string) return boolean;
function IS_EFINIX (DEVICE_FAMILY : string) return boolean;
function IS_XILINX (DEVICE_FAMILY : string) return boolean;
function EFX_MODE(SHOWAHEAD : string) return string;
end vendor_pkg_1;
package body vendor_pkg_1 is
function IS_ALTERA(DEVICE_FAMILY : string) return boolean is
begin
if DEVICE_FAMILY = "Cyclone V"
or DEVICE_FAMILY = "Cyclone 10 LP" then
return true;
else
return false;
end if;
end function IS_ALTERA;
function IS_EFINIX(DEVICE_FAMILY : string) return boolean is
begin
if DEVICE_FAMILY = "Efinix T20" then
return true;
else
return false;
end if;
end function IS_EFINIX;
function IS_XILINX(DEVICE_FAMILY : string) return boolean is
begin
if DEVICE_FAMILY = "Ultrascale+" then
return true;
else
return false;
end if;
end function IS_XILINX;
function EFX_MODE(SHOWAHEAD : string) return string is
begin
if SHOWAHEAD = "ON" then
return "FWFT";
else
return "STANDARD";
end if;
end function EFX_MODE;
end vendor_pkg_1;

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 KiB

Some files were not shown because too many files have changed in this diff Show more