Design a 1-12 counter with the following inputs and outputs:
You have the following components available:
module count4( input clk, input enable, input load, input [3:0] d, output reg [3:0] Q );
The c_enable, c_load, and c_d outputs are the signals that go to the internal counter's enable, load, and d inputs, respectively. Their purpose is to allow these signals to be checked for correctness.
- module top_module (
- input clk,
- input reset,
- input enable,
- output [3:0] Q,
- output c_enable,
- output c_load,
- output [3:0] c_d
- ); //
- assign c_enable=enable;
- /*
- always@(posedge clk) begin
- if(reset||Q>=12) begin
- c_load<=0;
- c_d<=1;
- end
- else
- c_load<=1;
- end
- */
- assign c_load=(reset||(Q>=12&&enable)) ? 1:0;
- assign c_d=c_load;
- count4 the_counter (clk, c_enable, c_load, c_d,Q);
-
- endmodule