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.

Syntax question: using WHEN statements

Status
Not open for further replies.

neocool

Member level 4
Joined
Jun 3, 2004
Messages
79
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,112
Hi, how do I implement something like that in one line, so that I don't drive DOUT at two locations?

DOUT <= DO_higher(SAMPLE_WIDTH-1 downto 0) when (CSN='0' and RDN='0' and ADDR(8)='1');
DOUT <= DO_lower(SAMPLE_WIDTH-1 downto 0) when (CSN='0' and RDN='0' and ADDR(8)='0');

Thanks
 

khorram

Full Member level 4
Joined
Oct 27, 2004
Messages
212
Helped
13
Reputation
26
Reaction score
1
Trophy points
1,298
Activity points
1,892
One of solutions is as follows:
DOUT <= DO_higher(SAMPLE_WIDTH-1 downto 0) WHEN CSN='0' and RDN='0' and ADDR()='1' ELSE DO_lower(SAMPLE_WIDTH-1 downto 0) WHEN CSN='0' and RDN='0' and ADDR()='0' ELSE DEFAULT_VALUE;

ANOTHER WAY:
Why don't you use an IF statement in a PROCESS statement instead of them?

You can replace them by the following process statement:

process(CSN, RDN, ADDR, DO_higher, DO_lower)
begin
if (CSN='0' and RDN='0' and ADDR()='1') then
DOUT <= DO_higher(SAMPLE_WIDTH-1 downto 0);
elsif (CSN='0' and RDN='0' and ADDR()='0') then
DOUT <= DO_lower(SAMPLE_WIDTH-1 downto 0);
else
DOUT <= DEFAULT_VALUE;
end if;
end process;

Regards,
KH
 

    neocool

    Points: 2
    Helpful Answer Positive Rating

neocool

Member level 4
Joined
Jun 3, 2004
Messages
79
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,112
So, it's allowed to use when-else-when-else statement..
I've tried it before, but I guess I've made some other mistake, so it didn't compile.

The reason I wanted to avoid process and if statements is because ISE adds a latch at the output, so there is a delay of one clock. I wanted to create no delay as this is a small fix inside my design.
Is there a way to remove that latch and still use IF inside process?

Regards
 

khorram

Full Member level 4
Joined
Oct 27, 2004
Messages
212
Helped
13
Reputation
26
Reaction score
1
Trophy points
1,298
Activity points
1,892
If you have an incomplete if statement, the synthesis tool will generate a latch. As you can see in the code, last else statement prevents to make a latch. You should assign a default value to the DOUT.

process(CSN, RDN, ADDR, DO_higher, DO_lower)
begin
if (CSN='0' and RDN='0' and ADDR()='1') then
DOUT <= DO_higher(SAMPLE_WIDTH-1 downto 0);
elsif (CSN='0' and RDN='0' and ADDR()='0') then
DOUT <= DO_lower(SAMPLE_WIDTH-1 downto 0);
else
DOUT <= DEFAULT_VALUE;

end if;
end process;

Regards,
KH
 

    neocool

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top