Question

In: Electrical Engineering

Create an integer to std_logic_vector function(i2std)

Create an integer to std_logic_vector function(i2std)

Solutions

Expert Solution

---------------------------------------------------------------------------------------------------------------------------------------

------- I2STD using NUMERIC_STD

------- Replace 7 with desired vector length

use ieee.numeric_std.all;

signal in_1   : integer;

signal out_1 : std_logic_vector(7 downto 0);

signal out_2 : std_logic_vector(7 downto 0);

---- Conversion of positive integers or unsigned integers

out_1 <= std_logic_vector(to_unsigned(in_1, out_1'length));

---- Conversion of positive or negative integers or signed integers

out_2 <= std_logic_vector(to_signed(in_1, out_2'length));

----------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------------

------- I2STD USING STD_LOGIC_ARITH

------- Replace 7 with desired vector length

-----Conversion of integer to unsigned std_logic_vector

use ieee.std_logic_arith.all;

signal in_1 : integer;

signal out_1 : unsigned(7 downto 0);

out_1 <= conv_unsigned(in_1, out_1'length);

--------Conversion from integer to std_logic_vector

------- When a negative number is inputted, the result will be in 2's complement vector.

signal in_2 : integer;

signal out_2 : std_logic_vector(7 downto 0);

out_2 <= conv_std_logic_vector(in_2, out_2'length);

----Conversion of integer to signed std_logic_vector

signal in_3 : integer;

signal out_3 : signed(7 downto 0);

out_3 <= conv_signed(in_3, out_3'length);

------------------------------------------------------------------------------------------------------------------------------------------


Related Solutions

R programming language A) Create a function that accepts two arguments, an integer and a vector...
R programming language A) Create a function that accepts two arguments, an integer and a vector of integers. It returns the count of the number of occurrences of the integer in the input vector. 1]Input: num_count <-function ??? 2]Input: num_count(2,c(1,1,2,2,3,3)) 2] Output: 2 3] Input: num_count(1,c(1,1,2,2,3,1,4,5,5,2,2,1,3)) 3] Output : 4 B) Create a function that accepts 3 integer values and returns their sum. However, if an integer value is evenly divisible by 3, then it does not count towards the...
C++ Only Create a function named PrintStudents, which takes a string input filename and an integer...
C++ Only Create a function named PrintStudents, which takes a string input filename and an integer minimum score value and a string output file name as a parameters. The function will read the student scores and names from the file and output the names of the students with scores greater than or equal to the value given. This function returns the integer number of entries read from the file. If the input file cannot be opened, return -1 and do...
Matlab program Create a function, when given a two-digit integer as input, prints the equivalent English...
Matlab program Create a function, when given a two-digit integer as input, prints the equivalent English phrase. For example, given 39, output thirty-nine. Limit the input numbers to be in the range 21 to 39.
Write a function that will accept a list of numbers and an integer (n). The function...
Write a function that will accept a list of numbers and an integer (n). The function should return a list containing every nth item from the input list, always starting with the first item in the list. The original list should not be modified. For example, if the function is passed the list [8, 3, 19, 26, 32, 12, 3, 7, 21, 16] and the integer 3, it will return the list [8, 26, 3, 16] If the function is...
Write a function convert_date that takes an integer as a parameter and returns three integer values...
Write a function convert_date that takes an integer as a parameter and returns three integer values representing the input converted into days, month and year (see the function docstring). Write a program named t03.py that tests the function by asking the user to enter a number and displaying the output day, month and year. Save the function in a PyDev library module named functions.py A sample run for t03.py: Enter a date in the format MMDDYYYY: 05272017 The output will...
A function the largest integer among three integers.
Write a function, which accept three integer values as arguments find the largest of three and then return the largest value to main program. Write a main program which will call the function by passing three integer values and print the value returned by the function.?
Challenge 4 – Random Integer in Range Write a function to return a random integer between...
Challenge 4 – Random Integer in Range Write a function to return a random integer between a minimum value and maximum value. var ival = IntRandomRange(, );
create table node( node_id integer primary key, node_color varchar(10)); create table edge( edge_id integer primary key,...
create table node( node_id integer primary key, node_color varchar(10)); create table edge( edge_id integer primary key, origin_id integer, destination_id integer, foreign key (origin_id) references node(node_id), foreign key (destination_id) references node(node_id)); write an SQL query that lists all those nodes that have edges with a destination node that has color 'red'.
Using C++ Write a template function that accepts an integer parameter and returns its integer square...
Using C++ Write a template function that accepts an integer parameter and returns its integer square root. The function should return -1, if the argument passed is not integer. Demonstrate the function with a suitable driver program .
write a function named as cubeCalculator that takes an integer pointer as function and return its...
write a function named as cubeCalculator that takes an integer pointer as function and return its cube value , you are required to compute the cube of a number using pointer notation , return the result as an integer value , use c++
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT