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.

System Verilog type "logic"

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
As far as I understand -
Verilog uses type "reg" for flip flops and type "wire" for combinatorial logic.

System Verilog on the other hand - has type "logic"
Is this type the same as "signal" in VHDL?
Can it be used interchangeably instead of "reg" and "wire" to describe any logic ?
 

In SV, logic is used for registers as well as wires while wire is used only for multi driven signals as only wires have a resolution function associated with them.
yes...something similar to signal in vhdl.
 

reg isn't always used for flip-flops, that is a misconception that many have. The example shown in the link, which I've copied below shows what I mean.
https://stackoverflow.com/questions/13282066/difference-of-systemverilog-data-types-reg-logic-bits

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
wire w_data;
assign w_data = y;
 
// Same function as above using reg
reg r_data;
always @* 
  r_data = y ;
 
// Now using logic...
// same as the wire from above, but using logic type.
logic  w_data;
assign w_data = y;
 
// Same function as reg above, but using logic type
logic r_data;
always @* 
  r_data = y ;



Personally I think the addition of this new type was pandering to the complaints that new learners were getting so confused over reg meaning "register" (a.k.a Flip-flops). I think this misconception reflects more on new learners not being studious enough or very poor instruction/instruction_materials. I'm not entirely sure I like the idea of a magic type that changes it's behavior depending on how it is used.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
As far as I understand -
Verilog uses type "reg" for flip flops and type "wire" for combinatorial logic.

System Verilog on the other hand - has type "logic"
Is this type the same as "signal" in VHDL?
Can it be used interchangeably instead of "reg" and "wire" to describe any logic ?

Reg and wire are just data types. As stated above, a reg is just a data type that can be assigned how you want where you want. It doesnt necessarily make a register. The logic data type was introduced in SV to stop people confusing the two (and theres no reason in SV just to make everything logic, and ignore reg and wire completly).

A signal in VHDL is equivalent to a non-blocking assignment in Verilog.
A variable in VHDL is equivalent to a blocking assignment in verilog
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
and theres no reason in SV just to make everything logic, and ignore reg and wire completly
I understand that...using "wire" and "reg" increases code readability
but is it legal to use "logic" instead of both ?
 

yes, see the link I posted, or the code I pasted from the link. I'm pretty sure it can also be used in an edge triggered always block too. I don't use logic, mainly because of it's "magical" qualities and the fact that not all tools support SV completely.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
I understand that...using "wire" and "reg" increases code readability
but is it legal to use "logic" instead of both ?

It only increases readability for people that write correct code.
If you come into it thinking reg type will always make a register, you're bound to stumble.

Yes, you can use logic anywhere you could previously use reg or wire.
Note, there is also the "bit" data type that is a 2 state type.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top