Parameters choose logic functionality
Example: Choose adder or subtractor
‘define ADD 0
‘define SUB 1
module addsub (a, b, c);
parameter width = 8;
parameter op = `ADD;
input [width-1:0] a, b;
output [width-1:0] c;
assign c = (op == `ADD) ? (a + b) : (a - b);
endmodule
...
addsub #(32,`SUB) c32(x, y, z);
...
Previous slide
Next slide
Back to first slide
View graphic version