?? counter_tc.v
字號:
//********************************************************
// Filename: counter_tc.v
//
// Parameterized counter module with sync reset
// and terminal count.
//********************************************************
module counter_tc(clk, reset, q, tc);
parameter N = 8; // number of bits
parameter TCNT = 256; // desired terminal count
input clk, reset;
output tc;
reg tc;
output [N-1:0] q;
reg [N-1:0] q;
// check for one less than what you want ...
wire tc_tmp;
assign tc_tmp = (q==TCNT-2);
// ... then register (causes 1-cycle delay)
always @(posedge clk)
if (reset) tc <= 0;
else tc <= tc_tmp;
// counter
always @(posedge clk)
if (reset) q <= 0;
else
begin
if (tc) q <= 0;
else q <= q + 1;
end
endmodule
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -