Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module count_4bit(
- input cin,
- output cout,
- output count [3:0]
- );
- parameter timeconst = 60;//constant
- integer count0;
- integer count1;
- integer count2;
- integer count3;
- reg d;
- reg count;
- initial d = 1'b0;
- always @ (posedge cin)//begin
- begin
- count0 <= (count0 + 1);
- if ((count0 == timeconst))
- begin
- count <= 0;
- count1 <= (count1 +1);
- end
- else if ((count1 == timeconst))
- begin
- count1 <= 0;
- count2 <= (count2 + 1);
- end
- else if ((count2 == timeconst))
- begin
- count2 <= 0;
- count3 <= (count3 + 1);
- end
- else if ((count3 == timeconst))
- begin
- count3 <= 0;
- d <= ~ (d);
- end
- cout <= d;
- end
- endmodule
Add Comment
Please, Sign In to add comment