欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
步長可變的加減計數器
[打印本頁]
作者:
WeTiGY
時間:
2016-11-25 23:21
標題:
步長可變的加減計數器
本帖最后由 WeTiGY 于 2016-11-25 23:28 編輯
實驗六
步長可變的加減計數器
一、實驗目的
1、掌握加減法計數器以及特殊功能計數器的設計原理;
2、用HDL語言設計多功能計數器。
二、硬件需求
EDA/SOPC
實驗箱一臺。
三、實驗原理
計數器的步長是指計數器每次的改變量。在很多應用場合,都希望計數器的步長可變。所謂步長可變,也就是計數器的步長是一個不定值,具體是多少是要靠外部干預的,比如外部給定其步長為5,那么該計數器每次要么增加5,要么減少5,也就是說計數器每次的改變量是5。這種步長可變的計數器才具有一定的實際意義,比如在直接數字頻率合成DDFS中的地址累加器就是一個步長可變的遞增計數器。
四、實驗內容
本實驗要完成的任務就是設計一個
8
位的計數器,步長的改變量要求從
0
~
15
,實驗中用撥擋開關模塊的
SW1A
~
SW4A
來作為步長改變量的輸入,用按鍵
F1
來控制計數器的增減,具體要求為:當
F1
輸入為高時,計數器為步長可變的加計數器;當
F1
輸入為低時,計數器為步長可變的減計數器。計數器輸出的
Q
值用
七段數碼管模塊
來表示。實驗中計數器的時鐘頻率為了便于眼睛觀察,同上個實驗一樣用
1Hz
的時鐘。
第一個為分頻模塊:
module divider_module
(
CLK,f_Out
);
input CLK;
output f_Out;
parameter T1s=26'd50_000_000;
reg [25:0]Count1;
always @ ( posedge CLK )
if( Count1 == T1s)
Count1 <= 26'd0;
else
Count1 <= Count1 + 1'b1;
reg rf_Out;
always @ ( posedge CLK )
if( Count1 >= 26'd0 && Count1 <= 26'd25_000_000)
rf_Out <= 1'b0;
else
rf_Out <= 1'b1;
assign f_Out = rf_Out;
endmodule
復制代碼
第二個為數碼管模塊:
module hex_module
(
f_Out,hex_one,hex_two,Q
);
input f_Out;
input [7:0] Q;
output [6:0] hex_one;
output [6:0] hex_two;
parameter _0=7'b0000001, _1=7'b1111001, _2=7'b0010010, _3=7'b0000011, _4=7'b1001100, _5=7'b0100100,
_6=7'b0100000, _7=7'b0001111, _8=7'b0000000, _9=7'b0000100, _A=7'b0001000, _B=7'b1100000,
_C=7'b0110001, _D=7'b1000010, _E=7'b0110000, _F=7'b0111000;
reg [7:0] i;
reg [7:0] u;
reg [6:0] rhex_one;
reg [6:0] rhex_two;
always@(posedge f_Out)
begin
i<=Q>>4;
case(i)
8'd0 : rhex_one<=_0; //0
8'd1 : rhex_one<=_1; //1
8'd2 : rhex_one<=_2; //2
8'd3 : rhex_one<=_3; //3
8'd4 : rhex_one<=_4; //4
8'd5 : rhex_one<=_5; //5
8'd6 : rhex_one<=_6; //6
8'd7 : rhex_one<=_7; //7
8'd8 : rhex_one<=_8; //8
8'd9 : rhex_one<=_9; //9
8'd10: rhex_one<=_A; //A
8'd11: rhex_one<=_B; //B
8'd12: rhex_one<=_C; //C
8'd13: rhex_one<=_D; //D
8'd14: rhex_one<=_E; //E
8'd15: rhex_one<=_F; //F
default: rhex_one<=_F; //F
endcase
u<=Q&8'h0f;
case(u)
8'd0 : rhex_one<=_0; //0
8'd1 : rhex_one<=_1; //1
8'd2 : rhex_one<=_2; //2
8'd3 : rhex_one<=_3; //3
8'd4 : rhex_one<=_4; //4
8'd5 : rhex_one<=_5; //5
8'd6 : rhex_one<=_6; //6
8'd7 : rhex_one<=_7; //7
8'd8 : rhex_one<=_8; //8
8'd9 : rhex_one<=_9; //9
8'd10: rhex_one<=_A; //A
8'd11: rhex_one<=_B; //B
8'd12: rhex_one<=_C; //C
8'd13: rhex_one<=_D; //D
8'd14: rhex_one<=_E; //E
8'd15: rhex_one<=_F; //F
default: rhex_one<=_F; //F
endcase
end
assign hex_one=rhex_one;
assign hex_two=rhex_two;
endmodule
復制代碼
第三個為計數模塊:
module ecount_module
(
f_Out,F1,D,Q
);
input f_Out;
input F1;
input [3:0] D;
output [7:0] Q;
reg [7:0] Q;
always@(posedge f_Out)
case(F1)
1'b1: begin
if(Q<8'd255) Q<=Q+D;
else Q<=8'b0;
end
1'b0: begin
if(Q>8'd0) Q<=Q-D;
else Q<=8'd255;
end
default: Q<=8'd255;
endcase
endmodule
復制代碼
第四個為頂層模塊:
module top_module
(
CLK,F1,D,hex_one,hex_two
);
input CLK;
input F1;
input [3:0] D;
output [6:0] hex_one;
output [6:0] hex_two;
divider_module u1
(
.CLK(CLK),
.f_Out(f_Out)
);
wire f_Out;
ecount_module u2
(
.f_Out(f_Out),
.D(D),
.F1(F1),
.Q(Q)
);
wire [7:0] Q;
hex_module u3
(
.f_Out(f_Out),
.hex_one(hex_one),
.hex_two(hex_two),
.Q(Q)
);
endmodule
復制代碼
注:仿真使用20分頻
仿真圖:
snjnsoi.jpg
(61.35 KB, 下載次數: 97)
下載附件
2016-11-25 23:20 上傳
作者:
dlq0000
時間:
2019-11-14 14:42
為什么我的仿真結果都是0啊
作者:
17509086609
時間:
2019-12-30 00:57
有沒有安裝包
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1