Access over 20 million homework & study documents

Create a Verilog module that implements an 8 bit 2s complement upd

Content type
User Generated
Rating
Showing Page:
1/2
Create a Verilog module that implements an 8-bit 2\'s
complement up/down counter with a synchronous reset to
zero and a special feature: It should not overflow. If it\'s
counting up and it hits the max positive, it should stay at
that count and not roll over into a negative number.
Similarly when counting down, if it hits the max negative, it
should stay at that value.
Solution
Code:
module counter(upOrDown,reset,clk,out);
input upOrDown,reset,clk;
output reg [7:0] out;
always @(posedge clk)
begin
if(reset)
out <= 0;
else if (upOrDown)
begin
if(out == 8\'d127)
out <= out;
else
out <= out +1 ;

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
Create a Verilog module that implements an 8 -bit 2\'s complement up/down counter with a synchronous reset to zero and a special feature: It should not overflow. If it \'s counting up and it hits the max positive, it should stay at that count and not roll over into a negative number. Similarly when counting down, if it hits the max negative, it should stay at that value. Solution Code: module counter(upOrDown,reset,clk,out); input upOrDown,reset,clk; output reg [7:0] out; always @(posedge clk) begin if(reset) out ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Nice! Really impressed with the quality.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4