VHDL : how to use rem and mod command in VHDL ? (syntax problem)
hello I want to take the binary number of 23. and in binary form it is : 010111
so if for example 23 mod 10 i will get 3 . how to do this comand in VHDL ? this is what I wrote so far :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY rem_command IS
GENERIC (display_resolution : INTEGER :=23; -- counter to get to the loest ferquncy
display_counter: INTEGER :=8); -- counter to get to 97KHz ferquincy
PORT (
CLK_IN :IN STD_LOGIC;
PWM_LIMIT :IN STD_LOGIC_VECTOR(display_counter downto 0);
COUNTER_VECTOR :IN STD_LOGIC_VECTOR(display_counter downto 0);
number_out: OUT STD_LOGIC
);
END rem_command;
ARCHITECTURE testing_reminder_command OF rem_command I
signal number : std_logic_vector(5 downto 0):="010111"; -- this is 23 in binary form
BEGIN
process(COUNTER_VECTOR,PWM_LIMIT,CLK_IN,number)
BEGIN
number <= 10 MOD number;
end process;
number_out<=number;
END testing_reminder_command ;
the error that I get is :
Error (10327): VHDL error at rem_command.vhd(48): can't determine
definition of operator ""mod"" -- found 0 possible definitions
maybe I need to add library ?
syntax vhdl
add a comment |
hello I want to take the binary number of 23. and in binary form it is : 010111
so if for example 23 mod 10 i will get 3 . how to do this comand in VHDL ? this is what I wrote so far :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY rem_command IS
GENERIC (display_resolution : INTEGER :=23; -- counter to get to the loest ferquncy
display_counter: INTEGER :=8); -- counter to get to 97KHz ferquincy
PORT (
CLK_IN :IN STD_LOGIC;
PWM_LIMIT :IN STD_LOGIC_VECTOR(display_counter downto 0);
COUNTER_VECTOR :IN STD_LOGIC_VECTOR(display_counter downto 0);
number_out: OUT STD_LOGIC
);
END rem_command;
ARCHITECTURE testing_reminder_command OF rem_command I
signal number : std_logic_vector(5 downto 0):="010111"; -- this is 23 in binary form
BEGIN
process(COUNTER_VECTOR,PWM_LIMIT,CLK_IN,number)
BEGIN
number <= 10 MOD number;
end process;
number_out<=number;
END testing_reminder_command ;
the error that I get is :
Error (10327): VHDL error at rem_command.vhd(48): can't determine
definition of operator ""mod"" -- found 0 possible definitions
maybe I need to add library ?
syntax vhdl
1
You need to read my answer here .
– Matthew Taylor
Nov 20 '18 at 10:35
I am sorry but I don't understand how can it help my problem
– Tomer Polski
Nov 20 '18 at 10:48
Your problem is exactly the same: themod
andrem
operators are not defined forstd_logic_vector
. You need to use a different type, for which they are defined, for exampleunsigned
. Basically, never use thestd_logic_vector
type for doing maths. It is not intended for that. If you're new to theunsigned
type and type conversions, then have a look at these examples.
– Matthew Taylor
Nov 20 '18 at 10:58
You'll find with number declared as type unsigned the assignment to number_out fails. number_out is type std_logic (and should be either std_logic_vector or unsigned with a matching element for each element of number, checked during signal update in simulation). If number_out is std_logic_vector (5 downto 0) then number must be be converted -number_out <= std_logic_vector(number);
Type unsigned and std_logic_vector are closely related allowing type conversion, both having the same element base type (std_ulogic) and both single dimensional array types. THEN the code will analyze (compile).
– user1155120
Nov 20 '18 at 19:21
NOW comes a nasty part.number <= 10 mod number;
with number in the process sensitivity list causes recursion, where eventually you'll divide by 0 during simulation, "DIV, MOD, or REM by zero" an error. The proper thing would be to merge the assignment of number_out -number_out <= std_logic_vector( 10 mod number);
presumably in the process. These two comments presume using package numeric_std.
– user1155120
Nov 20 '18 at 19:32
add a comment |
hello I want to take the binary number of 23. and in binary form it is : 010111
so if for example 23 mod 10 i will get 3 . how to do this comand in VHDL ? this is what I wrote so far :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY rem_command IS
GENERIC (display_resolution : INTEGER :=23; -- counter to get to the loest ferquncy
display_counter: INTEGER :=8); -- counter to get to 97KHz ferquincy
PORT (
CLK_IN :IN STD_LOGIC;
PWM_LIMIT :IN STD_LOGIC_VECTOR(display_counter downto 0);
COUNTER_VECTOR :IN STD_LOGIC_VECTOR(display_counter downto 0);
number_out: OUT STD_LOGIC
);
END rem_command;
ARCHITECTURE testing_reminder_command OF rem_command I
signal number : std_logic_vector(5 downto 0):="010111"; -- this is 23 in binary form
BEGIN
process(COUNTER_VECTOR,PWM_LIMIT,CLK_IN,number)
BEGIN
number <= 10 MOD number;
end process;
number_out<=number;
END testing_reminder_command ;
the error that I get is :
Error (10327): VHDL error at rem_command.vhd(48): can't determine
definition of operator ""mod"" -- found 0 possible definitions
maybe I need to add library ?
syntax vhdl
hello I want to take the binary number of 23. and in binary form it is : 010111
so if for example 23 mod 10 i will get 3 . how to do this comand in VHDL ? this is what I wrote so far :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY rem_command IS
GENERIC (display_resolution : INTEGER :=23; -- counter to get to the loest ferquncy
display_counter: INTEGER :=8); -- counter to get to 97KHz ferquincy
PORT (
CLK_IN :IN STD_LOGIC;
PWM_LIMIT :IN STD_LOGIC_VECTOR(display_counter downto 0);
COUNTER_VECTOR :IN STD_LOGIC_VECTOR(display_counter downto 0);
number_out: OUT STD_LOGIC
);
END rem_command;
ARCHITECTURE testing_reminder_command OF rem_command I
signal number : std_logic_vector(5 downto 0):="010111"; -- this is 23 in binary form
BEGIN
process(COUNTER_VECTOR,PWM_LIMIT,CLK_IN,number)
BEGIN
number <= 10 MOD number;
end process;
number_out<=number;
END testing_reminder_command ;
the error that I get is :
Error (10327): VHDL error at rem_command.vhd(48): can't determine
definition of operator ""mod"" -- found 0 possible definitions
maybe I need to add library ?
syntax vhdl
syntax vhdl
edited Nov 20 '18 at 10:37
Matthew Taylor
7,1612731
7,1612731
asked Nov 20 '18 at 10:32
Tomer PolskiTomer Polski
94
94
1
You need to read my answer here .
– Matthew Taylor
Nov 20 '18 at 10:35
I am sorry but I don't understand how can it help my problem
– Tomer Polski
Nov 20 '18 at 10:48
Your problem is exactly the same: themod
andrem
operators are not defined forstd_logic_vector
. You need to use a different type, for which they are defined, for exampleunsigned
. Basically, never use thestd_logic_vector
type for doing maths. It is not intended for that. If you're new to theunsigned
type and type conversions, then have a look at these examples.
– Matthew Taylor
Nov 20 '18 at 10:58
You'll find with number declared as type unsigned the assignment to number_out fails. number_out is type std_logic (and should be either std_logic_vector or unsigned with a matching element for each element of number, checked during signal update in simulation). If number_out is std_logic_vector (5 downto 0) then number must be be converted -number_out <= std_logic_vector(number);
Type unsigned and std_logic_vector are closely related allowing type conversion, both having the same element base type (std_ulogic) and both single dimensional array types. THEN the code will analyze (compile).
– user1155120
Nov 20 '18 at 19:21
NOW comes a nasty part.number <= 10 mod number;
with number in the process sensitivity list causes recursion, where eventually you'll divide by 0 during simulation, "DIV, MOD, or REM by zero" an error. The proper thing would be to merge the assignment of number_out -number_out <= std_logic_vector( 10 mod number);
presumably in the process. These two comments presume using package numeric_std.
– user1155120
Nov 20 '18 at 19:32
add a comment |
1
You need to read my answer here .
– Matthew Taylor
Nov 20 '18 at 10:35
I am sorry but I don't understand how can it help my problem
– Tomer Polski
Nov 20 '18 at 10:48
Your problem is exactly the same: themod
andrem
operators are not defined forstd_logic_vector
. You need to use a different type, for which they are defined, for exampleunsigned
. Basically, never use thestd_logic_vector
type for doing maths. It is not intended for that. If you're new to theunsigned
type and type conversions, then have a look at these examples.
– Matthew Taylor
Nov 20 '18 at 10:58
You'll find with number declared as type unsigned the assignment to number_out fails. number_out is type std_logic (and should be either std_logic_vector or unsigned with a matching element for each element of number, checked during signal update in simulation). If number_out is std_logic_vector (5 downto 0) then number must be be converted -number_out <= std_logic_vector(number);
Type unsigned and std_logic_vector are closely related allowing type conversion, both having the same element base type (std_ulogic) and both single dimensional array types. THEN the code will analyze (compile).
– user1155120
Nov 20 '18 at 19:21
NOW comes a nasty part.number <= 10 mod number;
with number in the process sensitivity list causes recursion, where eventually you'll divide by 0 during simulation, "DIV, MOD, or REM by zero" an error. The proper thing would be to merge the assignment of number_out -number_out <= std_logic_vector( 10 mod number);
presumably in the process. These two comments presume using package numeric_std.
– user1155120
Nov 20 '18 at 19:32
1
1
You need to read my answer here .
– Matthew Taylor
Nov 20 '18 at 10:35
You need to read my answer here .
– Matthew Taylor
Nov 20 '18 at 10:35
I am sorry but I don't understand how can it help my problem
– Tomer Polski
Nov 20 '18 at 10:48
I am sorry but I don't understand how can it help my problem
– Tomer Polski
Nov 20 '18 at 10:48
Your problem is exactly the same: the
mod
and rem
operators are not defined for std_logic_vector
. You need to use a different type, for which they are defined, for example unsigned
. Basically, never use the std_logic_vector
type for doing maths. It is not intended for that. If you're new to the unsigned
type and type conversions, then have a look at these examples.– Matthew Taylor
Nov 20 '18 at 10:58
Your problem is exactly the same: the
mod
and rem
operators are not defined for std_logic_vector
. You need to use a different type, for which they are defined, for example unsigned
. Basically, never use the std_logic_vector
type for doing maths. It is not intended for that. If you're new to the unsigned
type and type conversions, then have a look at these examples.– Matthew Taylor
Nov 20 '18 at 10:58
You'll find with number declared as type unsigned the assignment to number_out fails. number_out is type std_logic (and should be either std_logic_vector or unsigned with a matching element for each element of number, checked during signal update in simulation). If number_out is std_logic_vector (5 downto 0) then number must be be converted -
number_out <= std_logic_vector(number);
Type unsigned and std_logic_vector are closely related allowing type conversion, both having the same element base type (std_ulogic) and both single dimensional array types. THEN the code will analyze (compile).– user1155120
Nov 20 '18 at 19:21
You'll find with number declared as type unsigned the assignment to number_out fails. number_out is type std_logic (and should be either std_logic_vector or unsigned with a matching element for each element of number, checked during signal update in simulation). If number_out is std_logic_vector (5 downto 0) then number must be be converted -
number_out <= std_logic_vector(number);
Type unsigned and std_logic_vector are closely related allowing type conversion, both having the same element base type (std_ulogic) and both single dimensional array types. THEN the code will analyze (compile).– user1155120
Nov 20 '18 at 19:21
NOW comes a nasty part.
number <= 10 mod number;
with number in the process sensitivity list causes recursion, where eventually you'll divide by 0 during simulation, "DIV, MOD, or REM by zero" an error. The proper thing would be to merge the assignment of number_out - number_out <= std_logic_vector( 10 mod number);
presumably in the process. These two comments presume using package numeric_std.– user1155120
Nov 20 '18 at 19:32
NOW comes a nasty part.
number <= 10 mod number;
with number in the process sensitivity list causes recursion, where eventually you'll divide by 0 during simulation, "DIV, MOD, or REM by zero" an error. The proper thing would be to merge the assignment of number_out - number_out <= std_logic_vector( 10 mod number);
presumably in the process. These two comments presume using package numeric_std.– user1155120
Nov 20 '18 at 19:32
add a comment |
1 Answer
1
active
oldest
votes
If you definitely wanted to use the "mod" and "rem" operators:
- They are not defined in any of the packages that you are using.
- FIX: use ieee.numeric_std.all package
mod and rem don't operate on std_logic_vector. So, you need to implement type conversions on your std_logic_vector signals
1
mod
andrem
operate onunsigned
andsigned
types, too.
– Matthew Taylor
Nov 20 '18 at 11:27
I added the use iee.numeric_std.all package but now I get other error : signal number : unsigned(5 downto 0):="010111"; -- this is 23 in binary form
– Tomer Polski
Nov 20 '18 at 15:00
That sounds like you need to ask another question.
– Matthew Taylor
Nov 21 '18 at 11:24
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391049%2fvhdl-how-to-use-rem-and-mod-command-in-vhdl-syntax-problem%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you definitely wanted to use the "mod" and "rem" operators:
- They are not defined in any of the packages that you are using.
- FIX: use ieee.numeric_std.all package
mod and rem don't operate on std_logic_vector. So, you need to implement type conversions on your std_logic_vector signals
1
mod
andrem
operate onunsigned
andsigned
types, too.
– Matthew Taylor
Nov 20 '18 at 11:27
I added the use iee.numeric_std.all package but now I get other error : signal number : unsigned(5 downto 0):="010111"; -- this is 23 in binary form
– Tomer Polski
Nov 20 '18 at 15:00
That sounds like you need to ask another question.
– Matthew Taylor
Nov 21 '18 at 11:24
add a comment |
If you definitely wanted to use the "mod" and "rem" operators:
- They are not defined in any of the packages that you are using.
- FIX: use ieee.numeric_std.all package
mod and rem don't operate on std_logic_vector. So, you need to implement type conversions on your std_logic_vector signals
1
mod
andrem
operate onunsigned
andsigned
types, too.
– Matthew Taylor
Nov 20 '18 at 11:27
I added the use iee.numeric_std.all package but now I get other error : signal number : unsigned(5 downto 0):="010111"; -- this is 23 in binary form
– Tomer Polski
Nov 20 '18 at 15:00
That sounds like you need to ask another question.
– Matthew Taylor
Nov 21 '18 at 11:24
add a comment |
If you definitely wanted to use the "mod" and "rem" operators:
- They are not defined in any of the packages that you are using.
- FIX: use ieee.numeric_std.all package
mod and rem don't operate on std_logic_vector. So, you need to implement type conversions on your std_logic_vector signals
If you definitely wanted to use the "mod" and "rem" operators:
- They are not defined in any of the packages that you are using.
- FIX: use ieee.numeric_std.all package
mod and rem don't operate on std_logic_vector. So, you need to implement type conversions on your std_logic_vector signals
edited Nov 20 '18 at 11:48
answered Nov 20 '18 at 11:06
Sai VarunSai Varun
854
854
1
mod
andrem
operate onunsigned
andsigned
types, too.
– Matthew Taylor
Nov 20 '18 at 11:27
I added the use iee.numeric_std.all package but now I get other error : signal number : unsigned(5 downto 0):="010111"; -- this is 23 in binary form
– Tomer Polski
Nov 20 '18 at 15:00
That sounds like you need to ask another question.
– Matthew Taylor
Nov 21 '18 at 11:24
add a comment |
1
mod
andrem
operate onunsigned
andsigned
types, too.
– Matthew Taylor
Nov 20 '18 at 11:27
I added the use iee.numeric_std.all package but now I get other error : signal number : unsigned(5 downto 0):="010111"; -- this is 23 in binary form
– Tomer Polski
Nov 20 '18 at 15:00
That sounds like you need to ask another question.
– Matthew Taylor
Nov 21 '18 at 11:24
1
1
mod
and rem
operate on unsigned
and signed
types, too.– Matthew Taylor
Nov 20 '18 at 11:27
mod
and rem
operate on unsigned
and signed
types, too.– Matthew Taylor
Nov 20 '18 at 11:27
I added the use iee.numeric_std.all package but now I get other error : signal number : unsigned(5 downto 0):="010111"; -- this is 23 in binary form
– Tomer Polski
Nov 20 '18 at 15:00
I added the use iee.numeric_std.all package but now I get other error : signal number : unsigned(5 downto 0):="010111"; -- this is 23 in binary form
– Tomer Polski
Nov 20 '18 at 15:00
That sounds like you need to ask another question.
– Matthew Taylor
Nov 21 '18 at 11:24
That sounds like you need to ask another question.
– Matthew Taylor
Nov 21 '18 at 11:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391049%2fvhdl-how-to-use-rem-and-mod-command-in-vhdl-syntax-problem%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You need to read my answer here .
– Matthew Taylor
Nov 20 '18 at 10:35
I am sorry but I don't understand how can it help my problem
– Tomer Polski
Nov 20 '18 at 10:48
Your problem is exactly the same: the
mod
andrem
operators are not defined forstd_logic_vector
. You need to use a different type, for which they are defined, for exampleunsigned
. Basically, never use thestd_logic_vector
type for doing maths. It is not intended for that. If you're new to theunsigned
type and type conversions, then have a look at these examples.– Matthew Taylor
Nov 20 '18 at 10:58
You'll find with number declared as type unsigned the assignment to number_out fails. number_out is type std_logic (and should be either std_logic_vector or unsigned with a matching element for each element of number, checked during signal update in simulation). If number_out is std_logic_vector (5 downto 0) then number must be be converted -
number_out <= std_logic_vector(number);
Type unsigned and std_logic_vector are closely related allowing type conversion, both having the same element base type (std_ulogic) and both single dimensional array types. THEN the code will analyze (compile).– user1155120
Nov 20 '18 at 19:21
NOW comes a nasty part.
number <= 10 mod number;
with number in the process sensitivity list causes recursion, where eventually you'll divide by 0 during simulation, "DIV, MOD, or REM by zero" an error. The proper thing would be to merge the assignment of number_out -number_out <= std_logic_vector( 10 mod number);
presumably in the process. These two comments presume using package numeric_std.– user1155120
Nov 20 '18 at 19:32