Professional Documents
Culture Documents
Objectives:
Getting used to Modelsim software
Creating a Verilog file in Modelsim
Compiling and simulating a Verilog module
Analyzing the timing diagram of a Verilog Module
Software Used:
Modelsim
In Lab
Open modelsim in your PC and goto file->new->project as shown in fig:1
Click create new file and a new window will open up as shown in figure:3
Now press Ok
After this the file you created will appear in the workspace window as shown in figure:4
Try to keep the module name and file name same to avoid any error
A new window will appear as shown in figure:5 here you have to type your verilog code
Now press save and goto the work space window and select created file and than left and goto
if there is no error a check mark indication will be placed in front of the file as shown in figure:7
Now our design is ready and now we have to test it for this we have to create a test bench
Left click anywhere in workspace window and goto add to project->new file
Add name of the file and select type as verilog and press ok
Now edit this file and create a test bench for the module eample1 in this case
The verilog code for the test bench is shown below in figure:9
Now save this code and goto workspace window and select tb_example1.v file and left click on it and
compile it
Now select the tb_example1 file and goto simulate and goto work->tb_example and press ok as shown in
figure:10
Now in work space window a new simulation panel will appear as shown in figure:11
Now in sim panel right click on tb_example1 goto add to wave and a new window will appear here click
run to view simulation as shown in figure 12
In this task , you will run your first programme in Verilog which is a high-level language for ASIC design
and FPGA programming. Essentially it converts all logic into gates.
Create a file main .v (in a folder ‘hello') using notepad containing following code:
module main;
integer i;
initial
begin
$display("Hello, World");
$display("The system is up !");
for (i=0;i<5;i=i+1)
begin
$display(i);
end
end
endmodule
Goto File >> Change Directory and point to your ‘hello’ folder
Goto Work >> main. Double click to load simulation
Task 1:
Write Verilog code for following design
Task 2
Generate Fibonacci series using a verilog program