1、library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity adder is port( clk,rst : in std_logic; a,b : in std_logic_vector(3 downto 0); sum : out std_logic_vector(3 downto 0); c : out std_logic);end entity adder;architecture depict of adder issignal
2、 reg1: std_logic_vector(7 downto 0);signal reg2: std_logic_vector(6 downto 0);signal reg3: std_logic_vector(5 downto 0);begin bit0:process(clk,rst) begin if(rst=1) then reg1=00000000 elsif(rising_edge(clk) then reg1(0)= a(0) xor b(0); reg1(1)= a(0) and b(0); reg1(2)= a(1); reg1(3)= b(1); reg1(4)= a(
3、2); reg1(5)= b(2); reg1(6)= a(3); reg1(7)= b(3); end if; end process bit0; bit1: reg20000000 reg2(0)= reg1(0); reg2(1)= reg1(1) xor reg1(2) xor reg1(3); reg2(2)= (reg1(1) and reg1(2)or(reg1(1)and reg1(3)or(reg1(2)and reg1(3); reg2(6 downto 3)=reg1(7 downto 4); end process bit1; bit2: reg3000000 reg3
4、(1 downto 0)=reg2(1 downto 0); reg3(2)=reg2(2)xor reg2(3)xor reg2(4); reg3(3)=(reg2(2)and reg2(3)or(reg2(2)and reg2(4)or(reg2(3)and reg2(4); reg3(5 downto 4)=reg2( 6 downto 5); end process bit2; bit3: sum0000 c=0 sum(2 downto 0)=reg3(2 downto 0); sum(3)=reg3(3)xor reg3(4)xor reg3(5);=(reg3(3)and reg
5、3(4)or(reg3(3)and reg3(5)or(reg3(4)and reg3(5); end process bit3;end depict;entity noadd isend entity noadd;architecture depict of noadd issignal reg : std_logic_vector(4 downto 0);signal rega:signal regb: process(clk) begin if(rising_edge(clk)then rega& a; regb b; end if; end process; if(rst=)then
6、reg00000 elsif(rising_edge(clk)then=rega+regb; end if; sum=reg(3 downto 0); c=reg(4);4位十进制数计数器entity dec_disp is port(clk_cnt :sel1 :sel2 :sel3 :sel4 : out std_logic_vector(3 downto 0);end dec_disp;architecture behav of dec_disp issignal data1 : std_logic_vector(3 downto 0);signal data2 :signal data
7、3 :signal data4 : count:process(clk_cnt) if(rising_edge(clk_cnt)then if(data1=1001 data1 if(data2= data2=data1+1; if(data3= data3=data2+1; if(data4= data4=data3+1;=data4+1;end if;end process count;sel1=data1;sel2=data2;sel3=data3;sel4=data4;end behav;正弦波发生器sin.mif文件depth=256;width=8;address_radix=de
8、c;data_radix=dec;content 0: 131; 1: 134; 2: 137; 3: 141; 4: 144; 5: 147; 6: 150; 7: 153; 8: 156; 9: 159; 10: 162; 11: 165; 12: 168; 13: 171; 14: 174; 15: 177; 16: 180; 17: 183; 18: 186; 19: 188; 20: 191; 21: 194; 22: 196; 23: 199; 24: 202; 25: 204; 26: 207; 27: 209; 28: 212; 29: 214; 30: 216; 31!219
9、; 32:221; 33:223; 34:225; 35:227; 36:229; 37:231; 38:233; 39:234; 40:236; 41:238; 42:239; 43:241; 44:242; 45:244; 46:245; 47:246; 48:247; 49:249; 50:250; 51: 52:251; 53:252; 54:253; 55:254; 56: 57:255; 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
10、: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96:216; 97:214; 98:212; 99:209;100:207;101:204;102:202;103:199;104:196;105:194;106:191;107:188;108:186;109:183;110:180;111:177;112:174;113:171;114:168;115:165;116:162;117:159;118:156;119:153;120:150;121:147;122:144;123:141;124:137;125:134;126:131
11、;127:128;128:125;129:122;130:119;131:115;132:112;133:109;134:106;135:103;136:10;137:97;138:94;139:91;140:88;141:85;142:82;143:79;144:76;145:73;146:70;147:68;148:65;149:62;150:60;151:57;152:54;153:52;154:49;155:47;156:44;157:42;158:40;159:37;160:35;161:33;162:31;163:29;164:27;165:25;166:23;167:22;168
12、:20;169:18;170:17;171:15;172:14;173:12;174:11;175:176:9;177:7;178:6;179:180:5;181:4;182:3;183:2;184:185:1;186:187:188:0;189:190:191:192:193:194:195:196:197:198:199:200:201:202:203:204:205:206:207:208:209:210:211:212:213:214:215:216:217:218:219:220:221:222:223:224:225:226:227:228:229:230:231:232:233:234:235:236:70 ;237:238:239:240:241:242:243:244:245:246:100;247:248:249:250:251:252:253:254:255:end;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1