Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

verilog - Difference between wire and reg

I'm new in Verilog and i have question that i don't understand:

module my_func(t0, t1, t2, t3, s0, s1, res)
begin
  in t0, t1, t2, t3, s0, s1;
  out res;

  always begin
    if ( s0=0 && s1=0 )   res = t0;
    if ( s0=1 && s1=0 )   res = t1;
    if ( s0=0 && s1=1 )  res = t2;
    if ( s0=1 && s1=1 )   res = t3;
  end
endmodule

module my_FSM( input, output )
begin
  in input;
  out output;
  ??__(1)__ d[3];
  __(2)__ q[3];

always @ (in)
begin
  d[0] = input | q[2];
  d[1] = input & q[0];
  my_func(0, q[0], q[1], q[2], q[1], input, d[2]);
  out = q[2] & d[1];
end

always @(posedge clk)
begin
  q = d;
end

endmodule

The question is:

FILL The missing:
(1): wire, (2): reg (this is the truth answer )

Can someone explain why this the true answer and what the different between wire and reg?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

wire declarations technically aren't required in Verilog, unless you have overridden `default nettype, but I imagine that's not what is desired. But remember that things assigned in an always block must be of type 'reg'.

Good luck.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...