verilog课程设计
Ⅰ 二位整数平方运算器verilog语言实现,课程设计呀
你好,使用以下程序即可,使用时只需改变N值,N的取值大小请看注释,此程序适合对任意时钟的整数分频(包括奇偶),此程序已通过验证。根据你的情况,想得到1HZ,N取50000000即可;想得到5HZ,N取10000000即可。/******************************************************************************************Author:BobLiuE-mail:[email protected]:EP2C8Q208C8Tool:Quartus8.1Function:实现时钟的任意整数分频Version:2012-1-9v1.0********************************************************************************************/molediv_N(inputCLK,//基准时钟outputCLK_div_N//N分频后得到的时钟);wire[31:0]N=20;//N为分频系数,N≥2即可,N的值为CLK除以CLK_div_N后取整(四舍五入)/********************产生备用时钟1***************/reg[31:0]cnt1;regCLK_div_N_1;always@(posedgeCLK)beginif(N%2==0)//如果N为偶数beginif(N==2)//如果N为2CLK_div_N_1<=~CLK_div_N_1;elsebeginif(cnt1==(N-2)/2)begincnt1<=0;CLK_div_N_1<=~CLK_div_N_1;endelsecnt1<=cnt1+1;endendelse//如果N为奇数beginif(cnt1==N-1)cnt1<=0;elsecnt1<=cnt1+1;if((cnt1==N-1)||(cnt1==(N-1)/2))CLK_div_N_1<=~CLK_div_N_1;else;endend/***********************产生备用时钟2*********************/wireCLK0=(N%2)?(~CLK):0;//如果N为偶数,备用时钟2(CLK_div_N_2)恒为0,即不需要用到此备用时钟reg[31:0]cnt2;regCLK_div_N_2;always@(posedgeCLK0)beginif(cnt2==N-1)cnt2<=0;elsecnt2<=cnt2+1;if((cnt2==N-1)||(cnt2==(N-1)/2))CLK_div_N_2<=~CLK_div_N_2;end/********************产生最终分频时钟************************/assignCLK_div_N=CLK_div_N_1|CLK_div_N_2;endmole--BobLiu原创
Ⅱ 求verilog跑马灯课程设计
mole led(clk,rst,led_out);
input clk,rst;
output [4:0]led_out;
reg [30:0]cnt;
reg clk_0;
reg [4:0]led_out;
reg state;
always @ (posedge clk_0 or negedge rst)
if (!)
begin
state <= 0;
led_out <= 5'b11111;
end
else
case (state)
0:begin
led_out <= 5'b11110;
state <= 1;
end
1:begin
led_out <= {led_out[0],led_out[4:1]};
state <= 1;
end
endcase
always @ (posedge clk or negedge rst) //分频,在板子上可以看清
if (!rst)
cnt <= 0;
else
if (cnt <= 499998)
cnt <= cnt+1;
else
if (cnt == 499999)
cnt <= 0;
always @ (posedge clk or negedge rst)
if (!rst)
clk_0 <= 0;
else
if (cnt == 49999)
clk_0 <= ~clk_0;
endmole
Ⅲ verilog HDL8路抢答器课程设计怎么写啊
我刚替别人写的五路的,没调试过,但是ISE11.4综合正确。自己改成8路吧
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 15:59:03 07/08/2010
// Design Name:
// Mole Name: qiangdaqi
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
mole qiangdaqi(clk,Input1,Input2,Input3,Input4,Input5,Input6,en,LED,beep,LED1,LED2,LED3,LED4,LED5
);
input clk;
input Input1;
input Input2;
input Input3;
input Input4;
input Input5;
input Input6;
input en;
output LED;
output beep;
output LED1;
output LED2;
output LED3;
output LED4;
output LED5;
reg Inputflag;
reg [3:0]cache;
reg beepflag;
reg LED1;
reg LED2;
reg LED3;
reg LED4;
reg LED5;
reg [7:0]LED;
reg beep;
integer i;
always@(posedge clk)
begin
if(en==1)
begin
if(Inputflag==0)
begin
if(Input1==1)
begin
LED1=1;
Inputflag=1;
beep=1;
#100
beep=0;
cache=9;
end
else if(Input2==1)
begin
LED2=1;
Inputflag=1;
beep=1;
#100
beep=0;
cache=9;
end
else if(Input3==1)
begin
LED3=1;
Inputflag=1;
beep=1;
#100
beep=0;
cache=9;
end
else if(Input4==1)
begin
LED4=1;
Inputflag=1;
beep=1;
#100
beep=0;
cache=9;
end
else if(Input5==1)
begin
LED5=1;
Inputflag=1;
beep=1;
#100
beep=0;
cache=9;
end
else
begin
end
end
if(Inputflag==1)
begin
if(i<=100)
begin
i=i+1;
end
else
begin
case(cache)
4'b0000:
begin
LED=8'b11111100;
LED1=0;
LED2=0;
LED3=0;
LED4=0;
LED5=0;
cache=0;
beep=1;
#5
beep=0;
#5
beep=1;
#5
beep=0;
end
4'b0001: LED=8'b01100000;
4'b0010: LED=8'b11011010;
4'b0011: LED=8'b11110010;
4'b0100: LED=8'b01100110;
4'b0101: LED=8'b10110110;
4'b0110: LED=8'b10111110;
4'b0111: LED=8'b11100000;
4'b1000: LED=8'b11111110;
4'b1001: LED=8'b11110110;
default: LED=8'b11111100;
endcase
cache=cache-1;
end
end
end
else
begin
beep=0;
LED=11111100;
i=0;
end
end
endmole
Ⅳ 诚求 eda课程设计 单窗口排队电路 verilog hdl程序
mole traffic(clk,urgency,east_west,south_north,led);
input clk;
input urgency;
output [7:0]east_west,south_north;
output [5:0]led;
reg [7:0]east_west,south_north;
reg [5:0]led;
initial begin
east_west<=8'b0;
south_north<=8'b0;
led<=6'b100001;end
always @(posedge clk)
begin if(urgency==1) led<=6'b100100;
else if(east_west==8'b0 && south_north==8'b0) begin
east_west<=8'b00101101;
south_north<=8'b00101000;
led<=6'b100001;end
else if(east_west==8'b00000110 && south_north==8'b1) begin
east_west<=8'b00000101;
south_north<=8'b00000101;
led<=6'b100010; end
else if(east_west==8'b1 && south_north==8'b1 && led[5]==1'b1) begin
east_west<=8'b00101000;
south_north<=8'b00101101;
led<=6'b001100; end
else if(east_west==8'b1 && south_north==8'b00000110) begin
east_west<=8'b00000101;
south_north<=8'b00000101;
led<=6'b010100;end
else if(east_west==8'b1 && south_north==8'b1 && led[2]==1'b1) begin
east_west<=8'b00101101;
south_north<=8'b00101000;
led<=6'b100001; end
else if(east_west[3:0]==4'b0000) begin
east_west<=east_west-8'b111;
south_north<=south_north-1'b1; end
else if(south_north[3:0]==4'b0000) begin
east_west<=east_west-1'b1;
south_north<=south_north-8'b111; end
else begin
east_west<=east_west-1'b1;
south_north<=south_north-1'b1;
end
end
endmole
上面是我前一段时间写的交通灯控制器设计代码,相应的英文字母对应相应的信号
Ⅳ 求verilog简单cpu课程设计
mole clk_div(clk,out1,out2);
input clk;
output out1,out2;
reg out1,out2;
reg [31:0]cnt1,cnt2;
always @(posedge clk)begin//50MHz分频计数
if(cnt1<32'd24999999)
cnt1 <=cnt1 + 32'd1;
else
cnt1 <=32'd0;
end
always @(posedge clk)//分频后的半周期反转
if(cnt1 == 0)
out1<=~out1;
always @(posedge clk)begin//5MHz分频计数
if(cnt2<32'd4999999)
cnt2 <=cnt2 + 32'd1;
else
cnt2 <=32'd0;
end
always @(posedge clk)//20%占空比
if(cnt2 == 32'd999999)
out2<=0;
else if(cnt2 == 32'd4999999)
out2<=1;
endmole
Ⅵ 求一个用verilog语言写的数字时钟 带闹钟功能,数电课程设计
搜一下:求一个用verilog语言写的数字时钟
带闹钟功能,数电课程设计
Ⅶ 课程设计出租车计价器,用VERILOG语言编写
我去年做过这个,和你的要求差不多,暂停键相当于你的停止计费键,停止键详单与你的归零键,换挡键你就不用管它(按一档的速度运行),晶振的能改成50M就行了,能调的通。
1.设计要求
设计一个出租车计费器,能按路程计费,具体要求如下
(1)实现计费功能,计费标准为:按行驶里程计费,起步价为6.00元,并在车行驶3km后按1.2元/km计费,当计费器达到或超过20元时,每公里加收50%的车费,车停止和暂停时不计费。
(2)现场模拟汽车的启动、停止、暂停、和换档等状态。
(3)设计数码管动态扫描电路,将车费和路程显示出来,各有两位小数。
2.设计原理
设该出租车有启动键、停止键、暂停键、和挡位键。启动键为脉冲触发信号,当其为一个脉冲时,表示汽车以启动,并根据车速的选择和基本车速发出响应频率的脉冲(计费脉冲)来实现车费和路程的计数,同时车费显示起步价;当停止键为高电平时,表示汽车熄火,同时停止发出脉冲,此时车费和路程计数清零;当暂停键为高电平时,表示汽车暂停并停止发出脉冲,此时车费和路程计数暂停;挡位键用来改变车速,不同的挡位对应着不同的车速,同时路程计数的速度也不同。
出租车计费器可分为两大模块:控制模块和译码显示模块,系统框图如图9-9-1所示。控制模块实现了计费和路程的计数,并且通过不同的挡位来控制车速 。译码显示模块实现十进制到4为十进制的转换以及车费和路程的显示 。
mole taxi(scan,seg7,dp,clk20mhz,clk,start,stop,pause,speep);
output[7:0] scan; //数码管地址选择信号
output[6:0] seg7; //7段显示控制信号(abcdefg)
output dp; //小数点
input clk20mhz; //系统时钟为20MHz
input clk; //计费时钟
input start; //汽车起动
input stop; //汽车停止
input pause; //汽车暂停
input[1:0] speep; //挡位(4个挡位)
reg[7:0] scan;
reg[6:0] seg7;
reg dp;
reg[15:0] money_reg; //车费寄存器
reg[15:0] distance_reg; //路程寄存器
reg[3:0] num; //控制车速的计数器
reg[15:0] dis; //千米计数器
reg d; //千米标志位
reg clk1khz; //1kHz的分频时钟,用于扫描数码管地址
reg[3:0] data;
reg[3:0] m_one,m_ten,m_hun,m_tho; //钱数的4位十进制表示
reg[3:0] d_one,d_ten,d_hun,d_tho; //路程的4位十进制表示
reg[15:0] count;
reg[15:0] comb1;
reg[3:0] comb1_a,comb1_b,comb1_c,comb1_d;
reg[15:0] comb2;
reg[3:0] comb2_a,comb2_b,comb2_c,comb2_d;
reg[2:0] cnt;
always @(posedge clk)
begin
if(stop) //汽车停止,计费和路程清零
begin money_reg<='d0;
distance_reg<='d0;
dis<='d0;
num<='d0;
end
else if(start) //汽车起动后,起步价为6元
begin money_reg<='d600;
distance_reg<='d0;
dis<='d0;
num<='d0;
end
else
begin
if(!start&&!speep&&!pause&&!stop) //1挡
begin
if(num=='d9)
begin num<='d0;
distance_reg<=distance_reg+1;
dis<=dis+1;
end
else
begin num<=num+1; end
end
else if(!start&&speep=='b01&&!pause&&!stop) //2挡
begin
if(num=='d9)
begin num<='d0;
distance_reg<=distance_reg+2;
dis<=dis+2;
end
else
begin num<=num+1; end
end
else if(!start&&speep=='b10&&!pause&&!stop) //3挡
begin
if(num=='d9)
begin num<='d0;
distance_reg<=distance_reg+5;
dis<=dis+5;
end
else
begin num<=num+1; end
end
else if(!start&&speep=='b11&&!pause&&!stop) //4挡
begin
distance_reg<=distance_reg+1;
dis<=dis+1;
end
end
if(dis>='d100)
begin d<='d1;dis<='d0; end
else
begin d<='d0; end
if(distance_reg>='d300) //如果超过3km则按1.2元/km计算
begin
if(money_reg<'d2000&&d=='d1)
begin money_reg<=money_reg+'d120; end
else if(money_reg>='d2000&&d=='d1)
begin money_reg<=money_reg+'d180; end
end
//-------------------当计费器达到20元时,每千米加收50%的车费-------------
end
//---------------------------1kHz的分频时钟,用于扫描数码管地址----------------------
always @(posedge clk20mhz)
begin
if(count=='d10000)
begin clk1khz<=~clk1khz;count<='d0; end
else
begin count<=count+1; end
//----------------------------将车费的十进制数转化为4位十进制数-----------------------
if(comb1<money_reg)
begin
if(comb1_a=='d9&&comb1_b=='d9&&comb1_c=='d9)
begin
comb1_a<='b0000;
comb1_b<='b0000;
comb1_c<='b0000;
comb1_d<=comb1_d+1;
comb1<=comb1+1;
end
else if(comb1_a=='d9&&comb1_b=='d9)
begin
comb1_a<='b0000;
comb1_b<='b0000;
comb1_c<=comb1_c+1;
comb1<=comb1+1;
end
else if(comb1_a=='d9)
begin
comb1_a<='b0000;
comb1_b<=comb1_b+1;
comb1<=comb1+1;
end
else
begin
comb1_a<=comb1_a+1;
comb1<=comb1+1;
end
end
else if(comb1==money_reg)
begin
m_one<=comb1_a;
m_ten<=comb1_b;
m_hun<=comb1_c;
m_tho<=comb1_d;
end
else if(comb1>money_reg)
begin
comb1_a<='b0000;
comb1_b<='b0000;
comb1_c<='b0000;
comb1_d<='b0000;
comb1<='d0;
end
//---------------------------将路程的十进制转化为4位十进制数-----------------------
if(comb2<distance_reg)
begin
if(comb2_a=='d9&&comb2_b=='d9&&comb2_c=='d9)
begin
comb2_a<='b0000;
comb2_b<='b0000;
comb2_c<='b0000;
comb2_d<=comb2_d+1;
comb2<=comb2+1;
end
else if(comb2_a=='d9&&comb2_b=='d9)
begin
comb2_a<='b0000;
comb2_b<='b0000;
comb2_c<=comb2_c+1;
comb2<=comb2+1;
end
else if(comb2_a=='d9)
begin
comb2_a<='b0000;
comb2_b<=comb2_b+1;
comb2<=comb2+1;
end
else
begin
comb2_a<=comb2_a+1;
comb2<=comb2+1;
end
end
else if(comb2==distance_reg)
begin
d_one<=comb2_a;
d_ten<=comb2_b;
d_hun<=comb2_c;
d_tho<=comb2_d;
end
else if(comb2>distance_reg)
begin
comb2_a<='b0000;
comb2_b<='b0000;
comb2_c<='b0000;
comb2_d<='b0000;
comb2<='d0;
end
end
//-----------------------------数码管动态扫描----------------------------------
always @(posedge clk1khz)
begin
cnt<=cnt+1;
end
always @(cnt)
begin
case(cnt)
'b000:begin data<=m_one;dp<='d0;scan<='b00000001; end
'b001:begin data<=m_ten;dp<='d0;scan<='b00000010; end
'b010:begin data<=m_hun;dp<='d1;scan<='b00000100; end
'b011:begin data<=m_tho;dp<='d0;scan<='b00001000; end
'b100:begin data<=d_one;dp<='d0;scan<='b00010000; end
'b101:begin data<=d_ten;dp<='d0;scan<='b00100000; end
'b110:begin data<=d_hun;dp<='d1;scan<='b01000000; end
'b111:begin data<=d_tho;dp<='d0;scan<='b10000000; end
default:begin data<='bx;dp<='bx;scan<='bx; end
endcase
end
//---------------------------------7段译码----------------------------------
always @(data)
begin
case(data[3:0])
4'b0000:seg7[6:0]=7'b1111110;
4'b0001:seg7[6:0]=7'b0110000;
4'b0010:seg7[6:0]=7'b1101101;
4'b0011:seg7[6:0]=7'b1111001;
4'b0100:seg7[6:0]=7'b0110011;
4'b0101:seg7[6:0]=7'b1011011;
4'b0110:seg7[6:0]=7'b1011111;
4'b0111:seg7[6:0]=7'b1110000;
4'b1000:seg7[6:0]=7'b1111111;
4'b1001:seg7[6:0]=7'b1111011;
default:seg7[6:0]=7'b0000000;
endcase
end
endmole
具体的反考周润景老师的那本书。
Ⅷ 急需!! verilog的课程设计 题目为自动饮料售卖机
呵呵
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity vendor is
port(
reset :in std_logic; --系统内部给其他顾客重新操作的复位信号
clk :in std_logic;
--由外接信号发生器提供的1024Hz系统时钟信号
ok_buy :in std_logic; --购买确认的按键信号
cancel_buy :in std_logic; --购买取消的按键信号
coin_5 :in std_logic; --投入五角硬币的动作按键
coin_10 :in std_logic; --投入壹圆硬币的动作按键
select_cola :in std_logic; --选择可口可乐的按键信号
select_pepsi :in std_logic; --选择百事可乐的按键信号
led_cola_ok :out std_logic; --灯亮显示还有可口可乐
led_pepsi_ok :out std_logic; --灯亮显示还有百事可乐
led_cola_sel :out std_logic; --灯亮显示可口可乐选择键被按
led_pepsi_sel :out std_logic; --灯亮显示百事可乐选择键被按
led_buy :out std_logic; --灯亮显示按了购买确认键
led_cancel :out std_logic; --灯亮显示按了购买取消键
led_five :out std_logic_vector(2 downto 0);
--3个LED,投入1个五角硬币亮一个LED
led_ten :out std_logic_vector(1 downto 0);
--2个LED,投入1个壹圆硬币亮一个LED
void drinkmachine::showchoices()
{
cout.precision(2);
cout.setf(ios::fixed);
cout<<endl<<"您投入的金额是"<<moneyctr.money_from_buyer()<<"元。"<<endl;
cout<<endl<<"请选择商品代码"<<endl;
for(int i=0;i<5;i++)
{
cout<<i<<" "<<v_goods[i].goods_name()
<<" "<<v_goods[i].goods_price()<<"元"<<endl;
}
cout<<"5 退款并且退出"<<endl;
return;
}
Ⅸ 求实现方波,梯形波的源程序verilog语言 数电课程设计 谢谢
实现方波梯形波的源程序verilog语言数电设计什么时候交稿?有什么具体要求么.