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.

Help me programing an 8-bit latch with reset in verilog

Status
Not open for further replies.

stuntmaster

Newbie level 4
Joined
Apr 15, 2009
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,315
Verilog help plz

hi everyone i've tried to program an 8-bit latch in verilog with reset function
it should work as follow
if g==1 the 8-bit data will be latched and it will appear at the output
if g=0 what ever was latched will appear at the output
if reset=0 all 8-bit data will be zero and it will remain zero until g is logic one again

i' ve tried this code but it doesn't seem to work

hlep me plz



module latch1 (
q,
g,
d,
reset
);

output [7:0] q ;
input g;
input [7:0] d;

input reset ;
reg [7:0] q;
always @(d, g,reset) begin: _latch_logic
if ((g == 1) && (reset==0)) begin
q <= d;
end
else
q<=8'b0;
end

endmodule
 

Re: Verilog help plz

Try this

Code:
always @ *
begin

  if (reset)
    q = 8'h00;
  else if (g)
    q = d;

end
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top