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語言數電設計什麼時候交稿?有什麼具體要求么.