21352

Driving module input

Question:

I made some tests in some EDA playground, to check what simulator tools are reporting when in a module some inputs are driven.

Here is eda playground link : <a href="https://www.edaplayground.com/x/5qK4" rel="nofollow">https://www.edaplayground.com/x/5qK4</a>

So from my experiment the only way the tool is reporting some error when doing such thing is using the var keyword when defining the input.

Can someone explain why there is difference between the three different way to declare the input ?

I guess that means you can do port coercion when declaring it as wire

I post the code here as well

module test( input var logic a, input logic b, input c ); assign a = 1'b0; assign b = 1'b0; assign c = 1'b0; endmodule

Answer1:

This is an input variable of type logic:

input var logic a,

There's no debate about that because each is explicitly declared*.

Section 23.2.2.3 of IEEE 1800-2012 says (the <em>port kind</em> is var or wire):

<blockquote>

If the port kind is omitted: — For input and inout ports, the port shall default to a net of default net type. The default net type can be changed using the `default_nettype compiler directive

</blockquote>

Therefore, because the default default_nettype is wire, this is an input wire of type logic:

input logic b,

Section 23.2.2.3 of IEEE 1800-2012 also says:

<blockquote>

If the data type is omitted, it shall default to logic except for interconnect ports which have no data type

</blockquote>

Therefore this is an input wire of type logic:

input c

Now it is certainly illegal to drive a variable from an assign statement if it is already driven from somewhere else, so this line is definitely no good:

assign a = 1'b0;

Because input a is definitely a variable - that is explicit. But if we change that to (say)

always_comb a = 1'b0;

then it's still no good, because the input is considered to be driving the variable a using an assign statement and, as we already know, it is illegal to drive a variable from an assign statement if it is already driven from somewhere else.

However, because b and c are nets (of kind wire), it is fine to drive them from more than one place, so these lines <em>should be</em> OK:

assign b = 1'b0; assign c = 1'b0; <hr />

*No project was ever late because the typing too too long. Therefore, why not just do this?

Recommend

  • How to preserve png transparency?
  • How to create a separation between two SpriteKit objects
  • Changing UITableViewCell's width constraint's constant value for each instance
  • VideoJS Won't play in IE8 but plays in FireFox, Chrome and Safari
  • trouble referencing Windows Portable Device files in VBA?
  • Getting public URL to file in Google Drive using .NET API
  • NGINX/JENKINS: It appears that your reverse proxy set up is broken
  • About arm pc value in thumb 16/32bits mixed instructions stream
  • Insertion Sort in C#
  • Filter by multiple patterns with filter() and str_detect()
  • ob_start() failed to create buffer in laravel three
  • Dynamic Bootstrap Tabs using PHP/MySQL
  • How can I extend a Retrofit 2.0 Call?
  • Human readable URL Scheme for ASP.NET MVC
  • Adding items to an already existing jlist from another class
  • Extract the data specified in brackets '[ ]' from a string message in python
  • Weekday as String to number
  • 3 transitions, pausetime between transitions
  • NodeJS - installing local module
  • what is mean -(IBAction) behavior function?
  • wxPython UltimateListCtrl check (tick) listitem programatically
  • CABasicAnimation creates empty default value copy of CALayer
  • Avoiding duplicated data in same table with jquery
  • Android NDK refer to external libraries in JNI
  • Spongycastle is missing many algorithms when loaded on android
  • Using loops in Jasmine (with injected service)
  • Why am I getting an Argument exception when creating event handler dynamically?
  • How to get a time and Date Separately?
  • How to control xtics in gnuplot
  • playing mp3 from nsbundle
  • Set SelectedIndex of ListView in FlipView_SelectionChanged event
  • How to use Flask's render_template from an ajax POST form submit
  • Thumbnails for mxml components in Flex
  • Google Spreadsheet Script to Blink a range of Cells
  • VSTS work items list through REST API
  • Spring Boot fails to start
  • WPF custom control and direct content support