lecture21 - ECE 4514 Digital Design II Spring 2008 Lecture...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ECE 4514 Digital Design II Spring 2008 Lecture 21: Patrick Schaumont Spring 2008 ECE 4514 Digital Design II Lecture 21: Functions and Tasks Functions and Tasks A Language Lecture Patrick Schaumont Tasks and Functions b Help with the reusability of writing code module abc(...); map into a single function or task module abc(...); call Patrick Schaumont Spring 2008 ECE 4514 Digital Design II Lecture 21: Functions and Tasks endmodule endmodule Tasks vs Functions Tasks Functions Tasks, as well as functions, are behavioral constructs. They support expressions, if-then, case, loop statements They are local to a module, and called from within initial and always blocks. Patrick Schaumont Spring 2008 ECE 4514 Digital Design II Lecture 21: Functions and Tasks b Can contain event control (@, #, wait) b May execute in non-zero simulation time b Can have zero or more arguments of type in, out, inout b Cannot contain event control (@, #, wait) b Must execute in zero simulation time b Must have at least in input argument, and has a single output argument Functions module andorgate(q, a, b); output [1:0] q; input a, b; function mygate; input x, y; input op; case (op) 'b0: ygate x & y; Patrick Schaumont Spring 2008 ECE 4514 Digital Design II Lecture 21: Functions and Tasks 1'b0: mygate = x & y; 1'b1: mygate = x | y; default : mygate = 1'b0; endcase endfunction assign q[0] = mygate(a, b, 0); // and gate assign q[1] = mygate(a, b, 1); // or gate endmodule Functions module andorgate(q, a, b); output [1:0] q; input a, b; function mygate; input x, y; input op; case (op) 'b0: ygate x & y; x y op mygate Patrick Schaumont Spring 2008 ECE 4514 Digital Design II Lecture 21: Functions and Tasks 1'b0: mygate = x & y; 1'b1: mygate = x | y; default : mygate = 1'b0; endcase endfunction assign q[0] = mygate(a, b, 0); // and gate assign q[1] = mygate(a, b, 1); // or gate endmodule Functions module andorgate(q, a, b); output [1:0] q; input a, b; function mygate; input x, y; input op; case (op) 'b0: ygate x & y; x y op mygate Patrick Schaumont Spring 2008 ECE 4514 Digital Design II Lecture 21: Functions and Tasks 1'b0: mygate = x & y; 1'b1: mygate = x | y; default : mygate = 1'b0; endcase endfunction assign q[0] = mygate(a, b, 0); // and gate assign q[1] = mygate(a, b, 1); // or gate endmodule x y op Functions module andorgate(q, a, b); output [1:0] q; input a, b; function mygate; input x, y; input op; case (op) 'b0: ygate x & y; he logic is defined by Patrick Schaumont Spring 2008 ECE 4514 Digital Design II Lecture 21: Functions and Tasks 1'b0: mygate = x & y; 1'b1: mygate = x | y;...
View Full Document

This note was uploaded on 12/24/2011 for the course ECE 4514 taught by Professor Staff during the Fall '08 term at Virginia Tech.

Page1 / 27

lecture21 - ECE 4514 Digital Design II Spring 2008 Lecture...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online