1 / 23

Understanding Registers in Computer Architecture

Learn about registers, a small storage in CPUs, their role in RAM data management, and building a register file using VHDL in this detailed guide.

mackeys
Download Presentation

Understanding Registers in Computer Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 05 Sen Ma

  2. What is a Register ? “In computer architecture, a register is a small amount of storage available as part of a CPU. ” --Wikipedia

  3. What is Register ? “In computer architecture, a register is a small amount of storage available as part of a CPU. ” --Wikipedia Data in the Random-access memory (RAM)

  4. What is Register ? “In computer architecture, a register is a small amount of storage available as part of a CPU. ” --Wikipedia Data in the Random-access memory (RAM) Registers are stored in a structure called a register file which impalement by using RAM.

  5. What is Register ? Register File’s name Reg_File Assume we have 10 registers. R0 ~ R9 Each register has 16bits. Another assumption R0 = 0 and R1 = 1 (forever)

  6. What is Register ? Reg_File Oh Yeah, we have registers! We can design our own instructions How about this: R2 = R0 + R1

  7. What is Register ? Reg_File Oh Yeah, we have registers! We can design our own instructions How about this: R2 = R0 + R1 R2 = R0 + R1

  8. What is Register ? Reg_File Oh Yeah, we have registers! We can design our own instructions How about this: R2 = R0 + R1 R2 = R0 + R1

  9. What is Register ? Reg_File Oh Yeah, we have registers! We can design our own instructions How about this: R2 = R0 + R1 R2 = R0 + R1 We have already know the assembly language: R2 = R0 + R1 add R2, R0, R1

  10. What is Register ? Reg_File One more! add R3, R1, R2

  11. What is Register ? Reg_File One more! add R3, R1, R2

  12. What is Register ? Reg_File Behind the scene: You can think about the Reg_File is an Array. When you read from or write in the register, it is same operation on an array which you have already know.

  13. What is Register ? Register File’s name (array’s name) Reg_File Same Example: add R3, R1, R2 1 step, Read R1: Reg_File[1]

  14. What is Register ? Reg_File Same Example: add R3, R1, R2 1 step, Read R1: Reg_File[1] 2 step, Read R2: Reg_File[2]

  15. What is Register ? Reg_File Same Example: add R3, R1, R2 1 step, Read R1: Reg_File[1] 2 step, Read R2: Reg_File[2] 3 step Add Reg_File[1] + Reg_File[2]

  16. What is Register ? Reg_File Same Example: add R3, R1, R2 1 step, Read R1: Reg_File[1] 2 step, Read R2: Reg_File[2] 3 step Add Reg_File[1] + Reg_File[2] 4 step, Write R3: Reg_File[3] = Reg_File[1] + Reg_File[2]

  17. Register in VHDL Define an array in VHDL: type ram_type is array (15 downto 0) of std_logic_vector(15 downto 0); Reg_File

  18. Register in VHDL Define an array in VHDL: typeram_type is array (15 downto 0) of std_logic_vector(15 downto 0); Reg_File Define a type named “ram_type” which is a array with 16 item. Each item is a 16bits vector

  19. Register in VHDL Define an array in VHDL: typeram_type is array (15 downto 0) of std_logic_vector(15 downto 0); signalReg_File : ram_type; Reg_File Using the “ram_type” to define a signal named “Reg_File”.

  20. Register in VHDL Define an array in VHDL: typeram_type is array (15 downto 0) of std_logic_vector(15 downto 0); signalReg_File : ram_type; Reg_File Same Example: add R3, R1, R2 Reg_File(3) <= Reg_File(1) +Reg_File(2);

  21. Register clk b_data clear c_data A_addr A_data load b_addr c_addr

  22. Register Entity Register is port( clk: instd_logic; -- positive edge triggered clock clear: instd_logic; -- asynchronous reset a_addr: instd_logic_vector( 3 downto 0); -- input data port a_data: instd_logic_vector(15 downto 0); -- register select for input a load: instd_logic; -- load enable b_addr: instd_logic_vector( 3 downto 0); -- register select for output b c_addr: instd_logic_vector( 3 downto 0); -- register select for output c b_data: out std_logic_vector(15 downto 0); -- first output data port c_data: out std_logic_vector(15 downto 0) -- second output data port ); End Register;

  23. Register Requirements: • Create a register file. • It should have 16 registers, each being sixteen bits wide. • When the load signal is asserted, a rising edge on clk cause the data on a_data to be stored in the register identified by a_addr. • If the load signal is not asserted, a rising clock edge has no effect. • The data on b_data should be the contents of the register identified by b_addr. • The data on c_data should be the contents of the register identified by c_addr. • Register 0 always contains the value 0. Writing to register 0 is ignored. • Register 1 always contains the value 1. Writing to register 1 is ignored. • When the clear signal is 0, all registers (other than register 1) are reset to 0. Note that this is asynchronous. • Follow the instruction on page 129~130 in Xilinx XST User Guide, reference the example code to implement your own register file.

More Related