Skip to content

Instantly share code, notes, and snippets.

@christiaanb
Last active August 29, 2015 13:55
Show Gist options
  • Save christiaanb/8707744 to your computer and use it in GitHub Desktop.
Save christiaanb/8707744 to your computer and use it in GitHub Desktop.
interface addOne_i;
task automatic run (input integer a, output integer b);
b = a + 1;
endtask
endinterface
interface map_i #( parameter N=32, parameter type ELEMTYPE=logic )
( interface f );
task automatic run ( input ELEMTYPE arg [N-1:0]
, output ELEMTYPE res [N-1:0]);
for (int mapIter=0; mapIter < N; mapIter+=1)
f.run(arg[mapIter],res[mapIter]);
endtask
endinterface
module top (input integer in [7:0], output integer out [7:0]);
addOne_i addOne();
map_i #(.N($size(in)),.ELEMTYPE(integer)) map(addOne);
always_comb
map.run(in,out);
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment