Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Asynchronous adress decoder

Hi,

I have heired an old design which contains of a lot of AHDL moduls. I would like to rewrite these moduls into VHDL so that I can simulate them in modelsim.

One thing I realized is that the AHDL file used some kind of asynchronous adress decoding. this means that if the module is connected to the Avalon bus (as custom component or as an "Interface to user logic" like in my case) there are no wait timings. This means that the adress is given by the master on the first clock cycle and the slave has readily brought up the data at the second clock cycle. This can be done in AHDL like this:

CASE ADR IS
    WHEN 0 => Q  = counter1.q;
    WHEN 1 => Q  = counter2.q;
    WHEN 2 => Q = counter3.q;
END CASE;

This case statement is not synchronous but the counters are.

If I try to rewrite this in VHDL I'm not able to implement such a case statement outside a process. So I did this:

process(adr)
  begin    
    case adr is
	when b"00"	=> q <= ('0' & '0' &'0' &'0' &'0' &'0' &'0' &'0' & counter1);
	when b"01"	=> q <= ('0' & '0' &'0' &'0' &'0' &'0' &'0' &'0' & counter2);
	when b"10"	=> q <= counter3;
	when others => q <= (others => '0');			
     end case;      
  end process;

I simulated this in modelsim and it looks fine BUT is this something I should do for a synthezizable design?

In the end this seems to be the only option to get this VHDL component working as the AHDL component was working.

What are your opinions or suggestions about this? And is this a save way for an adress decoder in a "real" design?

Thanks,

Maik

9 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello,

    According to your description of the component behaviour it seems that there is a wait for a read access. Look at the join picture. If I understand well, your component has the same behaviour than the first picture, which has a wait parameter of 1. The second has no wait and the read data is provided on the same clock cycle than the request.

    If I misunderstood the behaviour of your component, sorry.

    Trick : you can write "00000000" & counter instead of what you wrote. You can even write X"00" & counter (X is to tell that the value is given in hexadecimal base)

    Jérôme
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    i've done gate level simulations of designs including AHDL just so i could use ModelSim. might be worth looking into.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Combinational logic, as described above, is fully synthesizable. If it's also reasonable depends on the design purpose, which is unknown so far.

    Your VHDL version is not exactly matching the AHDL code, I think. The latter is not writing zero to unsunused output bits or to all output bits in an "others" case. However, when not setting q in all cases, Quartus will warn about latch inference for q, which may be either intended or not, depending on the exact functional definition.

    P.S.: You didn't show the full AHDL code. Has the output signal an explicite or implicite default value of zero?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi guys,

    thanks for your replies!

    @Jérôme: The AHDL design used to have the behaviour with NO wait states (like the diagram below in your attachment). The "Interface to User Logic" component in my heired SOPC design confirmed this because it uses a waitstate of '0'

    In the first step of my porting to VHDL I made the mistake that I put the case-statement into the clock sensitive process. Therefore I had no chance to communicate with the SOPC system without any waitstates because I first had to register the adress on the first clock cycle after the master had set the adress on the avalon bus. At that time the avalon module was already reading the data which leads to an error.

    After I found that out I tried to impelement the adress decoding like in the AHDL modul which seems to be combinatorical instead of synchronous.

    The result was that I made an adress sensitive process in my VHDL module which (hopefully) behaves like the AHDL model.

    @thepancake: That sounds interesting. Can you please specify how you can simulate a AHDL design in modelsim? As far as I knew, modelsim is only capable of Verilog or VHDL.

    @FvM: I was aware about the fact that combinatorical logic is synthesizable. But I'm not quiet sure if it is reasonable to use this in an adress decoder logic. Well in my case I don't have an other chance if I would like to port the AHDL design to VHDL because as I described above the SOPV system uses no wait states. As this is an heired project, I ask myself if this sort of design is safe or if it has some hidden traps. If I say safe I mean is it common practice to implement adress decoders in combinatorical logic or is there a recommendation to implement it in synchronous logic? If so, then I have to change the SOPC module in the way to use at least 1 wait state.

    I don't understand your question about the implicite or explicite default value of the AHDL code. Could you please explain?

    Thanks,

    Maik
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I don't understand, why you see a difference between using AHDL and VHDL. Both languages can represent synchronous and synchronous designs, both above examples are asynchronous. If problems arise with an asynchronous VHDL design, it's the same with AHDL.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Well, below the line, you are right . . .

    If you say that Quartus is building the same combinatorical logic for both designs then it should work because it worked in AHDL as expected (or better to say: with no recognizable sideeffects . . ). I was not quiet sure if it is the case that the synthezized logic is the same. At least, if I look into the RTL of both designs they look different.

    But maybe here is a very experienced user who says: "Well, you can do it this way but I would recommend to do it in an other way because . . . "

    Personally I wonder why it is designed in such an asynchronous way because I would prefer the synchronous way. On the other side I'm a little fearfull to change this because if I get additional wait states and maybe my whole project gets timing issues I don't understand. . .

    Maik
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I expect that on the SOPC bus, read enable and address are set on one clock edge and the data is read back on the next. In this case, it's perfect to use asynchronous logic to decode the addresses and multiplex the read data.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    check out Generating Post-Synthesis Simulation Netlist Files in http://www.altera.com/literature/hb/qts/qts_qii53025.pdf on page 9. it won't give you the same flexibility of looking at internal signals like an RTL simulation, but you can make an AHDL file the top level of your project, export a VHDL netlist (called a .vho), and compile/simulate that in ModelSim.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    @thepancake: Thanks for this hint. Maybe this will save a lot of time for me in the future.

    Maik