You understood the structural description in Verilog.
You are currently using the Altera DE1 board.
Fine.
But you want more because you really want to understand how it works through a real example with your board.
And not a difficult one of course, a beginner tutorial with an easy example of instantiating a module from another module.
Let's get started.
We are going to create two files: an abstract and an object.
Object is an instantiation of abstract.
Really easy if you understand the object paradigm.
If you don't know what is this, just see the abstract as something that is needed to be instantiate to be real.
So our object will be sent to the board. The abstract cannot.
Once you have copied these two files, set object.v as top-level entity.
Then start compilation and send it to the board.
Each time you click KEY0 or KEY1, LEDR3 is lit.
// module abstract module abstract( input wire i0, i1, output reg result ); reg r0, r1; always @(i0, i1) begin r0 = ~i0 & ~i1; r1 = i0 & i1; result = r0 | r1; end endmodule
// module object module object( input wire [3:0] KEY, output wire [8:0] LEDR ); abstract( .i0(~KEY[0]), .i1(KEY[1]), .result(LEDR[3]) ); endmodule
A really easy example of how using modules in order to instante them.
If you get this example, the world is yours.
Well done, you've made it.
Comments
Lex van de Wiel (not verified)
Monday, November 5, 2018 - 10:25am
Permalink
I get how to use it, but I
I get how to use it, but I still have a question.
With Intel Quartus Prime (formerly Altera), using a generated testbench will generate BFMs (Bus Functional Models) that can be used for simulation.
Apart from the module calling, some values can also be changed by using the generated getters and setters functions.
So my question is: how do you call a function from a different module?
Add new comment