ccyy's coding zone
往前走,不要留恋路边的风景.
posts - 25,comments - 9,trackbacks - 0
最近一堆事情纠结..期末考+嵌入式+EDA....力不从心中...很久没搭理博客了...TI杯的电子竞赛的选拔赛也没去参加...
无聊中....贴下实验报告...

1、 题目:
用余3码设计一模43的可逆计数器,并将结果以十进制输出。(设工作频率为20MHz)

2、 设计思想
将计数器分文为可逆计数器和译码部分两个进程,计数器由ctrl引脚控制,ctrl为高时为高电平时为加法计数器,来一个脉冲计数器加3,当ctrl为低的时候为剑法计数器,来一个脉冲计数器减3,译码部分将余三码转化为相应的结果,即将0,3,6,9等转化为0,1,2,3等

3、 源程序
C++语言: 临时自用代码
LIBRARY IEEE ;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY counter IS
port(clk,ctrl,clr:IN STD_LOGIC;qa,qb,qc,qd,qe,qf:OUT STD_LOGIC);
--end counter;
END ENTITY counter;
ARCHITECTURE tmp OF counter IS
SIGNAL count_8: STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL output_6: STD_LOGIC_VECTOR(5 DOWNTO 0);
BEGIN
    qa<=output_6(0);
        qb<=output_6(1);
        qc<=output_6(2);
        qd<=output_6(3);
        qe<=output_6(4);
        qf<=output_6(5);
count:PROCESS(clk,clr) IS
BEGIN
      IF(clr='1') THEN
             count_8<=(OTHERS=>'0');
        ELSIF(clk'EVENT AND clk='1')THEN
             IF(ctrl='1')THEN
                IF(count_8="01111110")THEN
                    count_8<="00000000";
                ELSE
                    count_8<=count_8+"00000011";
                 END IF;
          ELSE
                IF(count_8="00000000")THEN
                     count_8<="01111110";
                ELSE
                     count_8<=count_8-"00000011";
                 END IF;
             END IF;
        END IF;
END PROCESS count;


decode: PROCESS(count_8) IS
      BEGIN
          --IF(count_8'EVENT)THEN
             CASE count_8 IS
          WHEN "00000000"=>output_6<="000000";
WHEN"00000011"=>output_6<="000001";WHEN"00000110"=>output_6<="000010;
WHEN"00001001"=>output_6<="000011";WHEN"00001100"=>output_6<="000100;
WHEN "00001111"=>output_6<="000101";WHEN "00010010"=>output_6<="000110";
WHEN "00010101"=>output_6<="000111";WHEN "00011000"=>output_6<="001000";
WHEN "00011011"=>output_6<="001001";WHEN "00011110"=>output_6<="001010";
WHEN "00100001"=>output_6<="001011";WHEN "00100100"=>output_6<="001100";
WHEN "00100111"=>output_6<="001101";WHEN "00101010"=>output_6<="001110";
WHEN "00101101"=>output_6<="001111";WHEN "00110000"=>output_6<="010000";
WHEN "00110011"=>output_6<="010001";WHEN "00110110"=>output_6<="010010";
WHEN "00111001"=>output_6<="010011";WHEN "00111100"=>output_6<="010100";
WHEN "00111111"=>output_6<="010101";WHEN "01000010"=>output_6<="010110";
WHEN "01000101"=>output_6<="010111";WHEN "01001000"=>output_6<="011000";
WHEN "01001011"=>output_6<="011001";WHEN "01001110"=>output_6<="011010";
WHEN "01010001"=>output_6<="011011";WHEN "01010100"=>output_6<="011100";
WHEN "01010111"=>output_6<="011101";WHEN "01011010"=>output_6<="011110";
WHEN "01011101"=>output_6<="011111";WHEN "01100000"=>output_6<="100000";
WHEN "01100011"=>output_6<="100001";WHEN "01100110"=>output_6<="100010";
WHEN "01101001"=>output_6<="100011";WHEN "01101100"=>output_6<="100100";
WHEN "01101111"=>output_6<="100101";WHEN "01110010"=>output_6<="100110";
WHEN "01110101"=>output_6<="100111";WHEN "01111000"=>output_6<="101000";
WHEN "01111011"=>output_6<="101001";WHEN "01111110"=>output_6<="101010";
                WHEN OTHERS=>output_6<="000000";
                END CASE;
        --END IF;
   END PROCESS decode;
END tmp;
据说这届acm暑假集训又该在徐汇了啊...不错~~

在网上偶遇ZY大牛...ms ZY大神最近在拉人去创新工厂啊...听说有楼天成等大牛~~

李开复的《世界因你而不同》快看完了...膜拜中.....对一些跨国公司ms有了些了解...感觉自己真是啥都不知道的...- -||
阅读全文
类别:My Works 查看评论
文章来源:http://hi.baidu.com/%D2%EC%B6%C8%BF%D5%BC%E4%5F%B5%DA%CB%C4%CE%AC/blog/item/eb82dd1bbfdcd44842a9ad64.html
posted on 2010-07-01 23:35 ccyy 阅读(285) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理