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...
C++ Fix my code This code is for imitating the round robin cpu scheduling algorithim using...
C++ Fix my code This code is for imitating the round robin cpu scheduling algorithim using linked lists. Currently I am able to input processes and store / display them properly. The issue begins somewhere after I have displayed the processlist (I get a segmentation fault (core dumped) or the code doesnt seem to run). I have marked the location of where I think the issue begins with a comment. Please fix the code so that it is working properly....
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...
#include<iostream> #include<iomanip> using namespace std; int main() { //variables int choice; float radius,base,height,area; const double PI=3.14159;...
#include<iostream> #include<iomanip> using namespace std; int main() { //variables int choice; float radius,base,height,area; const double PI=3.14159; //repeat until user wants to quits while(true) { //menu cout<<endl<<endl<<"Geometry Calculator"<<endl<<endl; cout<<"1. Calculate the area of a circle"<<endl; cout<<"2. Calculate the area of a triangle"<<endl; cout<<"3. Quit"<<endl<<endl; //prompt for choice cout<<"Enter your choice(1-3): "; cin>>choice; cout<<endl; //if choice is circle if(choice==1) { cout<<"What is the radius of the circle? "; cin>>radius; //calculating area area=PI*radius*radius; cout<<endl<<"The area of the circle is "<<fixed<<setprecision(3)<<area<<endl; } //if choice...
convert to python 3 from python 2 from Tkinter import * # the blueprint for a...
convert to python 3 from python 2 from Tkinter import * # the blueprint for a room class Room(object): # the constructor def __init__(self,name,image): # rooms have a name, exits (e.g., south), exit locations (e.g., to the south is room n), # items (e.g., table), item descriptions (for each item), and grabbables (things that can # be taken and put into the inventory) self.name = name self.image = image self.exits = {} self.items = {} self.grabbables = [] # getters...
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...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...