Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need sample code for checking the msb bit of a std_logic_vector in vhdl

Status
Not open for further replies.

ammassk

Member level 2
Joined
Jul 19, 2012
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,606
dear all,

Please help me to write vhdl code for checking MSB bit of a std_logic_vector.
 

Let us assume the signal you want to check is named "test" (assuming an 8-bit std_logic_vector). Here is how you would go about checking the MSB of that signal...

Code:
signal test : std_logic_vector(7 downto 0);

begin

test_signal : process
begin
if (test(7) = '1')then
--insert code to execute when MSB = 1;
elsif (test(7) = '0') then
--insert code to execute when MSB = 0;
end if;
end process;

Regards,
Willis
 

or even better, for a std_logic_vector of length N (maybe its in a function, so you dont even have access to N if N was a generic):

Code:
test_signal : process
begin
if (test( test'high ) = '1')then
--insert code to execute when MSB = 1;
elsif (test( test'high ) = '0') then
--insert code to execute when MSB = 0;
end if;
end process;
 

This version can also handle the crazy big-endian bit numbering (0 to 7):

Code VHDL - [expand]
1
if test(test'left) = '1' then


Both little-endian and big-endian bit numbering normally have the most significant bit on the left side when a value is presented in written form.
 

I used this for vhdl coding. this is not synthesisable, i think. I got error "Signal alpha cannot be synthesized, bad synchronous description. The description style you are using to describe a synchronous element (register, memory, etc.) is not supported in the current software release". I am using 10.1 version of xilinx. Can you please tell me how it make the code sythesizable?
 

if you posted the code, we could help you with the problem.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top