Program counter

  The program is stored in memory with the first instruction at binary address 0000, the second instruction at address 0001, the third at address 0010 and so on.  The program counter, which is part of the control unit, counts from 0000 to 1111. Its job is to send to the memory the address of next instruction.

  The program counter is reset to 0000 before computer run. When the computer run begins, the program counter sends address 0000 to the memory. The program counter is then incremented to get 0001. After the first instruction is fetched and executed, the program counter sends address 0001 to the memory. Again the program counter is incremented. After the second isntruction is fetched and executed, the program counter sends address 0010 to the memory. In this way, the program counter is keeping track of the next instruction to be fetched and executed.

  The program counter is like someone pointing at a list of instruction, saying do this first, do this second, etc. This is why the program counter is sometimes called a pointer; it points to an address in memory where something important is being stored.

  1. library IEEE;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5. entity PC is
  6. port
  7. (
  8. EP : in std_logic;     --! Active high output enable from PC, or tri-state
  9. CLR : in std_logic;     --! Active high asynchronous clear
  10. CLK : in std_logic;      --! Falling edge clock
  11. CP : in std_logic;     --! Active high enable PC to count
  12. Q : out std_logic_vector( downto ) --! 4-bit PC output
  13. );
  14. end PC ;
  15.  
  16. architecture beh of PC is
  17.  
  18. signal count : std_logic_vector( downto );
  19.  
  20. begin
  21.  
  22. process (CLR,EP,CP,CLK,count)
  23. begin
  24. if CLR = '' then
  25. Q <= "";
  26. count <= "";
  27. elsif CP = '' then
  28. if (CLK'event and CLK = '') then
  29. if count < "" then
  30. count <= count + ;
  31. else
  32. count <= "";
  33. end if;
  34. end if;
  35. end if;
  36.  
  37. if EP = '' then
  38. Q <= "ZZZZ";
  39. else
  40. Q <= count;
  41. end if;
  42.  
  43. end process;
  44.  
  45. end beh;

Question: why do not use the following code in process?

  1. begin
  2. if EP = '' then
  3. Q <= "ZZZZ";
  4. elsif CLR = '' then
  5. Q <= "";
  6. count <= "";
  7. elsif CP = '' then
  8. if(CLK'event and CLK = '') then
  9. if count < "" then
  10. count <= count + ;
  11. else
  12. count <= "";
  13. end if;
  14. end if;
  15. end if;
  16.  
  17. end process;

Answer: first code, line 40, Q <= count


Own code for ASIC: use package ieee.numeric_std

  1. library IEEE;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;

  4. entity PC is
  5. port
  6. (
  7. EP : in std_logic; --! Active high output enable from PC, or tri-state
  8. CLR : in std_logic; --! Active high asynchronous clear
  9. CLK : in std_logic; --! Falling edge clock
  10. CP : in std_logic; --! Active high enable PC to count
  11. Q : out std_logic_vector( downto ) --! 4-bit PC output
  12. );
  13. end PC ;
  14.  
  15. architecture beh of PC is
  16.  
  17. signal count : std_logic_vector( downto );
  18.  
  19. begin
  20.  
  21. process (CLR,EP,CP,CLK,count)
  22. begin
  23. if CLR = '' then
  24. 25  -- Q <= "0000";
  25. count <= "";
  26. elsif CP = '' then
  27. if (CLK'event and CLK = '') then
  28. if count < "" then
  29. count <= std_logic_vector(unsigned(count) + );
  30. else
  31. count <= "";
  32. end if;
  33. end if;
  34. end if;
  35.  
  36. if EP = '' then
  37. Q <= "ZZZZ"; -- not good, in ASIC use only std_logic signal state '0', '1'
  38. else
  39. Q <= count;
  40. end if;
  41.  
  42. end process;
  43.  
  44. end beh;

 Question: In ASIC design, why use only std_logic signal states '0', '1'(and 'Z' for FPGA)???

SAP computer之program counter的更多相关文章

  1. 指令计数器--Program counter

    别名:指令指针.指令地址寄存器.程序计数器: 操作:顺序操作(计数器加一).分支操作(计数器修改): The program counter (PC), commonly called the ins ...

  2. SAP computer之input and MAR

    Input and MAR Below the program counter is the input and MAR block. It includes the address and data ...

  3. Will Georgia Tech's $7K online M.S. in computer science program make the grade?

    https://newatlas.com/georgia-tech--graduate-computer-science-degree-mooc/28763/ Georgia Tech to offe ...

  4. SAP computer之RAM

    RAM The RAM is a 16 X 8 static TTL RAM. We can program the RAM by means of the address and data swit ...

  5. SAP Module Pool Program Learning Documentation——Commit Work and Update dtab

    When using Native SQL to directly manipulate database tables, it makes a difference to use COMMIT WO ...

  6. SAP computer之architecture

    Simple-As-Possible computer introduces all the cruicial ideas behind computer operation without bury ...

  7. JVM之PC寄存器(Program Counter Register)

    基本特性: 当前线程执行的字节码的行号指示器. Java虚拟机支持多个线程同时执行,每一个线程都有自己的pc寄存器. 任意时刻,一个线程都只会执行一个方法的代码,称为该线程的当前方法,对于非nativ ...

  8. Application binary interface and method of interfacing binary application program to digital computer

    An application binary interface includes linkage structures for interfacing a binary application pro ...

  9. [Advance] How to debug a program (上)

    Tool GDB Examining Memory (data or in machine instructions) You can use the command x (for “examine” ...

随机推荐

  1. 【codeforces 765E】Tree Folding

    [题目链接]:http://codeforces.com/problemset/problem/765/E [题意] 给你一棵树; 可以把一个节点的两条相同长度的链合并成一条链; 且这两条相同长度的链 ...

  2. Master Nginx(7) - Nginx for the Developer

    Caching integration No application caching Caching in the database Caching in the filesystem Changin ...

  3. map put

    public class test { static Map<String, Map<String, Integer>> mapB = new HashMap<Strin ...

  4. 给sunpinyin加速

    因为sunpinyin词库一大就会卡,因此需要自己添加一个脚本给sunpinyin加速. 加速的原理就是把词库添加到内存,现在内存都这么大,根本不在乎这么几兆,当然输入体验更重要啦- 首先先建一个脚本 ...

  5. Istio是啥?一文带你彻底了解!

    原标题:Istio是啥?一文带你彻底了解! " 如果你比较关注新兴技术的话,那么很可能在不同的地方听说过 Istio,并且知道它和 Service Mesh 有着牵扯. 这篇文章可以作为了解 ...

  6. App的登陆注册接口安全设计

    最近一APP产品,我担任的主要模块之一是后台登录注册模块的接口开发.基本完成,就说说并记录一下关于登录注册接口的一些东西,因为也涉及到接口的安全方面的问题. 1.先一般的app的登录注册接口安全设计上 ...

  7. R语言为数据框添加列名或行名

    1.添加列名 wts=c(1,1,1) names(wts)=c("setosa","versicolor","virginica") 2. ...

  8. 一个神奇的PHP框架:Phalcon 之初识

    前言 公司的APP响应速度比较慢,公司大神决定使用C语言编写的PHP框架Phalcon 代替原来的框架,响应速度有比较大的提升.以前只是听说过,没有深入的了解过.即然工作中有用到,便花点时间了解了下, ...

  9. iOS: 在Swift中优雅的实现Substring

    在Swift中,当我们想要截取某个字符串时,方法如下: let carNumber = "沪A12345" let startIndex = advance(userCar.car ...

  10. CF #329 C

    C题我还以为是拉格朗日插值... 其实可以想象到,必须有这样一个函数,经过某一点时,其它圆相关的函数要为0. 于是,可以构造这样的一个函数,对于x有 (x/2)*(1-abs(t-i)+abs(1-a ...