mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	Updated to use the newest imperasDV.
This commit is contained in:
		
							parent
							
								
									dc97ee5f82
								
							
						
					
					
						commit
						bf69a2e1cd
					
				@ -1,10 +1,10 @@
 | 
			
		||||
all: rvvidaemon
 | 
			
		||||
 | 
			
		||||
rvvidaemon: rvvidaemon.o
 | 
			
		||||
	gcc $^ /opt/riscv/ImperasDV-OpenHW/Imperas/lib/Linux64/ImperasLib/imperas.com/verification/riscv/1.0/model.so  -o rvvidaemon
 | 
			
		||||
	gcc $^ /opt/riscv/ImperasDV-OpenHW/lib/Linux64/ImperasLib/imperas.com/verification/riscv/1.0/model.so  -o rvvidaemon
 | 
			
		||||
 | 
			
		||||
%.o:%.c
 | 
			
		||||
	gcc -I/opt/riscv/ImperasDV-OpenHW/Imperas/ImpProprietary/include/host -c $^ -o $@
 | 
			
		||||
	gcc -I/opt/riscv/ImperasDV-OpenHW/ImpProprietary/include/host -I/opt/riscv/ImperasDV-OpenHW/ImpPublic/include/host/rvvi/ -c $^ -o $@
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	rm *.o rvvidaemon
 | 
			
		||||
 | 
			
		||||
@ -1,697 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2005-2023 Imperas Software Ltd., www.imperas.com
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *   http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 | 
			
		||||
 * either express or implied.
 | 
			
		||||
 *
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
/*! \file rvviApi.h
 | 
			
		||||
 *  \brief RVVI interface, C API header.
 | 
			
		||||
**/
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
typedef uint32_t bool_t;
 | 
			
		||||
 | 
			
		||||
#define RVVI_API_VERSION_MAJOR 1
 | 
			
		||||
#define RVVI_API_VERSION_MINOR 34
 | 
			
		||||
#define RVVI_TRUE 1
 | 
			
		||||
#define RVVI_FALSE 0
 | 
			
		||||
#define RVVI_INVALID_INDEX -1
 | 
			
		||||
#define RVVI_MEMORY_PRIVILEGE_READ 1
 | 
			
		||||
#define RVVI_MEMORY_PRIVILEGE_WRITE 2
 | 
			
		||||
#define RVVI_MEMORY_PRIVILEGE_EXEC 4
 | 
			
		||||
#define RVVI_API_VERSION ((RVVI_API_VERSION_MAJOR << 24) | RVVI_API_VERSION_MINOR)
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    RVVI_METRIC_RETIRES = 0,
 | 
			
		||||
    RVVI_METRIC_TRAPS = 1,
 | 
			
		||||
    RVVI_METRIC_MISMATCHES = 2,
 | 
			
		||||
    RVVI_METRIC_COMPARISONS_PC = 3,
 | 
			
		||||
    RVVI_METRIC_COMPARISONS_GPR = 4,
 | 
			
		||||
    RVVI_METRIC_COMPARISONS_FPR = 5,
 | 
			
		||||
    RVVI_METRIC_COMPARISONS_CSR = 6,
 | 
			
		||||
    RVVI_METRIC_COMPARISONS_VR = 7,
 | 
			
		||||
    RVVI_METRIC_COMPARISONS_INSBIN = 8,
 | 
			
		||||
    RVVI_METRIC_CYCLES = 9,
 | 
			
		||||
    RVVI_METRIC_ERRORS = 10,
 | 
			
		||||
    RVVI_METRIC_WARNINGS = 11,
 | 
			
		||||
    RVVI_METRIC_FATALS = 12,
 | 
			
		||||
} rvviMetricE;
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*! \brief Check the compiled RVVI API version.
 | 
			
		||||
 *
 | 
			
		||||
 *  Makes sure the RVVI implementation linked with matches the versions defined in this header file. This should be called before any other RVVI API function. If this function returns RVVI_FALSE, no other RVVI API function should be called.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param version Should be set to RVVI_API_VERSION.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_TRUE if versions matches otherwise RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviVersionCheck(
 | 
			
		||||
    uint32_t version);
 | 
			
		||||
 | 
			
		||||
/*! \brief Initialize the DV reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param programPath File path of the ELF file to be executed. This parameter can be NULL if required.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_TRUE if the reference was initialized successfully else RVVI_FALSE.
 | 
			
		||||
 *
 | 
			
		||||
 *  \note The reference model will begin execution from the entry point of the provided ELF file but can be overridden by the rvviRefPcSet() function.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefInit(
 | 
			
		||||
    const char *programPath);
 | 
			
		||||
 | 
			
		||||
/*! \brief Force the PC of the reference model to be particular value.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to change the PC register of.
 | 
			
		||||
 *  \param address The address to change the PC register to.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_TRUE on success else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefPcSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint64_t address);
 | 
			
		||||
 | 
			
		||||
/*! \brief Shutdown the reference module releasing any used resources.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns RVVI_TRUE if shutdown was successful else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefShutdown(void);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify the reference that a CSR is considered volatile.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that will have its CSR made volatile.
 | 
			
		||||
 *  \param csrIndex Index of the CSR register to be considered volatile (0x0 to 0xfff).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns RVVI_TRUE if operation was successful else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefCsrSetVolatile(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify the reference that a memory region is volatile.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param addressLow Lower address of the volatile memory region
 | 
			
		||||
 *  \param addressHigh Upper address of the volatile memory region (inclusive)
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns RVVI_TRUE if operation was successful else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefMemorySetVolatile(
 | 
			
		||||
    uint64_t addressLow,
 | 
			
		||||
    uint64_t addressHigh);
 | 
			
		||||
 | 
			
		||||
/*! \brief Lookup a net on the reference model and return its index.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param name The net name to locate.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Unique index for this net or RVVI_INVALID_INDEX if it was not found.
 | 
			
		||||
 *
 | 
			
		||||
 *  \note Please consult the model datasheet for a list of valid net names.
 | 
			
		||||
 *  \note See also, rvviRefNetSet().
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefNetIndexGet(
 | 
			
		||||
    const char *name);
 | 
			
		||||
 | 
			
		||||
/*! \brief Extract a byte from the reference models vector register.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to extract the vector register byte from.
 | 
			
		||||
 *  \param vrIndex The vector register index (0 to 31).
 | 
			
		||||
 *  \param byteIndex The byte offset into the vector register (note 0 is LSB).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Byte that has been extracted from the vector register.
 | 
			
		||||
**/
 | 
			
		||||
extern uint8_t rvviRefVrGet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t vrIndex,
 | 
			
		||||
    uint32_t byteIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify RVVI that a byte in the DUTs vector register has changed.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that has updated its vector register.
 | 
			
		||||
 *  \param vrIndex The vector register index (0 to 31).
 | 
			
		||||
 *  \param byteIndex The byte offset into the vector register (note 0 is LSB).
 | 
			
		||||
 *  \param data New byte value in the DUTs vector register.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviDutVrSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t vrIndex,
 | 
			
		||||
    uint32_t byteIndex,
 | 
			
		||||
    uint8_t data);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify RVVI that a DUT floating point register has been written to.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that has updated its FPR.
 | 
			
		||||
 *  \param fprIndex The FPR index within the register file (0 to 31).
 | 
			
		||||
 *  \param value The value that has been written.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviDutFprSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t fprIndex,
 | 
			
		||||
    uint64_t value);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify RVVI that a DUT GPR has been written to.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that has updated its GPR.
 | 
			
		||||
 *  \param gprIndex The GPR index within the register file.
 | 
			
		||||
 *  \param value The value that has been written.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviDutGprSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t gprIndex,
 | 
			
		||||
    uint64_t value);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify RVVI that a DUT CSR has been written to.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that has updated its CSR.
 | 
			
		||||
 *  \param csrIndex The CSR index (0x0 to 0xfff).
 | 
			
		||||
 *  \param value The value that has been written.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviDutCsrSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex,
 | 
			
		||||
    uint64_t value);
 | 
			
		||||
 | 
			
		||||
/*! \brief Place a net in a specific net group.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param netIndex The net index returned prior by rvviRefNetIndexGet().
 | 
			
		||||
 *  \param group The group index to place this net into.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefNetGroupSet(
 | 
			
		||||
    uint64_t netIndex,
 | 
			
		||||
    uint32_t group);
 | 
			
		||||
 | 
			
		||||
/*! \brief Propagate a net change to the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param netIndex The net index returned prior by rvviRefNetIndexGet().
 | 
			
		||||
 *  \param value The new value to set the net state to.
 | 
			
		||||
 *  \param when Time of arrival of this net, in simulation time. The `when` parameter may be measured in simulation time or cycles. It allows the RVVI-API to know which net changes have arrived at the same time.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefNetSet(
 | 
			
		||||
    uint64_t netIndex,
 | 
			
		||||
    uint64_t value,
 | 
			
		||||
    uint64_t when);
 | 
			
		||||
 | 
			
		||||
/*! \brief Read the state of a net on the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param netIndex The net index returned prior by rvviRefNetIndexGet().
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The value present on the specified net.
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefNetGet(
 | 
			
		||||
    uint64_t netIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify the reference that a DUT instruction has retired.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that has retired an instruction.
 | 
			
		||||
 *  \param dutPc The address of the instruction that has retired.
 | 
			
		||||
 *  \param dutInsBin The binary instruction representation.
 | 
			
		||||
 *  \param debugMode True if this instruction was executed in debug mode.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviDutRetire(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint64_t dutPc,
 | 
			
		||||
    uint64_t dutInsBin,
 | 
			
		||||
    bool_t debugMode);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify the reference that the DUT received a trap.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that has retired an instruction.
 | 
			
		||||
 *  \param dutPc The address of the instruction that has retired.
 | 
			
		||||
 *  \param dutInsBin The binary instruction representation.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviDutTrap(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint64_t dutPc,
 | 
			
		||||
    uint64_t dutInsBin);
 | 
			
		||||
 | 
			
		||||
/*! \brief Invalidate the reference models LR/SC reservation.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart of which the LR/SC reservation will be made invalid.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefReservationInvalidate(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Step the reference model until the next event.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being stepped.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns RVVI_TRUE if the step was successful else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefEventStep(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Compare all GPR register values between reference and DUT.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being compared.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_FALSE if there are any mismatches, otherwise RVVI_TRUE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefGprsCompare(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Compare GPR registers that have been written to between the reference and DUT. This can be seen as a super set of the rvviRefGprsCompare function. This comparator will also flag differences in the set of registers that have been written to.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being compared.
 | 
			
		||||
 *  \param ignoreX0 RVVI_TRUE to not compare writes to the x0 register, which may be treated as a special case, otherwise RVVI_FALSE.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_FALSE if there are any mismatches, otherwise RVVI_TRUE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefGprsCompareWritten(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    bool_t ignoreX0);
 | 
			
		||||
 | 
			
		||||
/*! \brief Compare retired instruction bytes between reference and DUT.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being compared.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_FALSE if there are any mismatches, otherwise RVVI_TRUE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefInsBinCompare(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Compare program counter for the retired instructions between DUT and the the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being compared.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_FALSE if there are any mismatches, otherwise RVVI_TRUE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefPcCompare(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Compare a CSR value between DUT and the the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being compared.
 | 
			
		||||
 *  \param csrIndex The index of the CSR register being compared.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_FALSE if there are any mismatches, otherwise RVVI_TRUE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefCsrCompare(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Enable or disable comparison of a specific CSR during rvviRefCsrsCompare.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that this should apply to.
 | 
			
		||||
 *  \param csrIndex The index of the CSR to enable or disable comparison of.
 | 
			
		||||
 *  \param enableState RVVI_TRUE to enable comparison or RVVI_FALSE to disable.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefCsrCompareEnable(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex,
 | 
			
		||||
    bool_t enableState);
 | 
			
		||||
 | 
			
		||||
/*! \brief Specify a bitmask to direct bit level CSR comparisons.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that this should apply to.
 | 
			
		||||
 *  \param csrIndex The index of the CSR to control the comparison of.
 | 
			
		||||
 *  \param mask Bitmask to enable or disable bits during CSR compare operations. Bits set to 1 will be compared and 0 bits are ignored.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefCsrCompareMask(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex,
 | 
			
		||||
    uint64_t mask);
 | 
			
		||||
 | 
			
		||||
/*! \brief Compare all CSR values between DUT and the the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  This function will compare the value of all CSRs between the reference and the DUT. Note that specific CSRs can be removed from this comparison by using the rvviRefCsrCompareEnable function.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being compared.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_FALSE if there are any mismatches, otherwise RVVI_TRUE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefCsrsCompare(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Compare all RVV vector register values between reference and DUT.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being compared.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_FALSE if there are any mismatches, otherwise RVVI_TRUE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefVrsCompare(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Compare all floating point register values between reference and DUT.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The ID of the hart that is being compared.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_FALSE if there are any mismatches, otherwise RVVI_TRUE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefFprsCompare(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Write to the GPR of a hart in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to write the GPR of.
 | 
			
		||||
 *  \param gprIndex Index of the GPR register to write.
 | 
			
		||||
 *  \param gprValue Value to write into the GPR register.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefGprSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t gprIndex,
 | 
			
		||||
    uint64_t gprValue);
 | 
			
		||||
 | 
			
		||||
/*! \brief Read a GPR value from a hart in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to retrieve the GPR from.
 | 
			
		||||
 *  \param gprIndex Index of the GPR register to read.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return GPR value read from the reference model.
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefGprGet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t gprIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Read a GPR written mask from the last rvviRefEventStep.
 | 
			
		||||
 *
 | 
			
		||||
 *  Each bit index in the mask returned indicates if the corresponding GPR has been written to by the reference model. Ie, if bit 3 is set, then X3 was written to.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to retrieve the GPR written mask from.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The GPR written mask.
 | 
			
		||||
**/
 | 
			
		||||
extern uint32_t rvviRefGprsWrittenGet(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Return the program counter of a hart in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to retrieve the PC from.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The program counter of the specified hart.
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefPcGet(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Read a CSR value from a hart in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to retrieve the CSR from.
 | 
			
		||||
 *  \param csrIndex Index of the CSR register to read (0x0 to 0xfff).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The CSR register value read from the specified hart.
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefCsrGet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Return the binary representation of the previously retired instruction.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to retrieve the instruction from.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The instruction bytes.
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefInsBinGet(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Write the value of a floating point register for a hart in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to retrieve the FPR register from.
 | 
			
		||||
 *  \param fprIndex Index of the floating point register to read.
 | 
			
		||||
 *  \param fprValue The bit pattern to be written into the floating point register.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefFprSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t fprIndex,
 | 
			
		||||
    uint64_t fprValue);
 | 
			
		||||
 | 
			
		||||
/*! \brief Read a floating point register value from a hart in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to retrieve the FPR register from.
 | 
			
		||||
 *  \param fprIndex Index of the floating point register to read.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The FPR register value read from the specified hart.
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefFprGet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t fprIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Notify RVVI that the DUT has been written to memory.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that issued the data bus write.
 | 
			
		||||
 *  \param address The address the hart is writing to.
 | 
			
		||||
 *  \param value The value placed on the data bus.
 | 
			
		||||
 *  \param byteEnableMask The byte enable mask provided for this write.
 | 
			
		||||
 *
 | 
			
		||||
 *  \note Bus writes larger than 64bits should be reported using multiple calls to this function.
 | 
			
		||||
 *  \note byteEnableMask bit 0 corresponds to address+0, bEnMask bit 1 corresponds to address+1, etc.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviDutBusWrite(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint64_t address,
 | 
			
		||||
    uint64_t value,
 | 
			
		||||
    uint64_t byteEnableMask);
 | 
			
		||||
 | 
			
		||||
/*! \brief Write data to the reference models physical memory space.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to write from the perspective of.
 | 
			
		||||
 *  \param address The address being written to.
 | 
			
		||||
 *  \param data The data byte being written into memory.
 | 
			
		||||
 *  \param size Size of the data being written in bytes (1 to 8).
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefMemoryWrite(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint64_t address,
 | 
			
		||||
    uint64_t data,
 | 
			
		||||
    uint32_t size);
 | 
			
		||||
 | 
			
		||||
/*! \brief Read data from the reference models physical memory space.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart to read from the perspective of.
 | 
			
		||||
 *  \param address The address being read from.
 | 
			
		||||
 *  \param size Size of the data being read in bytes (1 to 8).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The data that has been read from reference memory.
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefMemoryRead(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint64_t address,
 | 
			
		||||
    uint32_t size);
 | 
			
		||||
 | 
			
		||||
/*! \brief Disassemble an arbitrary instruction encoding.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId Hart with the ISA we are disassembling for.
 | 
			
		||||
 *  \param address Address of the instruction in memory.
 | 
			
		||||
 *  \param insBin The raw instruction that should be disassembled.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Null terminated string containing the disassembly.
 | 
			
		||||
**/
 | 
			
		||||
extern const char *rvviDasmInsBin(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint64_t address,
 | 
			
		||||
    uint64_t insBin);
 | 
			
		||||
 | 
			
		||||
/*! \brief Return the name of a CSR in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId Hart with the CSR we are looking up the name of.
 | 
			
		||||
 *  \param csrIndex The index of the CSR we are looking up (0x0 to 0xfff inclusive).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Null terminated string containing the CSR name.
 | 
			
		||||
**/
 | 
			
		||||
extern const char *rvviRefCsrName(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Return the ABI name of a GPR in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId Hart with the GPR we are looking up the name of.
 | 
			
		||||
 *  \param gprIndex The index of the GPR we are looking up (0 to 31 inclusive).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Null terminated string containing the GPR ABI name.
 | 
			
		||||
**/
 | 
			
		||||
extern const char *rvviRefGprName(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t gprIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Check if a CSR is present in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId Hart with the CSR we are checking the presence of.
 | 
			
		||||
 *  \param csrIndex The index of the CSR we are checking for (0x0 to 0xfff inclusive).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_TRUE if the CSR is present in the reference model else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefCsrPresent(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Check if floating point registers are present in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId Hart Id we are checking for the presence of floating point registers.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_TRUE if the floating point registers are present in the reference model else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefFprsPresent(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Check if vector registers are present in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId Hart Id we are checking for the presence of vector registers.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_TRUE if the vector registers are present in the reference model else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefVrsPresent(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Return the name of a FPR in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId Hart with the FPR we are looking up the name of.
 | 
			
		||||
 *  \param fprIndex The index of the FPR we are looking up (0 to 31 inclusive).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Null terminated string containing the FPR name.
 | 
			
		||||
**/
 | 
			
		||||
extern const char *rvviRefFprName(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t fprIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Return the name of a vector register in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId Hart with the VR we are looking up the name of.
 | 
			
		||||
 *  \param vrIndex The index of the VR we are looking up (0 to 31 inclusive).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Null terminated string containing the VR name.
 | 
			
		||||
**/
 | 
			
		||||
extern const char *rvviRefVrName(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t vrIndex);
 | 
			
		||||
 | 
			
		||||
/*! \brief Return a string detailing the last RVVI-API error.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The error string or an empty string if no error has occurred.
 | 
			
		||||
**/
 | 
			
		||||
extern const char *rvviErrorGet(void);
 | 
			
		||||
 | 
			
		||||
/*! \brief Query a verification metric from the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param metric An enumeration identifying the metric to query and return.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The scalar quantity that has been queried.
 | 
			
		||||
**/
 | 
			
		||||
extern uint64_t rvviRefMetricGet(
 | 
			
		||||
    rvviMetricE metric);
 | 
			
		||||
 | 
			
		||||
/*! \brief Set the value of a CSR in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart which we are modifying the CSR of.
 | 
			
		||||
 *  \param csrIndex The index of the CSR we are modifying (0x0 to 0xfff inclusive).
 | 
			
		||||
 *  \param value The value to write into the CSR.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefCsrSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex,
 | 
			
		||||
    uint64_t value);
 | 
			
		||||
 | 
			
		||||
/*! \brief Dump the current register state of a hart in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart which we should dump the register state of.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefStateDump(
 | 
			
		||||
    uint32_t hartId);
 | 
			
		||||
 | 
			
		||||
/*! \brief Load an additional program into the address space of the processor.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param programPath File path of the ELF file to be loaded into memory.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return RVVI_TRUE if the program was loaded successfully otherwise RVVI_FALSE
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefProgramLoad(
 | 
			
		||||
    const char *programPath);
 | 
			
		||||
 | 
			
		||||
/*! \brief Apply fine grain control over a CSRs volatility in the reference model.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that will have its CSR volatility adjusted.
 | 
			
		||||
 *  \param csrIndex Index of the CSR register to have its volatility modified (0x0 to 0xfff).
 | 
			
		||||
 *  \param csrMask Bitmask specifying volatility, set bits will be treated as volatile, clear bits are not
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns RVVI_TRUE if operation was successful else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefCsrSetVolatileMask(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t csrIndex,
 | 
			
		||||
    uint64_t csrMask);
 | 
			
		||||
 | 
			
		||||
/*! \brief Pass the current testbench cycle count to the RVVI implementation.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param cycleCount The current cycle count of the DUT. This value is directly related to, and must be consistent with, the `when` parameter for rvviRefNetSet().
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviDutCycleCountSet(
 | 
			
		||||
    uint64_t cycleCount);
 | 
			
		||||
 | 
			
		||||
/*! \brief Pass a vendor specific integer configuration parameter to the RVVI implementation.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param configParam The configuration option that is to have its associated value set. This is vendor specific and not defined as part of the RVVI-API.
 | 
			
		||||
 *  \param value An integer containing the data that should be passed to the configuration option.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns RVVI_TRUE if operation was successful else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefConfigSetInt(
 | 
			
		||||
    uint64_t configParam,
 | 
			
		||||
    uint64_t value);
 | 
			
		||||
 | 
			
		||||
/*! \brief Pass a vendor specific string configuration parameter to the RVVI implementation.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param configParam The configuration option that is to have its associated value set. This is vendor specific and not defined as part of the RVVI-API.
 | 
			
		||||
 *  \param value A string containing the data that should be passed to the configuration option.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns RVVI_TRUE if operation was successful else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefConfigSetString(
 | 
			
		||||
    uint64_t configParam,
 | 
			
		||||
    const char *value);
 | 
			
		||||
 | 
			
		||||
/*! \brief Given the name of a CSR, its unique index/address will be returned.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId HartId of the hart containing the CSR we are looking up the index of.
 | 
			
		||||
 *  \param csrName The CSR name for which the CSR index should be retrieved.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns the CSR index if the operation was successful else RVVI_INVALID_INDEX.
 | 
			
		||||
**/
 | 
			
		||||
extern uint32_t rvviRefCsrIndex(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    const char *csrName);
 | 
			
		||||
 | 
			
		||||
/*! \brief Set the privilege mode for a region of the address space.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param addrLo Lower address defining the memory region.
 | 
			
		||||
 *  \param addrHi Upper address defining the memory region (inclusive).
 | 
			
		||||
 *  \param access Access flags for this memory region; a combination of RVVI_PRIV_... flags or 0.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Returns RVVI_TRUE if operation was successful else RVVI_FALSE.
 | 
			
		||||
**/
 | 
			
		||||
extern bool_t rvviRefMemorySetPrivilege(
 | 
			
		||||
    uint64_t addrLo,
 | 
			
		||||
    uint64_t addrHi,
 | 
			
		||||
    uint32_t access);
 | 
			
		||||
 | 
			
		||||
/*! \brief Update a byte in one of the reference models vector registers.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param hartId The hart that should have its vector register updated.
 | 
			
		||||
 *  \param vrIndex The vector register index (0 to 31).
 | 
			
		||||
 *  \param byteIndex The byte offset into the vector register (note 0 is LSB).
 | 
			
		||||
 *  \param data New byte value to be written into the vector register.
 | 
			
		||||
**/
 | 
			
		||||
extern void rvviRefVrSet(
 | 
			
		||||
    uint32_t hartId,
 | 
			
		||||
    uint32_t vrIndex,
 | 
			
		||||
    uint32_t byteIndex,
 | 
			
		||||
    uint8_t data);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}  // extern "C"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -41,11 +41,9 @@
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <net/if.h>
 | 
			
		||||
#include <netinet/ether.h>
 | 
			
		||||
#include <linux/udp.h>
 | 
			
		||||
#include "rvviApi.h" // *** bug fix me when this file gets included into the correct directory.
 | 
			
		||||
#include "idv/idv.h"
 | 
			
		||||
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
 | 
			
		||||
#define DEST_MAC0	0x43
 | 
			
		||||
#define DEST_MAC1	0x68
 | 
			
		||||
@ -69,8 +67,6 @@
 | 
			
		||||
#define DEFAULT_IF	"eno1"
 | 
			
		||||
 | 
			
		||||
FILE *VivadoPipeFP;
 | 
			
		||||
int sockfd;
 | 
			
		||||
struct ifreq ifopts, if_mac;	/* set promiscuous mode */
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  uint64_t PC;
 | 
			
		||||
@ -104,7 +100,6 @@ int ProcessRvviAll(RequiredRVVI_t *InstructionData);
 | 
			
		||||
void set_gpr(int hart, int reg, uint64_t value);
 | 
			
		||||
void set_fpr(int hart, int reg, uint64_t value);
 | 
			
		||||
int state_compare(int hart, uint64_t Minstret);
 | 
			
		||||
void SendILATrigger();
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv){
 | 
			
		||||
  
 | 
			
		||||
@ -114,57 +109,40 @@ int main(int argc, char **argv){
 | 
			
		||||
    return -1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* // step 1 open a pipe to vivado */
 | 
			
		||||
  /* if (( VivadoPipeFP = popen("vivado -mode tcl", "w")) == NULL){ */
 | 
			
		||||
  /*   perror("popen"); */
 | 
			
		||||
  /*   exit(1); */
 | 
			
		||||
  /* } */
 | 
			
		||||
  /* fputs("open_hw_manager\n", VivadoPipeFP); */
 | 
			
		||||
  /* fputs("connect_hw_server -url localhost:3121\n", VivadoPipeFP); */
 | 
			
		||||
  /* fputs("current_hw_target [get_hw_targets *\/xilinx_tcf/Digilent/\*]\n", VivadoPipeFP); */
 | 
			
		||||
  /* fputs("open_hw_target\n", VivadoPipeFP); */
 | 
			
		||||
  /* fputs("set_property PARAM.FREQUENCY 7500000 [get_hw_targets localhost:3121/xilinx_tcf/Digilent/210319B7CA87A]\n", VivadoPipeFP); */
 | 
			
		||||
  // step 1 open a pipe to vivado
 | 
			
		||||
  if (( VivadoPipeFP = popen("vivado -mode tcl", "w")) == NULL){
 | 
			
		||||
    perror("popen");
 | 
			
		||||
    exit(1);
 | 
			
		||||
  }
 | 
			
		||||
  fputs("open_hw_manager\n", VivadoPipeFP);
 | 
			
		||||
  fputs("connect_hw_server -url localhost:3121\n", VivadoPipeFP);
 | 
			
		||||
  fputs("current_hw_target [get_hw_targets */xilinx_tcf/Digilent/*]\n", VivadoPipeFP);
 | 
			
		||||
  fputs("open_hw_target\n", VivadoPipeFP);
 | 
			
		||||
  fputs("set_property PARAM.FREQUENCY 7500000 [get_hw_targets localhost:3121/xilinx_tcf/Digilent/210319B7CA87A]\n", VivadoPipeFP);
 | 
			
		||||
 | 
			
		||||
  /* // *** bug these need to made relative paths. */
 | 
			
		||||
  /* fputs("set_property PROBES.FILE {/home/ross/repos/cvw/fpga/generator/WallyFPGA.runs/impl_1/fpgaTop.ltx} [get_hw_devices xc7a100t_0]\n", VivadoPipeFP); */
 | 
			
		||||
  /* fputs("set_property FULL_PROBES.FILE {/home/ross/repos/cvw/fpga/generator/WallyFPGA.runs/impl_1/fpgaTop.ltx} [get_hw_devices xc7a100t_0]\n", VivadoPipeFP); */
 | 
			
		||||
  /* fputs("set_property PROGRAM.FILE {/home/ross/repos/cvw/fpga/generator/WallyFPGA.runs/impl_1/fpgaTop.bit} [get_hw_devices xc7a100t_0]\n", VivadoPipeFP); */
 | 
			
		||||
  /* fputs("refresh_hw_device [lindex [get_hw_devices xc7a100t_0] 0]\n", VivadoPipeFP); */
 | 
			
		||||
  /* fputs("[get_hw_devices xc7a100t_0] -filter {CELL_NAME=~\"u_ila_0\"}]]\n", VivadoPipeFP); */
 | 
			
		||||
  /* fflush(VivadoPipeFP); */
 | 
			
		||||
  // *** bug these need to made relative paths.
 | 
			
		||||
  fputs("set_property PROBES.FILE {/home/ross/repos/cvw/fpga/generator/WallyFPGA.runs/impl_1/fpgaTop.ltx} [get_hw_devices xc7a100t_0]\n", VivadoPipeFP);
 | 
			
		||||
  fputs("set_property FULL_PROBES.FILE {/home/ross/repos/cvw/fpga/generator/WallyFPGA.runs/impl_1/fpgaTop.ltx} [get_hw_devices xc7a100t_0]\n", VivadoPipeFP);
 | 
			
		||||
  fputs("set_property PROGRAM.FILE {/home/ross/repos/cvw/fpga/generator/WallyFPGA.runs/impl_1/fpgaTop.bit} [get_hw_devices xc7a100t_0]\n", VivadoPipeFP);
 | 
			
		||||
  fputs("refresh_hw_device [lindex [get_hw_devices xc7a100t_0] 0]\n", VivadoPipeFP);
 | 
			
		||||
  fputs("[get_hw_devices xc7a100t_0] -filter {CELL_NAME=~\"u_ila_0\"}]]\n", VivadoPipeFP);
 | 
			
		||||
  
 | 
			
		||||
  int sockfd;
 | 
			
		||||
  uint8_t buf[BUF_SIZ];
 | 
			
		||||
  int sockopt;
 | 
			
		||||
  struct ifreq ifopts;	/* set promiscuous mode */
 | 
			
		||||
  struct ether_header *eh = (struct ether_header *) buf;
 | 
			
		||||
  ssize_t headerbytes, numbytes, payloadbytes;
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
  /* Open RAW socket to receive frames */
 | 
			
		||||
  if ((sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETHER_TYPE))) == -1) {
 | 
			
		||||
    // *** remove. This is not the problem
 | 
			
		||||
  //if ((sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) == -1) {
 | 
			
		||||
    perror("socket");
 | 
			
		||||
  }
 | 
			
		||||
  printf("sockfd %x\n", sockfd);
 | 
			
		||||
  printf("Here 0\n");
 | 
			
		||||
 | 
			
		||||
  /* Set interface to promiscuous mode - do we need to do this every time? */
 | 
			
		||||
  memset(&ifopts, 0, sizeof(struct ifreq));
 | 
			
		||||
  strncpy(ifopts.ifr_name, argv[1], IFNAMSIZ-1);
 | 
			
		||||
  ioctl(sockfd, SIOCGIFFLAGS, &ifopts);
 | 
			
		||||
 | 
			
		||||
  /* Get the index of the interface to send on */
 | 
			
		||||
  //memset(&if_idx, 0, sizeof(struct ifreq));
 | 
			
		||||
  //strncpy(if_idx.ifr_name, argv[1], IFNAMSIZ-1);
 | 
			
		||||
  if (ioctl(sockfd, SIOCGIFINDEX, &ifopts) < 0)
 | 
			
		||||
    perror("SIOCGIFINDEX");
 | 
			
		||||
 | 
			
		||||
  /* Get the MAC address of the interface to send on */
 | 
			
		||||
  memset(&if_mac, 0, sizeof(struct ifreq));
 | 
			
		||||
  strncpy(if_mac.ifr_name, argv[1], IFNAMSIZ-1);
 | 
			
		||||
  if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0)
 | 
			
		||||
    perror("SIOCGIFHWADDR");
 | 
			
		||||
 | 
			
		||||
  printf("Here 1\n");
 | 
			
		||||
  ifopts.ifr_flags |= IFF_PROMISC;
 | 
			
		||||
  ioctl(sockfd, SIOCSIFFLAGS, &ifopts);
 | 
			
		||||
@ -185,8 +163,6 @@ int main(int argc, char **argv){
 | 
			
		||||
    exit(EXIT_FAILURE);
 | 
			
		||||
  }
 | 
			
		||||
  printf("Here 4\n");
 | 
			
		||||
  SendILATrigger();
 | 
			
		||||
  exit(0);
 | 
			
		||||
 | 
			
		||||
  if(!rvviVersionCheck(RVVI_API_VERSION)){
 | 
			
		||||
    printf("Bad RVVI_API_VERSION\n");
 | 
			
		||||
@ -265,8 +241,7 @@ int main(int argc, char **argv){
 | 
			
		||||
 | 
			
		||||
  printf("Simulation halted due to mismatch\n");
 | 
			
		||||
 | 
			
		||||
  //pclose(VivadoPipeFP);
 | 
			
		||||
  printf("closed pipe to vivado\n");
 | 
			
		||||
  pclose(VivadoPipeFP);
 | 
			
		||||
  close(sockfd);
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
@ -316,82 +291,18 @@ int state_compare(int hart, uint64_t Minstret){
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (result == 0) {
 | 
			
		||||
    SendILATrigger();
 | 
			
		||||
    sprintf(buf, "MISMATCH @ instruction # %ld\n", Minstret);
 | 
			
		||||
    idvMsgError(buf);
 | 
			
		||||
    /* fputs("run_hw_ila [get_hw_ilas -of_objects [get_hw_devices xc7a100t_0] -filter {CELL_NAME=~\"u_ila_0\"}] -trigger_now\n", VivadoPipeFP); */
 | 
			
		||||
    /* fputs("current_hw_ila_data [upload_hw_ila_data hw_ila_1]\n", VivadoPipeFP); */
 | 
			
		||||
    /* fputs("display_hw_ila_data [current_hw_ila_data]\n", VivadoPipeFP); */
 | 
			
		||||
    /* fputs("write_hw_ila_data -force my_hw_ila_data [current_hw_ila_data]\n", VivadoPipeFP); */
 | 
			
		||||
    /* fflush(VivadoPipeFP); */
 | 
			
		||||
    fputs("run_hw_ila [get_hw_ilas -of_objects [get_hw_devices xc7a100t_0] -filter {CELL_NAME=~\"u_ila_0\"}] -trigger_now\n", VivadoPipeFP);
 | 
			
		||||
    fputs("current_hw_ila_data [upload_hw_ila_data hw_ila_1]\n", VivadoPipeFP);
 | 
			
		||||
    fputs("display_hw_ila_data [current_hw_ila_data]\n", VivadoPipeFP);
 | 
			
		||||
    fputs("write_hw_ila_data my_hw_ila_data [current_hw_ila_data]\n", VivadoPipeFP);
 | 
			
		||||
    return -1;
 | 
			
		||||
    //if (ON_MISMATCH_DUMP_STATE) dump_state(hart);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SendILATrigger(){
 | 
			
		||||
  uint8_t buf[BUF_SIZ];
 | 
			
		||||
  struct ether_header *eh = (struct ether_header *) buf;
 | 
			
		||||
  int crc32;
 | 
			
		||||
  struct sockaddr_ll socket_address;
 | 
			
		||||
  
 | 
			
		||||
  eh->ether_dhost[0] = DEST_MAC0;
 | 
			
		||||
  eh->ether_dhost[1] = DEST_MAC1;
 | 
			
		||||
  eh->ether_dhost[2] = DEST_MAC2;
 | 
			
		||||
  eh->ether_dhost[3] = DEST_MAC3;
 | 
			
		||||
  eh->ether_dhost[4] = DEST_MAC4;
 | 
			
		||||
  eh->ether_dhost[5] = DEST_MAC5;
 | 
			
		||||
  //c8:4b:d6:5f:89:25 is the real source mac for this laptop. I don't think it needs to be correct.
 | 
			
		||||
  /* eh->ether_shost[0] = SRC_MAC0; */
 | 
			
		||||
  /* eh->ether_shost[1] = SRC_MAC1; */
 | 
			
		||||
  /* eh->ether_shost[2] = SRC_MAC2; */
 | 
			
		||||
  /* eh->ether_shost[3] = SRC_MAC3; */
 | 
			
		||||
  /* eh->ether_shost[4] = SRC_MAC4; */
 | 
			
		||||
  /* eh->ether_shost[5] = SRC_MAC5; */
 | 
			
		||||
  eh->ether_shost[0] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[0];
 | 
			
		||||
  eh->ether_shost[1] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[1];
 | 
			
		||||
  eh->ether_shost[2] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[2];
 | 
			
		||||
  eh->ether_shost[3] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[3];
 | 
			
		||||
  eh->ether_shost[4] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[4];
 | 
			
		||||
  eh->ether_shost[5] = ((uint8_t *)&if_mac.ifr_hwaddr.sa_data)[5];
 | 
			
		||||
  eh->ether_type = htons(ETH_P_IP);
 | 
			
		||||
  //buf[12] = (ETHER_TYPE) >> 8;
 | 
			
		||||
  //buf[13] = (ETHER_TYPE) && 0xFF; // *** does not work for some reason
 | 
			
		||||
  buf[13] = 0;
 | 
			
		||||
  buf[14] = 't';
 | 
			
		||||
  buf[15] = 'r';
 | 
			
		||||
  buf[16] = 'i';
 | 
			
		||||
  buf[17] = 'g';
 | 
			
		||||
  buf[18] = 'i';
 | 
			
		||||
  buf[19] = 'n';
 | 
			
		||||
  memset(&buf[20], 0, 40); // fill 36 bytes of 0
 | 
			
		||||
  int i;
 | 
			
		||||
  printf("buffer: ");
 | 
			
		||||
  for(i = 0; i < 60; i++){
 | 
			
		||||
    printf("%02x ", buf[i]);
 | 
			
		||||
  }
 | 
			
		||||
  printf("\n");
 | 
			
		||||
  //if (sendto(sockfd, buf, 60, 0, NULL, 0)) {
 | 
			
		||||
  printf("sockfd %x\n", sockfd);
 | 
			
		||||
  /* Index of the network device */
 | 
			
		||||
  socket_address.sll_ifindex = ifopts.ifr_ifindex;
 | 
			
		||||
  /* Address length*/
 | 
			
		||||
  socket_address.sll_halen = ETH_ALEN;
 | 
			
		||||
  /* Destination MAC */
 | 
			
		||||
  socket_address.sll_addr[0] = DEST_MAC0;
 | 
			
		||||
  socket_address.sll_addr[1] = DEST_MAC1;
 | 
			
		||||
  socket_address.sll_addr[2] = DEST_MAC2;
 | 
			
		||||
  socket_address.sll_addr[3] = DEST_MAC3;
 | 
			
		||||
  socket_address.sll_addr[4] = DEST_MAC4;
 | 
			
		||||
  socket_address.sll_addr[5] = DEST_MAC5;
 | 
			
		||||
  if (sendto(sockfd, buf, 60, MSG_DONTROUTE, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll)) < 0) {
 | 
			
		||||
    perror("ugh why???????????????????? sendto()");
 | 
			
		||||
    exit(3);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void set_gpr(int hart, int reg, uint64_t value){
 | 
			
		||||
  rvviDutGprSet(hart, reg, value);
 | 
			
		||||
}
 | 
			
		||||
@ -554,4 +465,3 @@ void BitShiftArray(uint8_t *dst, uint8_t *src, uint8_t ShiftAmount, int Length){
 | 
			
		||||
  byte1 = byte1 >> ShiftAmount;
 | 
			
		||||
  dst[Length-1] = byte1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user