Removed deprecated level interrupt support and tidied redundant code.
This commit is contained in:
parent
9b47a08179
commit
0d49352d02
16 changed files with 107 additions and 204 deletions
20
code/VProc.h
20
code/VProc.h
|
|
@ -35,7 +35,7 @@
|
|||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#define VERSION_STRING "VProc version 1.12.5. Copyright (c) 2004-2025 Simon Southwell."
|
||||
#define VERSION_STRING "VProc version 1.13.0. Copyright (c) 2004-2025 Simon Southwell."
|
||||
|
||||
#ifndef VP_MAX_NODES
|
||||
#define VP_MAX_NODES 64
|
||||
|
|
@ -56,13 +56,16 @@
|
|||
// Indexes for PLI function arguments
|
||||
#define VPNODENUM_ARG 1
|
||||
#define VPINTERRUPT_ARG 2
|
||||
#define VPVALUE_ARG 2
|
||||
#define VPDATAIN_ARG 2
|
||||
#define VPDATAOUT_ARG 3
|
||||
#define VPADDR_ARG 4
|
||||
#define VPRW_ARG 5
|
||||
#define VPTICKS_ARG 6
|
||||
|
||||
#define VPINDEX_ARG 2
|
||||
#define VPDATAIN_ARG 3
|
||||
#define VPDATAOUT_ARG 4
|
||||
#define VPADDR_ARG 5
|
||||
#define VPRW_ARG 6
|
||||
#define VPTICKS_ARG 7
|
||||
#define VPRESTORE_ARG 8
|
||||
#define VPACCESSIN_ARG 3
|
||||
#define VACCESSOUT_ARG 4
|
||||
|
||||
// A default string buffer size
|
||||
#define DEFAULT_STR_BUF_SIZE 32
|
||||
|
|
@ -99,14 +102,12 @@ typedef struct {
|
|||
// Simulation to user thread exchange structure
|
||||
typedef struct {
|
||||
unsigned int data_in;
|
||||
unsigned int interrupt;
|
||||
} rcv_buf_t, *prcv_buf_t;
|
||||
|
||||
// Shared object handle typedef
|
||||
typedef void * handle_t;
|
||||
|
||||
// Callback pointer types
|
||||
typedef int (*pVUserInt_t) (void);
|
||||
typedef int (*pVUserIrqCB_t) (int);
|
||||
typedef int (*pPyIrqCB_t) (int, int);
|
||||
typedef int (*pVUserCB_t) (int);
|
||||
|
|
@ -123,7 +124,6 @@ typedef struct {
|
|||
sem_t rcv;
|
||||
send_buf_t send_buf;
|
||||
rcv_buf_t rcv_buf;
|
||||
pVUserInt_t VInt_table[MAX_INTERRUPT_LEVEL+1];
|
||||
pVUserIrqCB_t VUserIrqCB;
|
||||
pPyIrqCB_t PyIrqCB;
|
||||
vecIrqState_t irqState;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// VProcClass.h Date: 2023/12/29
|
||||
//
|
||||
// Copyright (c) 2023-2024 Simon Southwell.
|
||||
// Copyright (c) 2023-2025 Simon Southwell.
|
||||
//
|
||||
// This file is part of VProc.
|
||||
//
|
||||
|
|
@ -64,7 +64,6 @@ public:
|
|||
int burstRead (const unsigned addr, void *data, const unsigned wordlen) {return VBurstRead (addr, data, wordlen, node);};
|
||||
int tick (const unsigned ticks) {return VTick (ticks, node);};
|
||||
void regIrq (const pVUserIrqCB_t func) { VRegIrq (func, node);};
|
||||
void regInterrupt (const int level, const pVUserInt_t func) { VRegInterrupt (level, func, node);};
|
||||
void regUser (const pVUserCB_t func) { VRegUser (func, node);};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// VSched.c Date: 2004/12/13
|
||||
//
|
||||
// Copyright (c) 2004-2024 Simon Southwell.
|
||||
// Copyright (c) 2004-2025 Simon Southwell.
|
||||
//
|
||||
// This file is part of VProc.
|
||||
//
|
||||
|
|
@ -89,7 +89,7 @@ VPROC_RTN_TYPE (*vhpi_startup_routines[])() = {
|
|||
// Get the parameter values of a foreign procedure using VHPI methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
static void getVhpiParams(const struct vhpiCbDataS* cb, int args[], int args_size)
|
||||
static void getVhpiParams(const struct vhpiCbDataS* cb, int args[], const int args_size)
|
||||
{
|
||||
int idx = 0;
|
||||
vhpiValueT value;
|
||||
|
|
@ -115,7 +115,7 @@ static void getVhpiParams(const struct vhpiCbDataS* cb, int args[], int args_siz
|
|||
// Set the parameters values of a foreign procedure using VHPI methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
static void setVhpiParams(const struct vhpiCbDataS* cb, int args[], int start_of_outputs, int args_size)
|
||||
static void setVhpiParams(const struct vhpiCbDataS* cb, const int args[], const int start_of_outputs, const int args_size)
|
||||
{
|
||||
int idx = 0;
|
||||
vhpiValueT value;
|
||||
|
|
@ -191,7 +191,7 @@ void (*vlog_startup_routines[])() =
|
|||
// Get task arguments using VPI calls
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
int getArgs (vpiHandle taskHdl, int value[])
|
||||
int getArgs (const vpiHandle taskHdl, int value[])
|
||||
{
|
||||
int idx = 0;
|
||||
struct t_vpi_value argval;
|
||||
|
|
@ -218,7 +218,7 @@ int getArgs (vpiHandle taskHdl, int value[])
|
|||
// Update task arguments using VPI calls
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
int updateArgs (vpiHandle taskHdl, int value[])
|
||||
int updateArgs (const vpiHandle taskHdl, const int value[])
|
||||
{
|
||||
int idx = 0;
|
||||
struct t_vpi_value argval;
|
||||
|
|
@ -347,7 +347,7 @@ VPROC_RTN_TYPE VSched (VSCHED_PARAMS)
|
|||
|
||||
#if !defined(VPROC_VHDL) && !defined(VPROC_SV)
|
||||
int node;
|
||||
int Interrupt, VPDataIn;
|
||||
int VPDataIn;
|
||||
|
||||
vpiHandle taskHdl;
|
||||
|
||||
|
|
@ -358,7 +358,7 @@ VPROC_RTN_TYPE VSched (VSCHED_PARAMS)
|
|||
#else
|
||||
# ifdef VPROC_VHDL_VHPI
|
||||
int node;
|
||||
int Interrupt, VPDataIn;
|
||||
int VPDataIn;
|
||||
|
||||
getVhpiParams(cb, &args[1], VSCHED_NUM_ARGS);
|
||||
# endif
|
||||
|
|
@ -370,33 +370,11 @@ VPROC_RTN_TYPE VSched (VSCHED_PARAMS)
|
|||
|
||||
// Get argument value of $vsched call
|
||||
node = args[VPNODENUM_ARG];
|
||||
Interrupt = args[VPINTERRUPT_ARG];
|
||||
VPDataIn = args[VPDATAIN_ARG];
|
||||
#endif
|
||||
|
||||
// Sample inputs and update node state
|
||||
ns[node]->rcv_buf.data_in = VPDataIn;
|
||||
ns[node]->rcv_buf.interrupt = Interrupt;
|
||||
|
||||
//----------------------------------------------
|
||||
// Discard any level interrupt when vectored
|
||||
// IRQ enabled
|
||||
//----------------------------------------------
|
||||
|
||||
// If call to VSched is for interrupt and vector IRQ enabled (with C or Python callback registered)
|
||||
// don't process here with the level interrupt code and just return.
|
||||
if (Interrupt && (ns[node]->VUserIrqCB != NULL || ns[node]->PyIrqCB != NULL))
|
||||
{
|
||||
#if !defined(VPROC_VHDL) && !defined(VPROC_SV)
|
||||
return 0;
|
||||
#else
|
||||
# ifndef VPROC_VHDL_VHPI
|
||||
// Since not processing make a delta cycle on return
|
||||
*VPTicks = DELTA_CYCLE;
|
||||
# endif
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
// Send inputs to user thread
|
||||
|
|
@ -486,7 +464,7 @@ VPROC_RTN_TYPE VProcUser(VPROCUSER_PARAMS)
|
|||
|
||||
// Get argument values of $vprocuser call
|
||||
node = args[VPNODENUM_ARG];
|
||||
value = args[VPINTERRUPT_ARG];
|
||||
value = args[VPVALUE_ARG];
|
||||
|
||||
#else
|
||||
# ifdef VPROC_VHDL_VHPI
|
||||
|
|
@ -496,7 +474,7 @@ VPROC_RTN_TYPE VProcUser(VPROCUSER_PARAMS)
|
|||
|
||||
// Get argument values of VProcUser VHPI call
|
||||
node = args[VPNODENUM_ARG];
|
||||
value = args[VPINTERRUPT_ARG];
|
||||
value = args[VPVALUE_ARG];
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -588,14 +566,14 @@ VPROC_RTN_TYPE VAccess(VACCESS_PARAMS)
|
|||
node = args[VPNODENUM_ARG];
|
||||
idx = args[VPINDEX_ARG];
|
||||
|
||||
args[VPDATAOUT_ARG] = ((int *) ns[node]->send_buf.data_p)[idx];
|
||||
args[VACCESSOUT_ARG] = ((int *) ns[node]->send_buf.data_p)[idx];
|
||||
|
||||
((int *) ns[node]->send_buf.data_p)[idx] = args[VPDATAIN_ARG];
|
||||
((int *) ns[node]->send_buf.data_p)[idx] = args[VPACCESSIN_ARG];
|
||||
|
||||
setVhpiParams(cb, &args[1], VPDATAOUT_ARG-1, VACCESS_NUM_ARGS);
|
||||
setVhpiParams(cb, &args[1], VACCESSOUT_ARG-1, VACCESS_NUM_ARGS);
|
||||
# endif
|
||||
#else
|
||||
int node, idx;
|
||||
int node, idx;
|
||||
|
||||
vpiHandle taskHdl;
|
||||
|
||||
|
|
@ -607,9 +585,9 @@ VPROC_RTN_TYPE VAccess(VACCESS_PARAMS)
|
|||
node = args[VPNODENUM_ARG];
|
||||
idx = args[VPINDEX_ARG];
|
||||
|
||||
args[VPDATAOUT_ARG] = ((int *) ns[node]->send_buf.data_p)[idx];
|
||||
args[VACCESSOUT_ARG] = ((int *) ns[node]->send_buf.data_p)[idx];
|
||||
|
||||
((int *) ns[node]->send_buf.data_p)[idx] = args[VPDATAIN_ARG];
|
||||
((int *) ns[node]->send_buf.data_p)[idx] = args[VPACCESSIN_ARG];
|
||||
|
||||
updateArgs(taskHdl, &args[1]);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// VSched_pli.h Date: 2004/12/13
|
||||
//
|
||||
// Copyright (c) 2004-2024 Simon Southwell.
|
||||
// Copyright (c) 2004-2025 Simon Southwell.
|
||||
//
|
||||
// This file is part of VProc.
|
||||
//
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
#define VHALT_PARAMS int, int
|
||||
|
||||
#define VINIT_NUM_ARGS 1
|
||||
#define VSCHED_NUM_ARGS 7
|
||||
#define VSCHED_NUM_ARGS 6
|
||||
#define VPROCUSER_NUM_ARGS 2
|
||||
#define VIRQ_NUM_ARGS 2
|
||||
#define VACCESS_NUM_ARGS 4
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
# endif
|
||||
|
||||
#define VINIT_PARAMS int node
|
||||
#define VSCHED_PARAMS int node, int Interrupt, int VPDataIn, int* VPDataOut, int* VPAddr, int* VPRw, int* VPTicks
|
||||
#define VSCHED_PARAMS int node, int VPDataIn, int* VPDataOut, int* VPAddr, int* VPRw, int* VPTicks
|
||||
#define VPROCUSER_PARAMS int node, int value
|
||||
#define VIRQ_PARAMS int node, int value
|
||||
#define VACCESS_PARAMS int node, int idx, int VPDataIn, int* VPDataOut
|
||||
|
|
@ -150,15 +150,16 @@
|
|||
|
||||
#define VPROC_RTN_TYPE int
|
||||
|
||||
extern int getArgs (vpiHandle taskHdl, int value[]);
|
||||
extern int updateArgs (vpiHandle taskHdl, int value[]);
|
||||
// Export VPI tak argument functions for use externally (pcievhost ises them)
|
||||
extern int getArgs (const vpiHandle taskHdl, int value[]);
|
||||
extern int updateArgs (const vpiHandle taskHdl, const int value[]);
|
||||
|
||||
# endif
|
||||
|
||||
extern VPROC_RTN_TYPE VInit (VINIT_PARAMS);
|
||||
extern VPROC_RTN_TYPE VSched (VSCHED_PARAMS);
|
||||
extern VPROC_RTN_TYPE VProcUser (VPROCUSER_PARAMS);
|
||||
extern VPROC_RTN_TYPE VIrq (VIRQ_PARAMS);
|
||||
extern VPROC_RTN_TYPE VAccess (VACCESS_PARAMS);
|
||||
extern int VHalt (VHALT_PARAMS);
|
||||
extern VPROC_RTN_TYPE VInit (VINIT_PARAMS);
|
||||
extern VPROC_RTN_TYPE VSched (VSCHED_PARAMS);
|
||||
extern VPROC_RTN_TYPE VProcUser (VPROCUSER_PARAMS);
|
||||
extern VPROC_RTN_TYPE VIrq (VIRQ_PARAMS);
|
||||
extern VPROC_RTN_TYPE VAccess (VACCESS_PARAMS);
|
||||
extern int VHalt (VHALT_PARAMS);
|
||||
|
||||
|
|
|
|||
80
code/VUser.c
80
code/VUser.c
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// VUser.c Date: 2004/12/13
|
||||
//
|
||||
// Copyright (c) 2004-2024 Simon Southwell.
|
||||
// Copyright (c) 2004-2025 Simon Southwell.
|
||||
//
|
||||
// This file is part of VProc.
|
||||
//
|
||||
|
|
@ -52,12 +52,6 @@ int VUser (const unsigned node)
|
|||
|
||||
debug_io_printf("VUser(): node %d\n", node);
|
||||
|
||||
// Level interrupt callback table initialisation
|
||||
for (jdx = 0; jdx < 8; jdx++)
|
||||
{
|
||||
ns[node]->VInt_table[jdx] = NULL;
|
||||
}
|
||||
|
||||
// Callback intialisation
|
||||
ns[node]->VUserIrqCB = NULL;
|
||||
ns[node]->VUserCB = NULL;
|
||||
|
|
@ -138,7 +132,7 @@ static void VUserInit (const unsigned node)
|
|||
// the original IO message reply is waited for again.
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
static void VExch (psend_buf_t psbuf, prcv_buf_t prbuf, const unsigned node)
|
||||
static void VExch (const psend_buf_t psbuf, prcv_buf_t prbuf, const unsigned node)
|
||||
{
|
||||
int status;
|
||||
// Send message to simulator
|
||||
|
|
@ -152,47 +146,11 @@ static void VExch (psend_buf_t psbuf, prcv_buf_t prbuf, const unsigned node)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// Wait for response message from simulator
|
||||
debug_io_printf("VExch(): waiting for rcv[%d] semaphore\n", node);
|
||||
sem_wait(&(ns[node]->rcv));
|
||||
// Wait for response message from simulator
|
||||
debug_io_printf("VExch(): waiting for rcv[%d] semaphore\n", node);
|
||||
sem_wait(&(ns[node]->rcv));
|
||||
|
||||
*prbuf = ns[node]->rcv_buf;
|
||||
|
||||
// Check if this is an interrupt
|
||||
if (prbuf->interrupt > 0)
|
||||
{
|
||||
debug_io_printf("VExch(): node %d processing interrupt (%d)\n", node, prbuf->interrupt);
|
||||
|
||||
if (prbuf->interrupt > MAX_INTERRUPT_LEVEL)
|
||||
{
|
||||
VPrint("***Error: invalid interrupt level %d (VExch)\n", prbuf->interrupt);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ns[node]->VInt_table[prbuf->interrupt] != NULL)
|
||||
{
|
||||
// Call user registered interrupt function
|
||||
psbuf->ticks = (*(ns[node]->VInt_table[prbuf->interrupt]))();
|
||||
ns[node]->send_buf = *psbuf;
|
||||
|
||||
debug_io_printf("VExch(): interrupt send_buf[node].ticks = %d\n", ns[node]->send_buf.ticks);
|
||||
}
|
||||
|
||||
// Send new message to simulation
|
||||
debug_io_printf("VExch(): setting snd[%d] semaphore (interrupt)\n", node);
|
||||
|
||||
if ((status = sem_post(&(ns[node]->snd))) == -1)
|
||||
{
|
||||
VPrint("***Error: bad sem_post status (%d) on node %d (VExch)\n", status, node);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
// If the response was an interrupt, go back and wait for IO message response.
|
||||
// (This could be in the same cycle as the interrupt)
|
||||
}
|
||||
while (prbuf->interrupt > 0);
|
||||
*prbuf = ns[node]->rcv_buf;
|
||||
|
||||
debug_io_printf("VExch(): returning to user code from node %d\n", node);
|
||||
|
||||
|
|
@ -203,7 +161,7 @@ static void VExch (psend_buf_t psbuf, prcv_buf_t prbuf, const unsigned node)
|
|||
// =========================================================================
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// VWrite
|
||||
// VWrite()
|
||||
//
|
||||
// Invokes a write message exchange
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
@ -214,7 +172,7 @@ int VWrite (const unsigned addr, const unsigned data, const int delta, const uns
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// VWriteBE
|
||||
// VWriteBE()
|
||||
//
|
||||
// Invokes a write message exchange with byte enables
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
@ -370,26 +328,6 @@ int VTick (const unsigned ticks, const unsigned node)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// VRegInterrupt()
|
||||
//
|
||||
// Registers a user function as an level interrupt callback. Deprecated in
|
||||
// favour f vectored interrupts. Kept for backwards compatibility.
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
void VRegInterrupt (const int level, const pVUserInt_t func, const unsigned node)
|
||||
{
|
||||
debug_io_printf("VRegInterrupt(): at node %d, registering interrupt level %d\n", node, level);
|
||||
|
||||
if (level < MIN_INTERRUPT_LEVEL || level >= MAX_INTERRUPT_LEVEL)
|
||||
{
|
||||
VPrint("***Error: attempt to register an out of range interrupt level (VRegInterrupt)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ns[node]->VInt_table[level] = func;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// VRegIrq()
|
||||
//
|
||||
|
|
@ -424,7 +362,7 @@ void VRegIrqPy (const pPyIrqCB_t func, const unsigned node)
|
|||
|
||||
void VRegUser (const pVUserCB_t func, const unsigned node)
|
||||
{
|
||||
debug_io_printf("VRegFinish(): at node %d, registering finish callback function\n", node);
|
||||
debug_io_printf("VRegUser(): at node %d, registering user callback function\n", node);
|
||||
|
||||
ns[node]->VUserCB = func;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// VUser.h Date: 2005/01/10
|
||||
//
|
||||
// Copyright (c) 2005-2024 Simon Southwell.
|
||||
// Copyright (c) 2005-2025 Simon Southwell.
|
||||
//
|
||||
// This file is part of VProc.
|
||||
//
|
||||
|
|
@ -30,9 +30,6 @@
|
|||
#define DELTA_CYCLE -1
|
||||
#define GO_TO_SLEEP 0x7fffffff
|
||||
|
||||
#define MAX_INT_LEVEL 7
|
||||
#define MIN_INT_LEVEL 1
|
||||
|
||||
#define MAXBURSTLEN 4096
|
||||
|
||||
// When compiling in windows (32- or 64-bit) ...
|
||||
|
|
@ -75,9 +72,6 @@ extern int VTick (const unsigned ticks, const unsigned node);
|
|||
extern void VRegUser (const pVUserCB_t func, const unsigned node);
|
||||
extern void VRegIrq (const pVUserIrqCB_t func, const unsigned node);
|
||||
|
||||
// *** Deprecated in favour of VRegIrq ***/
|
||||
extern void VRegInterrupt (const int level, const pVUserInt_t func, const unsigned node);
|
||||
|
||||
// Internal function for Python interface
|
||||
extern void VRegIrqPy (const pPyIrqCB_t func, const unsigned node);
|
||||
|
||||
|
|
|
|||
BIN
doc/VProc.pdf
BIN
doc/VProc.pdf
Binary file not shown.
16
f_VProc.v
16
f_VProc.v
|
|
@ -3,7 +3,7 @@
|
|||
// SystemVerilog side Virtual Processor, for running host
|
||||
// programs as control in simulation.
|
||||
//
|
||||
// Copyright (c) 2024 Simon Southwell.
|
||||
// Copyright (c) 2004-2025 Simon Southwell.
|
||||
//
|
||||
// This file is part of VProc.
|
||||
//
|
||||
|
|
@ -168,18 +168,6 @@ begin
|
|||
// before starting accesses
|
||||
if (Initialised == 1'b1)
|
||||
begin
|
||||
// If an interrupt active, call VSched with interrupt value
|
||||
if (IntSamp > 0)
|
||||
begin
|
||||
`VSched(NodeI, IntSamp, DataInSamp, VPDataOut, VPAddr, VPRW, VPTicks);
|
||||
|
||||
// If interrupt routine returns non-zero tick, then override
|
||||
// current tick value. Otherwise, leave at present value.
|
||||
if (VPTicks > 0)
|
||||
begin
|
||||
TickCount = VPTicks;
|
||||
end
|
||||
end
|
||||
|
||||
// If vector IRQ enabled, call VIirq when interrupt value changes, passing in
|
||||
// new value
|
||||
|
|
@ -222,7 +210,7 @@ begin
|
|||
end
|
||||
|
||||
// Get new access command
|
||||
`VSched(NodeI, IntSamp, DataInSamp, VPDataOut, VPAddr, VPRW, VPTicks);
|
||||
`VSched(NodeI, DataInSamp, VPDataOut, VPAddr, VPRW, VPTicks);
|
||||
|
||||
// Update the outputs
|
||||
Burst <= VPRW[`BLKBITS];
|
||||
|
|
|
|||
33
f_vproc.vhd
33
f_vproc.vhd
|
|
@ -1,6 +1,6 @@
|
|||
-- =============================================================
|
||||
--
|
||||
-- Copyright (c) 2021-2023 Simon Southwell. All rights reserved.
|
||||
-- Copyright (c) 2021-2025 Simon Southwell. All rights reserved.
|
||||
--
|
||||
-- Date: 4th May 2021
|
||||
--
|
||||
|
|
@ -123,25 +123,7 @@ begin
|
|||
|
||||
if Initialised = 1 then
|
||||
|
||||
if IntSamp > 0 then
|
||||
|
||||
-- If an interrupt active, call $vsched with interrupt value
|
||||
VSched(to_integer(unsigned(Node)),
|
||||
IntSamp,
|
||||
DataInSamp,
|
||||
VPDataOut,
|
||||
VPAddr,
|
||||
VPRW,
|
||||
VPTicks);
|
||||
|
||||
-- If interrupt routine returns non-zero tick, then override
|
||||
-- current tick value. Otherwise, leave at present value.
|
||||
if VPTicks > 0 then
|
||||
TickVal := VPTicks;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
-- Call $virq when interrupt value changes, passing in
|
||||
-- Call VIrq when interrupt value changes, passing in
|
||||
-- new value
|
||||
if IntSamp /= IntSampLast then
|
||||
VIrq(to_integer(unsigned(Node)), IntSamp);
|
||||
|
|
@ -166,14 +148,14 @@ begin
|
|||
|
||||
if BlkCount <= 1 then
|
||||
|
||||
-- If this is the last transfer in a burst, call $vaccess with
|
||||
-- If this is the last transfer in a burst, call VAccess with
|
||||
-- the last data input sample.
|
||||
if BlkCount = 1 then
|
||||
BlkCount := 0;
|
||||
|
||||
|
||||
if RD = '1' then
|
||||
AccIdx := AccIdx + 1;
|
||||
|
||||
|
||||
VAccess(to_integer(unsigned(Node)),
|
||||
AccIdx,
|
||||
DataInSamp,
|
||||
|
|
@ -183,7 +165,6 @@ begin
|
|||
|
||||
-- Host process message scheduler called
|
||||
VSched(to_integer(unsigned(Node)),
|
||||
IntSamp,
|
||||
DataInSamp,
|
||||
VPDataOut,
|
||||
VPAddr,
|
||||
|
|
@ -202,13 +183,13 @@ begin
|
|||
-- If new BlkCount is non-zero, setup burst transfer
|
||||
if BlkCount /= 0 then
|
||||
BurstFirst <= '1';
|
||||
|
||||
|
||||
-- If a single word transfer, set the last flag
|
||||
if BlkCount = 1 then
|
||||
BurstLast <= '1';
|
||||
end if;
|
||||
|
||||
-- On writes, override VPDataOut to get from burst access task $VAccess at index 0
|
||||
-- On writes, override VPDataOut to get from burst access task VAccess at index 0
|
||||
if to_unsigned(VPRW, 32)(WEbit) = '1' then
|
||||
AccIdx := 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- =============================================================
|
||||
--
|
||||
-- Copyright (c) 2021-2023 Simon Southwell. All rights reserved.
|
||||
-- Copyright (c) 2021-2025 Simon Southwell. All rights reserved.
|
||||
--
|
||||
-- Date: 4th May 2021
|
||||
--
|
||||
|
|
@ -32,7 +32,6 @@ package vproc_pkg is
|
|||
|
||||
procedure VSched (
|
||||
node : in integer;
|
||||
Interrupt : in integer;
|
||||
VPDataIn : in integer;
|
||||
VPDataOut : out integer;
|
||||
VPAddr : out integer;
|
||||
|
|
@ -78,7 +77,6 @@ package body vproc_pkg is
|
|||
|
||||
procedure VSched (
|
||||
node : in integer;
|
||||
Interrupt : in integer;
|
||||
VPDataIn : in integer;
|
||||
VPDataOut : out integer;
|
||||
VPAddr : out integer;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- =============================================================
|
||||
--
|
||||
-- Copyright (c) 2024 Simon Southwell. All rights reserved.
|
||||
-- Copyright (c) 2024-2025 Simon Southwell. All rights reserved.
|
||||
--
|
||||
-- Date: 29th March 2024
|
||||
--
|
||||
|
|
@ -31,7 +31,6 @@ package vproc_pkg is
|
|||
|
||||
procedure VSched (
|
||||
node : in integer;
|
||||
Interrupt : in integer;
|
||||
VPDataIn : in integer;
|
||||
VPDataOut : out integer;
|
||||
VPAddr : out integer;
|
||||
|
|
@ -73,7 +72,6 @@ package body vproc_pkg is
|
|||
|
||||
procedure VSched (
|
||||
node : in integer;
|
||||
Interrupt : in integer;
|
||||
VPDataIn : in integer;
|
||||
VPDataOut : out integer;
|
||||
VPAddr : out integer;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- =============================================================
|
||||
--
|
||||
-- Copyright (c) 2024 Simon Southwell. All rights reserved.
|
||||
-- Copyright (c) 2024-2025 Simon Southwell. All rights reserved.
|
||||
--
|
||||
-- Date: 28th March 2024
|
||||
--
|
||||
|
|
@ -31,7 +31,6 @@ package vproc_pkg is
|
|||
|
||||
procedure VSched (
|
||||
node : in integer;
|
||||
Interrupt : in integer;
|
||||
VPDataIn : in integer;
|
||||
VPDataOut : out integer;
|
||||
VPAddr : out integer;
|
||||
|
|
@ -73,7 +72,6 @@ package body vproc_pkg is
|
|||
|
||||
procedure VSched (
|
||||
node : in integer;
|
||||
Interrupt : in integer;
|
||||
VPDataIn : in integer;
|
||||
VPDataOut : out integer;
|
||||
VPAddr : out integer;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Top level demonstration test environment for VProc
|
||||
*
|
||||
* Copyright (c) 2004-2024 Simon Southwell.
|
||||
* Copyright (c) 2004-2025 Simon Southwell.
|
||||
*
|
||||
* This file is part of VProc.
|
||||
*
|
||||
|
|
@ -56,7 +56,6 @@ integer Interrupt0;
|
|||
integer Interrupt1;
|
||||
reg [31:0] VPDataIn0;
|
||||
reg nreset_h;
|
||||
integer restart;
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// Signals
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**************************************************************/
|
||||
/* VUserMain.c Date: 2004/12/13 */
|
||||
/* */
|
||||
/* Copyright (c) 2004-2024 Simon Southwell. */
|
||||
/* Copyright (c) 2004-2025 Simon Southwell. */
|
||||
/* All rights reserved. */
|
||||
/* */
|
||||
/**************************************************************/
|
||||
|
|
@ -18,7 +18,7 @@ static int node = 0;
|
|||
static int Reset = 0;
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Interrupt callback function for level 1
|
||||
// ISR function for level 1
|
||||
// ------------------------------------------------------------
|
||||
|
||||
static int VInterrupt_1(void)
|
||||
|
|
@ -28,7 +28,7 @@ static int VInterrupt_1(void)
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Interrupt callback function for level 4
|
||||
// ISR function for level 4
|
||||
// ------------------------------------------------------------
|
||||
|
||||
static int VInterrupt_4(void)
|
||||
|
|
@ -38,6 +38,23 @@ static int VInterrupt_4(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Interrrupt callback function
|
||||
// ------------------------------------------------------------
|
||||
|
||||
static int VInterrupt (int level)
|
||||
{
|
||||
switch(level)
|
||||
{
|
||||
case 1: VInterrupt_1(); break;
|
||||
case 4: VInterrupt_4(); break;
|
||||
case 0: break;
|
||||
default:
|
||||
VPrint("***ERROR: VInterrupt(): unrecognised interrupt vector (0x%08x)\n", level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// VuserMainX entry point for node 0
|
||||
// ------------------------------------------------------------
|
||||
|
|
@ -51,9 +68,8 @@ void VUserMain0()
|
|||
|
||||
VPrint("VUserMain0(): node=%d\n", node);
|
||||
|
||||
// Register functions as interrupt levels 1 and 4 routines
|
||||
VRegInterrupt(1, VInterrupt_1, node);
|
||||
VRegInterrupt(4, VInterrupt_4, node);
|
||||
// Register function for interrupt
|
||||
VRegIrq(VInterrupt, node);
|
||||
|
||||
do
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**************************************************************/
|
||||
/* VUserMain.c Date: 2004/12/13 */
|
||||
/* */
|
||||
/* Copyright (c) 2004-2024 Simon Southwell. */
|
||||
/* Copyright (c) 2004-2025 Simon Southwell. */
|
||||
/* All rights reserved. */
|
||||
/* */
|
||||
/**************************************************************/
|
||||
|
|
@ -18,7 +18,7 @@ static int node = 0;
|
|||
static int Reset = 0;
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Interrupt callback function for level 1
|
||||
// Interrupt function for level 1
|
||||
// ------------------------------------------------------------
|
||||
|
||||
static int VInterrupt_1(void)
|
||||
|
|
@ -28,7 +28,7 @@ static int VInterrupt_1(void)
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Interrupt callback function for level 4
|
||||
// Interrupt function for level 4
|
||||
// ------------------------------------------------------------
|
||||
|
||||
static int VInterrupt_4(void)
|
||||
|
|
@ -38,6 +38,23 @@ static int VInterrupt_4(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Interrrupt callback function
|
||||
// ------------------------------------------------------------
|
||||
|
||||
static int VInterrupt (int level)
|
||||
{
|
||||
switch(level)
|
||||
{
|
||||
case 1: VInterrupt_1(); break;
|
||||
case 4: VInterrupt_4(); break;
|
||||
case 0: break;
|
||||
default:
|
||||
VPrint("***ERROR: VInterrupt(): unrecognised interrupt vector (0x%08x)\n", level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// VuserMainX entry point for node 0
|
||||
// ------------------------------------------------------------
|
||||
|
|
@ -51,9 +68,8 @@ void VUserMain0()
|
|||
|
||||
VPrint("VUserMain0(): node=%d\n", node);
|
||||
|
||||
// Register functions as interrupt levels 1 and 4 routines
|
||||
VRegInterrupt(1, VInterrupt_1, node);
|
||||
VRegInterrupt(4, VInterrupt_4, node);
|
||||
// Register function for interrupt
|
||||
VRegIrq(VInterrupt, node);
|
||||
|
||||
do
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// Verilog side Virtual Processor, for running host
|
||||
// programs as control in simulation.
|
||||
//
|
||||
// Copyright (c) 2024 Simon Southwell.
|
||||
// Copyright (c) 2024-2025 Simon Southwell.
|
||||
//
|
||||
// This file is part of VProc.
|
||||
//
|
||||
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
import "DPI-C" function void VInit (input int node);
|
||||
|
||||
import "DPI-C" function void VSched (input int node,
|
||||
input int Interrupt,
|
||||
import "DPI-C" function void VSched (input int node,
|
||||
input int VPDataIn,
|
||||
output int VPDataOut,
|
||||
output int VPAddr,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue