Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare an output with multiple zeros in VHDL

Tags:

vhdl

Hello i am trying to find a way to replace this command: Bus_S <= "0000000000000000000000000000000" & Ne; with something more convenient. Counting zeros one by one is not very sophisticated. The program is about an SLT unit for an ALU in mips. The SLT gets only 1 bit(MSB of an ADDSU32) and has an output of 32 bits all zeros but the first bit that depends on the Ne=MSB of ADDSU32. (plz ignore ALUop for the time being)

entity SLT_32x is
   Port ( Ne : in  STD_LOGIC;
         ALUop : in STD_LOGIC_VECTOR (1 downto 0);
         Bus_S : out  STD_LOGIC_VECTOR (31 downto 0));
end SLT_32x;

architecture Behavioral of SLT_32x is
begin
  Bus_S <= "0000000000000000000000000000000" & Ne; 
end Behavioral;

Is there a way to use (30 downto 0)='0' or something like that? Thanks.

like image 785
BugShotGG Avatar asked Jan 24 '12 09:01

BugShotGG


People also ask

What does := do in VHDL?

You use := to do variable assignment, which takes place immediately. So if you have a signal, you always use <= . If you have a variable, you always use := .

How do you assign a value to a signal in VHDL?

Signals are defined in the architecture before the begin statement. Variables are assigned using the := assignment symbol. Signals are assigned using the <= assignment symbol. Variables that are assigned immediately take the value of the assignment.

What is downto in VHDL?

The keywords downto and to specify the direction of ranges in VHDL. downto is descending (going down); to is ascending (going up).


2 Answers

Try this: bus_S <= (0 => Ne, others => '0') It means: set bit 0 to Ne, and set the other bits to '0'.

like image 156
Philippe Avatar answered Oct 23 '22 04:10

Philippe


alternative to the given answers:

architecture Behavioral of SLT_32x is
begin
  Bus_S <= (others => '0');
  Bus_S(0) <= ne;
end Behavioral;

Always the last assignment in a combinatoric process is taken into account. This makes very readable code when having a default assignment for most of the cases and afterwards adding the special cases, i.e. feeding a wide bus (defined as record) through a hierarchical block and just modifying some of the signals.

like image 25
iterationbound Avatar answered Oct 23 '22 04:10

iterationbound