Adding bear bones VProc based test bench template for reference

This commit is contained in:
Simon Southwell 2019-06-12 15:33:12 +01:00
commit bd68ef910b
18 changed files with 1187 additions and 0 deletions

View file

@ -0,0 +1,5 @@
@REM generate the testbench registers
@py -3 e:\git\fw_development_tools\logic_memory_mapper\gen_hdl.py -j .\doc\test.json -o .\ -s _auto
@py -3 e:\git\fw_development_tools\logic_memory_mapper\gen_htm.py -j .\doc\test.json -b csr -B
@REM Add project specific build here. Normally just point to top of the repository for hierarchical scan

View file

@ -0,0 +1,3 @@
# Compile the code into the appropriate libraries
vlog -quiet -f files_vlog.tcl -work work
vcom -quiet -2008 -f files.tcl -work work

View file

@ -0,0 +1,52 @@
[{
"ip_name" : "test",
"bus" : "csr",
"addr_hi_bit" : "28",
"addr_lo_bit" : "24",
"description" : "This block the top leve test bech",
"sub_blocks" : {
"uut" : {
"instance" : "",
"process" : "disabled",
"offset" : "0x00000000"
},
"memory" : {
"instance" : "",
"process" : "disabled",
"offset" : "0x08000000"
},
"local" : {
"instance" : "",
"process" : "enabled",
"offset" : "0x18000000"
}
},
"registers" : {
"control" : {
"address" : "0",
"width" : "3",
"description" : "Testbench simulation control",
"fields": {
"error" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0",
"description" : "Set error state"
},
"do_stop" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0",
"description" : "Request simulation to stop"
},
"do_finish" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0",
"description" : "Request simulation to finish"
}
}
}
}
}]

View file

@ -0,0 +1,19 @@
# ------------------------------------------------------
# If you update this file, also update ../../sim/comp.do
# ------------------------------------------------------
# #########################################
# Add project specific files here
# #########################################
# #########################################
# Testbench files
./test_pkg_auto.vhd
./test_csr_decode_auto.vhd
./test_csr_regs_auto.vhd
e:/git/fw_development_tools/verification/vproc/avsvproc.vhd
./tb_pkg.vhd
./tb_ctrl.vhd
./tb.vhd

View file

@ -0,0 +1,12 @@
# VProc test component
e:/git/fw_development_tools/verification/vproc/extradefs.v
e:/git/fw_development_tools/verification/vproc/vproc.v
e:/git/fw_development_tools/verification/mem_model/mem_model.v
# #########################################
# Add project specific files here
# #########################################
# #########################################

View file

@ -0,0 +1,73 @@
###################################################################
# Makefile for serialiser testcode in Modelsim
#
# Copyright (c) 2018 Global Inkjet Systems
#
###################################################################
# User files to build, passed in to vproc makefile build
USERCODE = VUserMain0.cpp utils.cpp
FWDEVTOOLS = e:/git/fw_development_tools
VPROCDIR = ${FWDEVTOOLS}/verification/vproc
MODELSIMDIR = c:\altera_17_1\ver\modelsim_ae
# Name of gnu-make executable
MAKE_EXE = mingw32-make
# Pick single target files for two auto-generations---UUT and test.
# The core.h file is always presentfor the UUT, and the test package
# for the test bench
TBAUTOFILE = test_pkg_auto.vhd
JSONFILES = ../../doc/*.json
# If no external code directory (e.g. a HAL) set this to local source directory, else set to code directory
EXTINCLDIR = ${CURDIR}/src
#------------------------------------------------------
# BUILD RULES
#------------------------------------------------------
# Build is dependant on generating the auto-gen file and
# processing makefile in vproc
all: ${TBAUTOFILE} vproc
# Make test bench auto-gen code dependant on all the JSON files to
# call the batch file if any have changed
${TBAUTOFILE}:
@cmd /c autogen.bat
# Call the vproc make file for it to determine if anything
# needs building.
.PHONY : vproc
vproc:
@${MAKE_EXE} -C ${VPROCDIR} TESTDIR=${CURDIR} USER_C="${USERCODE}" MODELSIMDIR="${MODELSIMDIR}" EXTINCLDIR="${EXTINCLDIR}"
#------------------------------------------------------
# EXECUTION RULES
#------------------------------------------------------
run: all
@vsim -c -do sim.do
rungui: all
@vsim -gui -do wave.do -do simg.do
compile:
@vsim -c -do compile.do -do quit
gui: rungui
sim: run
#------------------------------------------------------
# CLEANING RULES
#------------------------------------------------------
clean:
@${MAKE_EXE} -C ${VPROCDIR} USER_C="${USERCODE}" TESTDIR="${CURDIR}" clean
@rm -rf "wlf*"
@rm -rf "work"
@rm -rf *_auto.vhd

View file

@ -0,0 +1,17 @@
# Create clean libraries
foreach lib [list work] {
file delete -force -- $lib
vlib $lib
}
# Compile the code into the appropriate libraries
do compile.do
# Run the tests.
vsim -quiet -pli VProc.so -t 1ns tb
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
run -all
#Exit the simulations
quit

View file

@ -0,0 +1,15 @@
# Create clean libraries
foreach lib [list work] {
file delete -force -- $lib
vlib $lib
}
# Compile the code into the appropriate libraries
do compile.do
# Run the tests
vsim -gGUI_RUN=true -pli VProc.so -L altera_mf_ver -L altera_mf -t 100ps -gui tb
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave.do
run -all

View file

@ -0,0 +1,198 @@
/**************************************************************/
/* VUserMain.cpp Date: 2018/08/9 */
/* */
/* Copyright (c) 2018 GIS. All rights reserved. */
/* */
/**************************************************************/
// --------------------------------------------------
// INCLUDES
// --------------------------------------------------
#include <string.h>
#include "VUserMain0.h"
#include "utils.h"
#include "tb.h"
// Access to memory model's direct API (C linkage)
extern "C" {
#include "mem_model.h"
}
//######################################################
//# Add test code includes here
//######################################################
//#define DEBUG
// --------------------------------------------------
// DEFINES
// --------------------------------------------------
#define MAINTESTNUM 0
#define ALIVE_TEST_NUM 0x12345678
#define ALIVE_TEST_OFFSET 0x1000
// --------------------------------------------------
// STATIC VARIABLES
// --------------------------------------------------
// I'm node 0
static int node = 0;
// --------------------------------------------------
// Read function to access memory over CSR bus
// --------------------------------------------------
uint32_t csrReadMem (uint32_t addr, uint32_t* data)
{
uint32_t rdata;
// Read over the AVS bus
VRead(addr, &rdata, NORMAL_UPDATE, node);
*data = rdata;
// Model some access rate time
VTick(AVS_ACCESS_LEN, node);
#ifdef DEBUG
VPrint("csrReadMem : addr = 0x%08x data = 0x%08x\n", addr, *data); fflush(NULL);
#endif
return 0;
}
// --------------------------------------------------
// Write function to access memory over CSR bus
// --------------------------------------------------
void csrWriteMem (uint32_t addr, uint32_t data)
{
#ifdef DEBUG
VPrint("csrWriteMem : addr = 0x%08x data = 0x%08x\n", addr, data); fflush(NULL);
#endif
// Write over the AVS bus for this node
VWrite(addr, data, NORMAL_UPDATE, node);
// Model some access rate time
VTick(AVS_ACCESS_LEN, node);
}
// --------------------------------------------------
// Read function to access memory directly (bypass sim)
// --------------------------------------------------
uint32_t directReadMem (uint32_t addr, uint32_t* data)
{
uint32_t rdata;
*data = ReadRamWord(addr, true, node);
#ifdef DEBUG
VPrint("directReadMem : addr = 0x%08x data = 0x%08x\n", addr, *data); fflush(NULL);
#endif
return 0;
}
// --------------------------------------------------
// Write function to access memory directly (bypass sim)
// --------------------------------------------------
void directWriteMem (uint32_t addr, uint32_t data)
{
#ifdef DEBUG
VPrint("directWriteMem : addr = 0x%08x data = 0x%08x\n", addr, data); fflush(NULL);
#endif
WriteRamWord(addr, data, true, node);
}
// --------------------------------------------------
// Simulation control functions
// --------------------------------------------------
void stopSim(bool error)
{
csrWriteMem(TB_SIM_CTRL_REG, TB_SIM_CTRL_STOP_MASK | (error ? TB_SIM_CTRL_ERROR_MASK : 0));
}
void finishSim(int error)
{
csrWriteMem(TB_SIM_CTRL_REG, TB_SIM_CTRL_FINISH_MASK | (error ? TB_SIM_CTRL_ERROR_MASK : 0));
}
void usleepSim(unsigned time)
{
VTick((time * 1000)/SYS_CLK_PERIOD_NS, node);
}
void nsleepSim(unsigned time)
{
// Make ticks a minimum of 1, and do rounding to nearest clock period
unsigned ticks = (time < SYS_CLK_PERIOD_NS) ? 1 : ((time + SYS_CLK_PERIOD_NS/2)/SYS_CLK_PERIOD_NS);
VTick(ticks, node);
}
// ==================================================
// ENTRY POINT TO USER CODE FROM VPROC
// ==================================================
extern "C" void VUserMain0()
{
int error = 0;
int testnum = MAINTESTNUM;
uint32_t tmp1 = 0;
uint32_t tmp2 = 0;
VPrint("\n*****************************\n");
VPrint( "* Global Inkjet Systems *\n");
VPrint( "* Virtual Processor (VProc) *\n");
VPrint( "* Copyright (c) 2019 *\n");
VPrint( "*****************************\n\n");
VPrint("Entered VUserMain%d()\n\n", node);
// Parse arguments. As no argc and argv, pass in these as null, and it will look for
// vusermain.cfg, which should have a single line with the command line options. If this
// file doesn't exist, no parsing is done.
parseArgs(0, NULL, testnum);
usleepSim(1);
// Check we're alive by writing to memory over CSR bus
csrWriteMem(MEM_BASE_ADDR + ALIVE_TEST_OFFSET, ALIVE_TEST_NUM);
// Read back over CSR bus
csrReadMem (MEM_BASE_ADDR + ALIVE_TEST_OFFSET, &tmp1);
// Read directly from memory model (bypassing simulation)
directReadMem (MEM_BASE_ADDR + ALIVE_TEST_OFFSET, &tmp2);
if (tmp1 != ALIVE_TEST_NUM || tmp2 == ALIVE_TEST_NUM)
{
VPrint("\nVUserMain%d() failed start up memory access check\n\n", node);
error = 1;
}
// If start up check passed, run user test code
else
{
// Run the test code
switch(testnum)
{
case MAINTESTNUM :
// #######################################
// # Call test code here
// #######################################
break;
}
}
// Wait a bit
usleepSim(1);
// Tell the simulator to finish
VPrint("\nVUserMain%d() finishing with status %d\n\n", node, error);
finishSim(error);
// Sleep for ever, ticking. Don't exit or loop forever internally
// (e.g. while (1);) as simulation will hang.
SLEEP_FOREVER;
}

View file

@ -0,0 +1,41 @@
/**************************************************************/
/* VUserMain.h Date: 2018/08/09 */
/* */
/* Copyright (c) 2018 GIS. All rights reserved. */
/* */
/**************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
extern "C" {
#include "VUser.h"
}
// Define VProc call normal and delta values
#define NORMAL_UPDATE 0
#define DELTA_UPDATE 1
// Define a sensible time for a register access, in clock cycles
// Note that for the AVS BFM, the actual length is AVS_ACCESS_LEN + 2
//#define AVS_ACCESS_LEN 10
#define AVS_ACCESS_LEN 2
// In simulation the base address for the register bus is 0
#define CORE_BASE_ADDR 0x00000000
// Define a sleep forever macro
#define SLEEP_FOREVER {while(1) VTick(0x7fffffff, node);}
// Exported library functions that aim to virtualise away VProc details
void stopSim (bool error);
void finishSim (int error);
void usleepSim (unsigned time);
void nsleepSim (unsigned time);
uint32_t csrReadMem (uint32_t addr, uint32_t* data);
void csrWriteMem (uint32_t addr, uint32_t data);
uint32_t directReadMem (uint32_t addr, uint32_t* data);
void directWriteMem (uint32_t addr, uint32_t data);

View file

@ -0,0 +1,35 @@
/**************************************************************/
/* tb.h Date: 2018/08/9 */
/* */
/* Copyright (c) 2018 GIS. All rights reserved. */
/* */
/**************************************************************/
#include <stdio.h>
#include <stdlib.h>
#ifndef _TB_H_
#define _TB_H_
// Address of physical memory where output data starts
#define START_PHY_MEM 0x20000000
#define MEM_BASE_ADDR START_PHY_MEM
// Test bench address for local registers
#define TB_BASE_ADDR 0x60000000
#define TB_SIM_CTRL_REG (TB_BASE_ADDR + 0)
#define TB_CAPTURE_ADDR (TB_BASE_ADDR + 4)
#define TB_IMG_WIDTH_PX (TB_BASE_ADDR + 8)
#define TB_SIM_CTRL_ERROR_MASK 0x00000001
#define TB_SIM_CTRL_STOP_MASK 0x00000002
#define TB_SIM_CTRL_FINISH_MASK 0x00000004
#define TEST_ERROR 1
#define NOERROR 0
// This must match the test bench system clock period to get accurate sleep times in the software
#define SYS_CLK_PERIOD_NS 10
#endif

View file

@ -0,0 +1,103 @@
/**************************************************************/
/* utils.cpp Date: 2018/11/09 */
/* */
/* Copyright (c) 2018 GIS. All rights reserved. */
/* */
/**************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
// --------------------------------------------------
// DEFINES
// --------------------------------------------------
#define MAXARGS 100
#ifndef HDL_SIM
#define CFGFILENAME "host.cfg"
#else
#define CFGFILENAME "vusermain.cfg"
#endif
// --------------------------------------------------
// Parse configuration file arguments
// --------------------------------------------------
int parseArgs(int argcIn, char** argvIn, int &testnum)
{
int c;
int argc = 0;
char* argvBuf[MAXARGS];
char** argv = NULL;
char* argstr = NULL;
size_t len = 0;
char delim[2];
FILE* fp;
if (argcIn > 1)
{
argc = argcIn;
argv = argvIn;
}
else
{
fp = fopen(CFGFILENAME, "r");
if (fp == NULL)
return 1;
strcpy(delim, " ");
getline(&argstr, &len, fp);
strtok(argstr, delim);
fclose(fp);
if (argvBuf[0] != NULL)
{
argc = 1;
}
while((argvBuf[argc] = strtok(NULL, " ")) != NULL && argc < MAXARGS)
{
argc++;
}
argv = argvBuf;
}
testnum = 0;
int returnVal = 0;
opterr = 0;
while ((c = getopt (argc, argv, "ht:")) != -1)
{
switch (c)
{
case 't':
testnum = atoi(optarg);
break;
case 'h':
default:
printf("Usage: vusermain.cfg [-h] [-t <test num>]\n");
printf(" -t Specify test (default 0)\n");
printf("\n");
returnVal = 1;
break;
}
}
return returnVal;
}

View file

@ -0,0 +1,9 @@
/**************************************************************/
/* utils.h Date: 2018/11/09 */
/* */
/* Copyright (c) 2018 GIS. All rights reserved. */
/* */
/**************************************************************/
extern int parseArgs (int argcIn, char** argvIn, int &testnum);
extern uint32_t getPageMap (const void* addr);

View file

@ -0,0 +1,304 @@
-------------------------------------------------------------------------------
-- Title : Core directed test bench top level
-- Project : GEOMETRY
-------------------------------------------------------------------------------
-- File : tb.vhd
-- Author : Simon Southwell
-- Company : Global Inkjet Systems
-- Created : 2018-06-01
-- Platform :
-- Standard : VHDL 2008
-------------------------------------------------------------------------------
-- Description:
-- This block is the top level test banch for the geometry-serializer
-------------------------------------------------------------------------------
-- Copyright (c) 2018 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_misc.all;
library std;
use std.env.all;
use work.tb_pkg.all;
entity tb is
generic (
GUI_RUN : boolean := false
);
end entity;
architecture sim of tb is
---------------------------------------------
-- Signal declarations
---------------------------------------------
-- Clock signal
signal clk_x2 : std_logic;
signal clk : std_logic;
signal clk_div2 : std_logic;
signal rst_n : std_logic;
-- AVS
signal avs_csr_address : std_logic_vector (31 downto 0);
signal avs_csr_writedata : std_logic_vector (31 downto 0);
signal avs_csr_readdata : std_logic_vector (31 downto 0);
signal avs_csr_write : std_logic;
signal avs_csr_read : std_logic;
signal avs_csr_write_uut : std_logic;
signal avs_csr_read_uut : std_logic;
signal avs_csr_readdata_uut : std_logic_vector (31 downto 0) := (others => '0');
signal avs_csr_write_mem : std_logic;
signal avs_csr_read_mem : std_logic;
signal avs_csr_readdata_mem : std_logic_vector (31 downto 0);
signal avs_csr_write_tb : std_logic;
signal avs_csr_read_tb : std_logic;
signal avs_csr_readdata_tb : std_logic_vector (31 downto 0);
-- Avalon Master read interface from memory model
signal avm_rx_waitrequest : std_logic;
signal avm_rx_burstcount : std_logic_vector (11 downto 0);
signal avm_rx_address : std_logic_vector (31 downto 0);
signal avm_rx_read : std_logic := '0';
signal avm_rx_readdata : std_logic_vector (31 downto 0);
signal avm_rx_readdatavalid : std_logic;
-- Avalon Master write interface to memory model
signal avm_tx_waitrequest : std_logic;
signal avm_tx_burstcount : std_logic_vector (11 downto 0);
signal avm_tx_address : std_logic_vector (31 downto 0);
signal avm_tx_write : std_logic := '0';
signal avm_tx_writedata : std_logic_vector (31 downto 0);
-- Memory model write port signals
signal wr_valid : std_logic := '0';
signal wr_data : std_logic_vector (31 downto 0);
signal wr_addr : std_logic_vector (31 downto 0);
-- Simuation control and status
signal error : std_logic;
signal do_stop : std_logic;
signal do_finish : std_logic;
signal passed : boolean;
signal failed : boolean;
begin
-----------------------------------------
-- Test bench control
-----------------------------------------
tb_ctrl_inst : entity work.tb_ctrl
generic map(
GUI_RUN => GUI_RUN,
CLK_FREQ_MHZ => 100
)
port map (
-- Clock and reset outputs
clk => clk,
clk_div2 => clk_div2,
clk_x2 => clk_x2,
rst_n => rst_n,
-- Status and control inputs
error => error,
do_stop => do_stop,
do_finish => do_finish,
-- Test condition flags (for inspection externally)
failed => failed,
passed => passed
);
-----------------------------------------
-- Test bench address decode (auto-gen)
-----------------------------------------
test_csr_decode_inst : entity work.test_csr_decode
port map (
uut_write => avs_csr_write_uut,
uut_read => avs_csr_read_uut,
uut_readdata => avs_csr_readdata_uut,
local_write => avs_csr_write_tb,
local_read => avs_csr_read_tb,
local_readdata => avs_csr_readdata_tb,
memory_write => avs_csr_write_mem,
memory_read => avs_csr_read_mem,
memory_readdata => avs_csr_readdata_mem,
avs_address => avs_csr_address(28 downto 24),
avs_write => avs_csr_write,
avs_read => avs_csr_read,
avs_readdata => avs_csr_readdata
);
-----------------------------------------
-- Local test bench registers (auto-gen)
-----------------------------------------
test_csr_regs_inst : entity work.test_csr_regs
generic map (
ADDR_DECODE_WIDTH => 5
)
port map (
clk => clk,
rst_n => rst_n,
control_error => error,
control_do_stop => do_stop,
control_do_finish => do_finish,
avs_address => avs_csr_address(4 downto 0),
avs_write => avs_csr_write_tb,
avs_writedata => avs_csr_writedata,
avs_read => avs_csr_read_tb,
avs_readdata => avs_csr_readdata_tb
);
-----------------------------------------
-- Virtual processor with Avalon bus
-----------------------------------------
vproc_inst : entity work.avsvproc
generic map (
NODE_NUM => 0,
AUTO_VALID_CSR => true, -- Generate a CSR bus read data valid internally
SEQ_PAGE => 4x"F"
)
port map (
clk => clk,
rst_n => rst_n,
-- Avalon memory mapped master interface
avs_csr_address => avs_csr_address,
avs_csr_write => avs_csr_write,
avs_csr_writedata => avs_csr_writedata,
avs_csr_read => avs_csr_read,
avs_csr_readdata => avs_csr_readdata
);
-----------------------------------------
-- Instantiation of memory model
-----------------------------------------
mem_model_inst : entity work.mem_model
port map (
clk => clk,
rst_n => rst_n,
avs_address => avs_csr_address,
avs_write => avs_csr_write_mem,
avs_writedata => avs_csr_writedata,
avs_read => avs_csr_read_mem,
avs_readdata => avs_csr_readdata_mem,
avm_rx_waitrequest => avm_rx_waitrequest,
avm_rx_burstcount => avm_rx_burstcount,
avm_rx_address => "0" & avm_rx_address(30 downto 0), -- Removed ACP bit
avm_rx_read => avm_rx_read,
avm_rx_readdata => avm_rx_readdata,
avm_rx_readdatavalid => avm_rx_readdatavalid,
avm_tx_waitrequest => avm_tx_waitrequest,
avm_tx_burstcount => avm_tx_burstcount,
avm_tx_address => avm_tx_address,
avm_tx_write => avm_tx_write,
avm_tx_writedata => avm_tx_writedata,
wr_port_valid => wr_valid,
wr_port_data => wr_data,
wr_port_addr => wr_addr
);
-----------------------------------------
-- Instantiation of UUT
-----------------------------------------
-- ###########
-- # EXAMPLE #
-- ###########
-- core_inst : entity work.core
-- generic map (
-- EN_RX_AVM => true,
-- SLIM => true
-- )
-- port map (
-- clk => clk,
-- clk_x2 => clk_x2,
-- clk_div2 => clk_div2,
-- reset_n => rst_n,
--
-- avs_csr_address => avs_csr_address(15 downto 0),
-- avs_csr_write => avs_csr_write_uut,
-- avs_csr_writedata => avs_csr_writedata,
-- avs_csr_read => avs_csr_read_uut,
-- avs_csr_readdata => avs_csr_readdata_uut,
--
-- axm_awaddr => open,
-- axm_awprot => open,
-- axm_awvalid => open,
-- axm_awready => '1',
-- axm_wdata => open,
-- axm_wlast => open,
-- axm_wvalid => open,
-- axm_wready => '1',
-- axm_bvalid => '1',
-- axm_bready => open,
-- axm_araddr => avm_rx_address_axi,
-- axm_arlen => arlen,
-- axm_arsize => open,
-- axm_arburst => open,
-- axm_arcache => open,
-- axm_aruser => open,
-- axm_arprot => open,
-- axm_arvalid => avm_rx_read_axi,
-- axm_arready => axm_arready,
-- axm_rdata => avm_rx_readdata_axi,
-- axm_rvalid => avm_rx_readdatavalid_axi,
-- axm_rready => open,
--
-- avm_rx_waitrequest => avm_rx_waitrequest_raw,
-- avm_rx_burstcount => avm_rx_burstcount_raw,
-- avm_rx_address => avm_rx_address_raw,
-- avm_rx_read => avm_rx_read_raw,
-- avm_rx_readdata => avm_rx_readdata_raw,
-- avm_rx_readdatavalid => avm_rx_readdatavalid_raw,
--
-- avm_tx_waitrequest => avm_tx_waitrequest,
-- avm_tx_burstcount => avm_tx_burstcount,
-- avm_tx_address => avm_tx_address,
-- avm_tx_write => avm_tx_write,
-- avm_tx_writedata => avm_tx_writedata,
--
-- debug_out => debug
--
-- );
--
-- avm_rx_burstcount_axi <= "0000" & std_logic_vector(unsigned(arlen) + 1);
-- avm_rx_waitrequest_axi <= not axm_arready;
-- avm_rx_readdata_axi <= avm_rx_readdata;
-- avm_rx_readdatavalid_axi <= avm_rx_readdatavalid;
--
-- avm_rx_waitrequest_raw <= avm_rx_waitrequest;
-- avm_rx_readdata_raw <= avm_rx_readdata;
-- avm_rx_readdatavalid_raw <= avm_rx_readdatavalid;
--
-- avm_rx_burstcount <= avm_rx_burstcount_raw; -- avm_rx_burstcount_raw when avm_rx_read_raw = '1' else avm_rx_burstcount_axi;
-- avm_rx_address <= avm_rx_address_raw; -- avm_rx_address_raw when avm_rx_read_raw = '1' else avm_rx_address_axi;
-- avm_rx_read <= avm_rx_read_raw; -- avm_rx_read_axi or avm_rx_read_raw;
end architecture;

View file

@ -0,0 +1,137 @@
-------------------------------------------------------------------------------
-- Title : Core directed test bench control
-- Project : GEOMETRY
-------------------------------------------------------------------------------
-- File : tb.vhd
-- Author : Simon Southwell
-- Company : Global Inkjet Systems
-- Created : 2018-08-21
-- Platform :
-- Standard : VHDL 2008
-------------------------------------------------------------------------------
-- Description:
-- This block is test bench control block
-------------------------------------------------------------------------------
-- Copyright (c) 2018 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_misc.all;
library std;
use std.env.all;
use work.tb_pkg.all;
entity tb_ctrl is
generic (
GUI_RUN : boolean := false;
CLK_FREQ_MHZ : integer := 200
);
port (
-- Clock and reset outputs
clk_x2 : out std_logic;
clk : out std_logic := '1';
clk_div2 : out std_logic := '1';
rst_n : out std_logic := '1';
-- Simulation status and control inputs
error : in std_logic;
do_stop : in std_logic;
do_finish : in std_logic;
-- External end-of-simulation flags
failed : out boolean;
passed : out boolean
);
end entity;
architecture sim of tb_ctrl is
-- This defines the system clock frequency. The TB will generate a x4 clock and
-- derive the system clock at this frequency from this.
constant TIMEOUT_COUNT : integer := 10000000;
signal is_gui_run : boolean := false;
signal count : integer := 0;
signal end_sim : std_logic;
begin
-----------------------------------------
-- Clock and reset generation
-----------------------------------------
-- Clock generation with concurrent procedure call
clk_gen(clk_x2, Real(CLK_FREQ_MHZ) * 2.0E6); -- x2 clock
-- Derive system clock from master clock
process(clk_x2)
begin
if clk_x2'event and clk_x2 = '1' then
clk <= not clk;
end if;
end process;
process(clk)
begin
if clk'event and clk = '1' then
clk_div2 <= not clk_div2;
end if;
end process;
-- Generate a reset
process (clk)
begin
if (clk'event and clk = '1') then
count <= count + 1;
rst_n <= '1' when count > 10 else '0';
end if;
end process ;
-- End-of-simulation signals
end_sim <= '1' when count = TIMEOUT_COUNT or do_stop = '1' or do_finish = '1' else '0';
failed <= true when end_sim = '1' and error = '1' else false;
passed <= true when end_sim = '1' and error = '0' else false;
-----------------------------------------
-- Simulation control from VProc over
-- CSR bus
-----------------------------------------
-- Set a flag that this is a GUI simulation if the generic GUI_RUN set to 'true' externally
GEN_GUI : if GUI_RUN generate
is_gui_run <= true;
end generate GEN_GUI;
PROC_TB_SIM_CTRL : process (clk, rst_n)
begin
if (rst_n = '0') then
elsif clk'event and clk = '1' then
-----------------------------------------
-- End simulation
-----------------------------------------
-- If end of simulation, stop
if end_sim = '1' then
assert (error /= '1') report "*** FAIL: errors found" severity failure;
assert (error = '1') report "SUCCESS" severity note;
if is_gui_run or (do_stop = '1' and do_finish = '0') then
stop(0);
else
finish(0);
end if;
end if;
end if;
end process;
end architecture;

View file

@ -0,0 +1,106 @@
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_arith.all;
package tb_pkg is
type mem_t is array (0 to 255) of std_logic_vector(31 downto 0);
type stripe_t is array (0 to 18*2*3) of std_logic_vector(31 downto 0);
-- Define the base locations of the test blocks on the CSR interface
constant AVS_CSR_UUT_BASE : integer := 16#00000000#;
constant AVS_CSR_MEM_BASE : integer := 16#40000000#;
constant AVS_CSR_TB_BASE : integer := 16#40010000#;
constant AVS_CASE_TB_SIM_CTRL_OFFSET : std_logic_vector( 3 downto 0) := 4x"0";
constant TEST_BYTE0 : std_logic_vector( 7 downto 0) := 8x"55";
constant TEST_BYTE1 : std_logic_vector( 7 downto 0) := 8x"AA";
constant TEST_BYTE2 : std_logic_vector( 7 downto 0) := 8x"5A";
constant TEST_WORD0 : std_logic_vector(31 downto 0) := 32x"cafebabe";
constant TEST_WORD1 : std_logic_vector(31 downto 0) := 32x"facef00c";
constant TEST_WORD2 : std_logic_vector(31 downto 0) := 32x"19661066";
constant TEST_WORD3 : std_logic_vector(31 downto 0) := 32x"18591905";
constant TEST_WORD4 : std_logic_vector(31 downto 0) := 32x"f2ae42b0";
constant TEST_WORD5 : std_logic_vector(31 downto 0) := 32x"c087bae5";
constant TEST_ADDR0 : std_logic_vector(23 downto 0) := 24x"123456";
constant TEST_ADDR1 : std_logic_vector(23 downto 0) := 24x"654321";
constant TEST_ADDR2 : std_logic_vector(23 downto 0) := 24x"250864";
-- Times (in clock ticks) for things to happen
constant AVS_ACCESS_LEN : integer := 20;
constant AVS_FAST_ACCESS_LEN : integer := 3;
procedure clk_gen(
signal clk : out std_logic;
constant FREQ : real);
procedure avs_write_proc (
constant addr : in integer;
variable data : in std_logic_vector(31 downto 0);
signal avs_wr : out std_logic;
signal avs_addr : out std_logic_vector(31 downto 0);
signal avs_wdata : out std_logic_vector(31 downto 0)
);
procedure avs_read_proc (
constant addr : in integer;
signal avs_rd : out std_logic;
signal avs_addr : out std_logic_vector(31 downto 0)
);
end tb_pkg;
package body tb_pkg is
---------------------------------------------
-- Procedure for clock generation
---------------------------------------------
procedure clk_gen(signal clk : out std_logic; constant FREQ : real) is
constant PERIOD : time := 1 sec / FREQ; -- Full period
constant HIGH_TIME : time := PERIOD / 2; -- High time
constant LOW_TIME : time := PERIOD - HIGH_TIME; -- Low time; always >= HIGH_TIME
begin
-- Generate a clock cycle
loop
clk <= '1';
wait for HIGH_TIME;
clk <= '0';
wait for LOW_TIME;
end loop;
end procedure;
---------------------------------------------
-- Procedure to write to slave bus
---------------------------------------------
procedure avs_write_proc (
constant addr : in integer;
variable data : in std_logic_vector(31 downto 0);
signal avs_wr : out std_logic;
signal avs_addr : out std_logic_vector(31 downto 0);
signal avs_wdata : out std_logic_vector(31 downto 0)
) is
begin
avs_wr <= '1';
avs_addr <= std_logic_vector(to_unsigned(addr, 32));
avs_wdata <= data;
end avs_write_proc;
---------------------------------------------
-- Procedure to instigate a read from AVS bus
---------------------------------------------
procedure avs_read_proc (
constant addr : in integer;
signal avs_rd : out std_logic;
signal avs_addr : out std_logic_vector(31 downto 0)
) is
begin
avs_rd <= '1';
avs_addr <= std_logic_vector(to_unsigned(addr, 32));
end avs_read_proc;
end tb_pkg;

View file

@ -0,0 +1 @@
vusermain0 -t 0

View file

@ -0,0 +1,57 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /tb/clk_x2
add wave -noupdate /tb/clk
add wave -noupdate /tb/clk_div2
add wave -noupdate /tb/rst_n
add wave -noupdate /tb/do_finish
add wave -noupdate /tb/do_stop
add wave -noupdate /tb/error
add wave -noupdate /tb/failed
add wave -noupdate /tb/passed
add wave -noupdate -radix hexadecimal /tb/avm_rx_address
add wave -noupdate -radix hexadecimal /tb/avm_rx_burstcount
add wave -noupdate /tb/avm_rx_read
add wave -noupdate -radix hexadecimal -childformat {{/tb/avm_rx_readdata(31) -radix hexadecimal} {/tb/avm_rx_readdata(30) -radix hexadecimal} {/tb/avm_rx_readdata(29) -radix hexadecimal} {/tb/avm_rx_readdata(28) -radix hexadecimal} {/tb/avm_rx_readdata(27) -radix hexadecimal} {/tb/avm_rx_readdata(26) -radix hexadecimal} {/tb/avm_rx_readdata(25) -radix hexadecimal} {/tb/avm_rx_readdata(24) -radix hexadecimal} {/tb/avm_rx_readdata(23) -radix hexadecimal} {/tb/avm_rx_readdata(22) -radix hexadecimal} {/tb/avm_rx_readdata(21) -radix hexadecimal} {/tb/avm_rx_readdata(20) -radix hexadecimal} {/tb/avm_rx_readdata(19) -radix hexadecimal} {/tb/avm_rx_readdata(18) -radix hexadecimal} {/tb/avm_rx_readdata(17) -radix hexadecimal} {/tb/avm_rx_readdata(16) -radix hexadecimal} {/tb/avm_rx_readdata(15) -radix hexadecimal} {/tb/avm_rx_readdata(14) -radix hexadecimal} {/tb/avm_rx_readdata(13) -radix hexadecimal} {/tb/avm_rx_readdata(12) -radix hexadecimal} {/tb/avm_rx_readdata(11) -radix hexadecimal} {/tb/avm_rx_readdata(10) -radix hexadecimal} {/tb/avm_rx_readdata(9) -radix hexadecimal} {/tb/avm_rx_readdata(8) -radix hexadecimal} {/tb/avm_rx_readdata(7) -radix hexadecimal} {/tb/avm_rx_readdata(6) -radix hexadecimal} {/tb/avm_rx_readdata(5) -radix hexadecimal} {/tb/avm_rx_readdata(4) -radix hexadecimal} {/tb/avm_rx_readdata(3) -radix hexadecimal} {/tb/avm_rx_readdata(2) -radix hexadecimal} {/tb/avm_rx_readdata(1) -radix hexadecimal} {/tb/avm_rx_readdata(0) -radix hexadecimal}} -subitemconfig {/tb/avm_rx_readdata(31) {-radix hexadecimal} /tb/avm_rx_readdata(30) {-radix hexadecimal} /tb/avm_rx_readdata(29) {-radix hexadecimal} /tb/avm_rx_readdata(28) {-radix hexadecimal} /tb/avm_rx_readdata(27) {-radix hexadecimal} /tb/avm_rx_readdata(26) {-radix hexadecimal} /tb/avm_rx_readdata(25) {-radix hexadecimal} /tb/avm_rx_readdata(24) {-radix hexadecimal} /tb/avm_rx_readdata(23) {-radix hexadecimal} /tb/avm_rx_readdata(22) {-radix hexadecimal} /tb/avm_rx_readdata(21) {-radix hexadecimal} /tb/avm_rx_readdata(20) {-radix hexadecimal} /tb/avm_rx_readdata(19) {-radix hexadecimal} /tb/avm_rx_readdata(18) {-radix hexadecimal} /tb/avm_rx_readdata(17) {-radix hexadecimal} /tb/avm_rx_readdata(16) {-radix hexadecimal} /tb/avm_rx_readdata(15) {-radix hexadecimal} /tb/avm_rx_readdata(14) {-radix hexadecimal} /tb/avm_rx_readdata(13) {-radix hexadecimal} /tb/avm_rx_readdata(12) {-radix hexadecimal} /tb/avm_rx_readdata(11) {-radix hexadecimal} /tb/avm_rx_readdata(10) {-radix hexadecimal} /tb/avm_rx_readdata(9) {-radix hexadecimal} /tb/avm_rx_readdata(8) {-radix hexadecimal} /tb/avm_rx_readdata(7) {-radix hexadecimal} /tb/avm_rx_readdata(6) {-radix hexadecimal} /tb/avm_rx_readdata(5) {-radix hexadecimal} /tb/avm_rx_readdata(4) {-radix hexadecimal} /tb/avm_rx_readdata(3) {-radix hexadecimal} /tb/avm_rx_readdata(2) {-radix hexadecimal} /tb/avm_rx_readdata(1) {-radix hexadecimal} /tb/avm_rx_readdata(0) {-radix hexadecimal}} /tb/avm_rx_readdata
add wave -noupdate /tb/avm_rx_readdatavalid
add wave -noupdate /tb/avm_rx_waitrequest
add wave -noupdate -radix hexadecimal /tb/avm_tx_address
add wave -noupdate -radix hexadecimal /tb/avm_tx_burstcount
add wave -noupdate /tb/avm_tx_waitrequest
add wave -noupdate /tb/avm_tx_write
add wave -noupdate -radix hexadecimal /tb/avm_tx_writedata
add wave -noupdate -radix hexadecimal /tb/avs_csr_address
add wave -noupdate /tb/avs_csr_write
add wave -noupdate -radix hexadecimal /tb/avs_csr_writedata
add wave -noupdate /tb/avs_csr_read
add wave -noupdate -radix hexadecimal /tb/avs_csr_readdata
add wave -noupdate /tb/avs_csr_write_mem
add wave -noupdate /tb/avs_csr_read_mem
add wave -noupdate -radix hexadecimal /tb/avs_csr_readdata_mem
add wave -noupdate /tb/avs_csr_write_tb
add wave -noupdate /tb/avs_csr_read_tb
add wave -noupdate -radix hexadecimal /tb/avs_csr_readdata_tb
add wave -noupdate /tb/avs_csr_write_uut
add wave -noupdate /tb/avs_csr_read_uut
add wave -noupdate -radix hexadecimal /tb/avs_csr_readdata_uut
add wave -noupdate /tb/wr_addr
add wave -noupdate /tb/wr_data
add wave -noupdate /tb/wr_valid
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {0 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 199
configure wave -valuecolwidth 100
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} {2252300 ps}