Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers

Vhdl?

Altera_Forum
Honored Contributor II
1,721 Views

Can anyone help with explaining how the statement below works? I'm confused as to why you AND data_out? 

 

Is the statement saying  

 

if address = x then  

read_mux_out <= data_out 

 

Statement in question 

------------------------- 

read_mux_out <= A_REP(to_std_logic((((std_logic_vector'("000000000000000000000000000000") & (address)) = std_logic_vector'("00000000000000000000000000000000")))), 13) AND data_out; 

 

Thanks for any help 

Guy
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
683 Views

Hi gicolleta, 

 

the statement works right but too complicated to such simplest task :) 

 

1. std_logic_vector'("000000000 000000000000000000000") & (address) - produce 32bit vector from 2-bit address?  

2. compare it with 32'h0 and get one-bit result: to_std_logic((((std_logic_vector'("000000000 000000000000000000000") & (address)) = std_logic_vector'("0000000000000000000000000000000 0"))) 

3. replicate result upto data_out length vector : REP_A(0/1, 13) 

4. Finally just bit-wise AND data_out with '0 or '1 vector - propagate data_out to mux or not. 

 

Alternative: 

 

read_mux_out <= (others => '0') when address = "00" else data_out;
0 Kudos
Altera_Forum
Honored Contributor II
683 Views

 

--- Quote Start ---  

Hi gicolleta, 

 

the statement works right but too complicated to such simplest task :) 

 

1. std_logic_vector'("000000000 000000000000000000000") & (address) - produce 32bit vector from 2-bit address?  

2. compare it with 32'h0 and get one-bit result: to_std_logic((((std_logic_vector'("000000000 000000000000000000000") & (address)) = std_logic_vector'("0000000000000000000000000000000 0"))) 

3. replicate result upto data_out length vector : REP_A(0/1, 13) 

4. Finally just bit-wise AND data_out with '0 or '1 vector - propagate data_out to mux or not. 

 

Alternative: 

 

read_mux_out <= (others => '0') when address = "00" else data_out; 

--- Quote End ---  

 

 

Thanks Mixa :)
0 Kudos
Altera_Forum
Honored Contributor II
683 Views

Normally, I would refuse to edit such confuse VHDL code. It should be noted, that A_REP isn't a standard VHDL library function, I see that it's defined in altera_europa_support_lib.vhd. It's not clear to me, if it works at all to apply A_REP to the boolean result of a relational operation. 

 

It would be much better to use understandable standard VHDL 

if address = "00" then read_mux_out <= data_out; else read_mux_out <= (others => '0'); endif; 

respectively an conditional assignment in concurrent code.
0 Kudos
Altera_Forum
Honored Contributor II
683 Views

 

--- Quote Start ---  

Thanks Mixa :) 

--- Quote End ---  

 

 

No problem :) just a click on "Add to cms's Reputation" link at the top rigth of the post.
0 Kudos
Altera_Forum
Honored Contributor II
683 Views

I suspect this is one reason why some people unfairly regard VHDL as "verbose" - people write bad code and then call the lanbguage verbose because they don't use the strengths of the language to write simple clear code like the right honourable cms has just demonstrated.

0 Kudos
Reply