Quantcast
Channel: Altera Forums
Viewing all articles
Browse latest Browse all 19390

Additional circuit within a circuit - if then else

$
0
0
Hello,

I am a beginner to VHDL and currently have an assignment to complete. It is as follows:


  • A digital circuit has two 4-bit inputs a[3..0] and b[3..0]. A 4-bit output s[3..0] is to represent the value of a subtracted from b. In addition to this, the circuit has a single bit output t that is to be high if the result of the subtraction is zero. Write a vhdl description for this circuit. Fully test your design.


I have written the architecture correct for the subtractor part. This fully compiles. When I try to write the subcircuit for the If Then Else part about the 'the circuit has a single bit output t that is to be high if the result of the subtraction is zero' part I struggle.

This is my code so far

entity ComparatorSubtractor4Bit is port (
a,b : in integer range 0 to 15;
borrowin : in integer range 0 to 1;
sub : out integer range 0 to 15;
t : out integer range 0 to 1);
end ComparatorSubtractor4Bit;

architecture Adder of ComparatorSubtractor4Bit is
begin
sub<= a - b - borrowin; -- note borrow out will be sub[4]
process (a,b)
begin
if sub<= 0 then t<=1;
else t<=0;
end if;
end process;
end Adder;

I have written a sub If Then Else code on a previous assignment which involved the inputs being compared, however it seems to have a problem when I try to If Then Else the output.

Any help would be greatly appreciated

Sam

Viewing all articles
Browse latest Browse all 19390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>