[an error occurred while processing this directive]
|
Page 161:
Example:
This example defines a function called clogb2 that returns an integer which has the value of the ceiling of
the log base 2.
An instance of this ram_model with parameters assigned:
ram_model #(32,421) ram_a0(a_addr,a_wr,a_cs,a_data);
module ram_model (address, write, chip_select, data);
parameter data_width = 8;
parameter ram_depth = 256;
localparam adder_width = clogb2(ram_depth);
input [adder_width - 1:0] address;
input write, chip_select;
inout [data_width - 1:0] data;
//define the clogb2 function
function integer clogb2;
input depth;
integer i,result;
begin
for (i = 0; 2 ** i < depth; i = i + 1)
result = i + 1;
clogb2 = result;
end
endfunction
reg [data_width - 1:0] data_store[0:ram_depth - 1];
//the rest to the ram model
E-mail: info@telesys.ru