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

. Create a Python function that asks the user for a number (integer). The function should...
. Create a Python function that asks the user for a number (integer). The function should then tell the user how many hundreds can go into the number, and how much is left over. Hint: the % operator calculates the remainder of a division. For example, 10 % 3 gives a result 1. Hint2: Deal with the positive and negative values in separate parts of an if-else structure. Get the calculation work for positive values first. For negative values, make...
IN C++ Create a single function. and pass in a integer which is the the planet...
IN C++ Create a single function. and pass in a integer which is the the planet number. 1 will be Mercury and 9 will be Pluto, etc. Return via reference the planet name, planet weight ( or mass ) in kg, and the distance from the sun in km. Please create a nice looking table with headings and show the 9 planets. Here is an example of the first 4 planets in the table. You will need to add in...
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...
Create the function fact that had a positive integer argument and returns its factorial . Recall...
Create the function fact that had a positive integer argument and returns its factorial . Recall that factorial (n) = 1*2*3***n. For example factorial (4)=1*2*3*4=24, (python)
Q1) Create a function called max that receives two integer values and returns the value of...
Q1) Create a function called max that receives two integer values and returns the value of the bigger integer. Q2) Complete the missing code in the following program. Assume that a cosine function has already been created for you. Consider the following function header for the cos function. double cos (double x) #include void output_separator() { std::cout << "================"; } void greet_name(string name) { std::cout << "Hey " << name << "! How are you?"; } int sum(int x, int...
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.
Create a method that takes a HashMap<Integer, Integer> and returns the sum of the keys of...
Create a method that takes a HashMap<Integer, Integer> and returns the sum of the keys of the HashMap.
Create a Java program with a method that searches an integer array for a specified integer...
Create a Java program with a method that searches an integer array for a specified integer value **(see help with starting the method header below). If the array contains the specified integer, the method should return its index in the array. If not, the method should throw an Exception stating "Element not found in array" and end gracefully. Test the method in main with an array that you make and with user input for the "needle". starting header ** public...
Write a function intLog of type Integer -> Integer that returns the exponent of the largest...
Write a function intLog of type Integer -> Integer that returns the exponent of the largest power of 2 less than its integer argument. This needs to be a haskell function
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT