Type error resolving infix expression when compiling simple decoder - select

This is the code in vhdl:
library IEEE;
use IEEE.std_logic_1164.all;
entity DECODER_TWO is
port
(
SW : in std_logic_vector(2 downto 1);
LD : out std_logic_vector(4 downto 1)
);
end DECODER_TWO;
architecture MY_FIRST_DECODER of DECODER_TWO is
begin
with SW select
LD <= "1110" when "00",
LD <= "1101" when "01",
LD <= "1011" when "10",
LD <= "0111" when "11",
LD <= "1111" when others;
end MY_FIRST_DECODER;
When I try to compile this very simple 2 to 4-bit decoder I get the error message, no matter what I do
# ** Error: C:/skole/in3160/oblig2/DecoderArchitect.vhd(15): Type error resolving infix expression "<=" as type ieee.std_logic_1164.STD_LOGIC_VECTOR.
# ** Error: C:/skole/in3160/oblig2/DecoderArchitect.vhd(16): Type error resolving infix expression "<=" as type ieee.std_logic_1164.STD_LOGIC_VECTOR.
# ** Error: C:/skole/in3160/oblig2/DecoderArchitect.vhd(17): Type error resolving infix expression "<=" as type ieee.std_logic_1164.STD_LOGIC_VECTOR.
# ** Error: C:/skole/in3160/oblig2/DecoderArchitect.vhd(18): Type error resolving infix expression "<=" as type ieee.std_logic_1164.STD_LOGIC_VECTOR.
# ** Error: C:/skole/in3160/oblig2/DecoderArchitect.vhd(19): VHDL Compiler exiting
I can't see or understand what the problem is, since I don't get an error for '<=' in the first line, only line 2, 3, 4, and 5.

Related

SystemVerilog compile error when declaring interface for a module (undeclared identifier [12.5(IEEE)])

I am learning how to use interfaces to wrap around a DUT (top-level module entity) in SystemVerilog. So, for this purpose, I came up with a basic example where the DUT is a simple synchronous RAM.
However, while I try to compile my code, I receive an error for every signal declared in the interface and used in the module ("undeclared identifier [12.5(IEEE)]"). I hope to get the precious help from this community to understand my error. I kept the code short and hopefully readable. Thank you in advance!
I tried removing the parameters and transform them into fixed numbers as well as using the define directive to make them global but did not help. The error, in fact, shows up also with signals that are not parametrized (such as oe signal).
// ********** Define the INTERFACE TO MODULE RAM: **********
interface clocked_bus
#(
// ---------- Parameters definition: ----------
parameter MEM_WIDTH=16, // word size of the memory
parameter ADDR_WIDTH=8 // => [2^ADDR_WIDTH locations]
)
(
// ---------- I/Os declaration: ----------
input clk
);
// ---------- Ports declaration: ----------
logic wr_rd_n_en, oe;
logic [MEM_WIDTH-1:0] data_out;
logic [2**ADDR_WIDTH-1:0] addr;
logic [MEM_WIDTH-1:0] data_in;
endinterface
// ********** Define the MODULE RAM: **********
module RAM(input clk, clocked_bus cb);
// ---------- CREATION OF MEM MATRIX: ----------
logic [MEM_WIDTH-1:0] mem [2**ADDR_WIDTH-1:0];
// ---------- BEHAVIORAL ARCHITECTURE DEFINITION: ----------
always_ff#(posedge clk)
begin
if (wr_rd_n_en == 0)
if (oe ==1)
data_out <= mem[addr];
else
mem[addr] <= data_in;
end
endmodule
// ********** Define the MODULE RAM: **********
module top;
// Define the clock as 'free running process':
logic clk = 0;
always #10 clk = !clk;
// Instantiate the Interface:
clocked_bus #(.MEM_WIDTH(16), .ADDR_WIDTH(8)) cb(clk);
// Instantiate the DUT:
RAM mem1(clk, cb);
endmodule
I expect to compile however I get the following error:
interface worklib.clocked_bus:sv
errors: 0, warnings: 0
logic [MEM_WIDTH-1:0] mem [2**ADDR_WIDTH-1:0];
|
xmvlog: *E,UNDIDN (lab.sv,31|43): 'ADDR_WIDTH': undeclared identifier [12.5(IEEE)].
logic [MEM_WIDTH-1:0] mem [2**ADDR_WIDTH-1:0];
|
xmvlog: *E,UNDIDN (lab.sv,31|19): 'MEM_WIDTH': undeclared identifier [12.5(IEEE)].
if (wr_rd_n_en == 0)
|
xmvlog: *E,UNDIDN (lab.sv,36|21): 'wr_rd_n_en': undeclared identifier [12.5(IEEE)].
if (oe ==1)
|
xmvlog: *E,UNDIDN (lab.sv,37|17): 'oe': undeclared identifier [12.5(IEEE)].
data_out <= mem[addr];
|
xmvlog: *E,UNDIDN (lab.sv,38|23): 'data_out': undeclared identifier [12.5(IEEE)].
data_out <= mem[addr];
|
xmvlog: *E,UNDIDN (lab.sv,38|35): 'addr': undeclared identifier [12.5(IEEE)].
mem[addr] <= data_in;
|
xmvlog: *E,UNDIDN (lab.sv,40|19): 'addr': undeclared identifier [12.5(IEEE)].
mem[addr] <= data_in;
|
xmvlog: *E,UNDIDN (lab.sv,40|31): 'data_in': undeclared identifier [12.5(IEEE)].
module worklib.RAM:sv
errors: 8, warnings: 0
module worklib.top:sv
errors: 0, warnings: 0
When you access variables and parameters inside an interface, you should use the interface name to denote them. An interface provides a namespace capability by encapsulating those. Your code for RAM should look like the following:
module RAM(input clk, clocked_bus cb);
// ---------- CREATION OF MEM MATRIX: ----------
logic [cb.MEM_WIDTH-1:0] mem [2**cb.ADDR_WIDTH-1:0];
// ---------- BEHAVIORAL ARCHITECTURE DEFINITION: ----------
always_ff#(posedge clk)
begin
if (cb.wr_rd_n_en == 0)
if (cb.oe ==1)
cb.data_out <= mem[cb.addr];
else
mem[cb.addr] <= cb.data_in;
end
endmodule

Illegal Character Escape in Text.Smolder.Renderer.String.purs

In an attempt to compile my program, I received the following error regarding the file String.purs from the Text.Smolder.Renderer module:
Error found:
at bower_components\purescript-smolder\src\Text\Smolder\Renderer\String.purs:76:
56 - 76:57 (line 76, column 56 - line 76, column 57)
Unable to parse module:
Illegal character escape code
I looked at the source file and found the following at line 76:
toStream s = foldr (\c t -> c :< (Just t)) (mkCofree '\0' Nothing) cs
How can this be corrected? (And how on earth could a compiler error be in a public library!!!)

case statement in property not working for QuestaSim 10.4B

I am trying to write a property with a case statement, straight out of the SystemVerilog 2012 LRM.
property p_rate_select (logic [1:0] rate);
case (rate)
2'd0 : $rose(i_ffs_rdcount == 1) |=> $fell(o_telem_fifo_ready_n);
2'd1 : $rose(i_ffs_rdcount == 2) |=> $fell(o_telem_fifo_ready_n);
2'd2 : $rose(i_ffs_rdcount == 3) |=> $fell(o_telem_fifo_ready_n);
2'd3 : $rose(i_ffs_rdcount == 4) |=> $fell(o_telem_fifo_ready_n);
default : 0;
endcase
endproperty
Using QuestaSim 10.4B, I get the following error:
** Error: (vlog-13069) checker.sv(196):
near "case": syntax error, unexpected case, expecting disable.
Is case statements not supported with this version of Questasim?
You need Questa 10.4e or newer.

Using sections with OpenMP and MEX

I am trying to calculate 3x3 matrix inverse and multiply it by other 3x3 matrix.
The code for these calculations is working as a mex function.
My problem start when I am trying to use OpenMP library.
I have tried to make two parts of matrix inverse parallel, and I get many compile errors.
When commenting the pragmas the code compilation is clean.
Your help will be much appreciated.
/*==========================================================
* inv_and_mul_3by3.c
* inverse 3x3 matrix and multiply it by another 3x3 matrix
* The calling syntax is: outMatrix = (mat_to_inv,mat_to_mul)
*========================================================*/
#include "mex.h"
#include <omp.h>
/* The computational routine */
void inv_and_mul_3by3_omp(double *mat_to_mul, double *mat_to_inv, double *out)
{
// Description : out = inv(mat_to_inv)*mat_to_mul
double det;
double det_2by2;
double det_2by2B;
double inversed[9];
// Calculating 2x2 determinant that is being calculated for the 3x3 determinant
// and also for matrix inversion
det_2by2 = mat_to_inv[4]*mat_to_inv[8] - mat_to_inv[7]*mat_to_inv[5];
det_2by2B = mat_to_inv[1]*mat_to_inv[5] - mat_to_inv[4]*mat_to_inv[2];
/* Calculate the matrix deteminant */
det = mat_to_inv[0]*(det_2by2) - mat_to_inv[3]*(mat_to_inv[1]*mat_to_inv[8]-mat_to_inv[7]*mat_to_inv[2])+mat_to_inv[6]*(det_2by2B);
#pragma omp parallel sections
{
#pragma omp section {
// Calcualte the inversed matrix
inversed[0] = (det_2by2)/det;
inversed[3] = (mat_to_inv[6]*mat_to_inv[5] - mat_to_inv[3]*mat_to_inv[8])/det;
inversed[6] = (mat_to_inv[3]*mat_to_inv[7] - mat_to_inv[6]*mat_to_inv[4])/det;
inversed[1] = (mat_to_inv[7]*mat_to_inv[2] - mat_to_inv[1]*mat_to_inv[8])/det;
}
#pragma omp section {
inversed[4] = (mat_to_inv[0]*mat_to_inv[8] - mat_to_inv[6]*mat_to_inv[2])/det;
inversed[7] = (mat_to_inv[6]*mat_to_inv[1] - mat_to_inv[0]*mat_to_inv[7])/det;
inversed[2] = (det_2by2B)/det;
inversed[5] = (mat_to_inv[3]*mat_to_inv[2] - mat_to_inv[0]*mat_to_inv[5])/det;
inversed[8] = (mat_to_inv[0]*mat_to_inv[4] - mat_to_inv[3]*mat_to_inv[1])/det;
}
} /*-- End of sections block --*/
// multiply the matrix by the the matrix that was inversed
out[0] = mat_to_mul[0]*inversed[0] + mat_to_mul[3]*inversed[1] + mat_to_mul[6]*inversed[2];
out[1] = mat_to_mul[1]*inversed[0] + mat_to_mul[4]*inversed[1] + mat_to_mul[7]*inversed[2];
out[2] = mat_to_mul[2]*inversed[0] + mat_to_mul[5]*inversed[1] + mat_to_mul[8]*inversed[2];
out[3] = mat_to_mul[0]*inversed[3] + mat_to_mul[3]*inversed[4] + mat_to_mul[6]*inversed[5];
out[4] = mat_to_mul[1]*inversed[3] + mat_to_mul[4]*inversed[4] + mat_to_mul[7]*inversed[5];
out[5] = mat_to_mul[2]*inversed[3] + mat_to_mul[5]*inversed[4] + mat_to_mul[8]*inversed[5];
out[6] = mat_to_mul[0]*inversed[6] + mat_to_mul[3]*inversed[7] + mat_to_mul[6]*inversed[8];
out[7] = mat_to_mul[1]*inversed[6] + mat_to_mul[4]*inversed[7] + mat_to_mul[7]*inversed[8];
out[8] = mat_to_mul[2]*inversed[6] + mat_to_mul[5]*inversed[7] + mat_to_mul[8]*inversed[8];
} //end function
/* The gateway function */
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
double *inMatToInv; /* 3x3 input matrix that is inversed */
double *inMatToMul; /* 3x3 input matrix that multiply the inversed matrix*/
double *outMatrix; /* 3x3 output matrix */
/* create pointers to the real data in the input matrix */
inMatToInv = mxGetPr(prhs[0]);
inMatToMul = mxGetPr(prhs[1]);
/* create the output matrix */
plhs[0] = mxCreateDoubleMatrix(3,3,mxREAL);
/* get a pointer to the real data in the output matrix */
outMatrix = mxGetPr(plhs[0]);
/* call the computational routine */
inv_and_mul_3by3_omp(inMatToInv,inMatToMul,outMatrix);
}
This is the compile command I used in Matlab
mex inv_and_mul_3by3_omp.c COMPFLAGS="/openmp $COMPFLAGS"
Here are the compile errors:
Error using mex
inv_and_mul_3by3_omp.c
(32) : error C3005: '{' : unexpected token encountered on OpenMP
'section' directive
(35) : error C3047: Structured block in an OpenMP 'sections'
region must be preceded by '#pragma omp section'
(36) : error C3047: Structured block in an OpenMP 'sections'
region must be preceded by '#pragma omp section'
(37) : error C3047: Structured block in an OpenMP 'sections'
region must be preceded by '#pragma omp section'
(40) : error C3005: '{' : unexpected token encountered on OpenMP
'section' directive
(40) : error C3044: 'section' : only allowed directly nested
under an OpenMP 'sections' directive
(47) : error C2059: syntax error : '}'
(53) : error C2065: 'mat_to_mul' : undeclared identifier
(53) : error C2109: subscript requires array or pointer type
(53) : error C2065: 'inversed' : undeclared identifier
(54) : error C2369: 'out' : redefinition; different subscripts
(53) : see declaration of 'out'
(54) : error C2065: 'mat_to_mul' : undeclared identifier
(54) : error C2109: subscript requires array or pointer type
(54) : error C2065: 'inversed' : undeclared identifier
(55) : error C2369: 'out' : redefinition; different subscripts
(53) : see declaration of 'out'
(55) : error C2065: 'mat_to_mul' : undeclared identifier
(55) : error C2109: subscript requires array or pointer type
(55) : error C2065: 'inversed' : undeclared identifier
(56) : error C2369: 'out' : redefinition; different subscripts
(53) : see declaration of 'out'
(56) : error C2065: 'mat_to_mul' : undeclared identifier
(56) : error C2109: subscript requires array or pointer type
(56) : error C2065: 'inversed' : undeclared identifier
(57) : error C2369: 'out' : redefinition; different subscripts
(53) : see declaration of 'out'
(57) : error C2065: 'mat_to_mul' : undeclared identifier
(57) : error C2109: subscript requires array or pointer type
(57) : error C2065: 'inversed' : undeclared identifier
(58) : error C2369: 'out' : redefinition; different subscripts
(53) : see declaration of 'out'
(58) : error C2065: 'mat_to_mul' : undeclared identifier
(58) : error C2109: subscript requires array or pointer type
(58) : error C2065: 'inversed' : undeclared identifier
(59) : error C2369: 'out' : redefinition; different subscripts
(53) : see declaration of 'out'
(59) : error C2065: 'mat_to_mul' : undeclared identifier
(59) : error C2109: subscript requires array or pointer type
(59) : error C2065: 'inversed' : undeclared identifier
(60) : error C2369: 'out' : redefinition; different subscripts
(53) : see declaration of 'out'
(60) : error C2065: 'mat_to_mul' : undeclared identifier
(60) : error C2109: subscript requires array or pointer type
(60) : error C2065: 'inversed' : undeclared identifier
(62) : error C2059: syntax error : '}'
Try to replace this
#pragma omp section {
By this
#pragma omp section
{
First thing I'd do is strip out the nested parallelism. It's not nearly as useful as many beginners think it ought to be, it's not necessarily available without setting up the compiler and/or environment variables, and it is rushing ahead when you ought to be taking baby steps.
Replace this
#pragma omp parallel
{
#pragma omp parallel sections num_threads(2)
with
#pragma omp parallel sections
and adjust the rest of the code accordingly. To add to what I wrote above, it is usually a bad idea to try to specify the number of threads to use, leave that to the runtime system to figure out.
I don't pretend that this is a complete answer, but a step to simplify the code that may help illuminate where the error(s) are.

Error at MATLAB: cvlib_mex.obj : error LNK2019: unresolved external symbol (while trying to using cvlib_mex.c in MATLAB)

I am really in a very bad situation with my project. It is working with my 32bit-desktop and with the same versions of MATLAB (R2012a) and Visual Studio 2010 Express but it is not working on 64-bit laptop. Last error is below: while I am trying to execute this one:
function make_cvlib()
% make_cvlib -- Make the cvlib_mex in windows. It probably will
% work as well in Linux/Mac with only minor changes
%
% Author: Joaquim Luis
% Date: 07-Sept-2006
% Adjust for your own path
INCLUDE_CV = '''C:\Program Files\OpenCV\cv\include''';
INCLUDE_CXCORE = '''C:\Program Files\OpenCV\cxcore\include''';
LIB_CV = '''C:\Program Files\OpenCV\lib\cv.lib''';
LIB_CXCORE = '''C:\Program Files\OpenCV\lib\cxcore.lib''';
% -------------------------- Stop editing ---------------------------
include_cv = ['-I' INCLUDE_CV ' -I' INCLUDE_CXCORE];
library_cv = [LIB_CV ' ' LIB_CXCORE];
if (ispc)
opt_cv = '-O -DWIN64 -DDLL_CV100 -DDLL_CXCORE100';
else
opt_cv = '-O';
end
cmd = ['mex cvlib_mex.c' ' ' include_cv ' ' library_cv ' ' opt_cv];
eval(cmd)
Here is the error:
>> make_cvlib
Creating library C:\Users\hp\AppData\Local\Temp\mex_cj81oV\templib.x and object C:\Users\hp\AppData\Local\Temp\mex_cj81oV\templib.exp
cvlib_mex.obj : error LNK2019: unresolved external symbol cvAddS referenced in function cvSubS
cvlib_mex.obj : error LNK2019: unresolved external symbol cvEllipse referenced in function cvEllipseBox
cvlib_mex.obj : error LNK2019: unresolved external symbol cvSetData referenced in function localSetData
cvlib_mex.obj : error LNK2019: unresolved external symbol cvGetSeqElem referenced in function JapproxPoly
cvlib_mex.obj : error LNK2019: unresolved external symbol cvReleaseMemStorage referenced in function JapproxPoly
...(65 more)
cvlib_mex.mexw64 : fatal error LNK1120: 69 unresolved externals
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Link of 'cvlib_mex.mexw64' failed.
Error using mex (line 206)
Unable to complete successfully.
Error in make_cvlib (line 26)
eval(cmd)
Please show some points that I missed...