|
module df(f1hz,fin,doutt,coutt); input f1hz,fin; output [15:0] doutt; output coutt; wire [15:0] doutt; wire loadt; wire cnt_ent,rst_cntt; wire[3:0] outy1,outy2,outy3,outy4; wire cout1,cout2,cout3; testct1 u1(.clkk(f1hz),.cnt_en(cnt_ent),.rst_cnt(rst_cntt),.load(loadt)); cnt10 u2(.clk(fin),.rst(rst_cntt),.ena(cnt_ent),.outy(outy1),.cout(cout1)); cnt10 u3(cout1,rst_cntt,cnt_ent,outy2,cout2); cnt10 u4(cout2,rst_cntt,cnt_ent,outy3,cout3); cnt10 u5(cout3,ret_cntt,cnt_ent,outy4,coutt); reg4b u6(.load(loadt),.din(outy1),.dout(doutt[3:0])); reg4b u7(.load(loadt),.din(outy2),.dout(doutt[7:4])); reg4b u8(.load(loadt),.din(outy3),.dout(doutt[11:8])); reg4b u9(.load(loadt),.din(outy4),.dout(doutt[15:12])); endmodule
module testct1(clkk,cnt_en,rst_cnt,load); input clkk; output cnt_en,rst_cnt,load; reg rst_cnt; reg div2clk; always@(posedge clkk) begin div2clk=~div2clk; end always@(clkk or div2clk) begin if((clkk=='b0)&(div2clk=='b0)) rst_cnt='b1; else rst_cnt='b0; end
assign load=~div2clk; assign cnt_en=div2clk; endmodule module cnt10(clk,rst,ena,outy,cout); input clk,rst,ena; output[3:0] outy; output cout; reg[3:0] outy; always@(posedge clk) begin if(rst) uty='b0000; else if(ena) begin if(outy<'b1001) uty=outy+1; else uty='b0000; end end assign cout=outy[3]&outy[0]; endmodule
module reg4b(load,din,dout); input[3:0] din; input load; output[3:0] dout; reg[3:0]dout; always@(posedge load) begin dout=din; end endmodule
|