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.

sample and hold without latch infered

Status
Not open for further replies.

hulk789

Junior Member level 3
Joined
Jul 18, 2015
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
211
Code:
always @ (sample,inp) begin
         if(sample==0 ) begin
             vinp=vinp;
         end
         else begin
             vinp=inp;
         end
    end

is it possible to not infer a latch for a sample and hold type of code in synthesis.
 

No. Anything that has memory will infer a latch.
 

is it possible to not infer a latch for a sample and hold type of code in synthesis.

Yes, a flip flop.

Kevin Jennings

- - - Updated - - -

No. Anything that has memory will infer a latch.
You know better than that. Flip flops are memory and they are not a latch (in the context of what a designer would describe and use, not what a flip flop is at the transistor level).

Kevin
 
Anything that has memory will infer a latch.
Should be read "A memory in combinational always block". I guess.

There are some applications where you intentionally infer a latch, e.g. in some cases, a transparent latch is better suited as address register in a multiplexed processor bus than a flip-flop.
 

And the code specified by the OP is a latch


Code Verilog - [expand]
1
2
3
4
5
6
7
8
always @ (sample,inp) begin // combinational code as FvM mentioned
         if(sample==0 ) begin
             vinp=vinp;  // memory as Tricky mentions
         end
         else begin
             vinp=inp;
         end
    end



Without a posedge or negedge sensitivity on a signal the always block will always infer either combinational logic or a latch (if any outputs are fed back or not defined in a branch).
 
  • Like
Reactions: dpaul

    dpaul

    Points: 2
    Helpful Answer Positive Rating
And the code specified by the OP is a latch
Yes the OP posted code for a latch, but the question the OP posted is can you not infer a latch for a sample and hold. The answer there is yes, use a flip flop.

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top