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.

VHDL code for SR flip-flop built with NOR gates

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,302
Hello,
I know this is a simple 2-1 mux :
A <= '0' when X = '1' else '1'

But what does the following generate ?
A <= '0' when X = '1' else '1' when Y = '1' ;

How can you rewrite it ?
 

Re: unfamiliar VHDL code

I am not a VHDL expert (i am much more used to Verilog) but i belive that some states are missing, so it got undefined behavior.

So what happens when Y and X are 0? Undefined... it should be defined;

I belive the right should be:

Code:
A <= '0' WHEN X = '1' ELSE,
       '1' WHEN Y = '1' ELSE,
       <SOMETHING>;

Cya
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Re: unfamiliar VHDL code

I am not a VHDL expert (i am much more used to Verilog) but i belive that some states are missing, so it got undefined behavior.

So what happens when Y and X are 0? Undefined... it should be defined;

I belive the right should be:

Code:
A <= '0' WHEN X = '1' ELSE,
       '1' WHEN Y = '1' ELSE,
       <SOMETHING>;

Cya

It is defined behavior, the definition being from the LRM. If there is no update for a signal then it simply maintains the current state. Which is why std_match properly classified it as an SR latch (with reset taking precedence). If neither X or Y (analogous to R and S) are set, then the output A retains its present state, whatever that is.

I suspect the behavior is the same for Verilog and is also part of the Verilog LRM.

Kevin Jennings
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Re: unfamiliar VHDL code

K-J, std_match

You're saying that it's a transparent SR latch ?

---------- Post added at 22:00 ---------- Previous post was at 21:58 ----------

I was surprised to see pass the parsing check.
Most latches/FFs I've seen are described in a process.
 

Re: unfamiliar VHDL code

K-J, std_match
You're saying that it's a transparent SR latch ?

It's an SR latch...a transparent latch generally refers to a latch where you have a latch enable rather than a clock. I'm not sure what you mean by transparent SR latch, but I'm guessing that you mean it to be a latch that doesn't have an edge triggered storage. On that assumption, the original code that was posted was...
Code:
A <= '0' when X = '1' else '1' when Y = '1'
This form must be a concurrent statement, therefore it is not inside any process therefore it must be describing an SR latch not any edge triggered storage.

I was surprised to see pass the parsing check.
Most latches/FFs I've seen are described in a process.
I'm not sure what parsing check you're referring to. There is nothing invalid about the code so there is no reason why it won't make it through any compiler. However, whether you should or should not use such a thing in a design is a completely different question (hint: inside an FPGA or CPLD the answer is almost always a solid 'no'). In an ASIC, or other device where maybe there is an SR latch primitive the answer can be 'yes'.

Kevin Jennings
 

Re: unfamiliar VHDL code

I've seen this code in an asychronous CPLD design...
 

Re: unfamiliar VHDL code

You're saying that it's a transparent SR latch ?

I was surprised to see pass the parsing check.
Most latches/FFs I've seen are described in a process.

There is no such thing as a "transparent SR latch".
"transparent latch" and "SR latch" are different, but both have combinatorial feedback.
An "SR latch" can be implemented with a D-flip-flop if you only use the "set" and "clear" inputs.
You can not implement a "transparent latch" with a D-flip-flop.

Outside of the declared processes, each assignment is it's own process.
 
  • Like
Reactions: shaiko

    shaiko

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top