Advertisement
Guest User

comp_s32.comp

a guest
Aug 18th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. component comp "Two input digital comparator";
  2. pin in s_32 in0 "Inverting input to the comparator";
  3. pin in s_32 in1 "Non-inverting input to the comparator";
  4. pin out bit out "Normal output. True when \\fBin1\\fR > \\fBin0\\fR";
  5. pin out bit equal "Match output. True when difference between \\fBin1\\fR and \\fBin0\\fR is 0";
  6.  
  7. function _ fp "Update the comparator";
  8. license "GPL";
  9. ;;
  10. FUNCTION(_) {
  11. s_32 tmp = in1 - in0;
  12.  
  13. if(tmp < 0) {
  14. out = 0;
  15. equal = 0;
  16. } else if(tmp > 0){
  17. out = 1;
  18. equal = 0;
  19. } else {
  20. equal = 1;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement