惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
博客园 - Franky
D
DataBreaches.Net
B
Blog
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
WordPress大学
WordPress大学
P
Proofpoint News Feed
J
Java Code Geeks
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Martin Fowler
Martin Fowler
月光博客
月光博客
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
博客园 - 【当耐特】

莫拉维克猫屋

4D Radar - A Novel Sensing Paradigm for 3D Object Detection 粗略的cs231n学习笔记 simulink仿真数字通信系统 基于开源的livego搭建直播服务器 EDA实验二 功能可调综合计时器 NodeMCU-ESP8266联网获取实时天气并使用lcd1602显示 SSM框架:导出数据库内容到Excel表格 Java网络编程-TCP通信 我要这差分放大电路有何用? Hello World
EDA实验一 指令运算单元设计——第一次用FPGA开发板
liuzengyun · 2020-11-15 · via 莫拉维克猫屋

设计一个指令运算单元ALU,完成功能如下。
(1)操作类型1:将操作数1作为一个无符号二进制数,在七段管以十进制显示二进制序列等效值。
(2)操作类型2:实现操作数3、操作数4之间相加、减、乘的操作,在七段管以十/十六进制进制显示操作数和结果。操作数3和4为BCD码表示的2位十进制数(表示的值为00-99)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
module lab1(sw,hex0,hex1,hex2,hex3,hex4,hex5,hex6,hex7);
input[17:0] sw;
output[6:0] hex0,hex1,hex2,hex3,hex4,hex5,hex6,hex7;
reg[4:0] h7,h6,h5,h4,h3,h2,h1,h0;
reg[15:0] o1,o2,s;
reg[17:0] sw0;

always@(*)
begin
if(sw[3:0]>9) sw0[3:0]=9;
else sw0[3:0]=sw[3:0];
if(sw[7:4]>9) sw0[7:4]=9;
else sw0[7:4]=sw[7:4];
if(sw[11:8]>9) sw0[11:8]=9;
else sw0[11:8]=sw[11:8];
if(sw[15:12]>9) sw0[15:12]=9;
else sw0[15:12]=sw[15:12];

if(sw[17:16]==0)
begin
h7=16;
h6=16;
h5=16;
h0=sw[15:0]%10;
h1=sw[15:0]/10%10;
h2=sw[15:0]/100%10;
h3=sw[15:0]/1000%10;
h4=sw[15:0]/10000;
show(h0,hex0);
show(h1,hex1);
show(h2,hex2);
show(h3,hex3);
show(h4,hex4);
end
else if(sw[17:16]==1)
begin
o1=sw0[15:12]*10+sw0[11:8];
o2=sw0[7:4]*10+sw0[3:0];
s=o1+o2;
h7=sw0[15:12];
h6=sw0[11:8];
h5=sw0[7:4];
h0=s%10;
h1=s/10%10;
h2=s/100;
h3=16;
h4=sw0[3:0];
show(h0,hex0);
show(h1,hex1);
show(h2,hex2);
show(h3,hex3);
show(h4,hex4);
show(h5,hex5);
show(h6,hex6);
show(h7,hex7);
end
else if(sw[17:16]==2)
begin
o1=sw0[15:12]*10+sw0[11:8];
o2=sw0[7:4]*10+sw0[3:0];
s=o1*o2;
h7=sw0[15:12];
h6=sw0[11:8];
h5=sw0[7:4];
h0=s%10;
h1=s/10%10;
h2=s/100%10;
h3=s/1000%10;
h4=sw0[3:0];
show(h0,hex0);
show(h1,hex1);
show(h2,hex2);
show(h3,hex3);
show(h4,hex4);
show(h5,hex5);
show(h6,hex6);
show(h7,hex7);
end
else if(sw[17:16]==3)
begin
o1=sw0[15:12]*10+sw0[11:8];
o2=sw0[7:4]*10+sw0[3:0];
if(o1>=o2)
begin
s=o1-o2;
h7=sw0[15:12];
h6=sw0[11:8];
h5=sw0[7:4];
h0=s%10;
h1=s/10%10;
h2=s/100%10;
h3=16;
h4=sw0[3:0];
show(h0,hex0);
show(h1,hex1);
show(h2,hex2);
show(h3,hex3);
show(h4,hex4);
show(h5,hex5);
show(h6,hex6);
show(h7,hex7);
end
else
begin
s=o2-o1;
h7=sw0[15:12];
h6=sw0[11:8];
h5=sw0[7:4];
h0=s%10;
h1=s/10%10;
h2=s/100%10;
h3=10;
h4=sw0[3:0];
show(h0,hex0);
show(h1,hex1);
show(h2,hex2);
show(h3,hex3);
show(h4,hex4);
show(h5,hex5);
show(h6,hex6);
show(h7,hex7);
end
end
end

task show;
input reg[3:0] decc;
output reg[6:0] out;
if(decc==0) out=7'b1000000;
else if(decc==1) out=7'b1111001;
else if(decc==2) out=7'b0100100;
else if(decc==3) out=7'b0110000;
else if(decc==4) out=7'b0011001;
else if(decc==5) out=7'b0010010;
else if(decc==6) out=7'b0000010;
else if(decc==7) out=7'b1111000;
else if(decc==8) out=7'b0000000;
else if(decc==9) out=7'b0011000;
else if(decc==10)out=7'b0111111;
else out=7'b1111111;
endtask
endmodule