Question

Convert the following code using variables rather than signals. Comment on the differences of a code...

Convert the following code using variables rather than signals. Comment on the differences of a code that uses only signals to a code which makes use of variables.

entity converter is

port( sign_mag : in std_logic_vector(3 downto 0) ;

twos_comp : out std_logic_vector(3 downto 0) );

end converter;

architecture converter_arch of converter is

signal neg : std_logic_vector(3 downto 0);

begin

process(sign_mag)

begin

if (sign_mag <= 1000) then

twos_comp<=sign_mag;

else

neg <=('1' & not sign_mag(2 downto 0))+1;

twos_comp<=neg;

end if;

Homework Answers

Answer #1

// variable assign values immediately but signal assigned after delta delay

entity converter is //Entity converter is decleared

port( sign_mag : in std_logic_vector(3 downto 0) ; //Input is assigned as std logiicvecot hving width of 3

twos_comp : out std_logic_vector(3 downto 0) ); //Similarly outputis declared

end converter; //Endof entity

architecture converter_arch of converter is

begin

process(sign_mag) // process assigned with senstivity element sign_mag

Varible neg : std_logic_vector(3 downto 0); //Variable is assigned after process

begin

if (sign_mag <= 1000) then //conditional operator

twos_comp<=sign_mag; //Output is assigned

else

neg :=('1' & not sign_mag(2 downto 0))+1; //Variable are assigned using := operator where as signal use<= operator

twos_comp<=neg;

end if;

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Can someone create a test bench for this code in VHDL. (Please type it out) library...
Can someone create a test bench for this code in VHDL. (Please type it out) library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity USR_4Bit is port( LR,SER,clk,clear,OC: in std_logic; Da,Db,Dc,Dd: in std_logic; Qa,Qb,Qc,Qd,QCas: out std_logic); end USR_4Bit; architecture Structural of USR_4Bit is signal NLR,A1,A2,A3,A4,A5,A6,A7,A8: std_logic; signal Nclear,Nclk,Q1,Q2,Q3,Q4:std_logic; signal O1,O2,O3,O4 : std_logic; component andgate port(a,b: in std_logic; z : out std_logic); end component; component orgate port(a,b: in std_logic; z : out std_logic); end component; component notgate port(a: in std_logic; z : out std_logic); end...
Write a code in c++ using linear insertion following the steps below. Comment your work. 1....
Write a code in c++ using linear insertion following the steps below. Comment your work. 1.    Ask the user for the name of a file containing data. If it does not exist, the program should display an error, then ask for a new file name. Entering an asterisk (*) as the first and only character on a line should terminate the program. 2.     You can use a statically-allocated one-dimensional array of doubles for this with length 100. You...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...
The Business Case for Agility “The battle is not always to the strongest, nor the race...
The Business Case for Agility “The battle is not always to the strongest, nor the race to the swiftest, but that’s the way to bet ’em!”  —C. Morgan Cofer In This Chapter This chapter discusses the business case for Agility, presenting six benefits for teams and the enterprise. It also describes a financial model that shows why incremental development works. Takeaways Agility is not just about the team. There are product-management, project-management, and technical issues beyond the team’s control. Lean-Agile provides...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Mattel Responds to Ethical Challenges Business Ethics This case was written by Debbie Thorne, John Fraedrich,...
Mattel Responds to Ethical Challenges Business Ethics This case was written by Debbie Thorne, John Fraedrich, O. C. Ferrell, and Jennifer Jackson, with the editorial assistance of Jennifer Sawayda. This case was developed for classroom discussion rather than to illustrate either effective or ineffective handling of an administrative, ethical, or legal discussion by management. All sources used for this case were obtained through publicly available material. Mattel, Inc. is a world leader in the design, manufacture, and marketing of family...