基于CPLD的数字钟设计(二)
2006-04-28 11:24
375 查看
把代码改了一下,编译通过了,接下来得做仿真,除错了。呵呵,新手,自己鼓励一下自己!
/*+FHDR--------------------------------------------------------
file name: clock.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Clock: 1hz
Reset: Synchronous,Low
include: counter60.v
counter24.v
--------------------------------------
Keywords: Counter, Digital Clock
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
`include "counter60.v"
`include "counter24.v"
`include "sel.v"
module clock(clk,
fm_key,
fh_key,
reset,
h,
m,
s);
input clk;
input fm_key;
input fh_key;
input reset;
output [4:0] h;
output [6:0] m;
output [6:0] s;
counter60 counters (.clk(clk),
.reset(reset),
.cout(cout_s),
.out(s));
counter60 counterm (.clk(clkm),
.reset(reset),
.cout(cout_m),
.out(m));
counter24 counterh (.clk(clkh),
.reset(reset),
.cout(cout_h),
.out(h));
sel selm (.a(clk),
.b(cout_s),
.f(clkm),
.sel(fm_key));
sel selh (.a(clk),
.b(cout_m),
.f(clkh),
.sel(fh_key));
endmodule
/*+FHDR--------------------------------------------------------
file name: counter60.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
include: counter6.v
counter10.v
--------------------------------------
Keywords: Counter
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
`include "counter6.v"
`include "counter10.v"
module counter60(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [6:0] out;
wire cout_6;
wire cout_10;
wire [2:0] out_6;
wire [3:0] out_10;
counter6 counter6_1 (.clk(clk),
.reset(reset),
.cout(cout_6),
.out(out_6));
counter10 counter10(.clk(cout_6),
.reset(reset),
.cout(cout),
.out(out_10));
assign out = {out_6,out_10};
endmodule
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
`include "counter6.v"
`include "counter4.v"
module counter24(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [4:0] out;
wire cout_6;
wire cout_4;
wire [2:0] out_6;
wire [1:0] out_4;
counter6 counter6_0 (.clk(clk),
.reset(reset),
.cout(cout_6),
.out(out_6));
counter4 counter4 (.clk(cout_6),
.reset(reset),
.cout(cout),
.out(out_4));
assign out = {out_6,out_4};
endmodule
/*+FHDR--------------------------------------------------------
file name: counter6.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Keywords: Counter
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
module counter6(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [2:0] out;
reg cout;
reg [2:0] out;
reg [2:0] counter;
always@(posedge clk)
if(!reset)
out <= 0;
else
for(counter=1;counter<6;counter=counter+1)
out <= counter;
endmodule
/*+FHDR--------------------------------------------------------
file name: counter10.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Keywords: Counter
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
module counter10(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [3:0] out;
reg cout;
reg [3:0] out;
reg [3:0] counter;
always@(posedge clk)
if(!reset)
out <= 0;
else
for(counter=1;counter<10;counter=counter+1)
out <= counter;
endmodule
/*+FHDR--------------------------------------------------------
file name: counter4.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Keywords: Counter
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
module counter4(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [1:0] out;
reg cout;
reg [1:0] out;
reg [1:0] counter;
always@(posedge clk)
if(!reset)
out <= 0;
else
for(counter=1;counter<4;counter=counter+1)
out <= counter;
endmodule
/*+FHDR--------------------------------------------------------
file name: sel.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Keywords: select devise
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
module sel(a,
b,
f,
sel);
input a;
input b;
input sel;
output f;
assign f = (a||sel)&(!sel||b);
endmodule
/*+FHDR--------------------------------------------------------
file name: clock.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Clock: 1hz
Reset: Synchronous,Low
include: counter60.v
counter24.v
--------------------------------------
Keywords: Counter, Digital Clock
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
`include "counter60.v"
`include "counter24.v"
`include "sel.v"
module clock(clk,
fm_key,
fh_key,
reset,
h,
m,
s);
input clk;
input fm_key;
input fh_key;
input reset;
output [4:0] h;
output [6:0] m;
output [6:0] s;
counter60 counters (.clk(clk),
.reset(reset),
.cout(cout_s),
.out(s));
counter60 counterm (.clk(clkm),
.reset(reset),
.cout(cout_m),
.out(m));
counter24 counterh (.clk(clkh),
.reset(reset),
.cout(cout_h),
.out(h));
sel selm (.a(clk),
.b(cout_s),
.f(clkm),
.sel(fm_key));
sel selh (.a(clk),
.b(cout_m),
.f(clkh),
.sel(fh_key));
endmodule
/*+FHDR--------------------------------------------------------
file name: counter60.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
include: counter6.v
counter10.v
--------------------------------------
Keywords: Counter
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
`include "counter6.v"
`include "counter10.v"
module counter60(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [6:0] out;
wire cout_6;
wire cout_10;
wire [2:0] out_6;
wire [3:0] out_10;
counter6 counter6_1 (.clk(clk),
.reset(reset),
.cout(cout_6),
.out(out_6));
counter10 counter10(.clk(cout_6),
.reset(reset),
.cout(cout),
.out(out_10));
assign out = {out_6,out_10};
endmodule
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
`include "counter6.v"
`include "counter4.v"
module counter24(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [4:0] out;
wire cout_6;
wire cout_4;
wire [2:0] out_6;
wire [1:0] out_4;
counter6 counter6_0 (.clk(clk),
.reset(reset),
.cout(cout_6),
.out(out_6));
counter4 counter4 (.clk(cout_6),
.reset(reset),
.cout(cout),
.out(out_4));
assign out = {out_6,out_4};
endmodule
/*+FHDR--------------------------------------------------------
file name: counter6.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Keywords: Counter
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
module counter6(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [2:0] out;
reg cout;
reg [2:0] out;
reg [2:0] counter;
always@(posedge clk)
if(!reset)
out <= 0;
else
for(counter=1;counter<6;counter=counter+1)
out <= counter;
endmodule
/*+FHDR--------------------------------------------------------
file name: counter10.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Keywords: Counter
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
module counter10(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [3:0] out;
reg cout;
reg [3:0] out;
reg [3:0] counter;
always@(posedge clk)
if(!reset)
out <= 0;
else
for(counter=1;counter<10;counter=counter+1)
out <= counter;
endmodule
/*+FHDR--------------------------------------------------------
file name: counter4.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Keywords: Counter
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
module counter4(clk,
reset,
cout,
out);
input clk;
input reset;
output cout;
output [1:0] out;
reg cout;
reg [1:0] out;
reg [1:0] counter;
always@(posedge clk)
if(!reset)
out <= 0;
else
for(counter=1;counter<4;counter=counter+1)
out <= counter;
endmodule
/*+FHDR--------------------------------------------------------
file name: sel.v
Author: Clarke.Lee
E-mail: clarke.lee@163.com
--------------------------------------
Keywords: select devise
//-FHDR---------------------------------------------------------*/
`timescale 1ns/1ns
module sel(a,
b,
f,
sel);
input a;
input b;
input sel;
output f;
assign f = (a||sel)&(!sel||b);
endmodule
相关文章推荐
- 基于Quartus II 的FPGA/CPLD数字系统设计与应用(原理图编辑)
- 基于CPLD的数字钟设计(一)
- [论文学习]2014.04.28基于CPLD的LCOS场序彩色视频控制器设计
- 基于达芬奇技术的数字视频系统设计与实现
- 基于matlab的数字陷波器设计
- 基于FPGA/CPLD设计与实现UART(VHDL)
- 基于CPLD和LVPECL门电路的脉宽可调窄脉冲信号发生器设计
- DE2-70数字系统设计(4)--基于Nios的LCD显示
- 基于basys2用verilog设计多功能数字钟(重写)
- 基于信号完整性分析的高速数字PCB 的设计方法
- 基于basys2用verilog设计多功能数字钟(重写)
- 基于USB2.0的高分辨率数字摄像头设计
- 基于图像传感器的CPLD视觉系统设计
- 基于DVB-SI的数字有线电视机顶盒节目指南的设计实现
- 基于FPGA的数字秒表的设计
- 设计题目:基于CPLD/FPGA的出租车计费器
- 基于FPGA/CPLD设计与实现UART
- 基于至简设计法的数字时钟设计
- 基于单片机和CPLD的高精度数据采集系统设计
- 基于matlab的数字图像处理GUI设计