Advertisement
Guest User

Untitled

a guest
Mar 8th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.73 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    23:01:23 03/07/2019
  6. -- Design Name:
  7. -- Module Name:    lab6Top - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. --use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31.  
  32. entity lab6Top is
  33. port (
  34.     clk : in std_logic;
  35.     op : in std_logic_vector(3 downto 0);
  36.     reset : in std_logic;
  37.     --button : in std_logic;
  38.     digit_en : out std_logic_vector(3 downto 0);
  39.     digit_out : out std_logic_vector(7 downto 0);
  40.     SW : inout STD_LOGIC_VECTOR (1 downto 0);
  41.     ALUOut : out std_logic_vector(15 downto 0);
  42.     ALUIn1 : out std_logic_vector(15 downto 0);
  43.     ALUIn2 : out std_logic_vector(15 downto 0);
  44.     IMOut1 : out std_logic_vector(15 downto 0)
  45.     );
  46.    
  47. end lab6Top;
  48.  
  49. architecture Behavioral of lab6Top is
  50.  
  51. component InstructionModule is
  52.     port (
  53.             clk : in std_logic;
  54.             op : in std_logic_vector(3 downto 0);
  55.             InstructionOut : out std_logic_vector(15 downto 0)
  56.     );
  57. end component;
  58.  
  59. component ALU is
  60. generic (
  61. Dwidth : integer := 16);
  62. port (
  63.         In1, In2 : in std_logic_vector(Dwidth - 1 downto 0);
  64.         ALUout : out std_logic_vector(Dwidth - 1 downto 0);
  65.         sel: in std_logic_vector (2 downto 0);
  66.         Cin : in std_logic;
  67.         zero, OVF, Cout : out std_logic
  68.         );
  69. end component;
  70.  
  71. component ControlUnit is
  72. port (
  73.     op : in STD_LOGIC_VECTOR (3 downto 0) := "0000";
  74.     clk : in STD_LOGIC;
  75.     reset : in STD_LOGIC;
  76. --  button : in STD_LOGIC; --buton to go through different displays for an op code
  77.     controlOut : out std_logic_vector(8 downto 0)
  78.     );
  79. end component;
  80.  
  81. component regfile is
  82.   generic(
  83.         Dwidth : integer := 16; --Data width (each register is 16 bits)
  84.         Awidth : integer := 4); --Address Width (2^4 = 16 registers)
  85.      Port (
  86.         ReadA1, ReadA2, WriteA : in std_logic_vector(Awidth - 1 downto 0);
  87.         DataD1, DataD2, Dummy : out std_logic_vector(Dwidth - 1 downto 0);
  88.         DataIn : in std_logic_vector(Dwidth -1 downto 0);
  89.         Wen, clk : in std_logic);
  90. end component;
  91.  
  92. component sevenSeg is
  93.     port ( microS : in  STD_LOGIC_VECTOR (15 downto 0);
  94.            digit_out : out  STD_LOGIC_VECTOR (7 downto 0);
  95.            digit_en : out  STD_LOGIC_VECTOR (3 downto 0);
  96.               clk : in STD_LOGIC;
  97.               SW : inout STD_LOGIC_VECTOR (1 downto 0)
  98.               );
  99. end component;
  100.  
  101. signal IMOut : std_logic_vector(15 downto 0);
  102. signal RegtoALU1 : std_logic_vector(15 downto 0);
  103. signal RegtoALU2 : std_logic_vector(15 downto 0);
  104. signal DummySig : std_logic_vector(15 downto 0);
  105. signal ALUOutSig : std_logic_vector(15 downto 0);
  106. signal controlOutSig: std_logic_vector(8 downto 0);
  107.  
  108.  
  109. signal ZeroSig : std_logic;
  110. signal OVFSig : std_logic;
  111. signal CoutSig : std_logic;
  112. begin
  113.  
  114. IM: InstructionModule port map(clk, op, IMOut);
  115. Control: ControlUnit port map(IMOut(15 downto 12), clk, reset, controlOutSig);
  116. reg: regfile port map(IMOut(11 downto 8), IMOut(7 downto 4), IMOut(3 downto 0), RegtoALU1, RegtoALU2, DummySig, ALUOutSig, controlOutSig(5), clk);
  117. ALU1: ALU port map(RegtoALU1, RegtoALU2, ALUOutSig, controlOutSig(4 downto 2), controlOutSig(1), ZeroSig, OVFSig, CoutSig);
  118. seg: sevenSeg port map(ALUOutSig, digit_out, digit_en, clk, SW);
  119.  
  120. ALUOut <= ALUOutSig;
  121. ALUIn1 <= RegtoALU1;
  122. ALUIn2 <= RegtoALU2;
  123. IMOut1 <= IMOut;
  124. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement