B
benn
Guest
I'm very new to Verilog, and I'm trying to learn by reading verilog
code from openCores.org... unfortunately, I see syntax thats not
entirely consistent.. I'm sure its makes total sense to everyone
else, but pretty confusing for me. For example...
Most "assign" assignments, use "=", as opposed to "<=" (perhaps it
doesn't matter), while most begin/end blocks have statements inside
that use "<=" as opposed to "="... confusing because I've also seen
code that uses "=" inside begin/end, so it must be acceptable!!).
Wire assignments ( wire a = b never seem to use "<=", but perhaps I
just haven't read enough examples. I think I'm starting to sound like
Andy Rooney, so I'll just cut to the questions:
1) When do you use "<=" over "="? Is there any rule where its
prohibited to use one or the other?
2) Is there a difference between "wire a = b;" and "assign a = b;"?
(i.e. when can you omit "assign")?
3) When a module has outputs, a "wire" of the same name is often (but
not always) declared as well. Why?
4) When would you use "reg" over "wire", for example, to me, "wire
[15:0]a;" and "reg [15:0]a" both create a 16 bit bus that can be used
for internal assignments (i.e. like variables in c).
5) The "?" operator always seems to come up in wire assignments only,
but not in begin/end blocks. Is this a coincidence? In other words,
is this legal:
input inWire;
output outWire;
begin
outWire = inWire ? 1'b0 : 1'b1;
end
Thanks!
code from openCores.org... unfortunately, I see syntax thats not
entirely consistent.. I'm sure its makes total sense to everyone
else, but pretty confusing for me. For example...
Most "assign" assignments, use "=", as opposed to "<=" (perhaps it
doesn't matter), while most begin/end blocks have statements inside
that use "<=" as opposed to "="... confusing because I've also seen
code that uses "=" inside begin/end, so it must be acceptable!!).
Wire assignments ( wire a = b never seem to use "<=", but perhaps I
just haven't read enough examples. I think I'm starting to sound like
Andy Rooney, so I'll just cut to the questions:
1) When do you use "<=" over "="? Is there any rule where its
prohibited to use one or the other?
2) Is there a difference between "wire a = b;" and "assign a = b;"?
(i.e. when can you omit "assign")?
3) When a module has outputs, a "wire" of the same name is often (but
not always) declared as well. Why?
4) When would you use "reg" over "wire", for example, to me, "wire
[15:0]a;" and "reg [15:0]a" both create a 16 bit bus that can be used
for internal assignments (i.e. like variables in c).
5) The "?" operator always seems to come up in wire assignments only,
but not in begin/end blocks. Is this a coincidence? In other words,
is this legal:
input inWire;
output outWire;
begin
outWire = inWire ? 1'b0 : 1'b1;
end
Thanks!