我正在使用Lattice Diamond,并且我有一个verilog文件,其中包含一堆`define语句来定义全局常量。
我将此“头”文件包含到另一个文件中。它找到文件,但是有错误:
“ 2049990错误-C:/ _ libraries / LatticeDiamond / verilog-uart / source / uart / uart_loopback_tb.v(184,38-184,53)(VERI-1128)UART_1_STOP_BIT未声明 “
我也将头文件的目录设置为实现的项目设置中的包含路径。
/********************************************************************************************
* @file UART_Header.v
* @brief
* Defines UART module parameter constants
*
* @details
* This file is to support the UART_core.v
*
*
* @namespace UART_
********************************************************************************************/
`ifndef UART_HEADER_FILE
`define UART_HEADER_FILE
// UART core register addresses
`define UART_WRITE_ADDR = 8'h00; ///< UART TX address
`define UART_READ_ADDR = 8'h00; ///< UART address to read received data
`define UART_LCR_ADDR = 8'h03; ///< Line control register
`define UART_LSR_ADDR = 8'h05; ///< Line status register
`define UART_DIV_LW_ADDR = 8'b00000111; ///< Baud Rate divisor register low word
`define UART_DIV_HW_ADDR = 8'b00000110; ///< Baud Rate divisor register high word
// UART core bit masks
`define UART_5_DATA_BITS = 16'b00000000; ///< 5 data bits mask
`define UART_6_DATA_BITS = 16'b00000001; ///< 6 data bits mask
`define UART_7_DATA_BITS = 16'b00000010; ///< 7 data bits mask
`define UART_8_DATA_BITS = 16'b00000011; ///< 8 data bits mask
`define UART_1_STOP_BIT = 16'b00000000; ///< 1 stop bit mask
`define UART_1_5_STOP_BIT = 16'b00000100; ///< 1.5 stop bits mask
`define UART_2_STOP_BIT = 16'b00001000; ///< 2 stop bits mask
`define UART_PARITY_ENABLE = 16'b00010000; ///< Enable parity bit mask
`define UART_PARITY_DISABLE = 16'b00000000; ///< Disable parity bit mask
`endif
//EOF
然后我有一个包含该文件的文件。
`ifndef UART_LOOPBACK_TB_FILE
`define UART_LOOPBACK_TB_FILE
//*******************************************************************************************
// Includes
//*******************************************************************************************
`include "source/uart/UART_header.v"
// Rest of the code for this file
.....................
UL_TB_WriteReg((UART_8_DATA_BITS | UART_1_STOP_BIT | UART_PARITY_DISABLE), UART_LCR_ADDR);
...................
`endif
为什么找不到我的`定义?包含头文件的文件甚至与头文件本身在同一目录中。莱迪思钻石公司支持吗?
我还尝试了`include“ UART_header.v”,因为它位于同一目录中,但这会产生相同的错误。
答案 0 :(得分:1)
您肯定是这个意思
UL_TB_WriteReg((`UART_8_DATA_BITS | `UART_1_STOP_BIT | `UART_PARITY_DISABLE), `UART_LCR_ADDR);
// ^ ^ ^ ^
在Verilog中定义的内容之前必须加反引号。