题目的意思是子模块四位二进制改成十二进制计数,并且是1-12。
因此初始的加载数据肯定为c_d = 1,关键点在于什么时候load,即load的条件,首先当子模块输出达到12时(且此时enable要是1)肯定要load,用Q=12&enable条件判断,其次reset置位的时候也要load用reset=1条件判断
- 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_load = (Q==12&enable | reset);
- assign c_enable = enable;
- assign c_d = 1;
-
- count4 the_counter (clk, c_enable, c_load, c_d, Q);
-
- endmodule