Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views4 pages

COA Lab Assignments With Waveforms and Code

The document outlines lab assignments for designing a 32-bit CPU's Register Set and Program Counter using VHDL. It details the objectives, internal designs, and VHDL code implementations for a 1-bit register, a 32-bit register, and a 32-bit program counter. Additionally, it includes simulation results for the implementations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

COA Lab Assignments With Waveforms and Code

The document outlines lab assignments for designing a 32-bit CPU's Register Set and Program Counter using VHDL. It details the objectives, internal designs, and VHDL code implementations for a 1-bit register, a 32-bit register, and a 32-bit program counter. Additionally, it includes simulation results for the implementations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

COA Lab Assignments - Combined Report

Lab 1: CSE/IT 222: Design of Register Set and Program Counter


Objectives:
• To implement, simulate and test the Register Set required for the 32-bit CPU.
• To implement, simulate and test the 32-bit Program Counter (PC) required for the 32-bit
CPU.

1. Register Design
The processor requires several registers, either 32-bit or 1-bit. Main inputs include clock
(clk), clear (clr), load/enable (ld) signals and an n-bit data (d). The n-bit output is denoted
by (q). You need to implement a 1-bit and a 32-bit register using VHDL. Entity names:
register1 and register32.

2. Program Counter Design


The Program Counter (PC) is a key component with a 32-bit output (q) and several inputs:
clk, clr, 32-bit input (d), load/enable (ld), and increment (inc). The PC loads input (d) on the
rising clock edge when ld is high, and increments when inc is high.

3. Internal Design of 32-bit Program Counter


The inc input selects between d or incremented pc. clr, ld, and clk connect directly to an
internal 32-bit register. Implement a 32-bit PC in VHDL as described.

Demonstrate the implementation and simulation results for parts 1, 2, and 3.

Simulation Results
Below are the screenshots of waveform simulations for Register and Program Counter
implementations:
VHDL Code Implementations

1. VHDL Code for 1-bit Register (register1)

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity register1 is
Port ( clk : in STD_LOGIC;
clr : in STD_LOGIC;
ld : in STD_LOGIC;
d : in STD_LOGIC;
q : out STD_LOGIC);
end register1;

architecture Behavioral of register1 is


begin
process(clk, clr)
begin
if clr = '1' then
q <= '0';
elsif rising_edge(clk) then
if ld = '1' then
q <= d;
end if;
end if;
end process;
end Behavioral;

2. VHDL Code for 32-bit Register (register32)

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity register32 is
Port ( clk : in STD_LOGIC;
clr : in STD_LOGIC;
ld : in STD_LOGIC;
d : in STD_LOGIC_VECTOR(31 downto 0);
q : out STD_LOGIC_VECTOR(31 downto 0));
end register32;

architecture Behavioral of register32 is


begin
process(clk, clr)
begin
if clr = '1' then
q <= (others => '0');
elsif rising_edge(clk) then
if ld = '1' then
q <= d;
end if;
end if;
end process;
end Behavioral;

3. VHDL Code for 32-bit Program Counter (PC)

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity program_counter is
Port ( clk : in STD_LOGIC;
clr : in STD_LOGIC;
ld : in STD_LOGIC;
inc : in STD_LOGIC;
d : in STD_LOGIC_VECTOR(31 downto 0);
q : out STD_LOGIC_VECTOR(31 downto 0));
end program_counter;

architecture Behavioral of program_counter is


signal pc_reg : STD_LOGIC_VECTOR(31 downto 0) := (others => '0');
begin
process(clk, clr)
begin
if clr = '1' then
pc_reg <= (others => '0');
elsif rising_edge(clk) then
if ld = '1' then
pc_reg <= d;
elsif inc = '1' then
pc_reg <= pc_reg + 1;
end if;
end if;
end process;

q <= pc_reg;
end Behavioral;

You might also like