How Do You Test a 16-Bit Difference Calculation in Verilog?

  • Thread starter Drao92
  • Start date
In summary, to solve the problems with your verilog homework, you can use an initial block to set the values of your variables and use simulation tools to view the binary signal.
  • #1
Drao92
72
0
Hello,
I just started learing verilog and i have 2 problems.
First one, i can't find an useful documentation on internet which might help me to solve my homework.
Second one, its the homework :D.
I have to make a program in verilog which calculates the difference between 2 numbers of 16 bits.
The problem is that i don't know how to test my design, i did try to put a=305, b=540 but when i run it (simulate-add to wave-run ) i don't see the binary signal, it shows me somthing green with this text inside 16`h0000. Can you tell me the right way to initiate the variables?
My code:
Code:
module Difft;
  reg [15:0]a;
  reg [15:0]b;
  wire [15:0]c;
  initial begin
    a=0;
    b=0;
    #2 a=70;
    b=35;
  end
  Diff DUT(.a(a),.b(b),.c(c));
endmodule
Code:
module Diff(input [15:0]a,input [15:0]b,output [15:0] c);
  assign c=a-b;
endmodule
 
Physics news on Phys.org
  • #2
To initiate the variables, you can use an initial block in your code. The initial block will allow you to set the values of the variables when the simulation starts. You can also use the '#' operator to specify a delay before the value of the variable is set. For example, to set the value of a to 305 and b to 540 you would use the following code: initial begin a=305; #2 b=540;endYou can then use simulation tools to view the binary signal.
 

Related to How Do You Test a 16-Bit Difference Calculation in Verilog?

1. What is Multisim and Verilog?

Multisim is a software program used for circuit design, simulation, and analysis. Verilog is a hardware description language used for designing and modeling digital systems.

2. How do I get started with Multisim and Verilog?

To get started, you can download Multisim from the official website and use online tutorials or user guides to learn the basics. For Verilog, you can use online resources or books to learn the syntax and get familiar with the language.

3. Can Multisim and Verilog be used for both analog and digital circuits?

Yes, Multisim and Verilog can be used for both analog and digital circuits. Multisim has a wide range of components and simulation capabilities for both types of circuits. Verilog is primarily used for digital systems, but it can also be used for analog circuits with some additional tools and techniques.

4. Are there any alternatives to using Multisim and Verilog?

Yes, there are other software programs and hardware description languages that can be used for circuit design and simulation. Some popular alternatives to Multisim include LTSpice, Proteus, and PSpice. Other languages similar to Verilog include VHDL and SystemVerilog.

5. Can Multisim and Verilog be used for large and complex circuits?

Yes, both Multisim and Verilog can handle large and complex circuits. Multisim has advanced simulation capabilities and Verilog has modular design principles that make it suitable for complex systems. However, for very large and complex circuits, there may be more specialized software and languages available.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
19K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
20K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
9K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
Back
Top